https://github.com/zone-eu/seq-index
Generate sequential indexes
https://github.com/zone-eu/seq-index
Last synced: 29 days ago
JSON representation
Generate sequential indexes
- Host: GitHub
- URL: https://github.com/zone-eu/seq-index
- Owner: zone-eu
- License: mit
- Created: 2016-08-03T15:49:42.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2025-12-09T08:38:27.000Z (6 months ago)
- Last Synced: 2026-01-12T04:59:35.794Z (5 months ago)
- Language: JavaScript
- Size: 150 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
```javascript
var SeqIndex = require('seq-index');
var indexer = new SeqIndex();
```
### get()
Generate a sequential ID using `get()`
```javascript
var id = indexer.get();
// 15654036c1709f68f2
```
### short()
Generate a sequential ID without instance suffix using `short()`
```javascript
var shortId = indexer.short();
// 15654036c1709f
```
### getByTime()
Use to convert a timestamp into a short ID for comparison
```javascript
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.