monotonic-lexicographic-timestamp
Monotonically increasing timestamp with lexicographic order. Simply adds a suffix if time is the same as the last call. Hex-encoded.
example
const mlts = // You can provide your own date or timestampconsole // '00'console // '00.01' // Otherwise it'll use Date.now()consoleconsole const custom = separator: '!' console // 'ff080afa6b2a9370'console // 'ff080afa6b2a9370!01'console // 'ff080afa6b2a9370!02'console // 'ff080afa6b2a9378'
api
mlts = require('monotonic-lexicographic-timestamp')([options])
Options are passed to unique-lexicographic-integer
:
options.separator
(string): defaults to'.'
options.strict
(boolean): opt-in to type-checking input. If true,mlts()
will throw:- A
TypeError
if input is not a number or ifNaN
- A
RangeError
if input is < 0 or >Number.MAX_SAFE_INTEGER
.
- A
see also
lexicographic-integer-encoding
: encoding forlevel(up)
install
With npm do:
npm install monotonic-lexicographic-timestamp
license
MIT © Vincent Weevers