Upgrade bson to 4.x (latest)

This commit is contained in:
Miroslav Bajtoš 2018-12-07 15:40:17 +01:00
parent 0cf0fa95ff
commit e834368502
No known key found for this signature in database
GPG Key ID: 6F2304BA9361C7E3
2 changed files with 8 additions and 2 deletions

View File

@ -624,6 +624,12 @@ function createPromiseCallback() {
return cb;
}
function isBsonType(value) {
// bson@1.x stores _bsontype on ObjectID instance, bson@4.x on prototype
return value.hasOwnProperty('_bsontype') ||
value.constructor.prototype.hasOwnProperty('_bsontype');
}
/**
* Dedupe an array
* @param {Array} an array
@ -636,7 +642,7 @@ function uniq(a) {
}
assert(Array.isArray(a), 'array argument is required');
var comparableA = a.map(
item => item.hasOwnProperty('_bsontype') ? item.toString() : item
item => isBsonType(item) ? item.toString() : item
);
for (var i = 0, n = comparableA.length; i < n; i++) {
if (comparableA.indexOf(comparableA[i]) === i) {

View File

@ -36,7 +36,7 @@
"devDependencies": {
"@types/node": "^10.0.8",
"async-iterators": "^0.2.2",
"bson": "^1.0.4",
"bson": "^4.0.1",
"coveralls": "^3.0.1",
"eslint": "^5.1.0",
"eslint-config-loopback": "^11.0.0",