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
- Host: GitHub
- URL: https://github.com/erfanium/deno-objectid
- Owner: erfanium
- License: mit
- Created: 2021-05-07T10:15:36.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-05-14T10:47:10.000Z (about 4 years ago)
- Last Synced: 2025-03-06T22:34:06.378Z (4 months ago)
- Topics: bson, bson-objectid, deno, objectid
- Language: TypeScript
- Homepage:
- Size: 5.86 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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);
```