Code coverage report for node-mongoskin/lib/helper.js

Statements: 100% (10 / 10)      Branches: 100% (6 / 6)      Functions: 100% (2 / 2)      Lines: 100% (10 / 10)      Ignored: none     

All files » node-mongoskin/lib/ » helper.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 231 1               1 31 7   24 6   18     1 2    
var mongodb = require('mongodb');
var ObjectID = mongodb.ObjectID;
 
/**
 * Convert to ObjectID.
 * 
 * @param {String} hex
 * @return {ObjectID}
 */
exports.toObjectID = function (hex) {
  if (hex instanceof ObjectID) {
    return hex;
  }
  if (!hex || hex.length !== 24) {
    return hex;
  }
  return ObjectID.createFromHexString(hex);
};
 
exports.isObjectID = function (idstr) {
  return ObjectID.isValid(idstr);
};