Skip to content

Commit

Permalink
馃 Merge PR #44434 keccak: fix type definition by @odanado
Browse files Browse the repository at this point in the history
  • Loading branch information
odanado committed May 4, 2020
1 parent 6de1126 commit cdffe89
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions types/keccak/index.d.ts
Expand Up @@ -15,13 +15,15 @@ export class Keccak extends Transform {
options: TransformOptions,
);
update(data: string | Buffer, encoding?: BufferEncoding): Keccak;
digest(encoding?: BufferEncoding): Buffer;
digest(): Buffer;
digest(encoding: BufferEncoding): string;
}

export class Shake extends Transform {
constructor(rate: number, capacity: number, delimitedSuffix: number | null, options: TransformOptions);
update(data: string | Buffer, encoding?: BufferEncoding): Shake;
squeeze(dataByteLength: number, encoding?: BufferEncoding): Buffer;
squeeze(dataByteLength: number): Buffer;
squeeze(dataByteLength: number, encoding: BufferEncoding): string;
}

export type KeccakAlgorithm = 'keccak224' | 'keccak256' | 'keccak384' | 'keccak512';
Expand Down
3 changes: 3 additions & 0 deletions types/keccak/keccak-tests.ts
Expand Up @@ -2,9 +2,12 @@ import create from 'keccak';

const keccak = create('keccak224'); // $ExpectType Keccak
keccak.update('alice').digest(); // $ExpectType Buffer
keccak.update('alice').digest("hex"); // $ExpectType string

const sha3 = create('sha3-224'); // $ExpectType Keccak
sha3.update('alice').digest(); // $ExpectType Buffer
sha3.update('alice').digest("utf-8"); // $ExpectType string

const shake = create('shake128'); // $ExpectType Shake
shake.update('alice').squeeze(42); // $ExpectType Buffer
shake.update('alice').squeeze(42, "ascii"); // $ExpectType string

0 comments on commit cdffe89

Please sign in to comment.