MCPcopy Create free account
hub / github.com/webpack/webpack / update

Method update

lib/util/hash/BatchedHash.js:49–83  ·  view source on GitHub ↗

* Update hash https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding * @param {string | Buffer} data data * @param {Encoding=} inputEncoding data encoding * @returns {Hash} updated hash

(data, inputEncoding)

Source from the content-addressed store, hash-verified

47 * @returns {Hash} updated hash
48 */
49 update(data, inputEncoding) {
50 if (this.string !== undefined) {
51 if (
52 typeof data === "string" &&
53 inputEncoding === this.encoding &&
54 this.string.length + data.length < MAX_SHORT_STRING
55 ) {
56 this.string += data;
57 return this;
58 }
59 if (this.encoding) {
60 update(this.hash, this.string, this.encoding);
61 } else {
62 update(this.hash, this.string);
63 }
64 this.string = undefined;
65 }
66 if (typeof data === "string") {
67 if (
68 data.length < MAX_SHORT_STRING &&
69 // base64 encoding is not valid since it may contain padding chars
70 (!inputEncoding || !inputEncoding.startsWith("ba"))
71 ) {
72 this.string = data;
73 this.encoding = inputEncoding;
74 } else if (inputEncoding) {
75 update(this.hash, data, inputEncoding);
76 } else {
77 update(this.hash, data);
78 }
79 } else {
80 update(this.hash, data);
81 }
82 return this;
83 }
84
85 /**
86 * Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}

Callers

nothing calls this directly

Calls 1

updateFunction · 0.70

Tested by

no test coverage detected