UNPKG

1.64 kBMarkdownView Raw
1# Installation
2> `npm install --save @types/iferr`
3
4# Summary
5This package contains type definitions for iferr (https://github.com/shesek/iferr).
6
7# Details
8Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/iferr.
9## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/iferr/index.d.ts)
10````ts
11type nodeCallback<T> = (err: Error | null, ...a: T[]) => any;
12
13// Delegates to `succ` on sucecss or to `fail` on error
14// ex: Thing.load(123, iferr(cb, thing => ...))
15declare function iferr<T>(fail: (err: Error) => void, succ: (...result: T[]) => void): nodeCallback<T>;
16
17declare namespace iferr {
18 // Delegates to `succ` on sucecss or to `fail` on error
19 // ex: Thing.load(123, iferr(cb, thing => ...))
20 function iferr<T>(fail: (err: Error) => void, succ: (...result: T[]) => void): nodeCallback<T>;
21
22 // Like iferr, but also catches errors thrown from `succ` and passes to `fail`
23 function tiferr<T>(fail: (err: Error) => void, succ: (...result: T[]) => void): nodeCallback<T>;
24
25 // Delegate to the success function on success, throws the error otherwise
26 // ex: Thing.load(123, throwerr(thing => ...))
27 function throwerr<T>(succ: (...result: T[]) => void): nodeCallback<T>;
28
29 // Prints errors when one is passed, or does nothing otherwise
30 // ex: Thing.load(123, printerr)
31 function printerr(): nodeCallback<any>;
32}
33
34export = iferr;
35
36````
37
38### Additional Details
39 * Last updated: Tue, 07 Nov 2023 03:09:37 GMT
40 * Dependencies: none
41
42# Credits
43These definitions were written by [segayuu](https://github.com/segayuu).
44
\No newline at end of file