Socket
Book a DemoInstallSign in
Socket

objectid

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

objectid

mongodb objectid utilities

3.2.1
latest
Source
npmnpm
Version published
Weekly downloads
1.5K
14.6%
Maintainers
1
Weekly downloads
 
Created
Source

objectid

mongodb objectid utilities

about

1.x is probably the version you want to use in a browser. 3.x focuses on compatibility with the npm mongodb driver.

installation

$ npm install objectid

usage

var objectid = require('objectid')

var id = objectid()

objectid.isValid(id)
// => true

objectid.isValid('4frsdef43wzx')
// => false

objectid.isValid returns true for mongodb native driver ObjectID objects, or any other representations with a .toString method which returns the hex string encoding of a valid objectid.

Calling objectid with an existing objectid - whether a string, an object created by this module, an objectid created by another driver (such as the result of a query) - will cast the value to an instanceof this module. It will throw if the argument is not a valid ObjectId.

Static Methods

ObjectId.equals(oidA, oidB) => Boolean

Curried to support creating equality predicates.

ObjectId.tryParse(oid, out, as) => Boolean

ObjectId.isValid(oid) => Boolean

Instance Methods

ObjectId#equals(oidB) => Boolean

ObjectId#toString() => String

ObjectId#toJSON() => String

running the tests

From package root:

$ npm install
$ npm test

contributors

jden jason@denizac.org @leJDen

license

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

Keywords

mongodb

FAQs

Package last updated on 21 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.