Socket
Socket
Sign inDemoInstall

bson

Package Overview
Dependencies
0
Maintainers
4
Versions
162
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.0 to 1.1.1

15

HISTORY.md

@@ -0,1 +1,16 @@

<a name="1.1.1"></a>
## [1.1.1](https://github.com/mongodb/js-bson/compare/v1.1.0...v1.1.1) (2019-03-08)
### Bug Fixes
* **object-id:** support 4.x->1.x interop for MinKey and ObjectId ([53419a5](https://github.com/mongodb/js-bson/commit/53419a5))
### Features
* replace new Buffer with modern versions ([24aefba](https://github.com/mongodb/js-bson/commit/24aefba))
<a name="1.1.0"></a>

@@ -2,0 +17,0 @@ # [1.1.0](https://github.com/mongodb/js-bson/compare/v1.0.9...v1.1.0) (2018-08-13)

10

lib/bson/binary.js

@@ -12,2 +12,4 @@ /**

var utils = require('./parser/utils');
/**

@@ -57,3 +59,3 @@ * A class representation of the BSON Binary type.

if (typeof Buffer !== 'undefined') {
this.buffer = new Buffer(buffer);
this.buffer = utils.toBuffer(buffer);
} else if (

@@ -73,3 +75,3 @@ typeof Uint8Array !== 'undefined' ||

if (typeof Buffer !== 'undefined') {
this.buffer = new Buffer(Binary.BUFFER_SIZE);
this.buffer = utils.allocBuffer(Binary.BUFFER_SIZE);
} else if (typeof Uint8Array !== 'undefined') {

@@ -113,3 +115,3 @@ this.buffer = new Uint8Array(new ArrayBuffer(Binary.BUFFER_SIZE));

// Create additional overflow buffer
var buffer = new Buffer(Binary.BUFFER_SIZE + this.buffer.length);
var buffer = utils.allocBuffer(Binary.BUFFER_SIZE + this.buffer.length);
// Combine the two buffers together

@@ -157,3 +159,3 @@ this.buffer.copy(buffer, 0, 0, this.buffer.length);

if (typeof Buffer !== 'undefined' && Buffer.isBuffer(this.buffer)) {
buffer = new Buffer(this.buffer.length + string.length);
buffer = utils.allocBuffer(this.buffer.length + string.length);
this.buffer.copy(buffer, 0, 0, this.buffer.length);

@@ -160,0 +162,0 @@ } else if (Object.prototype.toString.call(this.buffer) === '[object Uint8Array]') {

9

lib/bson/bson.js

@@ -21,3 +21,4 @@ 'use strict';

serializer = require('./parser/serializer'),
calculateObjectSize = require('./parser/calculate_size');
calculateObjectSize = require('./parser/calculate_size'),
utils = require('./parser/utils');

@@ -32,3 +33,3 @@ /**

// Current Internal Temporary Serialization Buffer
var buffer = new Buffer(MAXSIZE);
var buffer = utils.allocBuffer(MAXSIZE);

@@ -61,3 +62,3 @@ var BSON = function() {};

if (buffer.length < minInternalBufferSize) {
buffer = new Buffer(minInternalBufferSize);
buffer = utils.allocBuffer(minInternalBufferSize);
}

@@ -77,3 +78,3 @@

// Create the final buffer
var finishedBuffer = new Buffer(serializationIndex);
var finishedBuffer = utils.allocBuffer(serializationIndex);
// Copy into the finished buffer

@@ -80,0 +81,0 @@ buffer.copy(finishedBuffer, 0, 0, finishedBuffer.length);

@@ -73,2 +73,4 @@ 'use strict';

var utils = require('./parser/utils');
// Detect if the value is a digit

@@ -147,3 +149,3 @@ var isDigit = function(value) {

// var longtoHex = function(value) {
// var buffer = new Buffer(8);
// var buffer = utils.allocBuffer(8);
// var index = 0;

@@ -165,3 +167,3 @@ // // Encode the low 64 bits of the decimal

// var int32toHex = function(value) {
// var buffer = new Buffer(4);
// var buffer = utils.allocBuffer(4);
// var index = 0;

@@ -271,5 +273,5 @@ // // Encode the low 64 bits of the decimal

if (string[index] === 'i' || string[index] === 'I') {
return new Decimal128(new Buffer(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER));
return new Decimal128(utils.toBuffer(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER));
} else if (string[index] === 'N') {
return new Decimal128(new Buffer(NAN_BUFFER));
return new Decimal128(utils.toBuffer(NAN_BUFFER));
}

@@ -282,3 +284,3 @@ }

if (sawRadix) {
return new Decimal128(new Buffer(NAN_BUFFER));
return new Decimal128(utils.toBuffer(NAN_BUFFER));
}

@@ -328,3 +330,3 @@

if (!match || !match[2]) {
return new Decimal128(new Buffer(NAN_BUFFER));
return new Decimal128(utils.toBuffer(NAN_BUFFER));
}

@@ -341,3 +343,3 @@

if (string[index]) {
return new Decimal128(new Buffer(NAN_BUFFER));
return new Decimal128(utils.toBuffer(NAN_BUFFER));
}

@@ -390,3 +392,3 @@

} else {
return new Decimal128(new Buffer(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER));
return new Decimal128(utils.toBuffer(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER));
}

@@ -423,3 +425,3 @@ }

} else {
return new Decimal128(new Buffer(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER));
return new Decimal128(utils.toBuffer(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER));
}

@@ -474,3 +476,3 @@ }

return new Decimal128(
new Buffer(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER)
utils.toBuffer(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER)
);

@@ -560,3 +562,3 @@ }

// Encode into a buffer
var buffer = new Buffer(16);
var buffer = utils.allocBuffer(16);
index = 0;

@@ -563,0 +565,0 @@

// Custom inspect property name / symbol.
var inspect = 'inspect';
var utils = require('./parser/utils');
/**

@@ -61,3 +63,3 @@ * Machine id.

} else if (valid && typeof id === 'string' && id.length === 24 && hasBufferType) {
return new ObjectID(new Buffer(id, 'hex'));
return new ObjectID(utils.toBuffer(id, 'hex'));
} else if (valid && typeof id === 'string' && id.length === 24) {

@@ -162,3 +164,3 @@ return ObjectID.createFromHexString(id);

// Buffer used
var buffer = new Buffer(12);
var buffer = utils.allocBuffer(12);
// Encode time

@@ -282,3 +284,3 @@ buffer[3] = time & 0xff;

ObjectID.createFromTime = function createFromTime(time) {
var buffer = new Buffer([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
var buffer = utils.toBuffer([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
// Encode time into first 4 bytes

@@ -321,3 +323,3 @@ buffer[3] = time & 0xff;

// Use Buffer.from method if available
if (hasBufferType) return new ObjectID(new Buffer(string, 'hex'));
if (hasBufferType) return new ObjectID(utils.toBuffer(string, 'hex'));

@@ -324,0 +326,0 @@ // Calculate lengths

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

return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + 1;
} else if (value instanceof ObjectID || value['_bsontype'] === 'ObjectID') {
} else if (value instanceof ObjectID || value['_bsontype'] === 'ObjectID' || value['_bsontype'] === 'ObjectId') {
return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (12 + 1);

@@ -98,0 +98,0 @@ } else if (value instanceof Date || isDate(value)) {

@@ -17,2 +17,4 @@ 'use strict';

var utils = require('./utils');
var deserialize = function(buffer, options, isArray) {

@@ -119,3 +121,3 @@ options = options == null ? {} : options;

} else if (elementType === BSON.BSON_DATA_OID) {
var oid = new Buffer(12);
var oid = utils.allocBuffer(12);
buffer.copy(oid, 0, index, index + 12);

@@ -225,3 +227,3 @@ object[name] = new ObjectID(oid);

// Buffer to contain the decimal bytes
var bytes = new Buffer(16);
var bytes = utils.allocBuffer(16);
// Copy the next 16 bytes into the bytes buffer

@@ -526,3 +528,3 @@ buffer.copy(bytes, 0, index, index + 16);

// Read the oid
var oidBuffer = new Buffer(12);
var oidBuffer = utils.allocBuffer(12);
buffer.copy(oidBuffer, 0, index, index + 12);

@@ -529,0 +531,0 @@ oid = new ObjectID(oidBuffer);

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

Long = require('../long').Long,
MinKey = require('../min_key').MinKey,
Map = require('../map'),

@@ -255,3 +254,3 @@ Binary = require('../binary').Binary;

buffer[index++] = BSON.BSON_DATA_NULL;
} else if (value instanceof MinKey) {
} else if (value._bsontype === 'MinKey') {
buffer[index++] = BSON.BSON_DATA_MIN_KEY;

@@ -723,3 +722,3 @@ } else {

index = serializeNull(buffer, key, value, index, true);
} else if (value['_bsontype'] === 'ObjectID') {
} else if (value['_bsontype'] === 'ObjectID' || value['_bsontype'] === 'ObjectId') {
index = serializeObjectId(buffer, key, value, index, true);

@@ -832,3 +831,3 @@ } else if (Buffer.isBuffer(value)) {

index = serializeNull(buffer, key, value, index);
} else if (value['_bsontype'] === 'ObjectID') {
} else if (value['_bsontype'] === 'ObjectID' || value['_bsontype'] === 'ObjectId') {
index = serializeObjectId(buffer, key, value, index);

@@ -935,3 +934,3 @@ } else if (Buffer.isBuffer(value)) {

index = serializeNull(buffer, key, value, index);
} else if (value['_bsontype'] === 'ObjectID') {
} else if (value['_bsontype'] === 'ObjectID' || value['_bsontype'] === 'ObjectId') {
index = serializeObjectId(buffer, key, value, index);

@@ -938,0 +937,0 @@ } else if (Buffer.isBuffer(value)) {

@@ -11,5 +11,19 @@ 'use strict';

function newBuffer(item, encoding) {
return new Buffer(item, encoding);
}
function allocBuffer() {
return Buffer.alloc.apply(Buffer, arguments);
}
function toBuffer() {
return Buffer.from.apply(Buffer, arguments);
}
module.exports = {
normalizedFunctionString: normalizedFunctionString
normalizedFunctionString: normalizedFunctionString,
allocBuffer: typeof Buffer.alloc === 'function' ? allocBuffer : newBuffer,
toBuffer: typeof Buffer.from === 'function' ? toBuffer : newBuffer
};

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

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

@@ -18,0 +18,0 @@ "contributors": [],

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

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc