From e83436850276333f999fd1fe98f2ef905413389f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Fri, 7 Dec 2018 15:40:17 +0100 Subject: [PATCH] Upgrade bson to 4.x (latest) --- lib/utils.js | 8 +++++++- package.json | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/utils.js b/lib/utils.js index 3ddd0d37..3f218ea3 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -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) { diff --git a/package.json b/package.json index e9e49265..c7811fc1 100644 --- a/package.json +++ b/package.json @@ -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",