MCPcopy
hub / github.com/webpack/webpack / digest

Method digest

lib/util/hash/wasm-hash.js:199–209  ·  view source on GitHub ↗

* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding} * @param {string=} encoding encoding of the return value * @returns {string | Buffer} digest

(encoding)

Source from the content-addressed store, hash-verified

197 * @returns {string | Buffer} digest
198 */
199 digest(encoding) {
200 const { exports, buffered, mem, digestSize } = this;
201 exports.final(buffered);
202 this.instancesPool.push(this);
203 const hex = mem.toString("latin1", 0, digestSize);
204 if (encoding === "hex") return hex;
205 if (encoding === "binary" || !encoding) return Buffer.from(hex, "hex");
206 return Buffer.from(hex, "hex").toString(
207 /** @type {NodeJS.BufferEncoding} */ (encoding)
208 );
209 }
210}
211
212/**

Callers 1

digestFunction · 0.45

Calls 2

pushMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected