scopedid

0.3.0 • Public • Published

ScopedId

generic identifier class with types and optional versions

installation

$ npm install scopedid

usage

var ScopedId = require('scopedid')

var userId = '511083bb08ce6b1b00000003' // ObjectId string

var id = ScopedId('users', userId)

var id2 = ScopedId('users', userId)

ScopedId.equals(id, id2)
// => true

ScopedId.isValid(id)
// => true

ScopedId.toString()
// => 'users/511083bb08ce6b1b00000003'

Interface

ScopedId : {
  _id: ObjectId,
  scope: String,
  versionId : ObjectId|String (optional)
}

versionId can be an ObjectId or a string representing a version ref (like a branch).

See ObjectId

String format

{scope}/{_id} or {scope}/{_id}/{versionId}

Static Methods

ScopedId.equals(sidA, sidB) => Boolean

ScopedId.isValid(sid) => Boolean

ScopedId.tryParse(sid, out, as) => Boolean

Instance Methods

ScopedId#equals(sidB) => Boolean

ScopedId#toString() => String

ScopedId#toJSON() => String

running the tests

From package root,

$ npm install
$ npm test

contributors

jden jason@denizac.org

license

MIT. (c) 2013 Agile Diagnosis team@agilediagnosis.com. See LICENSE.md

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.3.0
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.3.0
    1
  • 0.2.1
    1
  • 0.2.0
    1
  • 0.1.0
    1

Package Sidebar

Install

npm i scopedid

Weekly Downloads

4

Version

0.3.0

License

MIT

Last publish

Collaborators