Hash.js 1.9 KB

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