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

tuid

v0.5.0

Published

Timed Uniqe Identifier

Downloads

16

Readme

Timed Unique Identifier

Build Status Coverage Status

Introduction

This is a variation of UUID version 1 defined in RFC4412.

The design goals of this variation is to make identifier growth as time elapses, which is index-friendly for database.

Install

npm install tuid

Usage

var tuid = requier('tuid');
var generator = tuid.Generator(); // create a generator with random node id
var id = generator.generateSync();
console.log(id.toString()); // prints: 1e660627-c30c-f010-0000-7affa0ae7874
console.log(id.toBuffer().toString('hex')); // prints: 1e660627c30cf01000007affa0ae7874

API

Generator

  • constructor([node: Buffer]) Constructor, take an optional buffer parameter, the buffer should be at least 6 byte. Typically it should be the MAC address of one network interface of the host machine. If the node buffer is not presented, random 6 bytes will be fetched via crypto.getPseudoRandomBytes.
  • generateSync(): Identifier Generate a Identifier synchronously. Note if identifier is generated too frequently, exceeding 65536000ops/1ms, an exception will be throw because due to conflict.
  • generate(): Promise<Identifier> Generate a Identifier. The returned promise is resolved immediately, unless the identifier generation is exceeding 65536000ops/1ms, in such situation, the promise will defer to a suitable time.

Implementation Detail

The identifier layout:

As show in above:

  1. the version changed to f to indicates that this is not a standard UUID implementation as currently only v1, v3, v4 and v5 is defined.

  2. Timestamp are encoded into a identifier from higher bit to lower bit in network byte order, to ensure the identifier growth when treated as a byte string as time elapses. The definition of timestamp is same with the ones defined in UUID v1, which is count of 100-nanoseconds since Gregorian Epoch (Oct. 15th, 1587). For system lacks of high resolution timer, such as Javascript, the lower bit of timestamp can be emulated by clock sequence.

  3. Clock sequence takes two bytes(16bits) and no reserved bits.

  4. Node field remains same with UUID v1.

License

Copyright (C) 2016 LAN Xingcan
All right reserved

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.