| 1 | /*
|
|---|
| 2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
|---|
| 3 | Author Tobias Koppers @sokra
|
|---|
| 4 | */
|
|---|
| 5 |
|
|---|
| 6 | "use strict";
|
|---|
| 7 |
|
|---|
| 8 | /** @typedef {import("../../declarations/WebpackOptions").HashDigest} Encoding */
|
|---|
| 9 | /** @typedef {string | typeof Hash} HashFunction */
|
|---|
| 10 |
|
|---|
| 11 | class Hash {
|
|---|
| 12 | /* istanbul ignore next */
|
|---|
| 13 | /**
|
|---|
| 14 | * Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
|---|
| 15 | * @abstract
|
|---|
| 16 | * @overload
|
|---|
| 17 | * @param {string | Buffer} data data
|
|---|
| 18 | * @returns {Hash} updated hash
|
|---|
| 19 | */
|
|---|
| 20 | /**
|
|---|
| 21 | * Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
|---|
| 22 | * @abstract
|
|---|
| 23 | * @overload
|
|---|
| 24 | * @param {string} data data
|
|---|
| 25 | * @param {Encoding} inputEncoding data encoding
|
|---|
| 26 | * @returns {Hash} updated hash
|
|---|
| 27 | */
|
|---|
| 28 | /**
|
|---|
| 29 | * Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
|---|
| 30 | * @abstract
|
|---|
| 31 | * @param {string | Buffer} data data
|
|---|
| 32 | * @param {Encoding=} inputEncoding data encoding
|
|---|
| 33 | * @returns {Hash} updated hash
|
|---|
| 34 | */
|
|---|
| 35 | update(data, inputEncoding) {
|
|---|
| 36 | const AbstractMethodError = require("../errors/AbstractMethodError");
|
|---|
| 37 |
|
|---|
| 38 | throw new AbstractMethodError();
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | /* istanbul ignore next */
|
|---|
| 42 | /**
|
|---|
| 43 | * Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
|---|
| 44 | * @abstract
|
|---|
| 45 | * @overload
|
|---|
| 46 | * @returns {Buffer} digest
|
|---|
| 47 | */
|
|---|
| 48 | /**
|
|---|
| 49 | * Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
|---|
| 50 | * @abstract
|
|---|
| 51 | * @overload
|
|---|
| 52 | * @param {Encoding} encoding encoding of the return value
|
|---|
| 53 | * @returns {string} digest
|
|---|
| 54 | */
|
|---|
| 55 | /**
|
|---|
| 56 | * Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
|---|
| 57 | * @abstract
|
|---|
| 58 | * @param {Encoding=} encoding encoding of the return value
|
|---|
| 59 | * @returns {string | Buffer} digest
|
|---|
| 60 | */
|
|---|
| 61 | digest(encoding) {
|
|---|
| 62 | const AbstractMethodError = require("../errors/AbstractMethodError");
|
|---|
| 63 |
|
|---|
| 64 | throw new AbstractMethodError();
|
|---|
| 65 | }
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | module.exports = Hash;
|
|---|