Skip to content

zone-eu/seq-index

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

seq-index

Generate sequential ID values. The generated value is a 18-byte hex string. The value consists of current timestamp, an incrementing counter and the instance id.

Install

Install from npm

npm install seq-index

Usage

Create SeqIndex instance

var SeqIndex = require('seq-index');
var indexer = new SeqIndex();

get()

Generate a sequential ID using get()

var id = indexer.get();
// 15654036c1709f68f2

short()

Generate a sequential ID without instance suffix using short()

var shortId = indexer.short();
// 15654036c1709f

getByTime()

Use to convert a timestamp into a short ID for comparison

var shortId = indexer.getByTime(1470300906242, 0);
// 15654c36302000
var id = shortId + indexer.suffix;
// 15654c3630200068f2

License

Dual license MIT or EUPL-1.1+

seq-index is part of the Zone Mail Suite (ZMS). Suite of programs and modules for an efficient, fast and modern email server.

About

Generate sequential indexes

Resources

License

Stars

Watchers

Forks

Packages

No packages published