Skip to content

Commit

Permalink
Allow mixed input arrays (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
novemberborn authored and sindresorhus committed Mar 13, 2019
1 parent c11e960 commit 999304f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Hash} from 'crypto';
import {Readable as ReadableStream} from 'stream';

export type ToStringEncoding = 'hex' | 'base64' | 'latin1';
export type HashaInput = string | string[] | Buffer | Buffer[];
export type HashaInput = Buffer | string | Array<Buffer | string>;
export type HashaEncoding = ToStringEncoding | 'buffer';

// TODO: Remove this clutter after https://github.com/Microsoft/TypeScript/issues/29729 is resolved
Expand Down
4 changes: 4 additions & 0 deletions index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ expectType<string>(hasha('unicorn', {algorithm: 'md5'}));
expectType<string>(hasha('unicorn', {encoding: 'latin1'}));
expectType<Buffer>(hasha('unicorn', {encoding: 'buffer'}));

expectType<string>(hasha(['unicorn']));
expectType<string>(hasha([Buffer.from('unicorn', 'utf8')]));
expectType<string>(hasha(['unicorn', Buffer.from('unicorn', 'utf8')]));

process.stdin.pipe(hasha.stream()).pipe(process.stdout);

expectType<Promise<string | null>>(hasha.fromStream(process.stdin));
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Returns a hash.

#### input

Type: `Buffer | string | Buffer[] | string[]`
Type: `Buffer | string | Array<Buffer | string>`

Buffer you want to hash.

Expand Down

0 comments on commit 999304f

Please sign in to comment.