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

Function createFingerprint

src/index.js:78–92  ·  view source on GitHub ↗
({
  globalObj = typeof global !== "undefined"
    ? global
    : typeof window !== "undefined"
      ? window
      : {},
  random: rand = random,
} = {})

Source from the content-addressed store, hash-verified

76on a random string.
77*/
78const createFingerprint = ({
79 globalObj = typeof global !== "undefined"
80 ? global
81 : typeof window !== "undefined"
82 ? window
83 : {},
84 random: rand = random,
85} = {}) => {
86 const globals = Object.keys(globalObj).toString();
87 const sourceString = globals.length
88 ? globals + createEntropy(bigLength, rand)
89 : createEntropy(bigLength, rand);
90
91 return hash(sourceString).substring(0, bigLength);
92};
93
94const createCounter = (count) => () => {
95 return count++;

Callers 2

index-test.jsFile · 0.90
initFunction · 0.85

Calls 2

createEntropyFunction · 0.85
hashFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…