Hash.js 1.9 KB

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