Skip to content

Latest commit

 

History

History
21 lines (15 loc) · 610 Bytes

README.md

File metadata and controls

21 lines (15 loc) · 610 Bytes

deno-objectId

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

API

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);