npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

moped-id

0.0.1

@forbeslindesay

npmHomeRepoSnykSocket
Downloads:0
$ npm install moped-id
DailyWeeklyMonthlyYearly

moped-id

ID generation and comparison for moped. MopedIds are also MongoDB ids, so you can also use this module as a convenient method for handling/generating MongoDB ids on the client (using browserify).

Build Status Dependency Status NPM version

Installation

npm install moped-id

Usage

var MopedId = require('moped-id');

// generate a new random moped-id
var id = new MopedId();

// construct a moped-id from a string
var idFromString = new MopedId('ffffffffff00000000000000');

// construct a moped-id from json object
var idFromObject = new MopedId({$oid: 'ffffffffff00000000000000'});

assert(MopedId.isMopedId(id) === true);
assert(MopedId.isMopedId(idFromString) === true);
assert(MopedId.isMopedId(idFromObject) === true);

assert(MopedId.isObjectId(id) === true);
assert(MopedId.isObjectId(idFromString) === true);
assert(MopedId.isObjectId(idFromObject) === true);

assert(MopedId.equal(idFromString, idFromObject) === true);
assert(MopedId.equal(id, idFromString) === false);
assert(MopedId.equal(id, 'foobar') === false);
assert(MopedId.equal('foobar', 'foobar') === true);

License

MIT