@@ 14285-14303 (lines=19) @@ | ||
14282 | BSONRegExp = __webpack_require__(310).BSONRegExp, |
|
14283 | Binary = __webpack_require__(318).Binary; |
|
14284 | ||
14285 | var deserialize = function (buffer, options, isArray) { |
|
14286 | options = options == null ? {} : options; |
|
14287 | var index = options && options.index ? options.index : 0; |
|
14288 | // Read the document size |
|
14289 | var size = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24; |
|
14290 | ||
14291 | // Ensure buffer is valid size |
|
14292 | if (size < 5 || buffer.length < size || size + index > buffer.length) { |
|
14293 | throw new Error("corrupt bson message"); |
|
14294 | } |
|
14295 | ||
14296 | // Illegal end value |
|
14297 | if (buffer[index + size - 1] != 0) { |
|
14298 | throw new Error("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00"); |
|
14299 | } |
|
14300 | ||
14301 | // Start deserializtion |
|
14302 | return deserializeObject(buffer, index, options, isArray); |
|
14303 | }; |
|
14304 | ||
14305 | var deserializeObject = function (buffer, index, options, isArray) { |
|
14306 | var evalFunctions = options['evalFunctions'] == null ? false : options['evalFunctions']; |
@@ 19-37 (lines=19) @@ | ||
16 | BSONRegExp = require('../regexp').BSONRegExp, |
|
17 | Binary = require('../binary').Binary; |
|
18 | ||
19 | var deserialize = function(buffer, options, isArray) { |
|
20 | options = options == null ? {} : options; |
|
21 | var index = options && options.index ? options.index : 0; |
|
22 | // Read the document size |
|
23 | var size = buffer[index] | buffer[index+1] << 8 | buffer[index+2] << 16 | buffer[index+3] << 24; |
|
24 | ||
25 | // Ensure buffer is valid size |
|
26 | if(size < 5 || buffer.length < size || (size + index) > buffer.length) { |
|
27 | throw new Error("corrupt bson message"); |
|
28 | } |
|
29 | ||
30 | // Illegal end value |
|
31 | if(buffer[index + size - 1] != 0) { |
|
32 | throw new Error("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00"); |
|
33 | } |
|
34 | ||
35 | // Start deserializtion |
|
36 | return deserializeObject(buffer, index, options, isArray); |
|
37 | } |
|
38 | ||
39 | var deserializeObject = function(buffer, index, options, isArray) { |
|
40 | var evalFunctions = options['evalFunctions'] == null ? false : options['evalFunctions']; |