source: frontend/node_modules/webpack/lib/util/hash/DebugHash.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 2.1 KB
RevLine 
[9af201e]1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Alexander Akait @alexander-akait
4*/
5
6"use strict";
7
8const Hash = require("../Hash");
9
10/** @typedef {import("../../../declarations/WebpackOptions").HashDigest} Encoding */
11
12/* istanbul ignore next */
13class DebugHash extends Hash {
14 constructor() {
15 super();
16 this.string = "";
17 }
18
19 /**
20 * Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
21 * @overload
22 * @param {string | Buffer} data data
23 * @returns {Hash} updated hash
24 */
25 /**
26 * Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
27 * @overload
28 * @param {string} data data
29 * @param {Encoding} inputEncoding data encoding
30 * @returns {Hash} updated hash
31 */
32 /**
33 * Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
34 * @param {string | Buffer} data data
35 * @param {Encoding=} inputEncoding data encoding
36 * @returns {Hash} updated hash
37 */
38 update(data, inputEncoding) {
39 if (typeof data !== "string") data = data.toString("utf8");
40 const prefix = Buffer.from("@webpack-debug-digest@").toString("hex");
41 if (data.startsWith(prefix)) {
42 data = Buffer.from(data.slice(prefix.length), "hex").toString();
43 }
44 this.string += `[${data}](${
45 /** @type {string} */
46 (
47 // eslint-disable-next-line unicorn/error-message
48 new Error().stack
49 ).split("\n", 3)[2]
50 })\n`;
51 return this;
52 }
53
54 /**
55 * Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
56 * @overload
57 * @returns {Buffer} digest
58 */
59 /**
60 * Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
61 * @overload
62 * @param {Encoding} encoding encoding of the return value
63 * @returns {string} digest
64 */
65 /**
66 * Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
67 * @param {Encoding=} encoding encoding of the return value
68 * @returns {string | Buffer} digest
69 */
70 digest(encoding) {
71 return Buffer.from(`@webpack-debug-digest@${this.string}`).toString("hex");
72 }
73}
74
75module.exports = DebugHash;
Note: See TracBrowser for help on using the repository browser.