Commit 0d35c2ee authored by Jaap Karan Singh's avatar Jaap Karan Singh

Removed dependency on mongoskin

parent 69ac9b57
......@@ -3,7 +3,6 @@
'use strict';
var _ = require('lodash');
var mongo = require('mongoskin');
exports.error = function testError(er) {
return (er instanceof Error);
......@@ -17,14 +16,14 @@ exports.function = function testFunction(fn) {
return (fn instanceof Function);
};
// works for both string representations and objectid instances
exports.objectId = function testObjectId(id) {
try {
new mongo.ObjectID(id.toString());
return true;
} catch(e) {
return false;
// coerce to string so the function can be generically used to test both strings and native objectIds created by the driver
id = id + '';
var len = id.length, valid = false;
if (len == 12 || len == 24) {
valid = /^[0-9a-fA-F]+$/.test(id);
}
return valid;
};
exports.plainObject = function testPlainObject(ob) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment