Comparing version 4.0.0 to 4.0.1
@@ -0,1 +1,6 @@ | ||
4.0.1 / 2022-01-20 | ||
================== | ||
* perf: remove sliced, add various microoptimizations #130 [Uzlopak](https://github.com/Uzlopak) | ||
* refactor: convert NodeCollection to a class #128 [jimmywarting](https://github.com/jimmywarting) | ||
4.0.0 / 2021-08-24 | ||
@@ -2,0 +7,0 @@ |
@@ -8,139 +8,123 @@ 'use strict'; | ||
const Collection = require('./collection'); | ||
const utils = require('../utils'); | ||
function NodeCollection(col) { | ||
this.collection = col; | ||
this.collectionName = col.collectionName; | ||
} | ||
class NodeCollection extends Collection { | ||
constructor(col) { | ||
super(); | ||
/** | ||
* inherit from collection base class | ||
*/ | ||
this.collection = col; | ||
this.collectionName = col.collectionName; | ||
} | ||
utils.inherits(NodeCollection, Collection); | ||
/** | ||
* find(match, options, function(err, docs)) | ||
*/ | ||
find(match, options, cb) { | ||
const cursor = this.collection.find(match, options); | ||
/** | ||
* find(match, options, function(err, docs)) | ||
*/ | ||
try { | ||
cursor.toArray(cb); | ||
} catch (error) { | ||
cb(error); | ||
} | ||
} | ||
NodeCollection.prototype.find = function(match, options, cb) { | ||
const cursor = this.collection.find(match, options); | ||
/** | ||
* findOne(match, options, function(err, doc)) | ||
*/ | ||
findOne(match, options, cb) { | ||
this.collection.findOne(match, options, cb); | ||
} | ||
try { | ||
cursor.toArray(cb); | ||
} catch (error) { | ||
cb(error); | ||
/** | ||
* count(match, options, function(err, count)) | ||
*/ | ||
count(match, options, cb) { | ||
this.collection.count(match, options, cb); | ||
} | ||
}; | ||
/** | ||
* findOne(match, options, function(err, doc)) | ||
*/ | ||
/** | ||
* distinct(prop, match, options, function(err, count)) | ||
*/ | ||
distinct(prop, match, options, cb) { | ||
this.collection.distinct(prop, match, options, cb); | ||
} | ||
NodeCollection.prototype.findOne = function(match, options, cb) { | ||
this.collection.findOne(match, options, cb); | ||
}; | ||
/** | ||
* update(match, update, options, function(err[, result])) | ||
*/ | ||
update(match, update, options, cb) { | ||
this.collection.update(match, update, options, cb); | ||
} | ||
/** | ||
* count(match, options, function(err, count)) | ||
*/ | ||
/** | ||
* update(match, update, options, function(err[, result])) | ||
*/ | ||
updateMany(match, update, options, cb) { | ||
this.collection.updateMany(match, update, options, cb); | ||
} | ||
NodeCollection.prototype.count = function(match, options, cb) { | ||
this.collection.count(match, options, cb); | ||
}; | ||
/** | ||
* update(match, update, options, function(err[, result])) | ||
*/ | ||
updateOne(match, update, options, cb) { | ||
this.collection.updateOne(match, update, options, cb); | ||
} | ||
/** | ||
* distinct(prop, match, options, function(err, count)) | ||
*/ | ||
/** | ||
* replaceOne(match, update, options, function(err[, result])) | ||
*/ | ||
replaceOne(match, update, options, cb) { | ||
this.collection.replaceOne(match, update, options, cb); | ||
} | ||
NodeCollection.prototype.distinct = function(prop, match, options, cb) { | ||
this.collection.distinct(prop, match, options, cb); | ||
}; | ||
/** | ||
* deleteOne(match, options, function(err[, result]) | ||
*/ | ||
deleteOne(match, options, cb) { | ||
this.collection.deleteOne(match, options, cb); | ||
} | ||
/** | ||
* update(match, update, options, function(err[, result])) | ||
*/ | ||
/** | ||
* deleteMany(match, options, function(err[, result]) | ||
*/ | ||
deleteMany(match, options, cb) { | ||
this.collection.deleteMany(match, options, cb); | ||
} | ||
NodeCollection.prototype.update = function(match, update, options, cb) { | ||
this.collection.update(match, update, options, cb); | ||
}; | ||
/** | ||
* remove(match, options, function(err[, result]) | ||
*/ | ||
remove(match, options, cb) { | ||
this.collection.remove(match, options, cb); | ||
} | ||
/** | ||
* update(match, update, options, function(err[, result])) | ||
*/ | ||
/** | ||
* findOneAndDelete(match, options, function(err[, result]) | ||
*/ | ||
findOneAndDelete(match, options, cb) { | ||
this.collection.findOneAndDelete(match, options, cb); | ||
} | ||
NodeCollection.prototype.updateMany = function(match, update, options, cb) { | ||
this.collection.updateMany(match, update, options, cb); | ||
}; | ||
/** | ||
* findOneAndUpdate(match, update, options, function(err[, result]) | ||
*/ | ||
findOneAndUpdate(match, update, options, cb) { | ||
this.collection.findOneAndUpdate(match, update, options, cb); | ||
} | ||
/** | ||
* update(match, update, options, function(err[, result])) | ||
*/ | ||
/** | ||
* var cursor = findCursor(match, options) | ||
*/ | ||
findCursor(match, options) { | ||
return this.collection.find(match, options); | ||
} | ||
NodeCollection.prototype.updateOne = function(match, update, options, cb) { | ||
this.collection.updateOne(match, update, options, cb); | ||
}; | ||
/** | ||
* aggregation(operators..., function(err, doc)) | ||
* TODO | ||
*/ | ||
} | ||
/** | ||
* replaceOne(match, update, options, function(err[, result])) | ||
*/ | ||
NodeCollection.prototype.replaceOne = function(match, update, options, cb) { | ||
this.collection.replaceOne(match, update, options, cb); | ||
}; | ||
/** | ||
* deleteOne(match, options, function(err[, result]) | ||
*/ | ||
NodeCollection.prototype.deleteOne = function(match, options, cb) { | ||
this.collection.deleteOne(match, options, cb); | ||
}; | ||
/** | ||
* deleteMany(match, options, function(err[, result]) | ||
*/ | ||
NodeCollection.prototype.deleteMany = function(match, options, cb) { | ||
this.collection.deleteMany(match, options, cb); | ||
}; | ||
/** | ||
* remove(match, options, function(err[, result]) | ||
*/ | ||
NodeCollection.prototype.remove = function(match, options, cb) { | ||
this.collection.remove(match, options, cb); | ||
}; | ||
/** | ||
* findOneAndDelete(match, options, function(err[, result]) | ||
*/ | ||
NodeCollection.prototype.findOneAndDelete = function(match, options, cb) { | ||
this.collection.findOneAndDelete(match, options, cb); | ||
}; | ||
/** | ||
* findOneAndUpdate(match, update, options, function(err[, result]) | ||
*/ | ||
NodeCollection.prototype.findOneAndUpdate = function(match, update, options, cb) { | ||
this.collection.findOneAndUpdate(match, update, options, cb); | ||
}; | ||
/** | ||
* var cursor = findCursor(match, options) | ||
*/ | ||
NodeCollection.prototype.findCursor = function(match, options) { | ||
return this.collection.find(match, options); | ||
}; | ||
/** | ||
* aggregation(operators..., function(err, doc)) | ||
* TODO | ||
*/ | ||
/** | ||
* Expose | ||
@@ -147,0 +131,0 @@ */ |
@@ -51,3 +51,3 @@ 'use strict'; | ||
if ('Buffer' === obj.constructor.name) | ||
return exports.cloneBuffer(obj); | ||
return Buffer.from(obj); | ||
} | ||
@@ -67,10 +67,12 @@ | ||
exports.cloneObject = function cloneObject(obj, options) { | ||
const minimize = options && options.minimize; | ||
const ret = {}; | ||
let hasKeys; | ||
let val; | ||
const keys = Object.keys(obj); | ||
let k; | ||
const minimize = options && options.minimize, | ||
ret = {}, | ||
keys = Object.keys(obj), | ||
len = keys.length; | ||
let hasKeys = false, | ||
val, | ||
k = '', | ||
i = 0; | ||
for (let i = 0; i < keys.length; ++i) { | ||
for (i = 0; i < len; ++i) { | ||
k = keys[i]; | ||
@@ -97,4 +99,6 @@ // Not technically prototype pollution because this wouldn't merge properties | ||
exports.cloneArray = function cloneArray(arr, options) { | ||
const ret = []; | ||
for (let i = 0, l = arr.length; i < l; i++) | ||
const ret = [], | ||
l = arr.length; | ||
let i = 0; | ||
for (; i < l; i++) | ||
ret.push(clone(arr[i], options)); | ||
@@ -283,15 +287,2 @@ return ret; | ||
/** | ||
* Determines if `arg` is an array. | ||
* | ||
* @param {Object} | ||
* @return {Boolean} | ||
* @see nodejs utils | ||
*/ | ||
exports.isArray = function(arg) { | ||
return Array.isArray(arg) || | ||
'object' == typeof arg && '[object Array]' == exports.toString(arg); | ||
}; | ||
/** | ||
* Object.keys helper | ||
@@ -318,3 +309,3 @@ */ | ||
function F() {} | ||
function F() { } | ||
F.prototype = proto; | ||
@@ -343,15 +334,2 @@ return new F; | ||
/** | ||
* Clones the contents of a buffer. | ||
* | ||
* @param {Buffer} buff | ||
* @return {Buffer} | ||
*/ | ||
exports.cloneBuffer = function(buff) { | ||
const dupe = Buffer.alloc(buff.length); | ||
buff.copy(dupe, 0, 0, buff.length); | ||
return dupe; | ||
}; | ||
/** | ||
* Check if this object is an arguments object | ||
@@ -358,0 +336,0 @@ * |
{ | ||
"name": "mquery", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "Expressive query building for MongoDB", | ||
@@ -20,8 +20,7 @@ "main": "lib/mquery.js", | ||
"debug": "4.x", | ||
"regexp-clone": "^1.0.0", | ||
"sliced": "1.0.1" | ||
"regexp-clone": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"eslint": "5.x", | ||
"eslint-plugin-mocha-no-only": "1.1.0", | ||
"eslint": "8.x", | ||
"eslint-plugin-mocha-no-only": "1.1.1", | ||
"mocha": "9.x", | ||
@@ -28,0 +27,0 @@ "mongodb": "4.x" |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2
244765
6271
- Removedsliced@1.0.1
- Removedsliced@1.0.1(transitive)