@thi.ng/transducers 8.9.18 → 9.0.0
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/CHANGELOG.md +17 -1
- package/README.md +115 -144
- package/api.d.ts +21 -22
- package/assoc-map.d.ts +1 -1
- package/assoc-obj.d.ts +1 -1
- package/auto-obj.d.ts +1 -1
- package/compr.d.ts +1 -1
- package/conj.d.ts +1 -1
- package/count.d.ts +1 -1
- package/count.js +1 -2
- package/fill.d.ts +2 -2
- package/frequencies.d.ts +2 -2
- package/group-binary.d.ts +4 -4
- package/group-by-map.d.ts +1 -1
- package/group-by-map.js +1 -2
- package/group-by-obj.d.ts +1 -1
- package/group-by-obj.js +1 -2
- package/internal/drain.d.ts +1 -1
- package/juxtr.d.ts +4 -4
- package/map.d.ts +1 -1
- package/mapcat.d.ts +3 -3
- package/min-max.d.ts +1 -1
- package/moving-median.js +1 -2
- package/multiplex-obj.d.ts +2 -2
- package/noop.js +2 -1
- package/norm-count.d.ts +1 -1
- package/norm-count.js +1 -2
- package/norm-frequencies-auto.d.ts +2 -2
- package/norm-frequencies-auto.js +1 -2
- package/norm-frequencies.d.ts +2 -2
- package/package.json +13 -12
- package/push-copy.d.ts +1 -1
- package/push-sort.d.ts +2 -2
- package/push.d.ts +1 -1
- package/range.d.ts +2 -2
- package/reduce.d.ts +7 -7
- package/reduce.js +3 -5
- package/reduced.d.ts +3 -3
- package/reductions.d.ts +2 -2
- package/rename.d.ts +2 -2
- package/rename.js +6 -4
- package/run.d.ts +2 -2
- package/scan.d.ts +2 -2
- package/some.d.ts +1 -1
- package/some.js +1 -2
- package/step.d.ts +1 -1
- package/step.js +1 -1
- package/str.d.ts +1 -1
- package/struct.d.ts +6 -7
- package/struct.js +1 -1
- package/transduce.d.ts +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-
|
|
3
|
+
- **Last updated**: 2024-04-08T14:59:29Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,22 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
# [9.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/transducers@9.0.0) (2024-04-08)
|
|
13
|
+
|
|
14
|
+
#### 🛑 Breaking changes
|
|
15
|
+
|
|
16
|
+
- update Reducer, Transducer and other types ([95c43f3](https://github.com/thi-ng/umbrella/commit/95c43f3))
|
|
17
|
+
- BREAKING CHANGE: update generics in Reducer, Transducer and other types
|
|
18
|
+
- swap generic type args in `Reducer` and `IReducible` to be same order as in `Transducer`, `IXform`,
|
|
19
|
+
i.e. `Reducer<A, B>` maps items from type A to type B, **not** the other way (as was)!
|
|
20
|
+
- this new order is more logical, less confusing and also in line with upcoming async transducers pkg
|
|
21
|
+
- changes in userland should be minimal (if any), only impacted are custom reducer definitions
|
|
22
|
+
- update all pkg internal occurrences
|
|
23
|
+
- various other small refactorings, type/arg updates, e.g.
|
|
24
|
+
- add generics for `reduced()`/`ensureReduced()`/`unreduced()`
|
|
25
|
+
- update `step()` return type (incl. undefined)
|
|
26
|
+
- add `StructField` generics
|
|
27
|
+
|
|
12
28
|
### [8.9.6](https://github.com/thi-ng/umbrella/tree/@thi.ng/transducers@8.9.6) (2024-02-22)
|
|
13
29
|
|
|
14
30
|
#### ♻️ Refactoring
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
> [!NOTE]
|
|
10
|
-
> This is one of
|
|
10
|
+
> This is one of 191 standalone projects, maintained as part
|
|
11
11
|
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
|
|
12
12
|
> and anti-framework.
|
|
13
13
|
>
|
|
@@ -16,9 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
- [About](#about)
|
|
18
18
|
- [Status](#status)
|
|
19
|
-
- [
|
|
20
|
-
- [6.0.0 release](#600-release)
|
|
21
|
-
- [5.0.0 release](#500-release)
|
|
19
|
+
- [9.0.0 release](#900-release)
|
|
22
20
|
- [Support packages](#support-packages)
|
|
23
21
|
- [Related packages](#related-packages)
|
|
24
22
|
- [Blog posts](#blog-posts)
|
|
@@ -67,23 +65,23 @@
|
|
|
67
65
|
|
|
68
66
|
Lightweight transducer implementations for ES6 / TypeScript.
|
|
69
67
|
|
|
70
|
-
This library provides altogether ~
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
This library provides altogether ~170 transducers, reducers, sequence generators
|
|
69
|
+
(ES6 generators/iterators) and additional supporting functions for composing
|
|
70
|
+
data transformation pipelines.
|
|
73
71
|
|
|
74
|
-
The overall concept and many of the core functions offered here are
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
The overall concept and many of the core functions offered here are directly
|
|
73
|
+
inspired by the original Clojure implementation by Rich Hickey, though the
|
|
74
|
+
implementation does heavily differ (also in contrast to some other JS based
|
|
75
|
+
implementations) and dozens of less common, but generally highly useful
|
|
76
|
+
operators have been added. See full list below.
|
|
79
77
|
|
|
80
|
-
Furthermore, most transducers & reducers provided here accept an
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
`
|
|
85
|
-
|
|
86
|
-
|
|
78
|
+
Furthermore, most transducers & reducers provided here accept an optional input
|
|
79
|
+
iterable, which allows them to be used directly as transformers instead of
|
|
80
|
+
having to wrap them in one of the execution functions (i.e.
|
|
81
|
+
`transduce()`/`transduceRight()`, `reduce()`/`reduceRight()`, `iterator()`,
|
|
82
|
+
`run()`, `step()`). If called this way, transducer functions will return a
|
|
83
|
+
transforming ES6 iterator (generator) and reducing functions will return a
|
|
84
|
+
reduced result of the given input iterable.
|
|
87
85
|
|
|
88
86
|
## Status
|
|
89
87
|
|
|
@@ -91,52 +89,20 @@ will return a reduced result of the given input iterable.
|
|
|
91
89
|
|
|
92
90
|
[Search or submit any issues for this package](https://github.com/thi-ng/umbrella/issues?q=%5Btransducers%5D+in%3Atitle)
|
|
93
91
|
|
|
94
|
-
###
|
|
92
|
+
### 9.0.0 release
|
|
95
93
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
### 6.0.0 release
|
|
106
|
-
|
|
107
|
-
BREAKING CHANGES:
|
|
108
|
-
|
|
109
|
-
- The `interpolate` iterator for keyframe interpolation has been renamed
|
|
110
|
-
to `tween`. In its place there's a new higher order transducer called
|
|
111
|
-
`interpolate`, incl. syntax-sugar versions `interpolateHermite` and
|
|
112
|
-
`interpolateLinear`.
|
|
113
|
-
- The previously deprecated `wrapLeft`, `wrapRight` and `wrapBoth`
|
|
114
|
-
iterators have been removed.
|
|
115
|
-
- The `wrap` iterator has been renamed to `wrapSides` and has a new
|
|
116
|
-
signature/arguments, more aligned with the ones listed below.
|
|
117
|
-
|
|
118
|
-
The following new iterators have been added:
|
|
119
|
-
|
|
120
|
-
- `extendSides`
|
|
121
|
-
- `padSides`
|
|
122
|
-
- `symmetric`
|
|
123
|
-
|
|
124
|
-
### 5.0.0 release
|
|
125
|
-
|
|
126
|
-
Several previously included internal support functions have been
|
|
127
|
-
migrated to the
|
|
128
|
-
[@thi.ng/arrays](https://github.com/thi-ng/umbrella/tree/develop/packages/arrays)
|
|
129
|
-
package. You'll need to update your imports if you've been using any of
|
|
130
|
-
these directly. Note that some of these functions also have changes to
|
|
131
|
-
their arg order. See changelog.
|
|
132
|
-
|
|
133
|
-
Functions using randomness now all support an optional PRNG
|
|
134
|
-
implementation of the `IRandom` interface from the
|
|
135
|
-
[@thi.ng/random](https://github.com/thi-ng/umbrella/tree/develop/packages/random)
|
|
136
|
-
package.
|
|
94
|
+
This release corrects a longstanding stylistic issue regarding the order of
|
|
95
|
+
generic type args given to [`Reducer<A, B>`](#reducer), which now uses the
|
|
96
|
+
swapped & more logical order (i.e. reduce from `A` to `B`) and is the same order
|
|
97
|
+
of generic type args for `Transducer` and `AsyncTransducer` / `AsyncReducer` (in
|
|
98
|
+
the [thi.ng/transducers-async
|
|
99
|
+
package](https://github.com/thi-ng/umbrella/blob/develop/packages/transducers-async)).
|
|
100
|
+
Most userland code should be unimpacted by this change - this is only a breaking
|
|
101
|
+
change for custom reducer impls.
|
|
137
102
|
|
|
138
103
|
## Support packages
|
|
139
104
|
|
|
105
|
+
- [@thi.ng/transducers-async](https://github.com/thi-ng/umbrella/tree/develop/packages/transducers-async) - Async versions of various highly composable transducers, reducers and iterators
|
|
140
106
|
- [@thi.ng/transducers-binary](https://github.com/thi-ng/umbrella/tree/develop/packages/transducers-binary) - Binary data related transducers & reducers
|
|
141
107
|
- [@thi.ng/transducers-fsm](https://github.com/thi-ng/umbrella/tree/develop/packages/transducers-fsm) - Transducer-based Finite State Machine transformer
|
|
142
108
|
- [@thi.ng/transducers-hdom](https://github.com/thi-ng/umbrella/tree/develop/packages/transducers-hdom) - Transducer based UI updater for [@thi.ng/hdom](https://github.com/thi-ng/umbrella/tree/develop/packages/hdom)
|
|
@@ -165,7 +131,13 @@ package.
|
|
|
165
131
|
yarn add @thi.ng/transducers
|
|
166
132
|
```
|
|
167
133
|
|
|
168
|
-
|
|
134
|
+
ESM import:
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
import * as tx from "@thi.ng/transducers";
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Browser ESM import:
|
|
169
141
|
|
|
170
142
|
```html
|
|
171
143
|
<script type="module" src="https://cdn.skypack.dev/@thi.ng/transducers"></script>
|
|
@@ -176,7 +148,7 @@ ES module import:
|
|
|
176
148
|
For Node.js REPL:
|
|
177
149
|
|
|
178
150
|
```js
|
|
179
|
-
const
|
|
151
|
+
const tx = await import("@thi.ng/transducers");
|
|
180
152
|
```
|
|
181
153
|
|
|
182
154
|
Package sizes (brotli'd, pre-treeshake): ESM: 8.89 KB
|
|
@@ -696,50 +668,52 @@ Apart from type aliases, the only real types defined are:
|
|
|
696
668
|
#### Reducer
|
|
697
669
|
|
|
698
670
|
Reducers are the core building blocks of transducers. Unlike other
|
|
699
|
-
implementations using OOP approaches, a `Reducer` in this lib is a
|
|
700
|
-
|
|
701
|
-
|
|
671
|
+
implementations using OOP approaches, a `Reducer` in this lib is a simple
|
|
672
|
+
3-element array of functions, each addressing a separate processing step.
|
|
673
|
+
|
|
674
|
+
The bundled reducers are all wrapped in functions to provide a uniform API (and
|
|
675
|
+
some of them can be preconfigured and/or are stateful closures). However, it's
|
|
676
|
+
completely fine to define stateless reducers as constant arrays.
|
|
677
|
+
|
|
678
|
+
A `Reducer` is a 3-tuple of functions defining the different stages of a
|
|
679
|
+
reduction process: A `Reducer<A, B>` reduces values of type A to a single value
|
|
680
|
+
of type B.
|
|
681
|
+
|
|
682
|
+
The tuple items/functions in order:
|
|
702
683
|
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
684
|
+
1. Initialization function used to produce an initial default result (only used
|
|
685
|
+
if no such initial result was given by the user)
|
|
686
|
+
2. Completion function to post-process an already reduced result (for most
|
|
687
|
+
reducers this is merely the identity function)
|
|
688
|
+
3. Accumulation function, merging a new input value with the currently existing
|
|
689
|
+
(partially) reduced result/accumulator
|
|
707
690
|
|
|
708
691
|
```ts
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
* transformers should flush/apply their outstanding results.
|
|
718
|
-
*/
|
|
719
|
-
[1]: (acc: A) => A;
|
|
720
|
-
/**
|
|
721
|
-
* Reduction step. Combines new input with accumulator.
|
|
722
|
-
* If reduction should terminate early, wrap result via `reduced()`
|
|
723
|
-
*/
|
|
724
|
-
[2]: (acc: A, x: B) => A | Reduced<A>;
|
|
725
|
-
}
|
|
692
|
+
type Reducer<A, B> = [
|
|
693
|
+
// init
|
|
694
|
+
() => B,
|
|
695
|
+
// completion
|
|
696
|
+
(x: B) => B,
|
|
697
|
+
// accumulation
|
|
698
|
+
(acc: B, x: A) => B
|
|
699
|
+
];
|
|
726
700
|
|
|
727
701
|
// A concrete example:
|
|
728
|
-
const push: Reducer<any
|
|
702
|
+
const push: Reducer<any, any[]> = [
|
|
729
703
|
// init
|
|
730
704
|
() => [],
|
|
731
705
|
// completion (nothing to do in this case)
|
|
732
706
|
(acc) => acc,
|
|
733
|
-
//
|
|
707
|
+
// accumulation
|
|
734
708
|
(acc, x) => (acc.push(x), acc)
|
|
735
709
|
];
|
|
736
710
|
```
|
|
737
711
|
|
|
738
|
-
`partition`, `partitionBy`, `streamSort`, `streamShuffle` are (examples
|
|
739
|
-
of) transducers making use of their 1-arity completing function.
|
|
740
|
-
|
|
741
712
|
#### Reduced
|
|
742
713
|
|
|
714
|
+
Simple type wrapper to mark & identify a reducer's early termination. Does not
|
|
715
|
+
modify wrapped value by injecting magic properties.
|
|
716
|
+
|
|
743
717
|
```ts
|
|
744
718
|
import type { IDeref } from "@thi.ng/api";
|
|
745
719
|
|
|
@@ -750,9 +724,8 @@ class Reduced<T> implements IDeref<T> {
|
|
|
750
724
|
}
|
|
751
725
|
```
|
|
752
726
|
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
created via `reduced(x)` and handled via these helper functions:
|
|
727
|
+
Instances can be created via `reduced(x)` and handled via these helper
|
|
728
|
+
functions:
|
|
756
729
|
|
|
757
730
|
- `reduced(x: any): any`
|
|
758
731
|
- `isReduced(x: any): boolean`
|
|
@@ -761,18 +734,18 @@ created via `reduced(x)` and handled via these helper functions:
|
|
|
761
734
|
|
|
762
735
|
#### IReducible
|
|
763
736
|
|
|
764
|
-
By default `reduce()` consumes inputs via the standard ES6 `Iterable`
|
|
765
|
-
|
|
766
|
-
for some types: Array-like inputs are consumed via a traditional
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
737
|
+
By default `reduce()` consumes inputs via the standard ES6 `Iterable` interface,
|
|
738
|
+
i.e. using a `for..of..` loop, but the function also supports optimized routes
|
|
739
|
+
for some types: Array-like inputs are consumed via a traditional `for`-loop and
|
|
740
|
+
custom optimized iterations can be provided via implementations of the
|
|
741
|
+
`IReducible` interface in the source collection type. Examples can be found
|
|
742
|
+
here:
|
|
770
743
|
|
|
771
744
|
- [DCons](https://github.com/thi-ng/umbrella/tree/develop/packages/dcons/src/index.ts#L156)
|
|
772
745
|
- [SortedMap](https://github.com/thi-ng/umbrella/tree/develop/packages/associative/src/sorted-map.ts#L276)
|
|
773
746
|
|
|
774
|
-
**Note:** The `IReducible` interface is only used by `reduce()`,
|
|
775
|
-
|
|
747
|
+
**Note:** The `IReducible` interface is only used by `reduce()`, `transduce()`
|
|
748
|
+
and `run()`.
|
|
776
749
|
|
|
777
750
|
#### Transducer
|
|
778
751
|
|
|
@@ -780,20 +753,20 @@ From Rich Hickey's original definition:
|
|
|
780
753
|
|
|
781
754
|
> A transducer is a transformation from one reducing function to another
|
|
782
755
|
|
|
783
|
-
As shown in the examples above, transducers can be dynamically composed
|
|
784
|
-
|
|
785
|
-
|
|
756
|
+
As shown in the examples above, transducers can be dynamically composed (using
|
|
757
|
+
`comp()`) to form arbitrary data transformation pipelines without causing large
|
|
758
|
+
overheads for intermediate collections.
|
|
786
759
|
|
|
787
760
|
```ts
|
|
788
|
-
type Transducer<A, B> = (rfn: Reducer<
|
|
761
|
+
type Transducer<A, B> = (rfn: Reducer<B, any>) => Reducer<A, any>;
|
|
789
762
|
|
|
790
|
-
// concrete example of stateless transducer (expanded for clarity)
|
|
763
|
+
// concrete example of a stateless transducer (expanded for clarity)
|
|
791
764
|
function map<A, B>(fn: (x: A) => B): Transducer<A, B> {
|
|
792
|
-
return (
|
|
793
|
-
return [
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
(acc, x: A) =>
|
|
765
|
+
return ([init, complete, reduce]: Reducer<B, any>) => {
|
|
766
|
+
return <Reducer<A, any>>[
|
|
767
|
+
init,
|
|
768
|
+
complete,
|
|
769
|
+
(acc, x: A) => reduce(acc, fn(x))
|
|
797
770
|
];
|
|
798
771
|
};
|
|
799
772
|
}
|
|
@@ -801,14 +774,14 @@ function map<A, B>(fn: (x: A) => B): Transducer<A, B> {
|
|
|
801
774
|
// stateful transducer
|
|
802
775
|
// removes successive value repetitions
|
|
803
776
|
function dedupe<T>(): Transducer<T, T> {
|
|
804
|
-
return (
|
|
777
|
+
return ([init, complete, reduce]: Reducer<T, any>) => {
|
|
805
778
|
// state initialization
|
|
806
779
|
let prev = {};
|
|
807
|
-
return [
|
|
808
|
-
|
|
809
|
-
|
|
780
|
+
return <Reducer<T, any>>[
|
|
781
|
+
init,
|
|
782
|
+
complete,
|
|
810
783
|
(acc, x) => {
|
|
811
|
-
|
|
784
|
+
if (prev !== x) acc = reduce(acc, x);
|
|
812
785
|
prev = x;
|
|
813
786
|
return acc;
|
|
814
787
|
}
|
|
@@ -819,10 +792,10 @@ function dedupe<T>(): Transducer<T, T> {
|
|
|
819
792
|
|
|
820
793
|
#### IXform interface
|
|
821
794
|
|
|
822
|
-
Interface for types able to provide some internal functionality (or
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
795
|
+
Interface for types able to provide some internal functionality (or derive some
|
|
796
|
+
related transformation) as `Transducer`. Implementations of this interface can
|
|
797
|
+
be directly passed to all functions in this package where a `Transducer` arg is
|
|
798
|
+
expected.
|
|
826
799
|
|
|
827
800
|
```ts
|
|
828
801
|
import { map, push, range, transduce, type IXform } from "@thi.ng/transducers";
|
|
@@ -856,9 +829,9 @@ transduce(
|
|
|
856
829
|
|
|
857
830
|
`comp(f1, f2, ...)`
|
|
858
831
|
|
|
859
|
-
Returns new transducer composed from given transducers. Data flow is
|
|
860
|
-
|
|
861
|
-
|
|
832
|
+
Returns new transducer composed from given transducers. Data flow is from left
|
|
833
|
+
to right. Offers fast paths for up to 10 args. If more are given, composition is
|
|
834
|
+
done dynamically via for loop.
|
|
862
835
|
|
|
863
836
|
#### compR
|
|
864
837
|
|
|
@@ -870,17 +843,16 @@ Helper function to compose reducers.
|
|
|
870
843
|
|
|
871
844
|
`iterator<A, B>(tx: Transducer<A, B>, xs: Iterable<A>): IterableIterator<B>`
|
|
872
845
|
|
|
873
|
-
Similar to `transduce()`, but emits results as ES6 iterator (and hence
|
|
874
|
-
|
|
846
|
+
Similar to `transduce()`, but emits results as ES6 iterator (and hence doesn't
|
|
847
|
+
use a reduction function).
|
|
875
848
|
|
|
876
849
|
#### reduce
|
|
877
850
|
|
|
878
851
|
`reduce<A, B>(rfn: Reducer<A, B>, acc?: A, xs: Iterable<B>): A`
|
|
879
852
|
|
|
880
|
-
Reduces `xs` using given reducer and optional initial
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
an `ArrayLike` type.
|
|
853
|
+
Reduces `xs` using given reducer and optional initial accumulator/result. If
|
|
854
|
+
`xs` implements the `IReducible` interface, delegates to that implementation.
|
|
855
|
+
Likewise, uses a fast route if `xs` is an `ArrayLike` type.
|
|
884
856
|
|
|
885
857
|
#### reduceRight
|
|
886
858
|
|
|
@@ -893,8 +865,8 @@ into right-to-left order.
|
|
|
893
865
|
|
|
894
866
|
`transduce<A, B, C>(tx: Transducer<A, B>, rfn: Reducer<C, B>, acc?: C, xs: Iterable<A>): C`
|
|
895
867
|
|
|
896
|
-
Transforms iterable using given transducer and combines results with
|
|
897
|
-
|
|
868
|
+
Transforms iterable using given transducer and combines results with given
|
|
869
|
+
reducer and optional initial accumulator/result.
|
|
898
870
|
|
|
899
871
|
#### transduceRight
|
|
900
872
|
|
|
@@ -907,11 +879,10 @@ them into right-to-left order.
|
|
|
907
879
|
|
|
908
880
|
`run<A, B>(tx: Transducer<A, B>, fx: (x: B) => void, xs: Iterable<A>)`
|
|
909
881
|
|
|
910
|
-
Transforms iterable with given transducer and optional side effect
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
itself. Returns nothing.
|
|
882
|
+
Transforms iterable with given transducer and optional side effect without any
|
|
883
|
+
reduction step. If `fx` is given it will be called with every value produced by
|
|
884
|
+
the transducer. If `fx` is _not_ given, the transducer is assumed to include at
|
|
885
|
+
least one `sideEffect()` step itself. Returns nothing.
|
|
915
886
|
|
|
916
887
|
#### consume
|
|
917
888
|
|
|
@@ -937,9 +908,9 @@ consume(repeatedly2d((x, y) => console.log("output:", [x, y]), 2, 3));
|
|
|
937
908
|
|
|
938
909
|
### Transducers
|
|
939
910
|
|
|
940
|
-
All of the following functions can be used and composed as transducers.
|
|
941
|
-
|
|
942
|
-
|
|
911
|
+
All of the following functions can be used and composed as transducers. With a
|
|
912
|
+
few exceptions, most also accept an input iterable and then directly yield a
|
|
913
|
+
transforming iterator, e.g.
|
|
943
914
|
|
|
944
915
|
```ts
|
|
945
916
|
import { map, push, range, transduce } from "@thi.ng/transducers";
|
|
@@ -1062,9 +1033,9 @@ transduce(map((x) => x*10), push(), range(4))
|
|
|
1062
1033
|
|
|
1063
1034
|
### Reducers
|
|
1064
1035
|
|
|
1065
|
-
As with transducer functions, reducer functions can also given an
|
|
1066
|
-
|
|
1067
|
-
|
|
1036
|
+
As with transducer functions, reducer functions can also given an optional input
|
|
1037
|
+
iterable. If done so, the function will consume the input and return a reduced
|
|
1038
|
+
result (as if it would be called via `reduce()`).
|
|
1068
1039
|
|
|
1069
1040
|
- [add](https://github.com/thi-ng/umbrella/tree/develop/packages/transducers/src/add.ts)
|
|
1070
1041
|
- [assocMap](https://github.com/thi-ng/umbrella/tree/develop/packages/transducers/src/assoc-map.ts)
|
package/api.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Comparator, Fn, Fn0, IObjectOf } from "@thi.ng/api";
|
|
2
2
|
import type { Reduced } from "./reduced.js";
|
|
3
|
-
export type Transducer<A, B> = (rfn: Reducer<
|
|
3
|
+
export type Transducer<A, B> = (rfn: Reducer<B, any>) => Reducer<A, any>;
|
|
4
4
|
/**
|
|
5
5
|
* A transducer or a custom type with a {@link IXform} implementation.
|
|
6
6
|
*/
|
|
@@ -9,28 +9,27 @@ export type TxLike<A, B> = Transducer<A, B> | IXform<A, B>;
|
|
|
9
9
|
* Custom version of {@link TxLike} for use with {@link multiplex} and
|
|
10
10
|
* {@link multiplexObj}.
|
|
11
11
|
*/
|
|
12
|
-
export type MultiplexTxLike<
|
|
13
|
-
|
|
12
|
+
export type MultiplexTxLike<A, B> = TxLike<A, B> | [TxLike<A, B>, boolean];
|
|
13
|
+
/**
|
|
14
|
+
* Function which combines a new value of type `A` with accumulator of type `B`.
|
|
15
|
+
* If the reduction should terminate early, the function should wrap the result
|
|
16
|
+
* via {@link reduced}.
|
|
17
|
+
*/
|
|
18
|
+
export type ReductionFn<A, B> = (acc: B, x: A) => B | Reduced<B>;
|
|
14
19
|
/**
|
|
15
20
|
* A 3-tuple of functions defining the different stages of a reduction process.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* The items in order:
|
|
24
|
+
*
|
|
25
|
+
* 1. Initialization function used to produce an initial default result (only
|
|
26
|
+
* used if no such initial result was given by the user)
|
|
27
|
+
* 2. Completion function to post-process an already reduced result (for most
|
|
28
|
+
* reducers this is merely the identity function). Also see {@link reducer}.
|
|
29
|
+
* 3. Accumulation function, merging a new input value with the currently
|
|
30
|
+
* existing (partially) reduced result.
|
|
16
31
|
*/
|
|
17
|
-
export
|
|
18
|
-
/**
|
|
19
|
-
* Initialization function to produce a default initial result (only used if
|
|
20
|
-
* no such initial result was given by the user)
|
|
21
|
-
*/
|
|
22
|
-
[0]: Fn0<A>;
|
|
23
|
-
/**
|
|
24
|
-
* Completion function to post-process an already reduced result (for most
|
|
25
|
-
* reducers this is merely the identity function). Also see {@link reducer}.
|
|
26
|
-
*/
|
|
27
|
-
[1]: Fn<A, A>;
|
|
28
|
-
/**
|
|
29
|
-
* Accumulation function, merging a new input value with the currently
|
|
30
|
-
* existing (partially) reduced result.
|
|
31
|
-
*/
|
|
32
|
-
[2]: ReductionFn<A, B>;
|
|
33
|
-
}
|
|
32
|
+
export type Reducer<A, B> = [Fn0<B>, Fn<B, B>, ReductionFn<A, B>];
|
|
34
33
|
/**
|
|
35
34
|
* Interface for types able to provide some internal functionality (or
|
|
36
35
|
* derive some related transformation) as {@link Transducer}.
|
|
@@ -92,7 +91,7 @@ export interface IReducible<A, B> {
|
|
|
92
91
|
* @param rfn
|
|
93
92
|
* @param acc
|
|
94
93
|
*/
|
|
95
|
-
$reduce(rfn: ReductionFn<A, B>, acc:
|
|
94
|
+
$reduce(rfn: ReductionFn<A, B>, acc: B | Reduced<B>): B | Reduced<B>;
|
|
96
95
|
}
|
|
97
96
|
export type TransformFn = (x: any) => any;
|
|
98
97
|
export type TransformSubSpec = IObjectOf<TransformSpec | TransformFn>;
|
|
@@ -114,6 +113,6 @@ export interface SortOpts<A, B> {
|
|
|
114
113
|
}
|
|
115
114
|
export interface GroupByOpts<SRC, KEY, GROUP> {
|
|
116
115
|
key: Fn<SRC, KEY>;
|
|
117
|
-
group: Reducer<
|
|
116
|
+
group: Reducer<SRC, GROUP>;
|
|
118
117
|
}
|
|
119
118
|
//# sourceMappingURL=api.d.ts.map
|
package/assoc-map.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ import type { Reducer } from "./api.js";
|
|
|
4
4
|
* Reducer accepting key-value pairs / tuples and transforming / adding
|
|
5
5
|
* them to an ES6 Map.
|
|
6
6
|
*/
|
|
7
|
-
export declare function assocMap<A, B>(): Reducer<
|
|
7
|
+
export declare function assocMap<A, B>(): Reducer<Pair<A, B>, Map<A, B>>;
|
|
8
8
|
export declare function assocMap<A, B>(xs: Iterable<Pair<A, B>>): Map<A, B>;
|
|
9
9
|
//# sourceMappingURL=assoc-map.d.ts.map
|
package/assoc-obj.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ import type { Reducer } from "./api.js";
|
|
|
4
4
|
* Reducer accepting key-value pairs / tuples and updating / adding them
|
|
5
5
|
* to an object.
|
|
6
6
|
*/
|
|
7
|
-
export declare function assocObj<T>(): Reducer<
|
|
7
|
+
export declare function assocObj<T>(): Reducer<Pair<PropertyKey, T>, IObjectOf<T>>;
|
|
8
8
|
export declare function assocObj<T>(xs: Iterable<Pair<PropertyKey, T>>): IObjectOf<T>;
|
|
9
9
|
//# sourceMappingURL=assoc-obj.d.ts.map
|
package/auto-obj.d.ts
CHANGED
|
@@ -14,6 +14,6 @@ import type { Reducer } from "./api.js";
|
|
|
14
14
|
*
|
|
15
15
|
* @param prefix - shared prefix
|
|
16
16
|
*/
|
|
17
|
-
export declare function autoObj<T>(prefix: string): Reducer<IObjectOf<T
|
|
17
|
+
export declare function autoObj<T>(prefix: string): Reducer<T, IObjectOf<T>>;
|
|
18
18
|
export declare function autoObj<T>(prefix: string, xs: Iterable<T>): IObjectOf<T>;
|
|
19
19
|
//# sourceMappingURL=auto-obj.d.ts.map
|
package/compr.d.ts
CHANGED
|
@@ -25,5 +25,5 @@ import type { Reducer, ReductionFn } from "./api.js";
|
|
|
25
25
|
* @param rfn -
|
|
26
26
|
* @param fn -
|
|
27
27
|
*/
|
|
28
|
-
export declare const compR: <A, B, C>(rfn: Reducer<
|
|
28
|
+
export declare const compR: <A, B, C>(rfn: Reducer<B, C>, fn: ReductionFn<A, C>) => Reducer<A, C>;
|
|
29
29
|
//# sourceMappingURL=compr.d.ts.map
|
package/conj.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ import type { Reducer } from "./api.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Reducer. Like {@link push}, but for ES6 Sets.
|
|
4
4
|
*/
|
|
5
|
-
export declare function conj<T>(): Reducer<Set<T
|
|
5
|
+
export declare function conj<T>(): Reducer<T, Set<T>>;
|
|
6
6
|
export declare function conj<T>(xs: Iterable<T>): Set<T>;
|
|
7
7
|
//# sourceMappingURL=conj.d.ts.map
|
package/count.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { Reducer } from "./api.js";
|
|
|
6
6
|
* @param offset -
|
|
7
7
|
* @param step -
|
|
8
8
|
*/
|
|
9
|
-
export declare function count(offset?: number, step?: number): Reducer<
|
|
9
|
+
export declare function count(offset?: number, step?: number): Reducer<any, number>;
|
|
10
10
|
export declare function count(xs: Iterable<any>): number;
|
|
11
11
|
export declare function count(offset: number, xs: Iterable<any>): number;
|
|
12
12
|
export declare function count(offset: number, step: number, xs: Iterable<any>): number;
|
package/count.js
CHANGED
package/fill.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type { Reducer } from "./api.js";
|
|
|
7
7
|
*
|
|
8
8
|
* @param start -
|
|
9
9
|
*/
|
|
10
|
-
export declare function fill<T>(start?: number): Reducer<T
|
|
10
|
+
export declare function fill<T>(start?: number): Reducer<T, T[]>;
|
|
11
11
|
export declare function fill<T>(xs: Iterable<T>): T[];
|
|
12
12
|
export declare function fill<T>(start: number, xs: Iterable<T>): T[];
|
|
13
13
|
/**
|
|
@@ -15,7 +15,7 @@ export declare function fill<T>(start: number, xs: Iterable<T>): T[];
|
|
|
15
15
|
*
|
|
16
16
|
* @param start -
|
|
17
17
|
*/
|
|
18
|
-
export declare function fillN(start?: number): Reducer<
|
|
18
|
+
export declare function fillN(start?: number): Reducer<number, NumericArray>;
|
|
19
19
|
export declare function fillN(xs: Iterable<number>): NumericArray;
|
|
20
20
|
export declare function fillN(start: number, xs: Iterable<number>): NumericArray;
|
|
21
21
|
//# sourceMappingURL=fill.d.ts.map
|
package/frequencies.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Fn } from "@thi.ng/api";
|
|
2
2
|
import type { Reducer } from "./api.js";
|
|
3
|
-
export declare function frequencies<A>(): Reducer<Map<A, number
|
|
3
|
+
export declare function frequencies<A>(): Reducer<A, Map<A, number>>;
|
|
4
4
|
export declare function frequencies<A>(xs: Iterable<A>): Map<A, number>;
|
|
5
|
-
export declare function frequencies<A, B>(key: Fn<A, B>): Reducer<Map<B, number
|
|
5
|
+
export declare function frequencies<A, B>(key: Fn<A, B>): Reducer<A, Map<B, number>>;
|
|
6
6
|
export declare function frequencies<A, B>(key: Fn<A, B>, xs: Iterable<A>): Map<B, number>;
|
|
7
7
|
//# sourceMappingURL=frequencies.d.ts.map
|
package/group-binary.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { Reducer } from "./api.js";
|
|
|
5
5
|
* data structures. Any value can be indexed, as long as a numeric
|
|
6
6
|
* representation (key) can be obtained. This numeric key is produced by the
|
|
7
7
|
* supplied `key` function. IMPORTANT: the returned values MUST be unsigned and
|
|
8
|
-
* less than the provided bit length (i.e. `0
|
|
8
|
+
* less than the provided bit length (i.e. in the `[0,2**bits)` interval).
|
|
9
9
|
*
|
|
10
10
|
* By default the tree is constructed using plain objects for branches, with
|
|
11
11
|
* left branches stored as "l" and right ones as "r". The original values are
|
|
@@ -40,8 +40,8 @@ import type { Reducer } from "./api.js";
|
|
|
40
40
|
* import { groupBinary, identity, push, reduce } from "@thi.ng/transducers";
|
|
41
41
|
*
|
|
42
42
|
* tree = reduce(
|
|
43
|
-
* groupBinary(4, identity, ()=>[], push(), 0, 1),
|
|
44
|
-
* [1,2,3,4,5,6,7]
|
|
43
|
+
* groupBinary(4, identity, () => [], push(), 0, 1),
|
|
44
|
+
* [1, 2, 3, 4, 5, 6, 7]
|
|
45
45
|
* )
|
|
46
46
|
*
|
|
47
47
|
* tree[0][1][0][1] // 0101 == 5 in binary
|
|
@@ -78,5 +78,5 @@ import type { Reducer } from "./api.js";
|
|
|
78
78
|
* @param left - key for storing left branches (e.g. `0` for arrays)
|
|
79
79
|
* @param right - key for storing right branches (e.g. `1` for arrays)
|
|
80
80
|
*/
|
|
81
|
-
export declare const groupBinary: <T>(bits: number, key: Fn<T, number>, branch?: Fn0<IObjectOf<T[]>>, leaf?: Reducer<
|
|
81
|
+
export declare const groupBinary: <T>(bits: number, key: Fn<T, number>, branch?: Fn0<IObjectOf<T[]>>, leaf?: Reducer<T, any>, left?: PropertyKey, right?: PropertyKey) => Reducer<T, any>;
|
|
82
82
|
//# sourceMappingURL=group-binary.d.ts.map
|
package/group-by-map.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GroupByOpts, Reducer } from "./api.js";
|
|
2
|
-
export declare function groupByMap<SRC, KEY, GROUP>(opts?: Partial<GroupByOpts<SRC, KEY, GROUP>>): Reducer<Map<KEY, GROUP
|
|
2
|
+
export declare function groupByMap<SRC, KEY, GROUP>(opts?: Partial<GroupByOpts<SRC, KEY, GROUP>>): Reducer<SRC, Map<KEY, GROUP>>;
|
|
3
3
|
export declare function groupByMap<SRC, GROUP>(xs: Iterable<SRC>): Map<SRC, GROUP>;
|
|
4
4
|
export declare function groupByMap<SRC, KEY, GROUP>(opts: Partial<GroupByOpts<SRC, KEY, GROUP>>, xs: Iterable<SRC>): Map<KEY, GROUP>;
|
|
5
5
|
//# sourceMappingURL=group-by-map.d.ts.map
|
package/group-by-map.js
CHANGED
|
@@ -2,9 +2,8 @@ import { __groupByOpts } from "./internal/group-opts.js";
|
|
|
2
2
|
import { $$reduce } from "./reduce.js";
|
|
3
3
|
function groupByMap(...args) {
|
|
4
4
|
const res = $$reduce(groupByMap, args);
|
|
5
|
-
if (res !== void 0)
|
|
5
|
+
if (res !== void 0)
|
|
6
6
|
return res;
|
|
7
|
-
}
|
|
8
7
|
const opts = __groupByOpts(args[0]);
|
|
9
8
|
const [init, complete, reduce] = opts.group;
|
|
10
9
|
return [
|
package/group-by-obj.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IObjectOf } from "@thi.ng/api";
|
|
2
2
|
import type { GroupByOpts, Reducer } from "./api.js";
|
|
3
|
-
export declare function groupByObj<SRC, GROUP>(opts?: Partial<GroupByOpts<SRC, PropertyKey, GROUP>>): Reducer<IObjectOf<GROUP
|
|
3
|
+
export declare function groupByObj<SRC, GROUP>(opts?: Partial<GroupByOpts<SRC, PropertyKey, GROUP>>): Reducer<SRC, IObjectOf<GROUP>>;
|
|
4
4
|
export declare function groupByObj<SRC>(xs: Iterable<SRC>): IObjectOf<SRC[]>;
|
|
5
5
|
export declare function groupByObj<SRC, GROUP>(opts: Partial<GroupByOpts<SRC, PropertyKey, GROUP>>, xs: Iterable<SRC>): IObjectOf<GROUP>;
|
|
6
6
|
//# sourceMappingURL=group-by-obj.d.ts.map
|
package/group-by-obj.js
CHANGED
|
@@ -2,9 +2,8 @@ import { __groupByOpts } from "./internal/group-opts.js";
|
|
|
2
2
|
import { $$reduce } from "./reduce.js";
|
|
3
3
|
function groupByObj(...args) {
|
|
4
4
|
const res = $$reduce(groupByObj, args);
|
|
5
|
-
if (res)
|
|
5
|
+
if (res)
|
|
6
6
|
return res;
|
|
7
|
-
}
|
|
8
7
|
const opts = __groupByOpts(args[0]);
|
|
9
8
|
const [_init, complete, _reduce] = opts.group;
|
|
10
9
|
return [
|
package/internal/drain.d.ts
CHANGED
|
@@ -10,5 +10,5 @@ import type { ReductionFn } from "../api.js";
|
|
|
10
10
|
*
|
|
11
11
|
* @internal
|
|
12
12
|
*/
|
|
13
|
-
export declare const __drain: <T>(buf: T[], complete: Fn<any, any>, reduce: ReductionFn<
|
|
13
|
+
export declare const __drain: <T>(buf: T[], complete: Fn<any, any>, reduce: ReductionFn<T, any>) => (acc: T[]) => any;
|
|
14
14
|
//# sourceMappingURL=drain.d.ts.map
|
package/juxtr.d.ts
CHANGED
|
@@ -18,8 +18,8 @@ import type { Reducer } from "./api.js";
|
|
|
18
18
|
* // [ 10, [ 0, 1, 3, 6, 10 ], '1-2-3-4' ]
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
|
-
export declare function juxtR<
|
|
22
|
-
export declare function juxtR<
|
|
23
|
-
export declare function juxtR<
|
|
24
|
-
export declare function juxtR<
|
|
21
|
+
export declare function juxtR<A, B1>(r1: Reducer<A, B1>): Reducer<A, [B1]>;
|
|
22
|
+
export declare function juxtR<A, B1, B2>(r1: Reducer<A, B1>, r2: Reducer<A, B2>): Reducer<A, [B1, B2]>;
|
|
23
|
+
export declare function juxtR<A, B1, B2, B3>(r1: Reducer<A, B1>, r2: Reducer<A, B2>, r3: Reducer<A, B3>): Reducer<A, [B1, B2, B3]>;
|
|
24
|
+
export declare function juxtR<A, B1, B2, B3>(r1: Reducer<A, B1>, r2: Reducer<A, B2>, r3: Reducer<A, B3>, ...rs: Reducer<A, any>[]): Reducer<A, any[]>;
|
|
25
25
|
//# sourceMappingURL=juxtr.d.ts.map
|
package/map.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare function map<A, B>(fn: Fn<A, B>): Transducer<A, B>;
|
|
|
18
18
|
export declare function map<A, B>(fn: Fn<A, B>, src: Iterable<A>): IterableIterator<B>;
|
|
19
19
|
/**
|
|
20
20
|
* Convenience wrapper for {@link map} to transform an iterable with given `fn`
|
|
21
|
-
* and
|
|
21
|
+
* and immediately collect results into an array.
|
|
22
22
|
*/
|
|
23
23
|
export declare const mapA: <A, B>(fn: Fn<A, B>, src: Iterable<A>) => B[];
|
|
24
24
|
//# sourceMappingURL=map.d.ts.map
|
package/mapcat.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Fn } from "@thi.ng/api";
|
|
1
|
+
import type { Fn, Nullable } from "@thi.ng/api";
|
|
2
2
|
import type { Transducer } from "./api.js";
|
|
3
3
|
/**
|
|
4
4
|
* Transducer. Similar to {@link map}, but expects the given mapping function
|
|
@@ -19,6 +19,6 @@ import type { Transducer } from "./api.js";
|
|
|
19
19
|
*
|
|
20
20
|
* @param fn - mapping function
|
|
21
21
|
*/
|
|
22
|
-
export declare function mapcat<A, B>(fn: Fn<A, Iterable<B
|
|
23
|
-
export declare function mapcat<A, B>(fn: Fn<A, Iterable<B
|
|
22
|
+
export declare function mapcat<A, B>(fn: Fn<A, Nullable<Iterable<B>>>): Transducer<A, B>;
|
|
23
|
+
export declare function mapcat<A, B>(fn: Fn<A, Nullable<Iterable<B>>>, src: Iterable<A>): IterableIterator<B>;
|
|
24
24
|
//# sourceMappingURL=mapcat.d.ts.map
|
package/min-max.d.ts
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Returns a reducer which computes both the min and max values of given inputs.
|
|
3
3
|
* If the input source is empty the final result will be `[-∞,∞]`.
|
|
4
4
|
*/
|
|
5
|
-
export declare const minMax: () => import("./api.js").Reducer<
|
|
5
|
+
export declare const minMax: () => import("./api.js").Reducer<number, [number, number]>;
|
|
6
6
|
//# sourceMappingURL=min-max.d.ts.map
|
package/moving-median.js
CHANGED
|
@@ -5,9 +5,8 @@ import { map } from "./map.js";
|
|
|
5
5
|
import { partition } from "./partition.js";
|
|
6
6
|
function movingMedian(...args) {
|
|
7
7
|
const iter = __iter(movingMedian, args);
|
|
8
|
-
if (iter)
|
|
8
|
+
if (iter)
|
|
9
9
|
return iter;
|
|
10
|
-
}
|
|
11
10
|
const { key, compare } = __sortOpts(args[1]);
|
|
12
11
|
const n = args[0];
|
|
13
12
|
const m = n >> 1;
|
package/multiplex-obj.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ import type { MultiplexTxLike, Reducer, Transducer } from "./api.js";
|
|
|
24
24
|
* @param xforms - object of transducers
|
|
25
25
|
* @param rfn -
|
|
26
26
|
*/
|
|
27
|
-
export declare function multiplexObj<A, B>(xforms: IObjectOf<MultiplexTxLike<A, any>>, rfn?: Reducer<
|
|
27
|
+
export declare function multiplexObj<A, B>(xforms: IObjectOf<MultiplexTxLike<A, any>>, rfn?: Reducer<[PropertyKey, any], B>): Transducer<A, B>;
|
|
28
28
|
export declare function multiplexObj<A, B>(xforms: IObjectOf<MultiplexTxLike<A, any>>, src: Iterable<A>): IterableIterator<B>;
|
|
29
|
-
export declare function multiplexObj<A, B>(xforms: IObjectOf<MultiplexTxLike<A, any>>, rfn: Reducer<
|
|
29
|
+
export declare function multiplexObj<A, B>(xforms: IObjectOf<MultiplexTxLike<A, any>>, rfn: Reducer<[PropertyKey, any], B>, src: Iterable<A>): IterableIterator<B>;
|
|
30
30
|
//# sourceMappingURL=multiplex-obj.d.ts.map
|
package/noop.js
CHANGED
package/norm-count.d.ts
CHANGED
|
@@ -21,6 +21,6 @@ import type { Reducer } from "./api.js";
|
|
|
21
21
|
*
|
|
22
22
|
* @param norm -
|
|
23
23
|
*/
|
|
24
|
-
export declare function normCount(norm: number): Reducer<
|
|
24
|
+
export declare function normCount(norm: number): Reducer<any, number>;
|
|
25
25
|
export declare function normCount(norm: number, xs: Iterable<any>): number;
|
|
26
26
|
//# sourceMappingURL=norm-count.d.ts.map
|
package/norm-count.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { $$reduce } from "./reduce.js";
|
|
2
2
|
function normCount(...args) {
|
|
3
3
|
const res = $$reduce(normCount, args);
|
|
4
|
-
if (res !== void 0)
|
|
4
|
+
if (res !== void 0)
|
|
5
5
|
return res;
|
|
6
|
-
}
|
|
7
6
|
const norm = args[0];
|
|
8
7
|
return [() => 0, (acc) => acc / norm, (acc) => acc + 1];
|
|
9
8
|
}
|
|
@@ -18,8 +18,8 @@ import type { Reducer } from "./api.js";
|
|
|
18
18
|
* // Map(3) { 'a' => 0.5, 'b' => 0.25, 'c' => 0.25 }
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
|
-
export declare function normFrequenciesAuto<A>(): Reducer<Map<A, number
|
|
21
|
+
export declare function normFrequenciesAuto<A>(): Reducer<A, Map<A, number>>;
|
|
22
22
|
export declare function normFrequenciesAuto<A>(xs: Iterable<A>): Map<A, number>;
|
|
23
|
-
export declare function normFrequenciesAuto<A, B>(key: Fn<A, B>): Reducer<Map<B, number
|
|
23
|
+
export declare function normFrequenciesAuto<A, B>(key: Fn<A, B>): Reducer<A, Map<B, number>>;
|
|
24
24
|
export declare function normFrequenciesAuto<A, B>(key: Fn<A, B>, xs: Iterable<A>): Map<B, number>;
|
|
25
25
|
//# sourceMappingURL=norm-frequencies-auto.d.ts.map
|
package/norm-frequencies-auto.js
CHANGED
|
@@ -2,9 +2,8 @@ import { frequencies } from "./frequencies.js";
|
|
|
2
2
|
import { $$reduce } from "./reduce.js";
|
|
3
3
|
function normFrequenciesAuto(...args) {
|
|
4
4
|
const res = $$reduce(normFrequenciesAuto, args);
|
|
5
|
-
if (res !== void 0)
|
|
5
|
+
if (res !== void 0)
|
|
6
6
|
return res;
|
|
7
|
-
}
|
|
8
7
|
const [init, complete, reduce] = frequencies(...args);
|
|
9
8
|
let norm = 0;
|
|
10
9
|
return [
|
package/norm-frequencies.d.ts
CHANGED
|
@@ -19,8 +19,8 @@ import type { Reducer } from "./api.js";
|
|
|
19
19
|
*
|
|
20
20
|
* @param norm -
|
|
21
21
|
*/
|
|
22
|
-
export declare function normFrequencies<A>(norm: number): Reducer<Map<A, number
|
|
22
|
+
export declare function normFrequencies<A>(norm: number): Reducer<A, Map<A, number>>;
|
|
23
23
|
export declare function normFrequencies<A>(norm: number, xs: Iterable<A>): Map<A, number>;
|
|
24
|
-
export declare function normFrequencies<A, B>(norm: number, key: Fn<A, B>): Reducer<Map<B, number
|
|
24
|
+
export declare function normFrequencies<A, B>(norm: number, key: Fn<A, B>): Reducer<A, Map<B, number>>;
|
|
25
25
|
export declare function normFrequencies<A, B>(norm: number, key: Fn<A, B>, xs: Iterable<A>): Map<B, number>;
|
|
26
26
|
//# sourceMappingURL=norm-frequencies.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/transducers",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "Lightweight transducer implementations for ES6 / TypeScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -40,14 +40,14 @@
|
|
|
40
40
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@thi.ng/api": "^8.
|
|
44
|
-
"@thi.ng/arrays": "^2.9.
|
|
45
|
-
"@thi.ng/checks": "^3.
|
|
46
|
-
"@thi.ng/compare": "^2.3.
|
|
47
|
-
"@thi.ng/compose": "^
|
|
48
|
-
"@thi.ng/errors": "^2.5.
|
|
49
|
-
"@thi.ng/math": "^5.10.
|
|
50
|
-
"@thi.ng/random": "^3.7.
|
|
43
|
+
"@thi.ng/api": "^8.10.0",
|
|
44
|
+
"@thi.ng/arrays": "^2.9.2",
|
|
45
|
+
"@thi.ng/checks": "^3.6.0",
|
|
46
|
+
"@thi.ng/compare": "^2.3.1",
|
|
47
|
+
"@thi.ng/compose": "^3.0.0",
|
|
48
|
+
"@thi.ng/errors": "^2.5.3",
|
|
49
|
+
"@thi.ng/math": "^5.10.9",
|
|
50
|
+
"@thi.ng/random": "^3.7.2"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@microsoft/api-extractor": "^7.43.0",
|
|
@@ -59,7 +59,6 @@
|
|
|
59
59
|
"keywords": [
|
|
60
60
|
"2d",
|
|
61
61
|
"3d",
|
|
62
|
-
"nd",
|
|
63
62
|
"array",
|
|
64
63
|
"clojure",
|
|
65
64
|
"composition",
|
|
@@ -76,6 +75,7 @@
|
|
|
76
75
|
"interleave",
|
|
77
76
|
"interpolation",
|
|
78
77
|
"iterator",
|
|
78
|
+
"nd",
|
|
79
79
|
"partition",
|
|
80
80
|
"permutation",
|
|
81
81
|
"pipeline",
|
|
@@ -86,8 +86,8 @@
|
|
|
86
86
|
"set",
|
|
87
87
|
"sliding-window",
|
|
88
88
|
"stream",
|
|
89
|
-
"time",
|
|
90
89
|
"throttle",
|
|
90
|
+
"time",
|
|
91
91
|
"transducer",
|
|
92
92
|
"transformation",
|
|
93
93
|
"tween",
|
|
@@ -564,6 +564,7 @@
|
|
|
564
564
|
}
|
|
565
565
|
},
|
|
566
566
|
"thi.ng": {
|
|
567
|
+
"alias": "tx",
|
|
567
568
|
"blog": [
|
|
568
569
|
{
|
|
569
570
|
"title": "HOFs, Transducers, Reducers",
|
|
@@ -589,5 +590,5 @@
|
|
|
589
590
|
],
|
|
590
591
|
"year": 2016
|
|
591
592
|
},
|
|
592
|
-
"gitHead": "
|
|
593
|
+
"gitHead": "85ac4bd4d6d89f8e3689e2863d5bea0cecdb371c\n"
|
|
593
594
|
}
|
package/push-copy.d.ts
CHANGED
package/push-sort.d.ts
CHANGED
|
@@ -7,6 +7,6 @@ import type { Reducer } from "./api.js";
|
|
|
7
7
|
*
|
|
8
8
|
* @param cmp -
|
|
9
9
|
*/
|
|
10
|
-
export declare function pushSort<T>(cmp?: Comparator<T>): Reducer<T
|
|
11
|
-
export declare function pushSort<T>(cmp: Comparator<T
|
|
10
|
+
export declare function pushSort<T>(cmp?: Comparator<T>): Reducer<T, T[]>;
|
|
11
|
+
export declare function pushSort<T>(cmp: Comparator<T> | undefined, xs: Iterable<T>): T[];
|
|
12
12
|
//# sourceMappingURL=push-sort.d.ts.map
|
package/push.d.ts
CHANGED
package/range.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare function range(from: number, to: number, step: number): Range;
|
|
|
9
9
|
* and {@link IReducible} interfaces, the latter is used to accelerate use with
|
|
10
10
|
* {@link reduce}.
|
|
11
11
|
*/
|
|
12
|
-
export declare class Range implements Iterable<number>, IReducible<
|
|
12
|
+
export declare class Range implements Iterable<number>, IReducible<number, any> {
|
|
13
13
|
protected from: number;
|
|
14
14
|
protected to: number;
|
|
15
15
|
protected step: number;
|
|
@@ -17,6 +17,6 @@ export declare class Range implements Iterable<number>, IReducible<any, number>
|
|
|
17
17
|
constructor(from: number, to: number);
|
|
18
18
|
constructor(from: number, to: number, step: number);
|
|
19
19
|
[Symbol.iterator](): Generator<number, void, unknown>;
|
|
20
|
-
$reduce<T>(rfn: ReductionFn<
|
|
20
|
+
$reduce<T>(rfn: ReductionFn<number, T>, acc: T | Reduced<T>): T | Reduced<T>;
|
|
21
21
|
}
|
|
22
22
|
//# sourceMappingURL=range.d.ts.map
|
package/reduce.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Fn0, FnAny } from "@thi.ng/api";
|
|
2
2
|
import type { IReducible, Reducer, ReductionFn } from "./api.js";
|
|
3
|
-
export declare function reduce<A, B>(rfn: Reducer<A, B>, xs: Iterable<
|
|
4
|
-
export declare function reduce<A, B>(rfn: Reducer<A, B>, acc:
|
|
5
|
-
export declare function reduce<A, B>(rfn: Reducer<A, B>, xs: IReducible<A, B>):
|
|
6
|
-
export declare function reduce<A, B>(rfn: Reducer<A, B>, acc: A, xs: IReducible<A, B>):
|
|
7
|
-
export declare function reduceRight<A, B>(rfn: Reducer<A, B>, xs: ArrayLike<
|
|
8
|
-
export declare function reduceRight<A, B>(rfn: Reducer<A, B>, acc:
|
|
3
|
+
export declare function reduce<A, B>(rfn: Reducer<A, B>, xs: Iterable<A>): B;
|
|
4
|
+
export declare function reduce<A, B>(rfn: Reducer<A, B>, acc: B, xs: Iterable<A>): B;
|
|
5
|
+
export declare function reduce<A, B>(rfn: Reducer<A, B>, xs: IReducible<A, B>): B;
|
|
6
|
+
export declare function reduce<A, B>(rfn: Reducer<A, B>, acc: A, xs: IReducible<A, B>): B;
|
|
7
|
+
export declare function reduceRight<A, B>(rfn: Reducer<A, B>, xs: ArrayLike<A>): B;
|
|
8
|
+
export declare function reduceRight<A, B>(rfn: Reducer<A, B>, acc: B, xs: ArrayLike<A>): B;
|
|
9
9
|
/**
|
|
10
10
|
* Convenience helper for building a full {@link Reducer} using the identity
|
|
11
11
|
* function (i.e. `(x) => x`) as completion step (true for 90% of all
|
|
@@ -14,6 +14,6 @@ export declare function reduceRight<A, B>(rfn: Reducer<A, B>, acc: A, xs: ArrayL
|
|
|
14
14
|
* @param init - init step of reducer
|
|
15
15
|
* @param rfn - reduction step of reducer
|
|
16
16
|
*/
|
|
17
|
-
export declare const reducer: <A, B>(init: Fn0<
|
|
17
|
+
export declare const reducer: <A, B>(init: Fn0<B>, rfn: ReductionFn<A, B>) => Reducer<A, B>;
|
|
18
18
|
export declare const $$reduce: (rfn: FnAny<Reducer<any, any>>, args: any[]) => any;
|
|
19
19
|
//# sourceMappingURL=reduce.d.ts.map
|
package/reduce.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { identity } from "@thi.ng/api/fn";
|
|
1
2
|
import { implementsFunction } from "@thi.ng/checks/implements-function";
|
|
2
3
|
import { isArrayLike } from "@thi.ng/checks/is-arraylike";
|
|
3
4
|
import { isIterable } from "@thi.ng/checks/is-iterable";
|
|
@@ -19,10 +20,7 @@ function reduce(...args) {
|
|
|
19
20
|
);
|
|
20
21
|
}
|
|
21
22
|
function reduceRight(...args) {
|
|
22
|
-
const
|
|
23
|
-
const init = rfn[0];
|
|
24
|
-
const complete = rfn[1];
|
|
25
|
-
const reduce2 = rfn[2];
|
|
23
|
+
const [init, complete, reduce2] = args[0];
|
|
26
24
|
args = parseArgs(args);
|
|
27
25
|
let acc = args[0] == null ? init() : args[0];
|
|
28
26
|
const xs = args[1];
|
|
@@ -55,7 +53,7 @@ const reduceIterable = (rfn, acc, xs) => {
|
|
|
55
53
|
}
|
|
56
54
|
return acc;
|
|
57
55
|
};
|
|
58
|
-
const reducer = (init, rfn) => [init,
|
|
56
|
+
const reducer = (init, rfn) => [init, identity, rfn];
|
|
59
57
|
const $$reduce = (rfn, args) => {
|
|
60
58
|
const n = args.length - 1;
|
|
61
59
|
return isIterable(args[n]) ? args.length > 1 ? reduce(rfn.apply(null, args.slice(0, n)), args[n]) : reduce(rfn(), args[0]) : void 0;
|
package/reduced.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ export declare class Reduced<T> implements IDeref<T> {
|
|
|
4
4
|
constructor(val: T);
|
|
5
5
|
deref(): T;
|
|
6
6
|
}
|
|
7
|
-
export declare const reduced: (x:
|
|
7
|
+
export declare const reduced: <T>(x: T) => Reduced<T>;
|
|
8
8
|
export declare const isReduced: <T>(x: any) => x is Reduced<T>;
|
|
9
|
-
export declare const ensureReduced: (x:
|
|
10
|
-
export declare const unreduced: (x:
|
|
9
|
+
export declare const ensureReduced: <T>(x: T) => (T & Reduced<any>) | Reduced<T>;
|
|
10
|
+
export declare const unreduced: <T>(x: T | Reduced<T>) => T;
|
|
11
11
|
//# sourceMappingURL=reduced.d.ts.map
|
package/reductions.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Reducer } from "./api.js";
|
|
2
|
-
export declare function reductions<A, B>(rfn: Reducer<A, B>): Reducer<A
|
|
3
|
-
export declare function reductions<A, B>(rfn: Reducer<A, B>, xs: Iterable<
|
|
2
|
+
export declare function reductions<A, B>(rfn: Reducer<A, B>): Reducer<A, B[]>;
|
|
3
|
+
export declare function reductions<A, B>(rfn: Reducer<A, B>, xs: Iterable<A>): B[];
|
|
4
4
|
//# sourceMappingURL=reductions.d.ts.map
|
package/rename.d.ts
CHANGED
|
@@ -11,6 +11,6 @@ import type { Reducer, Transducer } from "./api.js";
|
|
|
11
11
|
* @param kmap
|
|
12
12
|
* @param rfn
|
|
13
13
|
*/
|
|
14
|
-
export declare function rename<A, B>(kmap: IObjectOf<PropertyKey | boolean> | Array<PropertyKey>, rfn?: Reducer<
|
|
15
|
-
export declare function rename<A, B>(kmap: IObjectOf<PropertyKey | boolean> | Array<PropertyKey>, rfn: Reducer<
|
|
14
|
+
export declare function rename<A, B>(kmap: IObjectOf<PropertyKey | boolean> | Array<PropertyKey>, rfn?: Reducer<[PropertyKey, any], B>): Transducer<A[], B>;
|
|
15
|
+
export declare function rename<A, B>(kmap: IObjectOf<PropertyKey | boolean> | Array<PropertyKey>, rfn: Reducer<[PropertyKey, any], B>, src: Iterable<A[]>): IterableIterator<B>;
|
|
16
16
|
//# sourceMappingURL=rename.d.ts.map
|
package/rename.js
CHANGED
|
@@ -10,19 +10,21 @@ function rename(...args) {
|
|
|
10
10
|
if (iter) {
|
|
11
11
|
return iter;
|
|
12
12
|
}
|
|
13
|
-
let kmap = args
|
|
13
|
+
let [kmap, reducer] = args;
|
|
14
14
|
if (isArray(kmap)) {
|
|
15
15
|
kmap = kmap.reduce((acc, k, i) => (acc[k] = i, acc), {});
|
|
16
16
|
}
|
|
17
|
-
if (
|
|
17
|
+
if (reducer) {
|
|
18
18
|
const ks = Object.keys(kmap);
|
|
19
19
|
return map(
|
|
20
20
|
(y) => transduce(
|
|
21
21
|
comp(
|
|
22
|
-
map(
|
|
22
|
+
map(
|
|
23
|
+
(k) => [k, y[kmap[k]]]
|
|
24
|
+
),
|
|
23
25
|
filter((x) => x[1] !== void 0)
|
|
24
26
|
),
|
|
25
|
-
|
|
27
|
+
reducer,
|
|
26
28
|
ks
|
|
27
29
|
)
|
|
28
30
|
);
|
package/run.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import type { IReducible, TxLike } from "./api.js";
|
|
|
11
11
|
* @param xs -
|
|
12
12
|
*/
|
|
13
13
|
export declare function run<A>(tx: TxLike<A, any>, xs: Iterable<A>): void;
|
|
14
|
-
export declare function run<A>(tx: TxLike<A, any>, xs: IReducible<
|
|
14
|
+
export declare function run<A>(tx: TxLike<A, any>, xs: IReducible<A, any>): void;
|
|
15
15
|
export declare function run<A, B>(tx: TxLike<A, B>, fx: Fn<B, void>, xs: Iterable<A>): void;
|
|
16
|
-
export declare function run<A, B>(tx: TxLike<A, B>, fx: Fn<B, void>, xs: IReducible<
|
|
16
|
+
export declare function run<A, B>(tx: TxLike<A, B>, fx: Fn<B, void>, xs: IReducible<A, any>): void;
|
|
17
17
|
//# sourceMappingURL=run.d.ts.map
|
package/scan.d.ts
CHANGED
|
@@ -43,6 +43,6 @@ import type { Reducer, Transducer } from "./api.js";
|
|
|
43
43
|
* @param rfn - reducer used as scan operator
|
|
44
44
|
* @param init -
|
|
45
45
|
*/
|
|
46
|
-
export declare function scan<A, B>(rfn: Reducer<
|
|
47
|
-
export declare function scan<A, B>(rfn: Reducer<
|
|
46
|
+
export declare function scan<A, B>(rfn: Reducer<A, B>, init?: B): Transducer<A, B>;
|
|
47
|
+
export declare function scan<A, B>(rfn: Reducer<A, B>, init: B, src: Iterable<A>): IterableIterator<B>;
|
|
48
48
|
//# sourceMappingURL=scan.d.ts.map
|
package/some.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type { Reducer } from "./api.js";
|
|
|
7
7
|
*
|
|
8
8
|
* @param pred -
|
|
9
9
|
*/
|
|
10
|
-
export declare function some<T>(pred?: Predicate<T>): Reducer<
|
|
10
|
+
export declare function some<T>(pred?: Predicate<T>): Reducer<T, boolean>;
|
|
11
11
|
export declare function some<T>(xs: Iterable<T>): boolean;
|
|
12
12
|
export declare function some<T>(pred: Predicate<T>, xs: Iterable<T>): boolean;
|
|
13
13
|
//# sourceMappingURL=some.d.ts.map
|
package/some.js
CHANGED
|
@@ -2,9 +2,8 @@ import { $$reduce, reducer } from "./reduce.js";
|
|
|
2
2
|
import { reduced } from "./reduced.js";
|
|
3
3
|
function some(...args) {
|
|
4
4
|
const res = $$reduce(some, args);
|
|
5
|
-
if (res !== void 0)
|
|
5
|
+
if (res !== void 0)
|
|
6
6
|
return res;
|
|
7
|
-
}
|
|
8
7
|
const pred = args[0];
|
|
9
8
|
return reducer(
|
|
10
9
|
() => false,
|
package/step.d.ts
CHANGED
|
@@ -51,5 +51,5 @@ import type { TxLike } from "./api.js";
|
|
|
51
51
|
* @param tx -
|
|
52
52
|
* @param unwrap -
|
|
53
53
|
*/
|
|
54
|
-
export declare const step: <A, B>(tx: TxLike<A, B>, unwrap?: boolean) => Fn<A, B | B[]>;
|
|
54
|
+
export declare const step: <A, B>(tx: TxLike<A, B>, unwrap?: boolean) => Fn<A, B | B[] | undefined>;
|
|
55
55
|
//# sourceMappingURL=step.d.ts.map
|
package/step.js
CHANGED
|
@@ -2,7 +2,7 @@ import { ensureTransducer } from "./ensure.js";
|
|
|
2
2
|
import { push } from "./push.js";
|
|
3
3
|
import { isReduced } from "./reduced.js";
|
|
4
4
|
const step = (tx, unwrap = true) => {
|
|
5
|
-
const
|
|
5
|
+
const [_, complete, reduce] = ensureTransducer(tx)(push());
|
|
6
6
|
let done = false;
|
|
7
7
|
return (x) => {
|
|
8
8
|
if (!done) {
|
package/str.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Reducer } from "./api.js";
|
|
2
|
-
export declare function str(sep?: string): Reducer<
|
|
2
|
+
export declare function str(sep?: string): Reducer<any, string>;
|
|
3
3
|
export declare function str(sep: string, xs: Iterable<any>): string;
|
|
4
4
|
//# sourceMappingURL=str.d.ts.map
|
package/struct.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { Fn } from "@thi.ng/api";
|
|
2
2
|
import type { Transducer } from "./api.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
3
|
+
/**
|
|
4
|
+
* Structfield definition: [name, number-of-inputs, transform?]
|
|
5
|
+
*/
|
|
6
|
+
export type StructField<T> = [string, number, Fn<T[], any>?];
|
|
8
7
|
/**
|
|
9
8
|
* Higher-order transducer to converts linear input into structured
|
|
10
9
|
* objects using given field specs and ordering.
|
|
@@ -39,6 +38,6 @@ export interface StructField extends Array<any> {
|
|
|
39
38
|
*
|
|
40
39
|
* @param fields -
|
|
41
40
|
*/
|
|
42
|
-
export declare function struct<
|
|
43
|
-
export declare function struct<
|
|
41
|
+
export declare function struct<A, B>(fields: StructField<A>[]): Transducer<A, B>;
|
|
42
|
+
export declare function struct<A, B>(fields: StructField<A>[], src: Iterable<A>): IterableIterator<B>;
|
|
44
43
|
//# sourceMappingURL=struct.d.ts.map
|
package/struct.js
CHANGED
|
@@ -2,8 +2,8 @@ import { isIterable } from "@thi.ng/checks/is-iterable";
|
|
|
2
2
|
import { comp } from "./comp.js";
|
|
3
3
|
import { iterator } from "./iterator.js";
|
|
4
4
|
import { mapKeys } from "./map-keys.js";
|
|
5
|
-
import { partition } from "./partition.js";
|
|
6
5
|
import { partitionOf } from "./partition-of.js";
|
|
6
|
+
import { partition } from "./partition.js";
|
|
7
7
|
import { rename } from "./rename.js";
|
|
8
8
|
function struct(fields, src) {
|
|
9
9
|
return isIterable(src) ? iterator(struct(fields), src) : comp(
|
package/transduce.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { IReducible, Reducer, Transducer, TxLike } from "./api.js";
|
|
2
|
-
export declare function transduce<A, B, C>(tx: TxLike<A, B>, rfn: Reducer<
|
|
3
|
-
export declare function transduce<A, B, C>(tx: TxLike<A, B>, rfn: Reducer<
|
|
4
|
-
export declare function transduce<A, B, C>(tx: TxLike<A, B>, rfn: Reducer<
|
|
5
|
-
export declare function transduce<A, B, C>(tx: TxLike<A, B>, rfn: Reducer<
|
|
6
|
-
export declare function transduce<A, B, C>(tx: TxLike<A, B>, rfn: Reducer<C, B>, acc: C, xs: IReducible<
|
|
7
|
-
export declare function transduceRight<A, B, C>(tx: TxLike<A, B>, rfn: Reducer<
|
|
8
|
-
export declare function transduceRight<A, B, C>(tx: TxLike<A, B>, rfn: Reducer<
|
|
9
|
-
export declare function transduceRight<A, B, C>(tx: TxLike<A, B>, rfn: Reducer<
|
|
2
|
+
export declare function transduce<A, B, C>(tx: TxLike<A, B>, rfn: Reducer<B, C>): Transducer<Iterable<A>, C>;
|
|
3
|
+
export declare function transduce<A, B, C>(tx: TxLike<A, B>, rfn: Reducer<B, C>, xs: Iterable<A>): C;
|
|
4
|
+
export declare function transduce<A, B, C>(tx: TxLike<A, B>, rfn: Reducer<B, C>, xs: IReducible<A, C>): C;
|
|
5
|
+
export declare function transduce<A, B, C>(tx: TxLike<A, B>, rfn: Reducer<B, C>, acc: C, xs: Iterable<A>): C;
|
|
6
|
+
export declare function transduce<A, B, C>(tx: TxLike<A, B>, rfn: Reducer<C, B>, acc: C, xs: IReducible<A, C>): C;
|
|
7
|
+
export declare function transduceRight<A, B, C>(tx: TxLike<A, B>, rfn: Reducer<B, C>): Transducer<ArrayLike<A>, C>;
|
|
8
|
+
export declare function transduceRight<A, B, C>(tx: TxLike<A, B>, rfn: Reducer<B, C>, xs: ArrayLike<A>): C;
|
|
9
|
+
export declare function transduceRight<A, B, C>(tx: TxLike<A, B>, rfn: Reducer<B, C>, acc: C, xs: ArrayLike<A>): C;
|
|
10
10
|
//# sourceMappingURL=transduce.d.ts.map
|