New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

maylily

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

maylily

distributable, serverless, and customizable unique ID number generator based on Snowflake

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

MayLily

distributable, serverless, and customizable unique ID number generator based on Snowflake

How to use

No external libraries or servers needed. Just import and call maylily()!

JavaScript

var maylily = require("maylily");

// returns a Promise object
maylily()
    .then(function(id) {
        // do something...
    })
    .catch(function(err) {
        // err is instance of Error
    });

ECMAScript 7 (async/await)

import maylily from "maylily";
try {
    // returns a Promise object
    const id = await maylily();
    // do something...
}
catch(err) {
    // err is instance of Error
}

How to customize

namedescriptiondefault
timeBasebase time in unixtime(millisec)946684800000 (2000-01-01T00:00:00Z)
machineIdidentifier of machine; must be unique in service0
machineBitsrequired bits to represent machineId2
generatorIdidentifier of generator; must be unique in machineprocess ID
generatorBitsrequired bits to represent generatorId7
sequenceBitsrequired bits to represent sequence5

Generated value is 53-bit integer.

 001011100000101111010101110101010111101 01 1101100 00010
                                                   |-----| sequence number (uses sequenceBits bits)
                                           |-------|       generatorId (uses generatorBits bits)
                                        |--|               machineId (uses machineBits bits)
|---------------------------------------|                  current time from timeBase in millisec (uses remaining bits)

example:

// holds the change until next change
maylily({
    timeBase: Date.parse("2017-01-01T00:00:00Z"),   // if your service starts in 2017, this is enough.
    machineBits: 1,                                 // if required machines are up to 2, this is enough.
    generatorBits: 0                                // if running process is only 1, this is enough.
});

Release note

  • 2017-01-21 version 1.0.0
    • First release.

Keywords

FAQs

Package last updated on 21 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc