MCPcopy Create free account
hub / github.com/npm/cli / pathSafeHash

Function pathSafeHash

workspaces/arborist/lib/retire-path.js:5–10  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3
4// use sha1 because it's faster, and collisions extremely unlikely anyway
5const pathSafeHash = s =>
6 crypto.createHash('sha1')
7 .update(s)
8 .digest('base64')
9 .replace(/[^a-zA-Z0-9]+/g, '')
10 .slice(0, 8)
11
12const retirePath = from => {
13 const d = dirname(from)

Callers 1

retirePathFunction · 0.85

Calls 2

replaceMethod · 0.80
updateMethod · 0.80

Tested by

no test coverage detected