An open API service indexing awesome lists of open source software.

https://github.com/erfanium/deno-objectid

Native bson objectId implementation for Deno
https://github.com/erfanium/deno-objectid

bson bson-objectid deno objectid

Last synced: 3 months ago
JSON representation

Native bson objectId implementation for Deno

Awesome Lists containing this project

README

        

# deno-objectId

Functional and Native bson objectId implementation for Deno, With ZERO third-party dependencies.
## API

```ts
import { objectId, getDate, decodeString, isValid } from "https://deno.land/x/[email protected]/mod.ts";
import { encodeToString } from "https://deno.land/[email protected]/encoding/hex.ts";

// Create ObjectId
const id: Uint8Array = objectId();

// Convert ObjectID to HexString
const hex: string = encodeToString(id); // "60950fa4beaf70cffc9ac75d"

// Convert HexString to ObjectID
const id: Uint8Array = decodeString(hex);

// Get objectId creation date
const date: Date = getDate(id);
```