@rimbu/common 1.1.0 → 2.0.1
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/dist/bun/async-optlazy.mts +18 -5
- package/dist/bun/internal.mts +0 -2
- package/dist/bun/optlazy.mts +12 -3
- package/dist/cjs/async-optlazy.cjs +60 -42
- package/dist/cjs/async-optlazy.cjs.map +1 -0
- package/dist/cjs/async-optlazy.d.cts +46 -0
- package/dist/cjs/collect.cjs +9 -31
- package/dist/cjs/collect.cjs.map +1 -0
- package/dist/cjs/collect.d.cts +29 -0
- package/dist/cjs/comp.cjs +519 -1598
- package/dist/cjs/comp.cjs.map +1 -0
- package/dist/cjs/comp.d.cts +239 -0
- package/dist/cjs/eq.cjs +375 -203
- package/dist/cjs/eq.cjs.map +1 -0
- package/dist/cjs/err.cjs +57 -50
- package/dist/cjs/err.cjs.map +1 -0
- package/dist/cjs/index-range.cjs +105 -109
- package/dist/cjs/index-range.cjs.map +1 -0
- package/dist/cjs/index-range.d.cts +42 -0
- package/dist/cjs/index.cjs +9 -1684
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +6 -0
- package/dist/cjs/internal.cjs +14 -1684
- package/dist/cjs/internal.cjs.map +1 -0
- package/dist/cjs/internal.d.cts +11 -0
- package/dist/cjs/optlazy.cjs +43 -36
- package/dist/cjs/optlazy.cjs.map +1 -0
- package/dist/cjs/optlazy.d.cts +42 -0
- package/dist/cjs/range.cjs +35 -49
- package/dist/cjs/range.cjs.map +1 -0
- package/dist/cjs/traverse-state.cjs +30 -46
- package/dist/cjs/traverse-state.cjs.map +1 -0
- package/dist/cjs/types.cjs +2 -17
- package/dist/cjs/types.cjs.map +1 -0
- package/dist/cjs/update.cjs +21 -32
- package/dist/cjs/update.cjs.map +1 -0
- package/dist/{types → esm}/async-optlazy.d.mts +10 -3
- package/dist/esm/async-optlazy.mjs +10 -4
- package/dist/esm/async-optlazy.mjs.map +1 -1
- package/dist/esm/comp.mjs.map +1 -1
- package/dist/esm/eq.d.mts +196 -0
- package/dist/esm/eq.mjs.map +1 -1
- package/dist/esm/err.d.mts +33 -0
- package/dist/esm/index-range.mjs.map +1 -1
- package/dist/{types → esm}/internal.d.mts +0 -2
- package/dist/esm/internal.mjs +0 -2
- package/dist/esm/internal.mjs.map +1 -1
- package/dist/{types → esm}/optlazy.d.mts +8 -2
- package/dist/esm/optlazy.mjs +7 -2
- package/dist/esm/optlazy.mjs.map +1 -1
- package/dist/esm/range.d.mts +35 -0
- package/dist/esm/range.mjs.map +1 -1
- package/dist/esm/traverse-state.d.mts +33 -0
- package/dist/esm/types.d.mts +31 -0
- package/dist/esm/update.d.mts +18 -0
- package/dist/esm/update.mjs.map +1 -1
- package/package.json +21 -14
- package/src/async-optlazy.mts +18 -5
- package/src/internal.mts +0 -2
- package/src/optlazy.mts +12 -3
- package/dist/bun/async-reducer.mts +0 -1157
- package/dist/bun/reducer.mts +0 -1025
- package/dist/cjs/async-reducer.cjs +0 -1621
- package/dist/cjs/reducer.cjs +0 -1621
- package/dist/esm/async-reducer.mjs +0 -638
- package/dist/esm/async-reducer.mjs.map +0 -1
- package/dist/esm/reducer.mjs +0 -669
- package/dist/esm/reducer.mjs.map +0 -1
- package/dist/types/async-reducer.d.mts +0 -542
- package/dist/types/reducer.d.mts +0 -542
- package/src/async-reducer.mts +0 -1157
- package/src/reducer.mts +0 -1025
- /package/dist/{types/eq.d.mts → cjs/eq.d.cts} +0 -0
- /package/dist/{types/err.d.mts → cjs/err.d.cts} +0 -0
- /package/dist/{types/range.d.mts → cjs/range.d.cts} +0 -0
- /package/dist/{types/traverse-state.d.mts → cjs/traverse-state.d.cts} +0 -0
- /package/dist/{types/types.d.mts → cjs/types.d.cts} +0 -0
- /package/dist/{types/update.d.mts → cjs/update.d.cts} +0 -0
- /package/dist/{types → esm}/collect.d.mts +0 -0
- /package/dist/{types → esm}/comp.d.mts +0 -0
- /package/dist/{types → esm}/index-range.d.mts +0 -0
- /package/dist/{types → esm}/index.d.mts +0 -0
package/dist/esm/reducer.mjs
DELETED
|
@@ -1,669 +0,0 @@
|
|
|
1
|
-
import { CollectFun, Eq, OptLazy } from './internal.mjs';
|
|
2
|
-
function identity(value) {
|
|
3
|
-
return value;
|
|
4
|
-
}
|
|
5
|
-
export var Reducer;
|
|
6
|
-
(function (Reducer) {
|
|
7
|
-
/**
|
|
8
|
-
* A base class that can be used to easily create `Reducer` instances.
|
|
9
|
-
* @typeparam I - the input value type
|
|
10
|
-
* @typeparam O - the output value type
|
|
11
|
-
* @typeparam S - the internal state type
|
|
12
|
-
*/
|
|
13
|
-
class Base {
|
|
14
|
-
constructor(init, next, stateToResult) {
|
|
15
|
-
this.init = init;
|
|
16
|
-
this.next = next;
|
|
17
|
-
this.stateToResult = stateToResult;
|
|
18
|
-
}
|
|
19
|
-
filterInput(pred) {
|
|
20
|
-
return create(() => ({
|
|
21
|
-
nextIndex: 0,
|
|
22
|
-
state: OptLazy(this.init),
|
|
23
|
-
}), (state, elem, index, halt) => {
|
|
24
|
-
if (pred(elem, index, halt)) {
|
|
25
|
-
state.state = this.next(state.state, elem, state.nextIndex++, halt);
|
|
26
|
-
}
|
|
27
|
-
return state;
|
|
28
|
-
}, (state) => this.stateToResult(state.state));
|
|
29
|
-
}
|
|
30
|
-
mapInput(mapFun) {
|
|
31
|
-
return create(this.init, (state, elem, index, halt) => this.next(state, mapFun(elem, index), index, halt), this.stateToResult);
|
|
32
|
-
}
|
|
33
|
-
collectInput(collectFun) {
|
|
34
|
-
return create(() => ({
|
|
35
|
-
nextIndex: 0,
|
|
36
|
-
state: OptLazy(this.init),
|
|
37
|
-
}), (state, elem, index, halt) => {
|
|
38
|
-
const nextElem = collectFun(elem, index, CollectFun.Skip, halt);
|
|
39
|
-
if (CollectFun.Skip !== nextElem) {
|
|
40
|
-
state.state = this.next(state.state, nextElem, state.nextIndex++, halt);
|
|
41
|
-
}
|
|
42
|
-
return state;
|
|
43
|
-
}, (state) => this.stateToResult(state.state));
|
|
44
|
-
}
|
|
45
|
-
mapOutput(mapFun) {
|
|
46
|
-
return create(this.init, this.next, (state) => mapFun(this.stateToResult(state)));
|
|
47
|
-
}
|
|
48
|
-
takeInput(amount) {
|
|
49
|
-
if (amount <= 0) {
|
|
50
|
-
return create(this.init, identity, this.stateToResult);
|
|
51
|
-
}
|
|
52
|
-
return this.filterInput((_, i, halt) => {
|
|
53
|
-
const more = i < amount;
|
|
54
|
-
if (!more)
|
|
55
|
-
halt();
|
|
56
|
-
return more;
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
dropInput(amount) {
|
|
60
|
-
if (amount <= 0)
|
|
61
|
-
return this;
|
|
62
|
-
return this.filterInput((_, i) => i >= amount);
|
|
63
|
-
}
|
|
64
|
-
sliceInput(from = 0, amount) {
|
|
65
|
-
if (undefined === amount)
|
|
66
|
-
return this.dropInput(from);
|
|
67
|
-
if (amount <= 0)
|
|
68
|
-
return create(this.init, identity, this.stateToResult);
|
|
69
|
-
if (from <= 0)
|
|
70
|
-
return this.takeInput(amount);
|
|
71
|
-
return this.takeInput(amount).dropInput(from);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
Reducer.Base = Base;
|
|
75
|
-
/**
|
|
76
|
-
* Returns a `Reducer` with the given options:
|
|
77
|
-
* @param init - the initial state value
|
|
78
|
-
* @param next - returns the next state value based on the given inputs:<br/>
|
|
79
|
-
* - current: the current state<br/>
|
|
80
|
-
* - next: the current input value<br/>
|
|
81
|
-
* - index: the input index value<br/>
|
|
82
|
-
* - halt: function that, when called, ensures no more elements are passed to the reducer
|
|
83
|
-
* @param stateToResult - a function that converts the current state to an output value
|
|
84
|
-
* @typeparam I - the input value type
|
|
85
|
-
* @typeparam O - the output value type
|
|
86
|
-
* @typeparam S - the internal state type
|
|
87
|
-
* @example
|
|
88
|
-
* ```ts
|
|
89
|
-
* const evenNumberOfOnes = Reducer
|
|
90
|
-
* .create(
|
|
91
|
-
* true,
|
|
92
|
-
* (current, value: number) => value === 1 ? !current : current,
|
|
93
|
-
* state => state ? 'even' : 'not even')
|
|
94
|
-
* const result = Stream.of(1, 2, 3, 2, 1)).reduce(evenNumberOfOnes)
|
|
95
|
-
* console.log+(result)
|
|
96
|
-
* // => 'even'
|
|
97
|
-
* ```
|
|
98
|
-
*/
|
|
99
|
-
function create(init, next, stateToResult) {
|
|
100
|
-
return new Reducer.Base(init, next, stateToResult);
|
|
101
|
-
}
|
|
102
|
-
Reducer.create = create;
|
|
103
|
-
/**
|
|
104
|
-
* Returns a `Reducer` of which the input, state, and output types are the same.
|
|
105
|
-
* @param init - the initial state value
|
|
106
|
-
* @param next - returns the next state value based on the given inputs:<br/>
|
|
107
|
-
* - current: the current state<br/>
|
|
108
|
-
* - next: the current input value<br/>
|
|
109
|
-
* - index: the input index value<br/>
|
|
110
|
-
* - halt: function that, when called, ensures no more elements are passed to the reducer
|
|
111
|
-
* @param stateToResult - (optional) a function that converts the current state to an output value
|
|
112
|
-
* @typeparam T - the overall value type
|
|
113
|
-
* @example
|
|
114
|
-
* ```ts
|
|
115
|
-
* const sum = Reducer
|
|
116
|
-
* .createMono(
|
|
117
|
-
* 0,
|
|
118
|
-
* (current, value) => current + value
|
|
119
|
-
* )
|
|
120
|
-
* const result = Stream.of(1, 2, 3, 2, 1)).reduce(sum)
|
|
121
|
-
* console.log+(result)
|
|
122
|
-
* // => 9
|
|
123
|
-
* ```
|
|
124
|
-
*/
|
|
125
|
-
function createMono(init, next, stateToResult) {
|
|
126
|
-
return create(init, next, stateToResult ?? identity);
|
|
127
|
-
}
|
|
128
|
-
Reducer.createMono = createMono;
|
|
129
|
-
/**
|
|
130
|
-
* Returns a `Reducer` of which the state and output types are the same.
|
|
131
|
-
* @param init - the initial state value
|
|
132
|
-
* @param next - returns the next state value based on the given inputs:<br/>
|
|
133
|
-
* - current: the current state<br/>
|
|
134
|
-
* - next: the current input value<br/>
|
|
135
|
-
* - index: the input index value<br/>
|
|
136
|
-
* - halt: function that, when called, ensures no more elements are passed to the reducer
|
|
137
|
-
* @param stateToResult - (optional) a function that converts the current state to an output value
|
|
138
|
-
* @typeparam I - the input value type
|
|
139
|
-
* @typeparam O - the output value type
|
|
140
|
-
* @example
|
|
141
|
-
* ```ts
|
|
142
|
-
* const boolToString = Reducer
|
|
143
|
-
* .createOutput(
|
|
144
|
-
* '',
|
|
145
|
-
* (current, value: boolean) => current + (value ? 'T' : 'F')
|
|
146
|
-
* )
|
|
147
|
-
* const result = Stream.of(true, false, true)).reduce(boolToString)
|
|
148
|
-
* console.log+(result)
|
|
149
|
-
* // => 'TFT'
|
|
150
|
-
* ```
|
|
151
|
-
*/
|
|
152
|
-
function createOutput(init, next, stateToResult) {
|
|
153
|
-
return create(init, next, stateToResult ?? identity);
|
|
154
|
-
}
|
|
155
|
-
Reducer.createOutput = createOutput;
|
|
156
|
-
/**
|
|
157
|
-
* A `Reducer` that sums all given numeric input values.
|
|
158
|
-
* @example
|
|
159
|
-
* ```ts
|
|
160
|
-
* console.log(Stream.range({ amount: 5 }).reduce(Reducer.sum))
|
|
161
|
-
* // => 10
|
|
162
|
-
* ```
|
|
163
|
-
*/
|
|
164
|
-
Reducer.sum = createMono(0, (state, next) => state + next);
|
|
165
|
-
/**
|
|
166
|
-
* A `Reducer` that calculates the product of all given numeric input values.
|
|
167
|
-
* @example
|
|
168
|
-
* ```ts
|
|
169
|
-
* console.log(Stream.range({ start: 1, amount: 5 }).reduce(product))
|
|
170
|
-
* // => 120
|
|
171
|
-
* ```
|
|
172
|
-
*/
|
|
173
|
-
Reducer.product = createMono(1, (state, next, _, halt) => {
|
|
174
|
-
if (0 === next)
|
|
175
|
-
halt();
|
|
176
|
-
return state * next;
|
|
177
|
-
});
|
|
178
|
-
/**
|
|
179
|
-
* A `Reducer` that calculates the average of all given numberic input values.
|
|
180
|
-
* @example
|
|
181
|
-
* ```ts
|
|
182
|
-
* console.log(Stream.range({ amount: 5 }).reduce(Reducer.average));
|
|
183
|
-
* // => 2
|
|
184
|
-
* ```
|
|
185
|
-
*/
|
|
186
|
-
Reducer.average = createMono(0, (avg, value, index) => avg + (value - avg) / (index + 1));
|
|
187
|
-
/**
|
|
188
|
-
* Returns a `Reducer` that remembers the minimum value of the inputs using the given `compFun` to compare input values
|
|
189
|
-
* @param compFun - a comparison function for two input values, returning 0 when equal, positive when greater, negetive when smaller
|
|
190
|
-
* @param otherwise - (default: undefineds) a fallback value when there were no input values given
|
|
191
|
-
* @example
|
|
192
|
-
* ```ts
|
|
193
|
-
* const stream = Stream.of('abc', 'a', 'abcde', 'ab')
|
|
194
|
-
* console.log(stream.minBy((s1, s2) => s1.length - s2.length))
|
|
195
|
-
* // 'a'
|
|
196
|
-
* ```
|
|
197
|
-
*/
|
|
198
|
-
Reducer.minBy = (compFun, otherwise) => {
|
|
199
|
-
const token = Symbol();
|
|
200
|
-
return create(token, (state, next) => {
|
|
201
|
-
if (token === state)
|
|
202
|
-
return next;
|
|
203
|
-
return compFun(state, next) < 0 ? state : next;
|
|
204
|
-
}, (state) => (token === state ? OptLazy(otherwise) : state));
|
|
205
|
-
};
|
|
206
|
-
/**
|
|
207
|
-
* Returns a `Reducer` that remembers the minimum value of the numberic inputs.
|
|
208
|
-
* @param otherwise - (default: undefined) a fallback value when there were no input values given
|
|
209
|
-
* @example
|
|
210
|
-
* ```ts
|
|
211
|
-
* console.log(Stream.of(5, 3, 7, 4).reduce(Reducer.min()))
|
|
212
|
-
* // => 3
|
|
213
|
-
* ```
|
|
214
|
-
*/
|
|
215
|
-
// prettier-ignore
|
|
216
|
-
Reducer.min = (otherwise) => {
|
|
217
|
-
return create(undefined, (state, next) => undefined !== state && state < next ? state : next, (state) => state ?? OptLazy(otherwise));
|
|
218
|
-
};
|
|
219
|
-
/**
|
|
220
|
-
* Returns a `Reducer` that remembers the maximum value of the inputs using the given `compFun` to compare input values
|
|
221
|
-
* @param compFun - a comparison function for two input values, returning 0 when equal, positive when greater, negetive when smaller
|
|
222
|
-
* @param otherwise - (default: undefined) a fallback value when there were no input values given
|
|
223
|
-
* @example
|
|
224
|
-
* ```ts
|
|
225
|
-
* const stream = Stream.of('abc', 'a', 'abcde', 'ab')
|
|
226
|
-
* console.log(stream.maxBy((s1, s2) => s1.length - s2.length))
|
|
227
|
-
* // 'abcde'
|
|
228
|
-
* ```
|
|
229
|
-
*/
|
|
230
|
-
Reducer.maxBy = (compFun, otherwise) => {
|
|
231
|
-
const token = Symbol();
|
|
232
|
-
return create(token, (state, next) => {
|
|
233
|
-
if (token === state)
|
|
234
|
-
return next;
|
|
235
|
-
return compFun(state, next) > 0 ? state : next;
|
|
236
|
-
}, (state) => (token === state ? OptLazy(otherwise) : state));
|
|
237
|
-
};
|
|
238
|
-
/**
|
|
239
|
-
* Returns a `Reducer` that remembers the maximum value of the numberic inputs.
|
|
240
|
-
* @param otherwise - (default: undefined) a fallback value when there were no input values given
|
|
241
|
-
* @example
|
|
242
|
-
* ```ts
|
|
243
|
-
* console.log(Stream.of(5, 3, 7, 4).reduce(Reducer.max()))
|
|
244
|
-
* // => 7
|
|
245
|
-
* ```
|
|
246
|
-
*/
|
|
247
|
-
// prettier-ignore
|
|
248
|
-
Reducer.max = (otherwise) => {
|
|
249
|
-
return create(undefined, (state, next) => undefined !== state && state > next ? state : next, (state) => state ?? OptLazy(otherwise));
|
|
250
|
-
};
|
|
251
|
-
/**
|
|
252
|
-
* Returns a `Reducer` that joins the given input values into a string using the given options.
|
|
253
|
-
* @param options - an object containing:<br/>
|
|
254
|
-
* - sep: (optional) a seperator string value between values in the output<br/>
|
|
255
|
-
* - start: (optional) a start string to prepend to the output<br/>
|
|
256
|
-
* - end: (optional) an end string to append to the output<br/>
|
|
257
|
-
* @example
|
|
258
|
-
* ```ts
|
|
259
|
-
* console.log(Stream.of(1, 2, 3).reduce(Reducer.join({ sep: '-' })))
|
|
260
|
-
* // => '1-2-3'
|
|
261
|
-
* ```
|
|
262
|
-
*/
|
|
263
|
-
function join({ sep = '', start = '', end = '', valueToString = String, } = {}) {
|
|
264
|
-
let curSep = '';
|
|
265
|
-
let curStart = start;
|
|
266
|
-
return create('', (state, next) => {
|
|
267
|
-
const result = curStart.concat(state, curSep, valueToString(next));
|
|
268
|
-
curSep = sep;
|
|
269
|
-
curStart = '';
|
|
270
|
-
return result;
|
|
271
|
-
}, (state) => state.concat(end));
|
|
272
|
-
}
|
|
273
|
-
Reducer.join = join;
|
|
274
|
-
/**
|
|
275
|
-
* Returns a `Reducer` that remembers the amount of input items provided.
|
|
276
|
-
* @param pred - (optional) a predicate that returns false if the item should not be counted given:<br/>
|
|
277
|
-
* - value: the current input value<br/>
|
|
278
|
-
* - index: the input value index
|
|
279
|
-
* @example
|
|
280
|
-
* ```ts
|
|
281
|
-
* const stream = Stream.range({ amount: 10 })
|
|
282
|
-
* console.log(stream.reduce(Reducer.count()))
|
|
283
|
-
* // => 10
|
|
284
|
-
* console.log(stream.reduce(Reducer.count(v => v < 5)))
|
|
285
|
-
* // => 5
|
|
286
|
-
* ```
|
|
287
|
-
*/
|
|
288
|
-
Reducer.count = (pred) => {
|
|
289
|
-
if (undefined === pred)
|
|
290
|
-
return createOutput(0, (_, __, i) => i + 1);
|
|
291
|
-
return createOutput(0, (state, next, i) => {
|
|
292
|
-
if (pred?.(next, i))
|
|
293
|
-
return state + 1;
|
|
294
|
-
return state;
|
|
295
|
-
});
|
|
296
|
-
};
|
|
297
|
-
/**
|
|
298
|
-
* Returns a `Reducer` that remembers the first input value for which the given `pred` function returns true.
|
|
299
|
-
* @param pred - a function taking an input value and its index, and returning true if the value should be remembered
|
|
300
|
-
* @param otherwise - (default: undefined) a fallback value to output if no input value yet has satisfied the given predicate
|
|
301
|
-
* @typeparam T - the input value type
|
|
302
|
-
* @typeparam O - the fallback value type
|
|
303
|
-
* @example
|
|
304
|
-
* ```ts
|
|
305
|
-
* console.log(Stream.range({ amount: 10 }).reduce(Reducer.firstWhere(v => v > 5)))
|
|
306
|
-
* // => 6
|
|
307
|
-
* ```
|
|
308
|
-
*/
|
|
309
|
-
Reducer.firstWhere = (pred, otherwise) => {
|
|
310
|
-
const token = Symbol();
|
|
311
|
-
return create(token, (state, next, i, halt) => {
|
|
312
|
-
if (token === state && pred(next, i)) {
|
|
313
|
-
halt();
|
|
314
|
-
return next;
|
|
315
|
-
}
|
|
316
|
-
return state;
|
|
317
|
-
}, (state) => (token === state ? OptLazy(otherwise) : state));
|
|
318
|
-
};
|
|
319
|
-
/**
|
|
320
|
-
* Returns a `Reducer` that remembers the first input value.
|
|
321
|
-
* @param otherwise - (default: undefined) a fallback value to output if no input value has been provided
|
|
322
|
-
* @typeparam T - the input value type
|
|
323
|
-
* @typeparam O - the fallback value type
|
|
324
|
-
* @example
|
|
325
|
-
* ```ts
|
|
326
|
-
* console.log(Stream.range{ amount: 10 }).reduce(Reducer.first())
|
|
327
|
-
* // => 0
|
|
328
|
-
* ```
|
|
329
|
-
*/
|
|
330
|
-
Reducer.first = (otherwise) => {
|
|
331
|
-
const token = Symbol();
|
|
332
|
-
return create(token, (state, next, _, halt) => {
|
|
333
|
-
halt();
|
|
334
|
-
if (token === state)
|
|
335
|
-
return next;
|
|
336
|
-
return state;
|
|
337
|
-
}, (state) => (token === state ? OptLazy(otherwise) : state));
|
|
338
|
-
};
|
|
339
|
-
/**
|
|
340
|
-
* Returns a `Reducer` that remembers the last input value for which the given `pred` function returns true.
|
|
341
|
-
* @param pred - a function taking an input value and its index, and returning true if the value should be remembered
|
|
342
|
-
* @param otherwise - (default: undefined) a fallback value to output if no input value yet has satisfied the given predicate
|
|
343
|
-
* @typeparam T - the input value type
|
|
344
|
-
* @typeparam O - the fallback value type
|
|
345
|
-
* @example
|
|
346
|
-
* ```ts
|
|
347
|
-
* console.log(Stream.range({ amount: 10 }).reduce(Reducer.lastWhere(v => v > 5)))
|
|
348
|
-
* // => 9
|
|
349
|
-
* ```
|
|
350
|
-
*/
|
|
351
|
-
Reducer.lastWhere = (pred, otherwise) => {
|
|
352
|
-
const token = Symbol();
|
|
353
|
-
return create(token, (state, next, i) => {
|
|
354
|
-
if (pred(next, i))
|
|
355
|
-
return next;
|
|
356
|
-
return state;
|
|
357
|
-
}, (state) => (token === state ? OptLazy(otherwise) : state));
|
|
358
|
-
};
|
|
359
|
-
/**
|
|
360
|
-
* Returns a `Reducer` that remembers the last input value.
|
|
361
|
-
* @param otherwise - (default: undefined) a fallback value to output if no input value has been provided
|
|
362
|
-
* @typeparam T - the input value type
|
|
363
|
-
* @typeparam O - the fallback value type
|
|
364
|
-
* @example
|
|
365
|
-
* ```ts
|
|
366
|
-
* console.log(Stream.range{ amount: 10 }).reduce(Reducer.last())
|
|
367
|
-
* // => 9
|
|
368
|
-
* ```
|
|
369
|
-
*/
|
|
370
|
-
Reducer.last = (otherwise) => {
|
|
371
|
-
const token = Symbol();
|
|
372
|
-
return create(() => token, (_, next) => next, (state) => (token === state ? OptLazy(otherwise) : state));
|
|
373
|
-
};
|
|
374
|
-
/**
|
|
375
|
-
* Returns a `Reducer` that ouputs false as long as no input value satisfies given `pred`, true otherwise.
|
|
376
|
-
* @typeparam T - the element type
|
|
377
|
-
* @param pred - a function taking an input value and its index, and returning true if the value satisfies the predicate
|
|
378
|
-
* @example
|
|
379
|
-
* ```ts
|
|
380
|
-
* console.log(Stream.range{ amount: 10 }).reduce(Reducer.some(v => v > 5))
|
|
381
|
-
* // => true
|
|
382
|
-
* ```
|
|
383
|
-
*/
|
|
384
|
-
function some(pred) {
|
|
385
|
-
return createOutput(false, (state, next, i, halt) => {
|
|
386
|
-
if (state)
|
|
387
|
-
return state;
|
|
388
|
-
const satisfies = pred(next, i);
|
|
389
|
-
if (satisfies) {
|
|
390
|
-
halt();
|
|
391
|
-
}
|
|
392
|
-
return satisfies;
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
Reducer.some = some;
|
|
396
|
-
/**
|
|
397
|
-
* Returns a `Reducer` that ouputs true as long as all input values satisfy the given `pred`, false otherwise.
|
|
398
|
-
* @typeparam T - the element type
|
|
399
|
-
* @param pred - a function taking an input value and its index, and returning true if the value satisfies the predicate
|
|
400
|
-
* @example
|
|
401
|
-
* ```ts
|
|
402
|
-
* console.log(Stream.range{ amount: 10 }).reduce(Reducer.every(v => v < 5))
|
|
403
|
-
* // => false
|
|
404
|
-
* ```
|
|
405
|
-
*/
|
|
406
|
-
function every(pred) {
|
|
407
|
-
return createOutput(true, (state, next, i, halt) => {
|
|
408
|
-
if (!state)
|
|
409
|
-
return state;
|
|
410
|
-
const satisfies = pred(next, i);
|
|
411
|
-
if (!satisfies) {
|
|
412
|
-
halt();
|
|
413
|
-
}
|
|
414
|
-
return satisfies;
|
|
415
|
-
});
|
|
416
|
-
}
|
|
417
|
-
Reducer.every = every;
|
|
418
|
-
/**
|
|
419
|
-
* Returns a `Reducer` that outputs false as long as the given `elem` has not been encountered in the input values, true otherwise.
|
|
420
|
-
* @typeparam T - the element type
|
|
421
|
-
* @param elem - the element to search for
|
|
422
|
-
* @param eq - (optional) a comparison function that returns true if te two given input values are considered equal
|
|
423
|
-
* @example
|
|
424
|
-
* ```ts
|
|
425
|
-
* console.log(Stream.range({ amount: 10 }).reduce(Reducer.contains(5)))
|
|
426
|
-
* // => true
|
|
427
|
-
* ```
|
|
428
|
-
*/
|
|
429
|
-
function contains(elem, eq = Object.is) {
|
|
430
|
-
return createOutput(false, (state, next, _, halt) => {
|
|
431
|
-
if (state)
|
|
432
|
-
return state;
|
|
433
|
-
const satisfies = eq(next, elem);
|
|
434
|
-
if (satisfies) {
|
|
435
|
-
halt();
|
|
436
|
-
}
|
|
437
|
-
return satisfies;
|
|
438
|
-
});
|
|
439
|
-
}
|
|
440
|
-
Reducer.contains = contains;
|
|
441
|
-
/**
|
|
442
|
-
* Returns a `Reducer` that takes boolean values and outputs true if all input values are true, and false otherwise.
|
|
443
|
-
* @example
|
|
444
|
-
* ```ts
|
|
445
|
-
* console.log(Stream.of(true, false, true)).reduce(Reducer.and))
|
|
446
|
-
* // => false
|
|
447
|
-
* ```
|
|
448
|
-
*/
|
|
449
|
-
Reducer.and = createMono(true, (state, next, _, halt) => {
|
|
450
|
-
if (!state)
|
|
451
|
-
return state;
|
|
452
|
-
if (!next)
|
|
453
|
-
halt();
|
|
454
|
-
return next;
|
|
455
|
-
});
|
|
456
|
-
/**
|
|
457
|
-
* Returns a `Reducer` that takes boolean values and outputs true if one or more input values are true, and false otherwise.
|
|
458
|
-
* @example
|
|
459
|
-
* ```ts
|
|
460
|
-
* console.log(Stream.of(true, false, true)).reduce(Reducer.or))
|
|
461
|
-
* // => true
|
|
462
|
-
* ```
|
|
463
|
-
*/
|
|
464
|
-
Reducer.or = createMono(false, (state, next, _, halt) => {
|
|
465
|
-
if (state)
|
|
466
|
-
return state;
|
|
467
|
-
if (next)
|
|
468
|
-
halt();
|
|
469
|
-
return next;
|
|
470
|
-
});
|
|
471
|
-
/**
|
|
472
|
-
* Returns a `Reducer` that outputs true if no input values are received, false otherwise.
|
|
473
|
-
* @example
|
|
474
|
-
* ```ts
|
|
475
|
-
* console.log(Stream.of(1, 2, 3).reduce(Reducer.isEmpty))
|
|
476
|
-
* // => false
|
|
477
|
-
* ```
|
|
478
|
-
*/
|
|
479
|
-
Reducer.isEmpty = createOutput(true, (_, __, ___, halt) => {
|
|
480
|
-
halt();
|
|
481
|
-
return false;
|
|
482
|
-
});
|
|
483
|
-
/**
|
|
484
|
-
* Returns a `Reducer` that outputs true if one or more input values are received, false otherwise.
|
|
485
|
-
* @example
|
|
486
|
-
* ```ts
|
|
487
|
-
* console.log(Stream.of(1, 2, 3).reduce(Reducer.nonEmpty))
|
|
488
|
-
* // => true
|
|
489
|
-
* ```
|
|
490
|
-
*/
|
|
491
|
-
Reducer.nonEmpty = createOutput(false, (_, __, ___, halt) => {
|
|
492
|
-
halt();
|
|
493
|
-
return true;
|
|
494
|
-
});
|
|
495
|
-
/**
|
|
496
|
-
* Returns a `Reducer` that collects received input values in an array, and returns a copy of that array as an output value when requested.
|
|
497
|
-
* @typeparam T - the element type
|
|
498
|
-
* @example
|
|
499
|
-
* ```ts
|
|
500
|
-
* console.log(Stream.of(1, 2, 3).reduce(Reducer.toArray()))
|
|
501
|
-
* // => [1, 2, 3]
|
|
502
|
-
* ```
|
|
503
|
-
*/
|
|
504
|
-
function toArray() {
|
|
505
|
-
return create(() => [], (state, next) => {
|
|
506
|
-
state.push(next);
|
|
507
|
-
return state;
|
|
508
|
-
}, (state) => state.slice());
|
|
509
|
-
}
|
|
510
|
-
Reducer.toArray = toArray;
|
|
511
|
-
/**
|
|
512
|
-
* Returns a `Reducer` that collects received input tuples into a mutable JS Map, and returns
|
|
513
|
-
* a copy of that map when output is requested.
|
|
514
|
-
* @typeparam K - the map key type
|
|
515
|
-
* @typeparam V - the map value type
|
|
516
|
-
* @example
|
|
517
|
-
* ```ts
|
|
518
|
-
* console.log(Stream.of([1, 'a'], [2, 'b']).reduce(Reducer.toJSMap()))
|
|
519
|
-
* // Map { 1 => 'a', 2 => 'b' }
|
|
520
|
-
* ```
|
|
521
|
-
*/
|
|
522
|
-
function toJSMap() {
|
|
523
|
-
return create(() => new Map(), (state, next) => {
|
|
524
|
-
state.set(next[0], next[1]);
|
|
525
|
-
return state;
|
|
526
|
-
}, (s) => new Map(s));
|
|
527
|
-
}
|
|
528
|
-
Reducer.toJSMap = toJSMap;
|
|
529
|
-
/**
|
|
530
|
-
* Returns a `Reducer` that collects received input values into a mutable JS Set, and returns
|
|
531
|
-
* a copy of that map when output is requested.
|
|
532
|
-
* @typeparam T - the element type
|
|
533
|
-
* @example
|
|
534
|
-
* ```ts
|
|
535
|
-
* console.log(Stream.of(1, 2, 3).reduce(Reducer.toJSSet()))
|
|
536
|
-
* // Set {1, 2, 3}
|
|
537
|
-
* ```
|
|
538
|
-
*/
|
|
539
|
-
function toJSSet() {
|
|
540
|
-
return create(() => new Set(), (state, next) => {
|
|
541
|
-
state.add(next);
|
|
542
|
-
return state;
|
|
543
|
-
}, (s) => new Set(s));
|
|
544
|
-
}
|
|
545
|
-
Reducer.toJSSet = toJSSet;
|
|
546
|
-
/**
|
|
547
|
-
* Returns a `Reducer` that collects 2-tuples containing keys and values into a plain JS object, and
|
|
548
|
-
* returns a copy of that object when output is requested.
|
|
549
|
-
* @typeparam K - the result object key type
|
|
550
|
-
* @typeparam V - the result object value type
|
|
551
|
-
* @example
|
|
552
|
-
* ```ts
|
|
553
|
-
* console.log(Stream.of(['a', 1], ['b', true]).reduce(Reducer.toJSObject()))
|
|
554
|
-
* // { a: 1, b: true }
|
|
555
|
-
* ```
|
|
556
|
-
*/
|
|
557
|
-
function toJSObject() {
|
|
558
|
-
return create(() => ({}), (state, entry) => {
|
|
559
|
-
state[entry[0]] = entry[1];
|
|
560
|
-
return state;
|
|
561
|
-
}, (s) => ({ ...s }));
|
|
562
|
-
}
|
|
563
|
-
Reducer.toJSObject = toJSObject;
|
|
564
|
-
/**
|
|
565
|
-
* Returns a `Reducer` that combines multiple input `reducers` by providing input values to all of them and collecting the outputs in an array.
|
|
566
|
-
* @param reducers - 2 or more reducers to combine
|
|
567
|
-
* @example
|
|
568
|
-
* ```ts
|
|
569
|
-
* const red = Reducer.combineArr(Reducer.sum, Reducer.average)
|
|
570
|
-
* console.log(Stream.range({amount: 9 }).reduce(red))
|
|
571
|
-
* // => [36, 4]
|
|
572
|
-
* ```
|
|
573
|
-
*/
|
|
574
|
-
function combineArr(...reducers) {
|
|
575
|
-
const createState = () => {
|
|
576
|
-
return reducers.map((reducer) => {
|
|
577
|
-
const result = {
|
|
578
|
-
reducer,
|
|
579
|
-
halted: false,
|
|
580
|
-
halt() {
|
|
581
|
-
result.halted = true;
|
|
582
|
-
},
|
|
583
|
-
state: OptLazy(reducer.init),
|
|
584
|
-
};
|
|
585
|
-
return result;
|
|
586
|
-
});
|
|
587
|
-
};
|
|
588
|
-
return create(createState, (allState, next, index, halt) => {
|
|
589
|
-
let anyNotHalted = false;
|
|
590
|
-
let i = -1;
|
|
591
|
-
const len = allState.length;
|
|
592
|
-
while (++i < len) {
|
|
593
|
-
const red = allState[i];
|
|
594
|
-
if (red.halted) {
|
|
595
|
-
continue;
|
|
596
|
-
}
|
|
597
|
-
red.state = red.reducer.next(red.state, next, index, red.halt);
|
|
598
|
-
if (!red.halted) {
|
|
599
|
-
anyNotHalted = true;
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
if (!anyNotHalted) {
|
|
603
|
-
halt();
|
|
604
|
-
}
|
|
605
|
-
return allState;
|
|
606
|
-
}, (allState) => allState.map((st) => st.reducer.stateToResult(st.state)));
|
|
607
|
-
}
|
|
608
|
-
Reducer.combineArr = combineArr;
|
|
609
|
-
/**
|
|
610
|
-
* Returns a `Reducer` that combines multiple input `reducers` by providing input values to all of them and collecting the outputs in the shape of the given object.
|
|
611
|
-
* @typeparam T - the input type for all the reducers
|
|
612
|
-
* @typeparam R - the result object shape
|
|
613
|
-
* @param reducerObj - an object of keys, and reducers corresponding to those keys
|
|
614
|
-
* @example
|
|
615
|
-
* ```ts
|
|
616
|
-
* const red = Reducer.combineObj({
|
|
617
|
-
* theSum: Reducer.sum,
|
|
618
|
-
* theAverage: Reducer.average
|
|
619
|
-
* });
|
|
620
|
-
*
|
|
621
|
-
* Stream.range({ amount: 9 }).reduce(red);
|
|
622
|
-
* // => { theSum: 36, theAverage: 4 }
|
|
623
|
-
* ```
|
|
624
|
-
*/
|
|
625
|
-
function combineObj(reducerObj) {
|
|
626
|
-
const createState = () => {
|
|
627
|
-
const allState = {};
|
|
628
|
-
for (const key in reducerObj) {
|
|
629
|
-
const reducer = reducerObj[key];
|
|
630
|
-
const result = {
|
|
631
|
-
reducer,
|
|
632
|
-
halted: false,
|
|
633
|
-
halt() {
|
|
634
|
-
result.halted = true;
|
|
635
|
-
},
|
|
636
|
-
state: OptLazy(reducer.init),
|
|
637
|
-
};
|
|
638
|
-
allState[key] = result;
|
|
639
|
-
}
|
|
640
|
-
return allState;
|
|
641
|
-
};
|
|
642
|
-
return create(createState, (allState, next, index, halt) => {
|
|
643
|
-
let anyNotHalted = false;
|
|
644
|
-
for (const key in allState) {
|
|
645
|
-
const red = allState[key];
|
|
646
|
-
if (red.halted) {
|
|
647
|
-
continue;
|
|
648
|
-
}
|
|
649
|
-
red.state = red.reducer.next(red.state, next, index, red.halt);
|
|
650
|
-
if (!red.halted) {
|
|
651
|
-
anyNotHalted = true;
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
if (!anyNotHalted) {
|
|
655
|
-
halt();
|
|
656
|
-
}
|
|
657
|
-
return allState;
|
|
658
|
-
}, (allState) => {
|
|
659
|
-
const result = {};
|
|
660
|
-
for (const key in allState) {
|
|
661
|
-
const st = allState[key];
|
|
662
|
-
result[key] = st.reducer.stateToResult(st.state);
|
|
663
|
-
}
|
|
664
|
-
return result;
|
|
665
|
-
});
|
|
666
|
-
}
|
|
667
|
-
Reducer.combineObj = combineObj;
|
|
668
|
-
})(Reducer || (Reducer = {}));
|
|
669
|
-
//# sourceMappingURL=reducer.mjs.map
|
package/dist/esm/reducer.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reducer.mjs","sourceRoot":"","sources":["../../src/reducer.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AASzD,SAAS,QAAQ,CAAI,KAAQ;IAC3B,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,KAAW,OAAO,CAm/BvB;AAn/BD,WAAiB,OAAO;IAiHtB;;;;;OAKG;IACH,MAAa,IAAI;QACf,YACW,IAAgB,EAChB,IAA+D,EAC/D,aAA8B;YAF9B,SAAI,GAAJ,IAAI,CAAY;YAChB,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,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;aAC1B,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