From 999304fb3e49bffa6ad9bfaaab0fedefd092f56b Mon Sep 17 00:00:00 2001 From: Mark Wubben Date: Wed, 13 Mar 2019 12:06:07 +0100 Subject: [PATCH] Allow mixed input arrays (#17) --- index.d.ts | 2 +- index.test-d.ts | 4 ++++ readme.md | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 0c30d6b..3c8da66 100644 --- a/index.d.ts +++ b/index.d.ts @@ -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; export type HashaEncoding = ToStringEncoding | 'buffer'; // TODO: Remove this clutter after https://github.com/Microsoft/TypeScript/issues/29729 is resolved diff --git a/index.test-d.ts b/index.test-d.ts index de0d85f..518bfcb 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -6,6 +6,10 @@ expectType(hasha('unicorn', {algorithm: 'md5'})); expectType(hasha('unicorn', {encoding: 'latin1'})); expectType(hasha('unicorn', {encoding: 'buffer'})); +expectType(hasha(['unicorn'])); +expectType(hasha([Buffer.from('unicorn', 'utf8')])); +expectType(hasha(['unicorn', Buffer.from('unicorn', 'utf8')])); + process.stdin.pipe(hasha.stream()).pipe(process.stdout); expectType>(hasha.fromStream(process.stdin)); diff --git a/readme.md b/readme.md index ff93098..c339073 100644 --- a/readme.md +++ b/readme.md @@ -63,7 +63,7 @@ Returns a hash. #### input -Type: `Buffer | string | Buffer[] | string[]` +Type: `Buffer | string | Array` Buffer you want to hash.