bson
Advanced tools
Comparing version 4.0.4 to 4.1.0
@@ -25,3 +25,3 @@ { | ||
], | ||
"version": "4.0.4" | ||
"version": "4.1.0" | ||
} |
@@ -5,2 +5,20 @@ # Change Log | ||
<a name="4.1.0"></a> | ||
# [4.1.0](https://github.com/mongodb/js-bson/compare/v4.0.4...v4.1.0) (2020-08-10) | ||
### Bug Fixes | ||
* spelling in deserializer errors ([4c6f2e4](https://github.com/mongodb/js-bson/commit/4c6f2e4)) | ||
* **object-id:** harden the duck-typing ([4b800ae](https://github.com/mongodb/js-bson/commit/4b800ae)) | ||
* parse value of Int32 in constructor ([5cda40f](https://github.com/mongodb/js-bson/commit/5cda40f)) | ||
* Reduce floating point precision required of extended json implementations ([#369](https://github.com/mongodb/js-bson/issues/369)) ([5e35d1a](https://github.com/mongodb/js-bson/commit/5e35d1a)) | ||
### Features | ||
* add support for primitives to EJSON.stringify ([329857d](https://github.com/mongodb/js-bson/commit/329857d)) | ||
<a name="4.0.4"></a> | ||
@@ -7,0 +25,0 @@ ## [4.0.4](https://github.com/mongodb/js-bson/compare/v4.0.3...v4.0.4) (2020-03-26) |
@@ -52,5 +52,13 @@ 'use strict'; | ||
return { | ||
$numberDouble: Number.isInteger(this.value) ? this.value.toFixed(1) : this.value.toString() | ||
}; | ||
let $numberDouble; | ||
if (Number.isInteger(this.value)) { | ||
$numberDouble = this.value.toFixed(1); | ||
if ($numberDouble.length >= 13) { | ||
$numberDouble = this.value.toExponential(13).toUpperCase(); | ||
} | ||
} else { | ||
$numberDouble = this.value.toString(); | ||
} | ||
return { $numberDouble }; | ||
} | ||
@@ -57,0 +65,0 @@ |
@@ -190,6 +190,3 @@ 'use strict'; | ||
const doc = Array.isArray(value) | ||
? serializeArray(value, options) | ||
: serializeDocument(value, options); | ||
const doc = serializeValue(value, options); | ||
return JSON.stringify(doc, replacer, space); | ||
@@ -196,0 +193,0 @@ } |
@@ -9,3 +9,3 @@ 'use strict'; | ||
* | ||
* @param {number|Number} value the number we want to represent as an int32. | ||
* @param {*} value the number we want to represent as an int32. | ||
* @return {Int32} | ||
@@ -18,3 +18,3 @@ */ | ||
this.value = value; | ||
this.value = +value; | ||
} | ||
@@ -21,0 +21,0 @@ |
@@ -88,3 +88,3 @@ 'use strict'; | ||
this.id = id; | ||
} else if (id != null && id.toHexString) { | ||
} else if (id != null && typeof id.toHexString === 'function') { | ||
// Duck-typing to support ObjectId from different npm packages | ||
@@ -342,3 +342,6 @@ return ObjectId.createFromHexString(id.toHexString()); | ||
// Duck-Typing detection of ObjectId like objects | ||
if (id.toHexString) { | ||
if ( | ||
typeof id.toHexString === 'function' && | ||
(id.id instanceof _Buffer || typeof id.id === 'string') | ||
) { | ||
return id.id.length === 12 || (id.id.length === 24 && checkForHexRegExp.test(id.id)); | ||
@@ -345,0 +348,0 @@ } |
@@ -290,5 +290,5 @@ 'use strict'; | ||
if (binarySize > totalBinarySize - 4) | ||
throw new Error('Binary type with subtype 0x02 contains to long binary size'); | ||
throw new Error('Binary type with subtype 0x02 contains too long binary size'); | ||
if (binarySize < totalBinarySize - 4) | ||
throw new Error('Binary type with subtype 0x02 contains to short binary size'); | ||
throw new Error('Binary type with subtype 0x02 contains too short binary size'); | ||
} | ||
@@ -316,5 +316,5 @@ | ||
if (binarySize > totalBinarySize - 4) | ||
throw new Error('Binary type with subtype 0x02 contains to long binary size'); | ||
throw new Error('Binary type with subtype 0x02 contains too long binary size'); | ||
if (binarySize < totalBinarySize - 4) | ||
throw new Error('Binary type with subtype 0x02 contains to short binary size'); | ||
throw new Error('Binary type with subtype 0x02 contains too short binary size'); | ||
} | ||
@@ -513,10 +513,10 @@ | ||
// Check if field length is to short | ||
// Check if field length is too short | ||
if (totalSize < 4 + 4 + objectSize + stringSize) { | ||
throw new Error('code_w_scope total size is to short, truncating scope'); | ||
throw new Error('code_w_scope total size is too short, truncating scope'); | ||
} | ||
// Check if totalSize field is to long | ||
// Check if totalSize field is too long | ||
if (totalSize > 4 + 4 + objectSize + stringSize) { | ||
throw new Error('code_w_scope total size is to long, clips outer document'); | ||
throw new Error('code_w_scope total size is too long, clips outer document'); | ||
} | ||
@@ -523,0 +523,0 @@ |
@@ -14,3 +14,3 @@ { | ||
], | ||
"version": "4.0.4", | ||
"version": "4.1.0", | ||
"author": "Christian Amor Kvalheim <christkv@gmail.com>", | ||
@@ -48,3 +48,3 @@ "license": "Apache-2.0", | ||
"rollup-plugin-node-resolve": "^3.4.0", | ||
"standard-version": "^4.4.0" | ||
"standard-version": "^8.0.1" | ||
}, | ||
@@ -66,3 +66,3 @@ "config": { | ||
"test": "npm run-script lint && npm run-script test-node && npm run-script test-browser", | ||
"test-node": "node --throw-deprecation node_modules/.bin/_mocha ./test/node", | ||
"test-node": "node --throw-deprecation node_modules/mocha/bin/_mocha ./test/node", | ||
"test-browser": "npm run-script build && node --throw-deprecation node_modules/.bin/karma start", | ||
@@ -69,0 +69,0 @@ "build": "rollup -c", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
1089700
26510
6