UNPKG

1.59 kBMarkdownView Raw
1# Installation
2> `npm install --save @types/statuses`
3
4# Summary
5This package contains type definitions for statuses (https://github.com/jshttp/statuses).
6
7# Details
8Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/statuses.
9## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/statuses/index.d.ts)
10````ts
11type NumericAscii = "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "0";
12type NonNumericAscii<S> = S extends `${NumericAscii}` ? never : any;
13
14type IsNumericString<S extends string> = S extends `${number}` ? any : never;
15
16type IsNonNumericString<S extends string> = S extends `${NonNumericAscii<S>}${infer _}` ? any : never;
17
18export = status;
19
20declare const status: status;
21
22interface status {
23 (code: number): string;
24 <S extends string>(code: S): status.Result<S>;
25
26 codes: number[];
27 code: { [msg: string]: number | undefined };
28 empty: { [code: number]: boolean | undefined };
29 message: { [code: number]: string | undefined };
30 redirect: { [code: number]: boolean | undefined };
31 retry: { [code: number]: boolean | undefined };
32}
33
34declare namespace status {
35 type Result<S extends string> = S extends IsNumericString<S> ? string
36 : S extends IsNonNumericString<S> ? number
37 : string | number;
38}
39
40````
41
42### Additional Details
43 * Last updated: Tue, 07 Nov 2023 20:08:00 GMT
44 * Dependencies: none
45
46# Credits
47These definitions were written by [Tanguy Krotoff](https://github.com/tkrotoff), and [BendingBender](https://github.com/BendingBender).
48
\No newline at end of file