npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@y0x54a/oid-node

v0.1.0

Published

@y0x54a/oid-node

Downloads

7

Readme

oid-node

NPM Version Build Status codecov

Installing

npm i @y0x54a/oid-node

Example

const {Oid453, Oid563} = require('@y0x54a/oid-node');
Oid453.create();
// 12-byte

Oid563.create();
// 14-byte
const oid = new Oid453('00112233445566778899aabb');

oid.getId();
// 00112233445566778899aabb

oid.getTimestamp();
// 1122867

oid.getRandom();
// 293490554760

oid.getIndex();
// 10070715

oid.toString();
// 00112233445566778899aabb

Oid453.validate(oid);
// true

Oid453.validate(oid.getId());
// true

Oid453.validate('00112233445566778899AABB');
// false

Oid563.validate(oid);
// false
const oid1 = Oid453.create(1122867);
const oid2 = Oid453.create(oid1);

oid1.getId() === oid2.getId();
// true

oid1.getTimestamp();
// 1122867

oid2.getTimestamp();
// 1122867

Oid453.generate(1122867);
// 00112233...
const oid = new Oid563('00112233445566778899aabbccdd');

oid.getId();
// 00112233445566778899aabbccdd

oid.getTimestamp();
// 287454020

oid.getRandom();
// 93898580466090

oid.getIndex();
// 12307677

oid.toString();
// 00112233445566778899aabbccdd

Oid563.validate(oid);
// true

Oid563.validate(oid.getId());
// true

Oid563.validate('00112233445566778899AABBCCDD');
// false

Oid453.validate(oid);
// false
const oid1 = Oid563.create(287454020);
const oid2 = Oid563.create(oid1);

oid1.getId() === oid2.getId();
// true

oid1.getTimestamp();
// 287454020

oid2.getTimestamp();
// 287454020

Oid563.generate(287454020);
// 0011223344...

API

  • Oid

  • Oid453

    • Methods

    • constructor(id: string | Oid)

    • getId(): string

    • getTimestamp(): number

    • getRandom(): number

    • getIndex(): number

    • toString(): string

    • Static Methods

    • create(id?: string | Oid | number): Oid453

    • validate(id: string | Oid): boolean

    • generate(timestamp: number): string

  • Oid563

    • Methods

    • constructor(id: string | Oid)

    • getId(): string

    • getTimestamp(): number

    • getRandom(): number

    • getIndex(): number

    • toString(): string

    • Static Methods

    • create(id?: string | Oid | number): Oid563

    • validate(id: string | Oid): boolean

    • generate(timestamp: number): string