-
-
Save artalar/bc6d1eb9a3477d15d2772e876169a444 to your computer and use it in GitHub Desktop.
This file contains 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
import { nanoid } from 'nanoid'; | |
const makeProxyNumberToReproducePreviousID = () => { | |
let step = 0; | |
return { | |
valueOf() { | |
// // if (!pool || pool.length < bytes) { | |
if (step === 0) { | |
step++; | |
return 0; | |
} | |
// } else if (poolOffset + bytes > pool.length) { | |
if (step === 1) { | |
step++; | |
return -Infinity; | |
} | |
// poolOffset += bytes | |
if (step === 2) { | |
step++; | |
return 0; | |
} | |
return 21; | |
}, | |
}; | |
}; | |
const ID1 = nanoid(); | |
const ID2 = nanoid(makeProxyNumberToReproducePreviousID()); | |
console.log({ ID1, ID2, isIDsEqual: ID1 === ID2 }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment