| 1 |
import {expectType} from 'tsd'; |
| 2 |
import hasha = require('.'); |
| 3 |
|
| 4 |
expectType<string>(hasha('unicorn')); |
| 5 |
expectType<string>(hasha('unicorn', {algorithm: 'md5'})); |
| 6 |
expectType<string>(hasha('unicorn', {encoding: 'latin1'})); |
| 7 |
expectType<Buffer>(hasha('unicorn', {encoding: 'buffer'})); |
| 8 |
|
| 9 |
expectType<string>(hasha(['unicorn'])); |
| 10 |
expectType<string>(hasha([Buffer.from('unicorn', 'utf8')])); |
| 11 |
expectType<string>(hasha(['unicorn', Buffer.from('unicorn', 'utf8')])); |
| 12 |
|
| 13 |
expectType<Promise<string>>(hasha.async('unicorn')); |
| 14 |
expectType<Promise<string>>(hasha.async('unicorn', {algorithm: 'md5'})); |
| 15 |
expectType<Promise<string>>(hasha.async('unicorn', {encoding: 'latin1'})); |
| 16 |
expectType<Promise<Buffer>>(hasha.async('unicorn', {encoding: 'buffer'})); |
| 17 |
|
| 18 |
expectType<Promise<string>>(hasha.async(['unicorn'])); |
| 19 |
expectType<Promise<string>>(hasha.async([Buffer.from('unicorn', 'utf8')])); |
| 20 |
expectType<Promise<string>>(hasha.async(['unicorn', Buffer.from('unicorn', 'utf8')])); |
| 21 |
|
| 22 |
process.stdin.pipe(hasha.stream()).pipe(process.stdout); |
| 23 |
|
| 24 |
expectType<Promise<string | null>>(hasha.fromStream(process.stdin)); |
| 25 |
expectType<Promise<string | null>>( |
| 26 |
hasha.fromStream(process.stdin, {encoding: 'hex'}) |
| 27 |
); |
| 28 |
expectType<Promise<Buffer | null>>( |
| 29 |
hasha.fromStream(process.stdin, {encoding: 'buffer'}) |
| 30 |
); |
| 31 |
|
| 32 |
expectType<Promise<string | null>>(hasha.fromFile('unicorn.png')); |
| 33 |
expectType<Promise<string | null>>( |
| 34 |
hasha.fromFile('unicorn.png', {encoding: 'base64'}) |
| 35 |
); |
| 36 |
expectType<Promise<Buffer | null>>( |
| 37 |
hasha.fromFile('unicorn.png', {encoding: 'buffer'}) |
| 38 |
); |
| 39 |
|
| 40 |
expectType<string>(hasha.fromFileSync('unicorn.png')); |
| 41 |
expectType<string>(hasha.fromFileSync('unicorn.png', {encoding: 'base64'})); |
| 42 |
expectType<Buffer>(hasha.fromFileSync('unicorn.png', {encoding: 'buffer'})); |