15815213711
2024-08-26 67b8b6731811983447e053d4396b3708c14dfe3c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { expectType } from 'tsd';
import { curl } from '..';
 
// curl
expectType<Buffer>((await curl<Buffer>('http://a.com')).data);
// RequestOptions
expectType<Buffer>((await curl<Buffer>('http://a.com', {})).data);
expectType<string>((await curl<string>('http://a.com', {
  method: 'HEAD',
})).data);
expectType<string>((await curl<string>('http://a.com', {
  method: 'head',
})).data);
 
// HttpClientResponse
const res = await curl<Buffer>('http://a.com');
expectType<number | undefined>(res.res.timing?.queuing);
expectType<number | undefined>(res.res.timing?.dnslookup);
expectType<number | undefined>(res.res.timing?.connected);
expectType<number | undefined>(res.res.timing?.requestSent);
expectType<number | undefined>(res.res.timing?.waiting);
expectType<number | undefined>(res.res.timing?.contentDownload);