1 | // Type definitions for http-assert 1.5
|
2 | // Project: https://github.com/jshttp/http-assert
|
3 | // Definitions by: jKey Lu <https://github.com/jkeylu>
|
4 | // Peter Squicciarini <https://github.com/stripedpajamas>
|
5 | // Alex Bulanov <https://github.com/sapfear>
|
6 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
7 | // TypeScript Version: 2.3
|
8 |
|
9 | /**
|
10 | * @param status the status code
|
11 | * @param msg the message of the error, defaulting to node's text for that status code
|
12 | * @param opts custom properties to attach to the error object
|
13 | */
|
14 | declare function assert(value: any, status?: number, msg?: string, opts?: Record<string, any>): asserts value;
|
15 | declare function assert(value: any, status?: number, opts?: Record<string, any>): asserts value;
|
16 |
|
17 | declare namespace assert {
|
18 | /**
|
19 | * @param status the status code
|
20 | * @param msg the message of the error, defaulting to node's text for that status code
|
21 | * @param opts custom properties to attach to the error object
|
22 | */
|
23 | type Assert = <T>(a: T, b: T, status?: number, msg?: string, opts?: Record<string, any>) => void;
|
24 |
|
25 | /**
|
26 | * @param status the status code
|
27 | * @param msg the message of the error, defaulting to node's text for that status code
|
28 | * @param opts custom properties to attach to the error object
|
29 | */
|
30 | type AssertOK = (a: any, status?: number, msg?: string, opts?: Record<string, any>) => asserts a;
|
31 |
|
32 | /**
|
33 | * @param status the status code
|
34 | * @param msg the message of the error, defaulting to node's text for that status code
|
35 | * @param opts custom properties to attach to the error object
|
36 | */
|
37 | type AssertEqual = (a: any, b: any, status?: number, msg?: string, opts?: Record<string, any>) => void;
|
38 |
|
39 | const equal: Assert;
|
40 | const notEqual: Assert;
|
41 | const ok: AssertOK;
|
42 | const strictEqual: AssertEqual;
|
43 | const notStrictEqual: AssertEqual;
|
44 | const deepEqual: AssertEqual;
|
45 | const notDeepEqual: AssertEqual;
|
46 | }
|
47 |
|
48 | export = assert;
|