unique-lexicographic-integer
lexicographic-integer
plus a suffix if input is the same as the last call. Hex-encoded.
example
const uli = require('unique-lexicographic-integer')
const encode = uli()
console.log(encode(0))
console.log(encode(0))
console.log(encode(1))
console.log(encode(300))
console.log(encode(300))
console.log(encode(300))
const strict = uli({ strict: true })
try {
strict('1')
} catch (err) {
console.log(err.message)
}
api
encode = require('unique-lexicographic-integer')([options])
options.separator
(string): defaults to '.'
options.strict
(boolean): opt-in to type-checking input. Handled by lexicographic-integer-encoding
. If true, encode will throw:
- A
TypeError
if input is not a number or if NaN
- A
RangeError
if input is < 0 or > Number.MAX_SAFE_INTEGER
.
see also
install
With npm do:
npm install unique-lexicographic-integer
license
MIT © Vincent Weevers