| 18 | * @returns {boolean} true, when both sources are equal |
| 19 | */ |
| 20 | const _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. |