Suids are distributed, Scoped, Unique IDs that are short and sweet.
See the main project for details.
npm install --save suid-js
var Suid = require('suid-js')
import Suid from 'suid-js'
var id = new Suid(1903154)
alert(id) // 14she
var id = new Suid('14she')
alert(id) // 14she
var id = new Suid("14she")
alert(id.valueOf()) // 1903154
var id = new Suid('14she')
var val = id.toNumber()
alert(val) // 1903154
var id = new Suid('14she')
var val = id.toString()
alert(val) // 14she
var ids = [new Suid(1903154), new Suid(1903155), new Suid(1903156)]
alert(ids) // [14she, 14shf, 14shg]
var vals = Suid.toNumber(ids)
alert(vals) // [1903154, 1903155, 1903156]
var ids = [new Suid(1903154), new Suid(1903155), new Suid(1903156)]
alert(ids) // [14she, 14shf, 14shg]
var vals = Suid.toString(ids)
alert(vals) // [14she, 14shf, 14shg]
var vals = [1903154, 1903155, 1903156]
alert(vals) // [1903154, 1903155, 1903156]
var ids = Suid.from(vals)
alert(ids) // [14she, 14shf, 14shg]
var vals = ['14she', '14shf', '14shg']
alert(vals) // [14she, 14shf, 14shg]
var ids = Suid.from(vals)
alert(ids) // [14she, 14shf, 14shg]
Bugs, feedback, questions and discussion are welcome on the issue tracker.
Copyright © 2017 by Stijn de Witt. Some rights reserved.
Creative Commons Attribution 4.0 International (CC BY 4.0)
https://creativecommons.org/licenses/by/4.0/