1 | # Installation
|
2 | > `npm install --save @types/co`
|
3 |
|
4 | # Summary
|
5 | This package contains type definitions for co (https://github.com/tj/co#readme).
|
6 |
|
7 | # Details
|
8 | Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/co.
|
9 | ## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/co/index.d.ts)
|
10 | ````ts
|
11 | // Type definitions for co 4.6
|
12 | // Project: https://github.com/tj/co#readme
|
13 | // Definitions by: Doniyor Aliyev <https://github.com/doniyor2109>
|
14 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
15 | // Minimum TypeScript Version: 3.6
|
16 |
|
17 | // Since TS 3.6 the checker knows that the correct type of returned values and yielded values https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-6.html
|
18 | // Generator<T, TReturn, TNext> => TReturn
|
19 | // Function => ReturnType<Function>
|
20 | // others => others
|
21 | type ExtractType<I> = I extends { [Symbol.iterator]: () => Iterator<any, infer TReturn, any> }
|
22 | ? TReturn
|
23 | : I extends (...args: any[]) => any
|
24 | ? ReturnType<I>
|
25 | : I;
|
26 |
|
27 | interface Co {
|
28 | <F extends (...args: any[]) => Iterator<any, any, any>>(fn: F, ...args: Parameters<F>): Promise<
|
29 | ExtractType<ReturnType<F>>
|
30 | >;
|
31 | default: Co;
|
32 | co: Co;
|
33 | wrap: <F extends (...args: any[]) => Iterator<any, any, any>>(
|
34 | fn: F,
|
35 | ) => (...args: Parameters<F>) => Promise<ExtractType<ReturnType<F>>>;
|
36 | }
|
37 |
|
38 | declare const co: Co;
|
39 |
|
40 | export = co;
|
41 |
|
42 | ````
|
43 |
|
44 | ### Additional Details
|
45 | * Last updated: Mon, 27 Sep 2021 14:01:21 GMT
|
46 | * Dependencies: none
|
47 | * Global values: none
|
48 |
|
49 | # Credits
|
50 | These definitions were written by [Doniyor Aliyev](https://github.com/doniyor2109).
|
51 |
|
\ | No newline at end of file |