Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/getHashDigest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ export const baseEncodeTables = {
export type BaseEncoding = keyof typeof baseEncodeTables;
export type DigestType = `base${BaseEncoding}`;

/**
* @param uint32Array - Treated as a long base-0x100000000 number, little endian
* @param divisor - The divisor
* @return Modulo (remainder) of the division
*/
function divmod32(uint32Array: Uint32Array, divisor: number): number {
let carry = 0;
for (let i = uint32Array.length - 1; i >= 0; i--) {
Expand Down
17 changes: 8 additions & 9 deletions lib/hash/wasm-hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export const MAX_SHORT_STRING: number = Math.floor((65536 - 64) / 4) & ~3;

export class WasmHash implements IHashLike {
/**
* @param {WebAssembly.Instance} instance wasm instance
* @param {WebAssembly.Instance[]} instancesPool pool of instances
* @param {number} chunkSize size of data chunks passed to wasm
* @param {number} digestSize size of digest returned by wasm
* @param instance - wasm instance
* @param instancesPool - pool of instances
* @param chunkSize - size of data chunks passed to wasm
* @param digestSize - size of digest returned by wasm
*/
exports: any;
mem: Buffer;
Expand Down Expand Up @@ -51,9 +51,9 @@ export class WasmHash implements IHashLike {
}

/**
* @param {Buffer | string} data data
* @param {BufferEncoding=} encoding encoding
* @returns {this} itself
* @param data - data
* @param encoding - encoding
* @returns itself
*/
update(data: Buffer | string, encoding: BufferEncoding): this {
if (typeof data === "string") {
Expand Down Expand Up @@ -128,8 +128,7 @@ export class WasmHash implements IHashLike {
}

/**
* @param {Buffer} data data
* @returns {void}
* @param data - data
*/
_updateWithBuffer(data: Buffer): void {
const { exports, buffered, mem } = this;
Expand Down