Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mquery

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mquery - npm Package Compare versions

Comparing version 0.5.1 to 0.5.2

9

History.md
0.5.2 / 2014-01-30
==================
* fixed; cloning ObjectId constructors
* fixed; cloning of ReadPreferences #30 [ashtuchkin](https://github.com/ashtuchkin)
* tests; use specific mongodb version #29 [AvianFlu](https://github.com/AvianFlu)
* tests; remove dependency on ObjectId #28 [refack](https://github.com/refack)
* tests; add failing ReadPref test
0.5.1 / 2014-01-17

@@ -3,0 +12,0 @@ ==================

5

lib/utils.js

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

if (obj.constructor) {
if (/ObjectI[dD]{1}/.test(obj.constructor.name)) {
if (/ObjectI[dD]$/.test(obj.constructor.name)) {
return 'function' == typeof obj.clone

@@ -33,2 +33,5 @@ ? obj.clone()

if ('ReadPreference' === obj._type && obj.isValid && obj.toObject)
return new obj.constructor(obj.mode, clone(obj.tags, options));
if ('Date' === obj.constructor.name || 'Function' === obj.constructor.name)

@@ -35,0 +38,0 @@ return new obj.constructor(+obj);

4

package.json
{
"name": "mquery",
"version": "0.5.1",
"version": "0.5.2",
"description": "Expressive query building for MongoDB",

@@ -19,3 +19,3 @@ "main": "index.js",

"devDependencies": {
"mongodb": "1.3.x",
"mongodb": "1.3.23",
"mocha": "1.9.x"

@@ -22,0 +22,0 @@ },

var utils = require('../lib/utils');
var assert = require('assert');
var mongo = require('mongodb');

@@ -31,2 +32,14 @@ describe('lib/utils', function() {

it('does not clone constructors named ObjectIdd', function(done) {
function ObjectIdd (id) {
this.id = id;
}
var o1 = new ObjectIdd('1234');
var o2 = utils.clone(o1);
assert.ok(!(o2 instanceof ObjectIdd));
done();
});
it('optionally clones ObjectId constructors using its clone method', function(done) {

@@ -56,2 +69,29 @@ function ObjectID (id) {

it('clones mongodb.ReadPreferences', function(done) {
var tags = [{dc: 'tag1'}];
var prefs = [
new mongo.ReadPreference("primary"),
new mongo.ReadPreference(mongo.ReadPreference.PRIMARY_PREFERRED),
new mongo.ReadPreference("primary", tags),
mongo.ReadPreference("primary", tags)
];
var prefsCloned = utils.clone(prefs);
for (var i = 0; i < prefsCloned.length; i++) {
assert.notEqual(prefs[i], prefsCloned[i]);
assert.ok(prefsCloned[i] instanceof mongo.ReadPreference);
assert.ok(prefsCloned[i].isValid());
if (prefs[i].tags) {
assert.ok(prefsCloned[i].tags);
assert.notEqual(prefs[i].tags, prefsCloned[i].tags);
assert.notEqual(prefs[i].tags[0], prefsCloned[i].tags[0]);
} else {
assert.equal(prefsCloned[i].tags, null);
}
}
done();
});
it('handles objects with no constructor', function(done) {

@@ -58,0 +98,0 @@ var name ='335';

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc