Skip to content

Commit 32b132c

Browse files
author
Ivan Kalagin
committed
add d.ts for each file
1 parent 58821dd commit 32b132c

File tree

183 files changed

+4529
-6163
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

183 files changed

+4529
-6163
lines changed

AggregateReducer.d.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export = AggregateReducer;
2+
/**
3+
* @name AggregateReducer
4+
*
5+
* @synopsis
6+
* ```coffeescript [specscript]
7+
* AggregateReducer(reducers Array<reducer function>) -> aggregateReducer function
8+
* ```
9+
*/
10+
declare function AggregateReducer(reducers: any): any;

Transducer.d.ts

+231
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
/**
2+
* @name Transducer.map
3+
*
4+
* @synopsis
5+
* ```coffeescript [specscript]
6+
* type Reducer = (
7+
* accumulator any,
8+
* value any,
9+
* indexOrKey? number|string,
10+
* collection? Foldable,
11+
* )=>(nextAccumulator Promise|any)
12+
*
13+
* type Transducer = Reducer=>Reducer
14+
*
15+
* Transducer.map(mapperFunc function) -> mappingTransducer Transducer
16+
* ```
17+
*
18+
* @description
19+
* Creates a mapping transducer. Items in the final reducing operation are transformed by the mapper function. It is possible to use an asynchronous mapper, however the reducing operation must support asynchronous execution. This library provides such implementations as [reduce](/docs/reduce) and [transform](/docs/transform).
20+
*
21+
* ```javascript [playground]
22+
* const square = number => number ** 2
23+
*
24+
* const concat = (array, item) => array.concat(item)
25+
*
26+
* const mapSquare = Transducer.map(square)
27+
* // mapSquare is a transducer
28+
*
29+
* const squareConcatReducer = mapSquare(concat)
30+
* // now mapSquare is passed the reducer function concat; squareConcatReducer
31+
* // is a reducer with chained functionality square and concat
32+
*
33+
* console.log(
34+
* reduce([1, 2, 3, 4, 5], squareConcatReducer, [])
35+
* ) // [1, 4, 9, 16, 25]
36+
*
37+
* // the same squareConcatReducer is consumable with vanilla JavaScript
38+
* console.log(
39+
* [1, 2, 3, 4, 5].reduce(squareConcatReducer, [])
40+
* ) // [1, 4, 9, 16, 25]
41+
*
42+
* // concat is implicit when transforming into arrays
43+
* console.log(
44+
* transform([1, 2, 3, 4, 5], Transducer.map(square), [])
45+
* ) // [1, 4, 9, 16, 25]
46+
* ```
47+
*
48+
* Read more on transducers [here](/blog/transducers-crash-course-rubico-v2).
49+
*/
50+
export function map(mapper: any): (arg0: any) => any;
51+
/**
52+
* @name Transducer.filter
53+
*
54+
* @synopsis
55+
* ```coffeescript [specscript]
56+
* type Reducer = (
57+
* accumulator any,
58+
* value any,
59+
* indexOrKey? number|string,
60+
* collection? Foldable,
61+
* )=>(nextAccumulator Promise|any)
62+
*
63+
* type Transducer = Reducer=>Reducer
64+
*
65+
* Transducer.filter(predicate function) -> filteringTransducer Transducer
66+
* ```
67+
*
68+
* @description
69+
* Creates a filtering transducer. A filtering reducer skips items of reducing operation if they test falsy by the predicate. It is possible to use an asynchronous predicate, however the reducing operation must support asynchronous execution. This library provides such implementations as [reduce](/docs/reduce) and [transform](/docs/transform).
70+
*
71+
* ```javascript [playground]
72+
* const isOdd = number => number % 2 == 1
73+
*
74+
* const concat = (array, item) => array.concat(item)
75+
*
76+
* const concatOddNumbers = filter(isOdd)(concat)
77+
*
78+
* console.log(
79+
* [1, 2, 3, 4, 5].reduce(concatOddNumbers, []),
80+
* ) // [1, 3, 5]
81+
* ```
82+
*/
83+
export function filter(predicate: any): (arg0: any) => any;
84+
/**
85+
* @name Transducer.flatMap
86+
*
87+
* @synopsis
88+
* ```coffeescript [specscript]
89+
* type Reducer = (
90+
* accumulator any,
91+
* value any,
92+
* indexOrKey? number|string,
93+
* collection? Foldable,
94+
* )=>(nextAccumulator Promise|any)
95+
*
96+
* type Transducer = Reducer=>Reducer
97+
*
98+
* Transducer.flatMap(flatMapper) -> flatMappingTransducer Transducer
99+
* ```
100+
*
101+
* @description
102+
* Creates a flatMapping transducer. A flatMapping transducer applies the flatMapping function to each item of the reducing operation, concatenating the results of the flatMapper execution into the final result. It is possible to use an asynchronous flatMapper, however the reducing operation must support asynchronous execution. This library provides such implementations as [reduce](/docs/reduce) and [transform](/docs/transform).
103+
*
104+
* ```javascript [playground]
105+
* const powers = number => [number, number ** 2, number ** 3]
106+
*
107+
* const numbers = [1, 2, 3, 4, 5]
108+
*
109+
* console.log(
110+
* transform(numbers, Transducer.flatMap(powers), [])
111+
* ) // [1, 1, 1, 2, 4, 8, 3, 9, 27, 4, 16, 64, 5, 25, 125]
112+
* ```
113+
*
114+
* Read more on transducers [here](/blog/transducers-crash-course-rubico-v2).
115+
*/
116+
export function flatMap(flatMapper: any): (arg0: any) => any;
117+
/**
118+
* @name Transducer.forEach
119+
*
120+
* @synopsis
121+
* ```coffeescript [specscript]
122+
* type Reducer = (
123+
* accumulator any,
124+
* value any,
125+
* indexOrKey? number|string,
126+
* collection? Foldable,
127+
* )=>(nextAccumulator Promise|any)
128+
*
129+
* type Transducer = Reducer=>Reducer
130+
*
131+
* Transducer.forEach(func function) -> forEachTransducer Transducer
132+
* ```
133+
*
134+
* @description
135+
* Creates an effectful pasthrough transducer. The effectful passthrough transducer applies the effectful function to each item of the reducing operation, leaving the reducing operation unchanged. It is possible to use an asynchronous effectful function, however the reducing operation must support asynchronous execution. This library provides such implementations as [reduce](/docs/reduce) and [transform](/docs/transform).
136+
*
137+
* ```javascript [playground]
138+
* const numbers = [1, 2, 3, 4, 5]
139+
* transform(numbers, compose([
140+
* Transducer.map(number => number ** 2),
141+
* Transducer.forEach(console.log), // 1 4 9 16 25
142+
* ]), null)
143+
* ```
144+
*/
145+
export function forEach(func: any): (arg0: any) => any;
146+
/**
147+
* @name Transducer.passthrough
148+
*
149+
* @synopsis
150+
* ```coffeescript [specscript]
151+
* type Reducer = (
152+
* accumulator any,
153+
* value any,
154+
* indexOrKey? number|string,
155+
* collection? Foldable,
156+
* )=>(nextAccumulator Promise|any)
157+
*
158+
* type Transducer = Reducer=>Reducer
159+
*
160+
* Transducer.passthrough(func function) -> passthroughTransducer Transducer
161+
* ```
162+
*
163+
* @description
164+
* Creates a pasthrough transducer. The passthrough transducer passes each item of the reducing operation through, leaving the reducing operation unchanged.
165+
*
166+
* ```javascript [playground]
167+
* const createAsyncNumbers = async function* () {
168+
* let number = 0
169+
* while (number < 10) {
170+
* yield number
171+
* number += 1
172+
* }
173+
* }
174+
*
175+
* transform(createAsyncNumbers(), Transducer.passthrough, [])
176+
* .then(console.log) // [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
177+
* ```
178+
*/
179+
export function passthrough(reducer: any): any;
180+
/**
181+
* @name Transducer.tryCatch
182+
*
183+
* @synopsis
184+
* ```coffeescript [specscript]
185+
* type Reducer = (
186+
* accumulator any,
187+
* item any,
188+
* indexOrKey? number|string,
189+
* collection? Foldable,
190+
* )=>(nextAccumulator Promise|any)
191+
*
192+
* type Transducer = Reducer=>Reducer
193+
*
194+
* Transducer.tryCatch(
195+
* transducerTryer Transducer,
196+
* catcher (error Error, item any)=>Promise|any,
197+
* ) -> tryCatchTransducer Transducer
198+
* ```
199+
*
200+
* @description
201+
* Creates an error handling transducer. The error handling transducer wraps a transducer and catches any errors thrown by the transducer with the catcher function. The catcher function is provided the error as well as the original item (before any processing by the transducer) for which the error was thrown. It is possible for either the transducer or the catcher to be asynchronous, however the reducing operation must support asynchronous execution. This library provides such implementations as [reduce](/docs/reduce) and [transform](/docs/transform).
202+
*
203+
* ```javascript [playground]
204+
* const db = new Map()
205+
* db.set('a', { id: 'a', name: 'George' })
206+
* db.set('b', { id: 'b', name: 'Jane' })
207+
* db.set('c', { id: 'c', name: 'Jill' })
208+
* db.set('e', { id: 'e', name: 'Jim' })
209+
*
210+
* const userIds = ['a', 'b', 'c', 'd', 'e']
211+
*
212+
* transform(userIds, Transducer.tryCatch(compose([
213+
* Transducer.map(async userId => {
214+
* if (db.has(userId)) {
215+
* return db.get(userId)
216+
* }
217+
* throw new Error(`user ${userId} not found`)
218+
* }),
219+
*
220+
* Transducer.forEach(user => {
221+
* console.log('Found', user.name)
222+
* })
223+
* ]), (error, userId) => {
224+
* console.error(error)
225+
* console.log('userId in catcher:', userId)
226+
* // original userId for which the error was thrown is provided
227+
* }), null)
228+
* ```
229+
230+
*/
231+
export function tryCatch(transducerTryer: any, catcher: any): (arg0: any) => any;

__.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export = __;
2+
import __ = require("./_internal/placeholder");

_internal/ComparisonOperator.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export = ComparisonOperator;
2+
declare function ComparisonOperator(comparator: any): (...args: any[]) => any;

_internal/FilteringAsyncIterator.d.ts

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
export = FilteringAsyncIterator;
2+
/**
3+
* @name FilteringAsyncIterator
4+
*
5+
* @synopsis
6+
* ```coffeescript [specscript]
7+
* const filteringAsyncIterator = new FilteringAsyncIterator(
8+
* asyncIterator AsyncIterator<T>,
9+
* predicate T=>boolean,
10+
* ) -> FilteringAsyncIterator<T>
11+
*
12+
* filteringAsyncIterator.next() -> { value: Promise, done: boolean }
13+
* ```
14+
*/
15+
declare function FilteringAsyncIterator(asyncIterator: any, predicate: any): {
16+
[x: number]: () => {
17+
[x: number]: any;
18+
isAsyncIteratorDone: boolean;
19+
next(): Promise<{
20+
value: any;
21+
done: boolean;
22+
}>;
23+
};
24+
isAsyncIteratorDone: boolean;
25+
next(): Promise<{
26+
value: any;
27+
done: boolean;
28+
}>;
29+
};

_internal/FilteringIterator.d.ts

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export = FilteringIterator;
2+
/**
3+
* @name FilteringIterator
4+
*
5+
* @synopsis
6+
* ```coffeescript [specscript]
7+
* FilteringIterator<
8+
* T any,
9+
* iterator Iterator<T>,
10+
* predicate T=>boolean, # no async
11+
* >(iterator, predicate) -> filteringIterator Iterator<T>
12+
*
13+
* filteringIterator.next() -> { value: T, done: boolean }
14+
* ```
15+
*
16+
* @description
17+
* Creates a filtering iterator, i.e. an iterator that filteres a source iterator by predicate.
18+
*/
19+
declare function FilteringIterator(iterator: any, predicate: any): {
20+
[x: number]: () => {
21+
[x: number]: any;
22+
next(): any;
23+
};
24+
next(): any;
25+
};
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
export = FlatMappingAsyncIterator;
2+
/**
3+
* @name FlatMappingAsyncIterator
4+
*
5+
* @synopsis
6+
* ```coffeescript [specscript]
7+
* new FlatMappingAsyncIterator(
8+
* asyncIterator AsyncIterator, flatMapper function,
9+
* ) -> FlatMappingAsyncIterator AsyncIterator
10+
* ```
11+
*
12+
* @execution concurrent
13+
*
14+
* @muxing
15+
*/
16+
declare function FlatMappingAsyncIterator(asyncIterator: any, flatMapper: any): {
17+
[x: number]: () => any;
18+
isAsyncIteratorDone: boolean;
19+
toString(): string;
20+
/**
21+
* @name FlatMappingAsyncIterator.prototype.next
22+
*
23+
* @synopsis
24+
* ```coffeescript [specscript]
25+
* new FlatMappingAsyncIterator(
26+
* asyncIterator AsyncIterator, flatMapper function,
27+
* ).next() -> Promise<{ value, done }>
28+
* ```
29+
*/
30+
next(): Promise<{
31+
value: any;
32+
done: boolean;
33+
}>;
34+
};

_internal/FlatMappingIterator.d.ts

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export = FlatMappingIterator;
2+
/**
3+
* @name FlatMappingIterator
4+
*
5+
* @synopsis
6+
* ```coffeescript [specscript]
7+
* FlatMappingIterator(
8+
* iterator Iterator, flatMapper function,
9+
* ) -> FlatMappingIterator { next, SymbolIterator }
10+
* ```
11+
*/
12+
declare function FlatMappingIterator(iterator: any, flatMapper: any): {
13+
[x: number]: () => any;
14+
next(): any;
15+
};

_internal/MappingAsyncIterator.d.ts

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export = MappingAsyncIterator;
2+
/**
3+
* @name MappingAsyncIterator
4+
*
5+
* @synopsis
6+
* ```coffeescript [specscript]
7+
* mappingAsyncIterator = new MappingAsyncIterator(
8+
* asyncIter AsyncIterator<T>,
9+
* mapper T=>Promise|any,
10+
* ) -> mappingAsyncIterator AsyncIterator
11+
*
12+
* mappingAsyncIterator.next() -> Promise<{ value: any, done: boolean }>
13+
* ```
14+
*/
15+
declare function MappingAsyncIterator(asyncIterator: any, mapper: any): {
16+
[x: number]: () => {
17+
[x: number]: any;
18+
next(): Promise<any>;
19+
};
20+
next(): Promise<any>;
21+
};

0 commit comments

Comments
 (0)