-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathindex.test-d.ts
51 lines (43 loc) · 1.76 KB
/
index.test-d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import process from 'node:process';
import {expectType} from 'tsd';
import {
hash,
hashSync,
hashFile,
hashFileSync,
hashingStream,
} from './index.js';
expectType<string>(hashSync('unicorn'));
expectType<string>(hashSync('unicorn', {algorithm: 'md5'}));
expectType<string>(hashSync('unicorn', {encoding: 'latin1'}));
expectType<Buffer>(hashSync('unicorn', {encoding: 'buffer'}));
expectType<string>(hashSync(['unicorn']));
expectType<string>(hashSync([Buffer.from('unicorn', 'utf8')]));
expectType<string>(hashSync(['unicorn', Buffer.from('unicorn', 'utf8')]));
expectType<Promise<string>>(hash('unicorn'));
expectType<Promise<string>>(hash('unicorn', {algorithm: 'md5'}));
expectType<Promise<string>>(hash('unicorn', {encoding: 'latin1'}));
expectType<Promise<Buffer>>(hash('unicorn', {encoding: 'buffer'}));
expectType<Promise<string>>(hash(['unicorn']));
expectType<Promise<string>>(hash([Buffer.from('unicorn', 'utf8')]));
expectType<Promise<string>>(hash(['unicorn', Buffer.from('unicorn', 'utf8')]));
process.stdin.pipe(hashingStream()).pipe(process.stdout);
/* eslint-disable @typescript-eslint/no-unsafe-argument */
expectType<Promise<string>>(hash(process.stdin));
expectType<Promise<string>>(
hash(process.stdin, {encoding: 'hex'}),
);
expectType<Promise<Buffer>>(
hash(process.stdin, {encoding: 'buffer'}),
);
/* eslint-enable @typescript-eslint/no-unsafe-argument */
expectType<Promise<string>>(hashFile('unicorn.png'));
expectType<Promise<string>>(
hashFile('unicorn.png', {encoding: 'base64'}),
);
expectType<Promise<Buffer>>(
hashFile('unicorn.png', {encoding: 'buffer'}),
);
expectType<string>(hashFileSync('unicorn.png'));
expectType<string>(hashFileSync('unicorn.png', {encoding: 'base64'}));
expectType<Buffer>(hashFileSync('unicorn.png', {encoding: 'buffer'}));