MCPcopy
hub / github.com/webpack/webpack / _isSourceEqual

Function _isSourceEqual

lib/util/source.js:20–31  ·  view source on GitHub ↗
(a, b)

Source from the content-addressed store, hash-verified

18 * @returns {boolean} true, when both sources are equal
19 */
20const _isSourceEqual = (a, b) => {
21 // prefer .buffer(), it's called anyway during emit
22 /** @type {Buffer | string} */
23 let aSource = typeof a.buffer === "function" ? a.buffer() : a.source();
24 /** @type {Buffer | string} */
25 let bSource = typeof b.buffer === "function" ? b.buffer() : b.source();
26 if (aSource === bSource) return true;
27 if (typeof aSource === "string" && typeof bSource === "string") return false;
28 if (!Buffer.isBuffer(aSource)) aSource = Buffer.from(aSource, "utf8");
29 if (!Buffer.isBuffer(bSource)) bSource = Buffer.from(bSource, "utf8");
30 return aSource.equals(bSource);
31};
32
33/**
34 * Checks whether this object is source equal.

Callers 1

isSourceEqualFunction · 0.85

Calls 1

sourceMethod · 0.80

Tested by

no test coverage detected