@rimbu/common 0.8.2 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -15
- package/dist/main/async-optlazy.js +6 -2
- package/dist/main/async-optlazy.js.map +1 -1
- package/dist/main/async-reducer.js +22 -22
- package/dist/main/async-reducer.js.map +1 -1
- package/dist/main/collect.js +1 -1
- package/dist/main/comp.js +29 -6
- package/dist/main/comp.js.map +1 -1
- package/dist/main/eq.js +27 -1
- package/dist/main/eq.js.map +1 -1
- package/dist/main/err.js +3 -1
- package/dist/main/err.js.map +1 -1
- package/dist/main/index-range.js +1 -1
- package/dist/main/index-range.js.map +1 -1
- package/dist/main/index.js +6 -1
- package/dist/main/index.js.map +1 -1
- package/dist/main/internal.js +13 -13
- package/dist/main/internal.js.map +1 -1
- package/dist/main/optlazy.js +4 -0
- package/dist/main/optlazy.js.map +1 -1
- package/dist/main/range.js.map +1 -1
- package/dist/main/reducer.js +75 -19
- package/dist/main/reducer.js.map +1 -1
- package/dist/main/update.js +3 -1
- package/dist/main/update.js.map +1 -1
- package/dist/module/async-optlazy.js +4 -0
- package/dist/module/async-optlazy.js.map +1 -1
- package/dist/module/async-reducer.js +12 -12
- package/dist/module/async-reducer.js.map +1 -1
- package/dist/module/collect.js +1 -1
- package/dist/module/comp.js +28 -5
- package/dist/module/comp.js.map +1 -1
- package/dist/module/eq.js +26 -0
- package/dist/module/eq.js.map +1 -1
- package/dist/module/err.js +2 -0
- package/dist/module/err.js.map +1 -1
- package/dist/module/index-range.js.map +1 -1
- package/dist/module/index.js +5 -0
- package/dist/module/index.js.map +1 -1
- package/dist/module/optlazy.js +4 -0
- package/dist/module/optlazy.js.map +1 -1
- package/dist/module/range.js.map +1 -1
- package/dist/module/reducer.js +75 -19
- package/dist/module/reducer.js.map +1 -1
- package/dist/module/update.js +3 -1
- package/dist/module/update.js.map +1 -1
- package/dist/types/async-optlazy.d.ts +4 -0
- package/dist/types/async-reducer.d.ts +37 -22
- package/dist/types/collect.d.ts +2 -2
- package/dist/types/comp.d.ts +32 -5
- package/dist/types/eq.d.ts +26 -0
- package/dist/types/err.d.ts +2 -0
- package/dist/types/index-range.d.ts +14 -13
- package/dist/types/index.d.ts +5 -0
- package/dist/types/optlazy.d.ts +4 -0
- package/dist/types/range.d.ts +11 -10
- package/dist/types/reducer.d.ts +100 -29
- package/dist/types/types.d.ts +0 -4
- package/dist/types/update.d.ts +3 -1
- package/package.json +6 -4
- package/src/async-optlazy.ts +4 -0
- package/src/async-reducer.ts +37 -22
- package/src/collect.ts +2 -2
- package/src/comp.ts +40 -13
- package/src/eq.ts +26 -0
- package/src/err.ts +2 -0
- package/src/index-range.ts +14 -13
- package/src/index.ts +6 -0
- package/src/optlazy.ts +4 -0
- package/src/range.ts +11 -10
- package/src/reducer.ts +107 -31
- package/src/types.ts +0 -5
- package/src/update.ts +3 -1
package/dist/module/reducer.js
CHANGED
|
@@ -85,16 +85,17 @@ export var Reducer;
|
|
|
85
85
|
/**
|
|
86
86
|
* Returns a `Reducer` with the given options:
|
|
87
87
|
* @param init - the initial state value
|
|
88
|
-
* @param next - returns the next state value based on the given inputs
|
|
89
|
-
* - current: the current state
|
|
90
|
-
* - next: the current input value
|
|
91
|
-
* - index: the input index value
|
|
88
|
+
* @param next - returns the next state value based on the given inputs:<br/>
|
|
89
|
+
* - current: the current state<br/>
|
|
90
|
+
* - next: the current input value<br/>
|
|
91
|
+
* - index: the input index value<br/>
|
|
92
92
|
* - halt: function that, when called, ensures no more elements are passed to the reducer
|
|
93
93
|
* @param stateToResult - a function that converts the current state to an output value
|
|
94
94
|
* @typeparam I - the input value type
|
|
95
95
|
* @typeparam O - the output value type
|
|
96
96
|
* @typeparam S - the internal state type
|
|
97
97
|
* @example
|
|
98
|
+
* ```ts
|
|
98
99
|
* const evenNumberOfOnes = Reducer
|
|
99
100
|
* .create(
|
|
100
101
|
* true,
|
|
@@ -103,6 +104,7 @@ export var Reducer;
|
|
|
103
104
|
* const result = Stream.of(1, 2, 3, 2, 1)).reduce(evenNumberOfOnes)
|
|
104
105
|
* console.log+(result)
|
|
105
106
|
* // => 'even'
|
|
107
|
+
* ```
|
|
106
108
|
*/
|
|
107
109
|
function create(init, next, stateToResult) {
|
|
108
110
|
return new Reducer.Base(init, next, stateToResult);
|
|
@@ -111,13 +113,15 @@ export var Reducer;
|
|
|
111
113
|
/**
|
|
112
114
|
* Returns a `Reducer` of which the input, state, and output types are the same.
|
|
113
115
|
* @param init - the initial state value
|
|
114
|
-
* @param next - returns the next state value based on the given inputs
|
|
115
|
-
* - current: the current state
|
|
116
|
-
* - next: the current input value
|
|
117
|
-
* - index: the input index value
|
|
116
|
+
* @param next - returns the next state value based on the given inputs:<br/>
|
|
117
|
+
* - current: the current state<br/>
|
|
118
|
+
* - next: the current input value<br/>
|
|
119
|
+
* - index: the input index value<br/>
|
|
118
120
|
* - halt: function that, when called, ensures no more elements are passed to the reducer
|
|
119
121
|
* @param stateToResult - (optional) a function that converts the current state to an output value
|
|
120
122
|
* @typeparam T - the overall value type
|
|
123
|
+
* @example
|
|
124
|
+
* ```ts
|
|
121
125
|
* const sum = Reducer
|
|
122
126
|
* .createMono(
|
|
123
127
|
* 0,
|
|
@@ -126,6 +130,7 @@ export var Reducer;
|
|
|
126
130
|
* const result = Stream.of(1, 2, 3, 2, 1)).reduce(sum)
|
|
127
131
|
* console.log+(result)
|
|
128
132
|
* // => 9
|
|
133
|
+
* ```
|
|
129
134
|
*/
|
|
130
135
|
function createMono(init, next, stateToResult) {
|
|
131
136
|
return create(init, next, stateToResult !== null && stateToResult !== void 0 ? stateToResult : identity);
|
|
@@ -134,14 +139,16 @@ export var Reducer;
|
|
|
134
139
|
/**
|
|
135
140
|
* Returns a `Reducer` of which the state and output types are the same.
|
|
136
141
|
* @param init - the initial state value
|
|
137
|
-
* @param next - returns the next state value based on the given inputs
|
|
138
|
-
* - current: the current state
|
|
139
|
-
* - next: the current input value
|
|
140
|
-
* - index: the input index value
|
|
142
|
+
* @param next - returns the next state value based on the given inputs:<br/>
|
|
143
|
+
* - current: the current state<br/>
|
|
144
|
+
* - next: the current input value<br/>
|
|
145
|
+
* - index: the input index value<br/>
|
|
141
146
|
* - halt: function that, when called, ensures no more elements are passed to the reducer
|
|
142
147
|
* @param stateToResult - (optional) a function that converts the current state to an output value
|
|
143
148
|
* @typeparam I - the input value type
|
|
144
149
|
* @typeparam O - the output value type
|
|
150
|
+
* @example
|
|
151
|
+
* ```ts
|
|
145
152
|
* const boolToString = Reducer
|
|
146
153
|
* .createOutput(
|
|
147
154
|
* '',
|
|
@@ -150,6 +157,7 @@ export var Reducer;
|
|
|
150
157
|
* const result = Stream.of(true, false, true)).reduce(boolToString)
|
|
151
158
|
* console.log+(result)
|
|
152
159
|
* // => 'TFT'
|
|
160
|
+
* ```
|
|
153
161
|
*/
|
|
154
162
|
function createOutput(init, next, stateToResult) {
|
|
155
163
|
return create(init, next, stateToResult !== null && stateToResult !== void 0 ? stateToResult : identity);
|
|
@@ -158,15 +166,19 @@ export var Reducer;
|
|
|
158
166
|
/**
|
|
159
167
|
* A `Reducer` that sums all given numeric input values.
|
|
160
168
|
* @example
|
|
169
|
+
* ```ts
|
|
161
170
|
* console.log(Stream.range({ amount: 5 }).reduce(Reducer.sum))
|
|
162
171
|
* // => 10
|
|
172
|
+
* ```
|
|
163
173
|
*/
|
|
164
174
|
Reducer.sum = createMono(0, (state, next) => state + next);
|
|
165
175
|
/**
|
|
166
176
|
* A `Reducer` that calculates the product of all given numeric input values.
|
|
167
177
|
* @example
|
|
178
|
+
* ```ts
|
|
168
179
|
* console.log(Stream.range({ start: 1, amount: 5 }).reduce(product))
|
|
169
180
|
* // => 120
|
|
181
|
+
* ```
|
|
170
182
|
*/
|
|
171
183
|
Reducer.product = createMono(1, (state, next, _, halt) => {
|
|
172
184
|
if (0 === next)
|
|
@@ -176,8 +188,10 @@ export var Reducer;
|
|
|
176
188
|
/**
|
|
177
189
|
* A `Reducer` that calculates the average of all given numberic input values.
|
|
178
190
|
* @example
|
|
191
|
+
* ```ts
|
|
179
192
|
* console.log(Stream.range({ amount: 5 }).reduce(Reducer.average));
|
|
180
193
|
* // => 2
|
|
194
|
+
* ```
|
|
181
195
|
*/
|
|
182
196
|
Reducer.average = createMono(0, (avg, value, index) => avg + (value - avg) / (index + 1));
|
|
183
197
|
/**
|
|
@@ -185,9 +199,11 @@ export var Reducer;
|
|
|
185
199
|
* @param compFun - a comparison function for two input values, returning 0 when equal, positive when greater, negetive when smaller
|
|
186
200
|
* @param otherwise - (default: undefineds) a fallback value when there were no input values given
|
|
187
201
|
* @example
|
|
202
|
+
* ```ts
|
|
188
203
|
* const stream = Stream.of('abc', 'a', 'abcde', 'ab')
|
|
189
204
|
* console.log(stream.minBy((s1, s2) => s1.length - s2.length))
|
|
190
205
|
* // 'a'
|
|
206
|
+
* ```
|
|
191
207
|
*/
|
|
192
208
|
Reducer.minBy = (compFun, otherwise) => {
|
|
193
209
|
const token = Symbol();
|
|
@@ -201,8 +217,10 @@ export var Reducer;
|
|
|
201
217
|
* Returns a `Reducer` that remembers the minimum value of the numberic inputs.
|
|
202
218
|
* @param otherwise - (default: undefined) a fallback value when there were no input values given
|
|
203
219
|
* @example
|
|
220
|
+
* ```ts
|
|
204
221
|
* console.log(Stream.of(5, 3, 7, 4).reduce(Reducer.min()))
|
|
205
222
|
* // => 3
|
|
223
|
+
* ```
|
|
206
224
|
*/
|
|
207
225
|
Reducer.min = (otherwise) => {
|
|
208
226
|
return create(undefined, (state, next) => undefined !== state && state < next ? state : next, (state) => state !== null && state !== void 0 ? state : OptLazy(otherwise));
|
|
@@ -212,9 +230,11 @@ export var Reducer;
|
|
|
212
230
|
* @param compFun - a comparison function for two input values, returning 0 when equal, positive when greater, negetive when smaller
|
|
213
231
|
* @param otherwise - (default: undefined) a fallback value when there were no input values given
|
|
214
232
|
* @example
|
|
233
|
+
* ```ts
|
|
215
234
|
* const stream = Stream.of('abc', 'a', 'abcde', 'ab')
|
|
216
235
|
* console.log(stream.maxBy((s1, s2) => s1.length - s2.length))
|
|
217
236
|
* // 'abcde'
|
|
237
|
+
* ```
|
|
218
238
|
*/
|
|
219
239
|
Reducer.maxBy = (compFun, otherwise) => {
|
|
220
240
|
const token = Symbol();
|
|
@@ -228,21 +248,25 @@ export var Reducer;
|
|
|
228
248
|
* Returns a `Reducer` that remembers the maximum value of the numberic inputs.
|
|
229
249
|
* @param otherwise - (default: undefined) a fallback value when there were no input values given
|
|
230
250
|
* @example
|
|
251
|
+
* ```ts
|
|
231
252
|
* console.log(Stream.of(5, 3, 7, 4).reduce(Reducer.max()))
|
|
232
253
|
* // => 7
|
|
254
|
+
* ```
|
|
233
255
|
*/
|
|
234
256
|
Reducer.max = (otherwise) => {
|
|
235
257
|
return create(undefined, (state, next) => undefined !== state && state > next ? state : next, (state) => state !== null && state !== void 0 ? state : OptLazy(otherwise));
|
|
236
258
|
};
|
|
237
259
|
/**
|
|
238
|
-
* Returns a `
|
|
239
|
-
* @options - an object containing
|
|
240
|
-
* - sep: (optional) a seperator string value between values in the output
|
|
241
|
-
* - start: (optional) a start string to prepend to the output
|
|
242
|
-
* - end: (optional) an end string to append to the output
|
|
260
|
+
* Returns a `yaReducer` that joins the given input values into a string using the given options.
|
|
261
|
+
* @param options - an object containing:<br/>
|
|
262
|
+
* - sep: (optional) a seperator string value between values in the output<br/>
|
|
263
|
+
* - start: (optional) a start string to prepend to the output<br/>
|
|
264
|
+
* - end: (optional) an end string to append to the output<br/>
|
|
243
265
|
* @example
|
|
266
|
+
* ```ts
|
|
244
267
|
* console.log(Stream.of(1, 2, 3).reduce(Reducer.join({ sep: '-' })))
|
|
245
268
|
* // => '1-2-3'
|
|
269
|
+
* ```
|
|
246
270
|
*/
|
|
247
271
|
function join({ sep = '', start = '', end = '', valueToString = String, } = {}) {
|
|
248
272
|
let curSep = '';
|
|
@@ -257,15 +281,17 @@ export var Reducer;
|
|
|
257
281
|
Reducer.join = join;
|
|
258
282
|
/**
|
|
259
283
|
* Returns a `Reducer` that remembers the amount of input items provided.
|
|
260
|
-
* @param pred - (optional) a predicate that returns false if the item should not be counted given
|
|
261
|
-
* - value: the current input value
|
|
284
|
+
* @param pred - (optional) a predicate that returns false if the item should not be counted given:<br/>
|
|
285
|
+
* - value: the current input value<br/>
|
|
262
286
|
* - index: the input value index
|
|
263
287
|
* @example
|
|
288
|
+
* ```ts
|
|
264
289
|
* const stream = Stream.range({ amount: 10 })
|
|
265
290
|
* console.log(stream.reduce(Reducer.count()))
|
|
266
291
|
* // => 10
|
|
267
292
|
* console.log(stream.reduce(Reducer.count(v => v < 5)))
|
|
268
293
|
* // => 5
|
|
294
|
+
* ```
|
|
269
295
|
*/
|
|
270
296
|
Reducer.count = (pred) => {
|
|
271
297
|
if (undefined === pred)
|
|
@@ -283,8 +309,10 @@ export var Reducer;
|
|
|
283
309
|
* @typeparam T - the input value type
|
|
284
310
|
* @typeparam O - the fallback value type
|
|
285
311
|
* @example
|
|
312
|
+
* ```ts
|
|
286
313
|
* console.log(Stream.range({ amount: 10 }).reduce(Reducer.firstWhere(v => v > 5)))
|
|
287
314
|
* // => 6
|
|
315
|
+
* ```
|
|
288
316
|
*/
|
|
289
317
|
Reducer.firstWhere = (pred, otherwise) => {
|
|
290
318
|
const token = Symbol();
|
|
@@ -302,8 +330,10 @@ export var Reducer;
|
|
|
302
330
|
* @typeparam T - the input value type
|
|
303
331
|
* @typeparam O - the fallback value type
|
|
304
332
|
* @example
|
|
333
|
+
* ```ts
|
|
305
334
|
* console.log(Stream.range{ amount: 10 }).reduce(Reducer.first())
|
|
306
335
|
* // => 0
|
|
336
|
+
* ```
|
|
307
337
|
*/
|
|
308
338
|
Reducer.first = (otherwise) => {
|
|
309
339
|
const token = Symbol();
|
|
@@ -321,8 +351,10 @@ export var Reducer;
|
|
|
321
351
|
* @typeparam T - the input value type
|
|
322
352
|
* @typeparam O - the fallback value type
|
|
323
353
|
* @example
|
|
354
|
+
* ```ts
|
|
324
355
|
* console.log(Stream.range({ amount: 10 }).reduce(Reducer.lastWhere(v => v > 5)))
|
|
325
356
|
* // => 9
|
|
357
|
+
* ```
|
|
326
358
|
*/
|
|
327
359
|
Reducer.lastWhere = (pred, otherwise) => {
|
|
328
360
|
const token = Symbol();
|
|
@@ -338,8 +370,10 @@ export var Reducer;
|
|
|
338
370
|
* @typeparam T - the input value type
|
|
339
371
|
* @typeparam O - the fallback value type
|
|
340
372
|
* @example
|
|
373
|
+
* ```ts
|
|
341
374
|
* console.log(Stream.range{ amount: 10 }).reduce(Reducer.first())
|
|
342
375
|
* // => 0
|
|
376
|
+
* ```
|
|
343
377
|
*/
|
|
344
378
|
Reducer.last = (otherwise) => {
|
|
345
379
|
const token = Symbol();
|
|
@@ -349,8 +383,10 @@ export var Reducer;
|
|
|
349
383
|
* Returns a `Reducer` that ouputs false as long as no input value satisfies given `pred`, true otherwise.
|
|
350
384
|
* @param pred - a function taking an input value and its index, and returning true if the value satisfies the predicate
|
|
351
385
|
* @example
|
|
386
|
+
* ```ts
|
|
352
387
|
* console.log(Stream.range{ amount: 10 }).reduce(Reducer.some(v => v > 5))
|
|
353
388
|
* // => true
|
|
389
|
+
* ```
|
|
354
390
|
*/
|
|
355
391
|
function some(pred) {
|
|
356
392
|
return createOutput(false, (state, next, i, halt) => {
|
|
@@ -368,8 +404,10 @@ export var Reducer;
|
|
|
368
404
|
* Returns a `Reducer` that ouputs true as long as all input values satisfy the given `pred`, false otherwise.
|
|
369
405
|
* @param pred - a function taking an input value and its index, and returning true if the value satisfies the predicate
|
|
370
406
|
* @example
|
|
407
|
+
* ```ts
|
|
371
408
|
* console.log(Stream.range{ amount: 10 }).reduce(Reducer.every(v => v < 5))
|
|
372
409
|
* // => false
|
|
410
|
+
* ```
|
|
373
411
|
*/
|
|
374
412
|
function every(pred) {
|
|
375
413
|
return createOutput(true, (state, next, i, halt) => {
|
|
@@ -388,8 +426,10 @@ export var Reducer;
|
|
|
388
426
|
* @param elem - the element to search for
|
|
389
427
|
* @param eq - (optional) a comparison function that returns true if te two given input values are considered equal
|
|
390
428
|
* @example
|
|
429
|
+
* ```ts
|
|
391
430
|
* console.log(Stream.range({ amount: 10 }).reduce(Reducer.contains(5)))
|
|
392
431
|
* // => true
|
|
432
|
+
* ```
|
|
393
433
|
*/
|
|
394
434
|
function contains(elem, eq = Object.is) {
|
|
395
435
|
return createOutput(false, (state, next, _, halt) => {
|
|
@@ -406,8 +446,10 @@ export var Reducer;
|
|
|
406
446
|
/**
|
|
407
447
|
* Returns a `Reducer` that takes boolean values and outputs true if all input values are true, and false otherwise.
|
|
408
448
|
* @example
|
|
449
|
+
* ```ts
|
|
409
450
|
* console.log(Stream.of(true, false, true)).reduce(Reducer.and))
|
|
410
451
|
* // => false
|
|
452
|
+
* ```
|
|
411
453
|
*/
|
|
412
454
|
Reducer.and = createMono(true, (state, next, _, halt) => {
|
|
413
455
|
if (!state)
|
|
@@ -419,8 +461,10 @@ export var Reducer;
|
|
|
419
461
|
/**
|
|
420
462
|
* Returns a `Reducer` that takes boolean values and outputs true if one or more input values are true, and false otherwise.
|
|
421
463
|
* @example
|
|
464
|
+
* ```ts
|
|
422
465
|
* console.log(Stream.of(true, false, true)).reduce(Reducer.or))
|
|
423
466
|
* // => true
|
|
467
|
+
* ```
|
|
424
468
|
*/
|
|
425
469
|
Reducer.or = createMono(false, (state, next, _, halt) => {
|
|
426
470
|
if (state)
|
|
@@ -432,8 +476,10 @@ export var Reducer;
|
|
|
432
476
|
/**
|
|
433
477
|
* Returns a `Reducer` that outputs true if no input values are received, false otherwise.
|
|
434
478
|
* @example
|
|
479
|
+
* ```ts
|
|
435
480
|
* console.log(Stream.of(1, 2, 3).reduce(Reducer.isEmpty))
|
|
436
481
|
* // => false
|
|
482
|
+
* ```
|
|
437
483
|
*/
|
|
438
484
|
Reducer.isEmpty = createOutput(true, (_, __, ___, halt) => {
|
|
439
485
|
halt();
|
|
@@ -442,8 +488,10 @@ export var Reducer;
|
|
|
442
488
|
/**
|
|
443
489
|
* Returns a `Reducer` that outputs true if one or more input values are received, false otherwise.
|
|
444
490
|
* @example
|
|
491
|
+
* ```ts
|
|
445
492
|
* console.log(Stream.of(1, 2, 3).reduce(Reducer.nonEmpty))
|
|
446
493
|
* // => true
|
|
494
|
+
* ```
|
|
447
495
|
*/
|
|
448
496
|
Reducer.nonEmpty = createOutput(false, (_, __, ___, halt) => {
|
|
449
497
|
halt();
|
|
@@ -452,8 +500,10 @@ export var Reducer;
|
|
|
452
500
|
/**
|
|
453
501
|
* Returns a `Reducer` that collects received input values in an array, and returns a copy of that array as an output value when requested.
|
|
454
502
|
* @example
|
|
503
|
+
* ```ts
|
|
455
504
|
* console.log(Stream.of(1, 2, 3).reduce(Reducer.toArray()))
|
|
456
505
|
* // => [1, 2, 3]
|
|
506
|
+
* ```
|
|
457
507
|
*/
|
|
458
508
|
function toArray() {
|
|
459
509
|
return create(() => [], (state, next) => {
|
|
@@ -466,8 +516,10 @@ export var Reducer;
|
|
|
466
516
|
* Returns a `Reducer` that collects received input tuples into a mutable JS Map, and returns
|
|
467
517
|
* a copy of that map when output is requested.
|
|
468
518
|
* @example
|
|
519
|
+
* ```ts
|
|
469
520
|
* console.log(Stream.of([1, 'a'], [2, 'b']).reduce(Reducer.toJSMap()))
|
|
470
521
|
* // Map { 1 => 'a', 2 => 'b' }
|
|
522
|
+
* ```
|
|
471
523
|
*/
|
|
472
524
|
function toJSMap() {
|
|
473
525
|
return create(() => new Map(), (state, next) => {
|
|
@@ -480,8 +532,10 @@ export var Reducer;
|
|
|
480
532
|
* Returns a `Reducer` that collects received input values into a mutable JS Set, and returns
|
|
481
533
|
* a copy of that map when output is requested.
|
|
482
534
|
* @example
|
|
535
|
+
* ```ts
|
|
483
536
|
* console.log(Stream.of(1, 2, 3).reduce(Reducer.toJSSet()))
|
|
484
537
|
* // Set {1, 2, 3}
|
|
538
|
+
* ```
|
|
485
539
|
*/
|
|
486
540
|
function toJSSet() {
|
|
487
541
|
return create(() => new Set(), (state, next) => {
|
|
@@ -494,9 +548,11 @@ export var Reducer;
|
|
|
494
548
|
* Returns a `Reducer` that combines multiple input `reducers` by providing input values to all of them and collecting the outputs in an array.
|
|
495
549
|
* @param reducers - 2 or more reducers to combine
|
|
496
550
|
* @example
|
|
551
|
+
* ```ts
|
|
497
552
|
* const red = Reducer.combine(Reducer.sum, Reducer.average)
|
|
498
553
|
* console.log(Stream.range({amount: 9 }).reduce(red))
|
|
499
554
|
* // => [36, 4]
|
|
555
|
+
* ```
|
|
500
556
|
*/
|
|
501
557
|
function combine(...reducers) {
|
|
502
558
|
const createState = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reducer.js","sourceRoot":"","sources":["../../src/reducer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAM,OAAO,EAAE,MAAM,YAAY,CAAC;AASrD,SAAS,QAAQ,CAAI,KAAQ;IAC3B,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,KAAW,OAAO,CA8yBvB;AA9yBD,WAAiB,OAAO;IAOtB;;;OAGG;IACH,SAAgB,IAAI,CAAI,IAAqB;QAC3C,IAAI,IAAI,YAAY,QAAQ;YAAE,OAAO,IAAI,EAAE,CAAC;QAC5C,OAAO,IAAS,CAAC;IACnB,CAAC;IAHe,YAAI,OAGnB,CAAA;IAgGD;;;;;OAKG;IACH,MAAa,IAAI;QACf,YACW,IAAqB,EACrB,IAA+D,EAC/D,aAA8B;YAF9B,SAAI,GAAJ,IAAI,CAAiB;YACrB,SAAI,GAAJ,IAAI,CAA2D;YAC/D,kBAAa,GAAb,aAAa,CAAiB;QACtC,CAAC;QAEJ,WAAW,CACT,IAA4D;YAE5D,OAAO,MAAM,CACX,GAAoC,EAAE,CAAC,CAAC;gBACtC,SAAS,EAAE,CAAC;gBACZ,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;aACvB,CAAC,EACF,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAmC,E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given `update` parameter, where it can either directly give a new value,
|
|
3
3
|
* or it is a function receiving the given `value`, and returns a new value.
|
|
4
|
-
* @param value - the current
|
|
4
|
+
* @param value - the current value
|
|
5
5
|
* @param update - an `Update` value, either a new value or a function receiving the old value
|
|
6
6
|
* and returning a new one.
|
|
7
7
|
* @example
|
|
8
|
+
* ```ts
|
|
8
9
|
* Update(1, 2) // => 2
|
|
9
10
|
* Update(1, () => 10) // => 10
|
|
10
11
|
* Update(1, v => v + 1) // => 2
|
|
12
|
+
* ```
|
|
11
13
|
*/
|
|
12
14
|
export function Update(value, update) {
|
|
13
15
|
if (typeof update === 'function') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../src/update.ts"],"names":[],"mappings":"AAKA
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../src/update.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,MAAM,CAAI,KAAQ,EAAE,MAAiB;IACnD,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE;QAChC,OAAQ,MAA0B,CAAC,KAAK,CAAC,CAAC;KAC3C;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -14,22 +14,26 @@ export declare namespace AsyncOptLazy {
|
|
|
14
14
|
* Returns the value or promised value contained in an `AsyncOptLazy` instance of type T.
|
|
15
15
|
* @param optLazy - the `AsyncOptLazy` value of type T
|
|
16
16
|
* @example
|
|
17
|
+
* ```ts
|
|
17
18
|
* AsyncOptLazy.toMaybePromise(1) // => 1
|
|
18
19
|
* AsyncOptLazy.toMaybePromise(() => 1) // => 1
|
|
19
20
|
* AsyncOptLazy.toMaybePromise(() => () => 1) // => () => 1
|
|
20
21
|
* AsyncOptLazy.toMaybePromise(async () => 1) // => Promise(1)
|
|
21
22
|
* AsyncOptLazy.toMaybePromise(Promise.resolve(1)) // => Promise(1)
|
|
23
|
+
* ```
|
|
22
24
|
*/
|
|
23
25
|
function toMaybePromise<T>(optLazy: AsyncOptLazy<T>): MaybePromise<T>;
|
|
24
26
|
/**
|
|
25
27
|
* Returns the value contained in an `AsyncOptLazy` instance of type T as a promise.
|
|
26
28
|
* @param optLazy - the `AsyncOptLazy` value of type T
|
|
27
29
|
* @example
|
|
30
|
+
* ```ts
|
|
28
31
|
* AsyncOptLazy.toPromise(1) // => Promise(1)
|
|
29
32
|
* AsyncOptLazy.toPromise(() => 1) // => Promise(1)
|
|
30
33
|
* AsyncOptLazy.toPromise(() => () => 1) // => Promise(() => 1)
|
|
31
34
|
* AsyncOptLazy.toPromise(async () => 1) // => Promise(1)
|
|
32
35
|
* AsyncOptLazy.toPromise(Promise.resolve(1)) // => Promise(1)
|
|
36
|
+
* ```
|
|
33
37
|
*/
|
|
34
38
|
function toPromise<T>(optLazy: AsyncOptLazy<T>): Promise<T>;
|
|
35
39
|
}
|
|
@@ -33,57 +33,67 @@ export declare namespace AsyncReducer {
|
|
|
33
33
|
onClose?(state: S, error?: unknown): MaybePromise<void>;
|
|
34
34
|
/**
|
|
35
35
|
* Returns an `AsyncReducer` instance that only passes values to the reducer that satisy the given `pred` predicate.
|
|
36
|
-
* @param pred - a potaentially asynchronous function that returns true if the value should be passed to the reducer based on the following inputs
|
|
37
|
-
* - value: the current input value
|
|
38
|
-
* - index: the current input index
|
|
36
|
+
* @param pred - a potaentially asynchronous function that returns true if the value should be passed to the reducer based on the following inputs:<br/>
|
|
37
|
+
* - value: the current input value<br/>
|
|
38
|
+
* - index: the current input index<br/>
|
|
39
39
|
* - halt: function that, when called, ensures no more new values are passed to the reducer
|
|
40
40
|
* @example
|
|
41
|
+
* ```ts
|
|
41
42
|
* AsyncReducer
|
|
42
43
|
* .createMono(0, async (c, v) => c + v)
|
|
43
44
|
* .filterInput(async v => v > 10)
|
|
44
45
|
* // this reducer will only sum values larger than 10
|
|
46
|
+
* ```
|
|
45
47
|
*/
|
|
46
48
|
filterInput(pred: (value: I, index: number, halt: () => void) => MaybePromise<boolean>): AsyncReducer<I, O>;
|
|
47
49
|
/**
|
|
48
50
|
* Returns an `AsyncReducer` instance that converts its input values using given `mapFun` before passing them to the reducer.
|
|
49
|
-
* @param mapFun - a potentially asynchronous function that returns a new value to pass to the reducer based on the following inputs
|
|
50
|
-
* - value: the current input value
|
|
51
|
+
* @param mapFun - a potentially asynchronous function that returns a new value to pass to the reducer based on the following inputs:<br/>
|
|
52
|
+
* - value: the current input value<br/>
|
|
51
53
|
* - index: the current input index
|
|
52
54
|
* @example
|
|
55
|
+
* ```ts
|
|
53
56
|
* AsyncReducer
|
|
54
57
|
* .createMono(0, async (c, v) => c + v)
|
|
55
58
|
* .mapInput(async v => v * 2)
|
|
56
59
|
* // this reducer will double all input values before summing them
|
|
60
|
+
* ```
|
|
57
61
|
*/
|
|
58
62
|
mapInput<I2>(mapFun: (value: I2, index: number) => MaybePromise<I>): AsyncReducer<I2, O>;
|
|
59
63
|
/**
|
|
60
64
|
* Returns an `AsyncReducer` instance that converts or filters its input values using given `collectFun` before passing them to the reducer.
|
|
61
|
-
* @param collectFun - a function receiving
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
65
|
+
* @param collectFun - a function receiving<br/>
|
|
66
|
+
* - `value`: the next value<br/>
|
|
67
|
+
* - `index`: the value index<br/>
|
|
68
|
+
* - `skip`: a token that, when returned, will not add a value to the resulting collection<br/>
|
|
69
|
+
* - `halt`: a function that, when called, ensures no next elements are passed
|
|
66
70
|
* @example
|
|
71
|
+
* ```ts
|
|
67
72
|
* AsyncReducer
|
|
68
73
|
* .createMono(0, async (c, v) => c + v)
|
|
69
74
|
* .collectInput(async (v, _, skip) => v <= 10 ? skip : v * 2)
|
|
70
75
|
* // this reducer will double all input values larger thant 10 before summing them,
|
|
71
76
|
* // and will skip all values smaller than 10
|
|
77
|
+
* ```
|
|
72
78
|
*/
|
|
73
79
|
collectInput<I2>(collectFun: AsyncCollectFun<I2, I>): AsyncReducer<I2, O>;
|
|
74
80
|
/**
|
|
75
81
|
* Returns an `AsyncReducer` instance that converts its output values using given `mapFun`.
|
|
76
82
|
* @param mapFun - a potentially asynchronous function that takes the current output value and converts it to a new output value
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
77
85
|
* AsyncReducer
|
|
78
86
|
* .createMono(0, async (c, v) => c + v)
|
|
79
87
|
* .mapOutput(async v => String(v))
|
|
80
88
|
* // this reducer will convert all its results to string before returning them
|
|
89
|
+
* ```
|
|
81
90
|
*/
|
|
82
91
|
mapOutput<O2>(mapFun: (value: O) => MaybePromise<O2>): AsyncReducer<I, O2>;
|
|
83
92
|
/**
|
|
84
93
|
* Returns an `AsyncReducer` instance that takes at most the given `amount` of input elements, and will ignore subsequent elements.
|
|
85
94
|
* @param amount - the amount of elements to accept
|
|
86
95
|
* @example
|
|
96
|
+
* ```ts
|
|
87
97
|
* await AsyncStream
|
|
88
98
|
* .from(Stream.range({ end: 10 }))
|
|
89
99
|
* .reduce(
|
|
@@ -92,12 +102,14 @@ export declare namespace AsyncReducer {
|
|
|
92
102
|
* .takeInput(2)
|
|
93
103
|
* )
|
|
94
104
|
* // => 1
|
|
105
|
+
* ```
|
|
95
106
|
*/
|
|
96
107
|
takeInput(amount: number): AsyncReducer<I, O>;
|
|
97
108
|
/**
|
|
98
109
|
* Returns a `Reducer` instance that skips the first given `amount` of input elements, and will process subsequent elements.
|
|
99
110
|
* @param amount - the amount of elements to skip
|
|
100
111
|
* @example
|
|
112
|
+
* ```ts
|
|
101
113
|
* await AsyncStream
|
|
102
114
|
* .from(Stream.range({ end: 10 }))
|
|
103
115
|
* .reduce(
|
|
@@ -106,6 +118,7 @@ export declare namespace AsyncReducer {
|
|
|
106
118
|
* .dropInput(9)
|
|
107
119
|
* )
|
|
108
120
|
* // => 19
|
|
121
|
+
* ```
|
|
109
122
|
*/
|
|
110
123
|
dropInput(amount: number): AsyncReducer<I, O>;
|
|
111
124
|
/**
|
|
@@ -113,6 +126,7 @@ export declare namespace AsyncReducer {
|
|
|
113
126
|
* @param from - (default: 0) the index at which to start processing elements
|
|
114
127
|
* @param amount - (optional) the amount of elements to process, if not given, processes all elements from the `from` index
|
|
115
128
|
* @example
|
|
129
|
+
* ```ts
|
|
116
130
|
* await AsyncStream
|
|
117
131
|
* .from(Stream.range({ end: 10 }))
|
|
118
132
|
* .reduce(
|
|
@@ -121,6 +135,7 @@ export declare namespace AsyncReducer {
|
|
|
121
135
|
* .sliceInput(1, 2)
|
|
122
136
|
* )
|
|
123
137
|
* // => 3
|
|
138
|
+
* ```
|
|
124
139
|
*/
|
|
125
140
|
sliceInput(from?: number, amount?: number): AsyncReducer<I, O>;
|
|
126
141
|
}
|
|
@@ -147,10 +162,10 @@ export declare namespace AsyncReducer {
|
|
|
147
162
|
/**
|
|
148
163
|
* Returns an `AsyncReducer` with the given options:
|
|
149
164
|
* @param init - the optionally lazy and/or promised initial state value
|
|
150
|
-
* @param next - returns (potentially asynchronously) the next state value based on the given inputs
|
|
151
|
-
* - current: the current state
|
|
152
|
-
* - next: the current input value
|
|
153
|
-
* - index: the input index value
|
|
165
|
+
* @param next - returns (potentially asynchronously) the next state value based on the given inputs:<br/>
|
|
166
|
+
* - current: the current state<br/>
|
|
167
|
+
* - next: the current input value<br/>
|
|
168
|
+
* - index: the input index value<br/>
|
|
154
169
|
* - halt: function that, when called, ensures no more elements are passed to the reducer
|
|
155
170
|
* @param stateToResult - a potentially asynchronous function that converts the current state to an output value
|
|
156
171
|
* @param onClose - (optional) a function that will be called when the reducer will no longer receive values
|
|
@@ -162,10 +177,10 @@ export declare namespace AsyncReducer {
|
|
|
162
177
|
/**
|
|
163
178
|
* Returns an `AsyncReducer` of which the input, state, and output types are the same.
|
|
164
179
|
* @param init - the optionally lazy and/or promised initial state value
|
|
165
|
-
* @param next - returns (potentially asynchronously) the next state value based on the given inputs
|
|
166
|
-
* - current: the current state
|
|
167
|
-
* - next: the current input value
|
|
168
|
-
* - index: the input index value
|
|
180
|
+
* @param next - returns (potentially asynchronously) the next state value based on the given inputs:<br/>
|
|
181
|
+
* - current: the current state<br/>
|
|
182
|
+
* - next: the current input value<br/>
|
|
183
|
+
* - index: the input index value<br/>
|
|
169
184
|
* - halt: function that, when called, ensures no more elements are passed to the reducer
|
|
170
185
|
* @param stateToResult - a potentially asynchronous function that converts the current state to an output value
|
|
171
186
|
* @param onClose - (optional) a function that will be called when the reducer will no longer receive values
|
|
@@ -177,10 +192,10 @@ export declare namespace AsyncReducer {
|
|
|
177
192
|
/**
|
|
178
193
|
* Returns an `AsyncReducer` of which the state and output types are the same.
|
|
179
194
|
* @param init - the optionally lazy and/or promised initial state value
|
|
180
|
-
* @param next - returns (potentially asynchronously) the next state value based on the given inputs
|
|
181
|
-
* - current: the current state
|
|
182
|
-
* - next: the current input value
|
|
183
|
-
* - index: the input index value
|
|
195
|
+
* @param next - returns (potentially asynchronously) the next state value based on the given inputs:<br/>
|
|
196
|
+
* - current: the current state<br/>
|
|
197
|
+
* - next: the current input value<br/>
|
|
198
|
+
* - index: the input index value<br/>
|
|
184
199
|
* - halt: function that, when called, ensures no more elements are passed to the reducer
|
|
185
200
|
* @param stateToResult - a potentially asynchronous function that converts the current state to an output value
|
|
186
201
|
* @param onClose - (optional) a function that will be called when the reducer will no longer receive values
|
package/dist/types/collect.d.ts
CHANGED
|
@@ -10,11 +10,11 @@ import type { MaybePromise } from './internal';
|
|
|
10
10
|
export declare type CollectFun<T, R> = (value: T, index: number, skip: CollectFun.Skip, halt: () => void) => R | CollectFun.Skip;
|
|
11
11
|
export declare namespace CollectFun {
|
|
12
12
|
/**
|
|
13
|
-
* Indicates, when returned from a collect function, to skip the
|
|
13
|
+
* Indicates, when returned from a collect function, to skip the value.
|
|
14
14
|
*/
|
|
15
15
|
const Skip: unique symbol;
|
|
16
16
|
/**
|
|
17
|
-
* Indicates, when returned from a collect function, to skip the
|
|
17
|
+
* Indicates, when returned from a collect function, to skip the value.
|
|
18
18
|
*/
|
|
19
19
|
type Skip = typeof Skip;
|
|
20
20
|
}
|