Comparing version 0.6.3 to 0.6.4
42
index.js
var mongodb = require('mongodb'); | ||
var memolite = require('memolite'); | ||
@@ -9,26 +10,2 @@ var DRIVER_COLLECTION_PROTO = mongodb.Collection.prototype; | ||
var memoize = function(fn) { | ||
var callFn = function(callback) { | ||
var stack = [callback]; | ||
action = function(callback) { | ||
stack.push(callback); | ||
}; | ||
fn(function(err, val) { | ||
action = err ? callFn : function(callback) { | ||
callback(null, val); | ||
}; | ||
while (stack.length) stack.shift()(err, val); | ||
}); | ||
}; | ||
var action = callFn; | ||
return function(callback) { | ||
action(callback); | ||
}; | ||
}; | ||
var forEachMethod = function(oldProto, newProto, fn) { | ||
@@ -115,3 +92,3 @@ Object.keys(oldProto).forEach(function(methodName) { | ||
var oncollection = this._get; | ||
var oncursor = memoize(function(callback) { | ||
var oncursor = memolite(function(callback) { | ||
args.push(callback); | ||
@@ -204,6 +181,2 @@ oncollection(function(err, collection) { | ||
var ObjectId = function(id) { | ||
return new mongodb.ObjectID(id); | ||
}; | ||
var connect = function(config, collections) { | ||
@@ -213,3 +186,3 @@ var that = {}; | ||
var ondb = memoize(function(callback) { | ||
var ondb = memolite(function(callback) { | ||
mongodb.Db.connect(connectionString, function(err, db) { | ||
@@ -222,10 +195,9 @@ if (err) return callback(err); | ||
that.bson = mongodb.BSONPure; | ||
that.bson = mongodb.BSONPure; // backwards compat | ||
that.ObjectId = mongodb.ObjectID; // backwards compat | ||
that.ObjectId = ObjectId; | ||
that.collection = function(name) { | ||
if (that[name]) return that[name]; | ||
var oncollection = memoize(function(callback) { | ||
var oncollection = memolite(function(callback) { | ||
ondb(function(err, db) { | ||
@@ -258,3 +230,3 @@ if (err) return callback(err); | ||
connect.connect = connect; // backwards compat | ||
connect.ObjectId = ObjectId; | ||
connect.ObjectId = mongodb.ObjectID; | ||
module.exports = connect; |
@@ -5,3 +5,3 @@ { | ||
"keywords": ["mongo", "db", "mongodb"], | ||
"version":"0.6.3", | ||
"version":"0.6.4", | ||
"repository": "git://github.com/gett/mongojs.git", | ||
@@ -14,3 +14,4 @@ "author": "Ge.tt <hello@ge.tt>", | ||
"dependencies": { | ||
"mongodb":"1.2.x" | ||
"mongodb":"1.2.x", | ||
"memolite":"~0.1.0" | ||
}, | ||
@@ -17,0 +18,0 @@ "scripts": { |
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
16188
2
418
+ Addedmemolite@~0.1.0
+ Addedmemolite@0.1.0(transitive)