MCPcopy Index your code
hub / github.com/nodejs/node / Hash

Function Hash

lib/internal/crypto/hash.js:95–119  ·  view source on GitHub ↗
(algorithm, options)

Source from the content-addressed store, hash-verified

93);
94
95function Hash(algorithm, options) {
96 if (!new.target)
97 return new Hash(algorithm, options);
98 const isCopy = algorithm instanceof _Hash;
99 if (!isCopy)
100 validateString(algorithm, 'algorithm');
101 let xofLen = typeof options === 'object' && options !== null ?
102 options.outputLength : undefined;
103 if (xofLen !== undefined) {
104 validateUint32(xofLen, 'options.outputLength');
105 // Coerce -0 to +0.
106 xofLen += 0;
107 }
108 // Lookup the cached ID from JS land because it's faster than decoding
109 // the string in C++ land.
110 const algorithmId = isCopy ? -1 : getCachedHashId(algorithm);
111 this[kHandle] = new _Hash(algorithm, xofLen, algorithmId, getHashCache());
112 this[kState] = {
113 [kFinalized]: false,
114 };
115 if (!isCopy && xofLen === undefined) {
116 maybeEmitDeprecationWarning(algorithm);
117 }
118 FunctionPrototypeCall(LazyTransform, this, options);
119}
120
121ObjectSetPrototypeOf(Hash.prototype, LazyTransform.prototype);
122ObjectSetPrototypeOf(Hash, LazyTransform);

Callers

nothing calls this directly

Calls 2

getCachedHashIdFunction · 0.85
getHashCacheFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…