MCPcopy
hub / github.com/paralleldrive/cuid2 / createIdPool

Function createIdPool

src/test-utils.js:31–48  ·  view source on GitHub ↗
({ max = 100000 } = {})

Source from the content-addressed store, hash-verified

29};
30
31export const createIdPool = async ({ max = 100000 } = {}) => {
32 const set = new Set();
33
34 for (let i = 0; i < max; i++) {
35 set.add(createId());
36 if (i % 10000 === 0) console.log(`${Math.floor((i / max) * 100)}%`);
37 if (set.size < i) {
38 info(`Collision at: ${i}`);
39 break;
40 }
41 }
42 info("No collisions detected");
43
44 const ids = [...set];
45 const numbers = ids.map((x) => idToBigInt(x.substring(1)));
46 const histogram = buildHistogram(numbers);
47 return { ids, numbers, histogram };
48};

Callers 1

histogram.jsFile · 0.90

Calls 3

infoFunction · 0.85
idToBigIntFunction · 0.85
buildHistogramFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…