Skip to content

Instantly share code, notes, and snippets.

@artalar
Created Jan 11, 2022
Embed
What would you like to do?
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