Created
March 20, 2018 22:28
-
-
Save moltar/1438292862de624b87e4ed8088f60fd6 to your computer and use it in GitHub Desktop.
duid conflict
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const duid = require('short-duid') | |
const inst = duid.init({ | |
shardId: 1, | |
salt: 'foo', | |
epochStart: 1517363935892 | |
}) | |
for (let i = 0; i < 100000; i += 1) { | |
const ids = inst.getDUIDInt(1) | |
const id = ids[0] | |
const hashed = inst.hashidEncode([id]) | |
const back = inst.hashidDecode(hashed)[0] | |
if (id !== back) { | |
console.log(i, ids, id, hashed, back) | |
process.exit() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Replying 4 years later :-( The init should be prepended with “new”. And it should be fixed now, I think