# objectid

> mongodb objectid utilities

Latest version **3.2.1** (published 2015-07-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install objectid
pnpm add objectid
yarn add objectid
bun add objectid
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.2.1 |
| Published | 2015-07-21 |
| First published | 2013-02-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 22 |
| Author | Agile Diagnosis |
| Maintainers | jden |
| Keywords | mongodb, objectid |

## Links

- npm: https://www.npmjs.com/package/objectid
- Repository: https://github.com/AgileDiagnosis/objectid
- Homepage: https://github.com/AgileDiagnosis/objectid#readme
- Issues: https://github.com/AgileDiagnosis/objectid/issues
- npm.io page: https://npm.io/package/objectid

## Dependencies (1)

- [bson](https://npm.io/package/bson.md) ^0.1.9

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 3.2.1 (latest) — 2015-07-21
- 3.2.0 — 2015-02-12
- 3.1.0 — 2013-06-11
- 3.0.1 — 2013-05-10
- 3.0.0 — 2013-05-09
- 2.3.0 — 2013-03-26
- 2.2.0 — 2013-03-26
- 2.1.0 — 2013-03-18
- 2.0.0 — 2013-03-18
- 1.1.0 — 2013-02-14
- 1.0.0 — 2013-02-05

## README

# 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

---
_Source: https://npm.io/package/objectid · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
