Socket
Socket
Sign inDemoInstall

bson

Package Overview
Dependencies
Maintainers
4
Versions
162
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bson - npm Package Compare versions

Comparing version 2.0.5 to 2.0.6

10

HISTORY.md

@@ -0,1 +1,11 @@

<a name="2.0.6"></a>
## [2.0.6](https://github.com/mongodb/js-bson/compare/v2.0.5...v2.0.6) (2018-04-27)
### Bug Fixes
* **deserializeStream:** allow multiple documents to be deserialized ([6fc5984](https://github.com/mongodb/js-bson/commit/6fc5984)), closes [#244](https://github.com/mongodb/js-bson/issues/244)
<a name="2.0.5"></a>

@@ -2,0 +12,0 @@ ## [2.0.5](https://github.com/mongodb/js-bson/compare/v2.0.4...v2.0.5) (2018-04-06)

6

lib/bson/binary.js

@@ -55,3 +55,3 @@ 'use strict';

} else {
throw new Error('only String, Buffer, Uint8Array or Array accepted');
throw new TypeError('only String, Buffer, Uint8Array or Array accepted');
}

@@ -84,5 +84,5 @@ } else {

if (byte_value['length'] != null && typeof byte_value !== 'number' && byte_value.length !== 1)
throw new Error('only accepts single character String, Uint8Array or Array');
throw new TypeError('only accepts single character String, Uint8Array or Array');
if ((typeof byte_value !== 'number' && byte_value < 0) || byte_value > 255)
throw new Error('only accepts number in a valid unsigned byte range 0-255');
throw new TypeError('only accepts number in a valid unsigned byte range 0-255');

@@ -89,0 +89,0 @@ // Decode the byte value once

@@ -131,2 +131,3 @@ 'use strict';

* @param {Object} [options.bsonRegExp=false] return BSON regular expressions as BSONRegExp instances.
* @param {boolean} [options.allowObjectSmallerThanBufferSize=false] allows the buffer to be larger than the parsed BSON object
* @return {Object} returns the deserialized Javascript Object.

@@ -187,3 +188,3 @@ * @api public

) {
options = options != null ? options : {};
options = Object.assign({ allowObjectSmallerThanBufferSize: true }, options);
var index = startIndex;

@@ -196,3 +197,3 @@ // Loop over all documents

// Update options with index
options['index'] = index;
options.index = index;
// Parse the document at this point

@@ -199,0 +200,0 @@ documents[docStartIndex + i] = this.deserialize(data, options);

@@ -145,3 +145,3 @@ 'use strict';

var invalidErr = function(string, message) {
throw new Error('"${string}" not a valid Decimal128 string - ' + message);
throw new TypeError('"${string}" not a valid Decimal128 string - ' + message);
};

@@ -214,3 +214,3 @@

if (string.length >= 7000) {
throw new Error('' + string + ' not a valid Decimal128 string');
throw new TypeError('' + string + ' not a valid Decimal128 string');
}

@@ -225,3 +225,3 @@

if ((!stringMatch && !infMatch && !nanMatch) || string.length === 0) {
throw new Error('' + string + ' not a valid Decimal128 string');
throw new TypeError('' + string + ' not a valid Decimal128 string');
}

@@ -297,3 +297,3 @@

if (sawRadix && !nDigitsRead) throw new Error('' + string + ' not a valid Decimal128 string');
if (sawRadix && !nDigitsRead) throw new TypeError('' + string + ' not a valid Decimal128 string');

@@ -300,0 +300,0 @@ // Read exponent if exists

@@ -53,3 +53,3 @@ 'use strict';

if (!valid && id != null) {
throw new Error(
throw new TypeError(
'Argument passed in must be a single String of 12 bytes or a string of 24 hex characters'

@@ -68,3 +68,3 @@ );

} else {
throw new Error(
throw new TypeError(
'Argument passed in must be a single String of 12 bytes or a string of 24 hex characters'

@@ -97,3 +97,3 @@ );

if (!this.id || !this.id.length) {
throw new Error(
throw new TypeError(
'invalid ObjectId, ObjectId.id must be either a string or a Buffer, but is [' +

@@ -308,3 +308,3 @@ JSON.stringify(this.id) +

if (typeof string === 'undefined' || (string != null && string.length !== 24)) {
throw new Error(
throw new TypeError(
'Argument passed in must be a single String of 12 bytes or a string of 24 hex characters'

@@ -311,0 +311,0 @@ );

@@ -26,7 +26,20 @@ 'use strict';

// Ensure buffer is valid size
if (size < 5 || buffer.length !== size || size + index > buffer.length) {
throw new Error('corrupt bson message');
if (size < 5) {
throw new Error(`bson size must be >= 5, is ${size}`);
}
if (options.allowObjectSmallerThanBufferSize && buffer.length < size) {
throw new Error(`buffer length ${buffer.length} must be >= bson size ${size}`);
}
if (!options.allowObjectSmallerThanBufferSize && buffer.length !== size) {
throw new Error(`buffer length ${buffer.length} must === bson size ${size}`);
}
if (size + index > buffer.length) {
throw new Error(
`(bson size ${size} + options.index ${index} must be <= buffer length ${buffer.length})`
);
}
// Illegal end value

@@ -33,0 +46,0 @@ if (buffer[index + size - 1] !== 0) {

@@ -289,3 +289,3 @@ 'use strict';

} else {
throw new Error('object [' + JSON.stringify(value) + '] is not a valid ObjectId');
throw new TypeError('object [' + JSON.stringify(value) + '] is not a valid ObjectId');
}

@@ -688,3 +688,3 @@

if (value && value.toBSON) {
if (typeof value.toBSON !== 'function') throw new Error('toBSON is not a function');
if (typeof value.toBSON !== 'function') throw new TypeError('toBSON is not a function');
value = value.toBSON();

@@ -868,6 +868,6 @@ }

if (object.toBSON) {
if (typeof object.toBSON !== 'function') throw new Error('toBSON is not a function');
if (typeof object.toBSON !== 'function') throw new TypeError('toBSON is not a function');
object = object.toBSON();
if (object != null && typeof object !== 'object')
throw new Error('toBSON function did not return an object');
throw new TypeError('toBSON function did not return an object');
}

@@ -880,3 +880,3 @@

if (value && value.toBSON) {
if (typeof value.toBSON !== 'function') throw new Error('toBSON is not a function');
if (typeof value.toBSON !== 'function') throw new TypeError('toBSON is not a function');
value = value.toBSON();

@@ -883,0 +883,0 @@ }

@@ -15,3 +15,3 @@ {

],
"version": "2.0.5",
"version": "2.0.6",
"author": "Christian Amor Kvalheim <christkv@gmail.com>",

@@ -18,0 +18,0 @@ "license": "Apache-2.0",

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc