blake3_js.d.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* tslint:disable */
  2. /* eslint-disable */
  3. /**
  4. * @param {Uint8Array} data
  5. * @param {Uint8Array} out
  6. */
  7. export function hash(data: Uint8Array, out: Uint8Array): void;
  8. /**
  9. * @returns {Blake3Hash}
  10. */
  11. export function create_hasher(): Blake3Hash;
  12. /**
  13. * @param {Uint8Array} key_slice
  14. * @returns {Blake3Hash}
  15. */
  16. export function create_keyed(key_slice: Uint8Array): Blake3Hash;
  17. /**
  18. * @param {string} context
  19. * @returns {Blake3Hash}
  20. */
  21. export function create_derive(context: string): Blake3Hash;
  22. /**
  23. */
  24. export class Blake3Hash {
  25. free(): void;
  26. /**
  27. * @returns {HashReader}
  28. */
  29. reader(): HashReader;
  30. /**
  31. * @param {Uint8Array} input_bytes
  32. */
  33. update(input_bytes: Uint8Array): void;
  34. /**
  35. * @param {Uint8Array} out
  36. */
  37. digest(out: Uint8Array): void;
  38. }
  39. /**
  40. */
  41. export class HashReader {
  42. free(): void;
  43. /**
  44. * @param {Uint8Array} bytes
  45. */
  46. fill(bytes: Uint8Array): void;
  47. /**
  48. * @param {BigInt} position
  49. */
  50. set_position(position: BigInt): void;
  51. }
  52. export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
  53. export interface InitOutput {
  54. readonly memory: WebAssembly.Memory;
  55. readonly hash: (a: number, b: number, c: number, d: number) => void;
  56. readonly create_hasher: () => number;
  57. readonly create_keyed: (a: number, b: number) => number;
  58. readonly create_derive: (a: number, b: number) => number;
  59. readonly __wbg_blake3hash_free: (a: number) => void;
  60. readonly blake3hash_reader: (a: number) => number;
  61. readonly blake3hash_update: (a: number, b: number, c: number) => void;
  62. readonly blake3hash_digest: (a: number, b: number, c: number) => void;
  63. readonly __wbg_hashreader_free: (a: number) => void;
  64. readonly hashreader_fill: (a: number, b: number, c: number) => void;
  65. readonly hashreader_set_position: (a: number, b: number, c: number) => void;
  66. readonly __wbindgen_malloc: (a: number) => number;
  67. readonly __wbindgen_free: (a: number, b: number) => void;
  68. readonly __wbindgen_realloc: (a: number, b: number, c: number) => number;
  69. }
  70. /**
  71. * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
  72. * for everything else, calls `WebAssembly.instantiate` directly.
  73. *
  74. * @param {InitInput | Promise<InitInput>} module_or_path
  75. *
  76. * @returns {Promise<InitOutput>}
  77. */
  78. export default function init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;