Generate IDs with strategy like Twitter Snowflake and encode it in short string
npm install snowflake-codonGenerate IDs with strategy like Twitter Snowflake and encode it in short string.
Install it via npm:
``shell`
npm install snowflake-codon
Include in your project:
`javascript`
var SnowflakeCodon = require("snowflake-codon");
Generate IDs with application ID and machine ID
`javascript``
var appId = 1; // optional, default value 0
var machineId = 99; // optional, default value 0
var firstYear = 2015; // optional, default value 1970
var timestampPrecision = 200; // optional, default value 1000 (ms)
var generator = new SnowflakeCodon(appId, machineId, firstYear, timestampPrecision);
var id = generator.nextId();
// id will be something like '0fw2tte10003300'
MIT