@thi.ng/transducers 8.9.6 → 8.9.7
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 +1 -1
- package/api.d.ts +5 -0
- package/auto-obj.d.ts +2 -0
- package/cat.d.ts +5 -3
- package/choices.d.ts +6 -2
- package/compr.d.ts +2 -0
- package/concat.d.ts +2 -0
- package/consume.d.ts +2 -0
- package/converge.d.ts +2 -0
- package/curve.d.ts +2 -0
- package/cycle.d.ts +2 -0
- package/dedupe.d.ts +2 -0
- package/deep-transform.d.ts +4 -2
- package/distinct.d.ts +2 -0
- package/dup.d.ts +2 -0
- package/every.d.ts +3 -1
- package/extend-sides.d.ts +2 -0
- package/filter-fuzzy.d.ts +2 -0
- package/flatten-with.d.ts +2 -0
- package/flatten.d.ts +2 -0
- package/group-binary.d.ts +6 -0
- package/interpolate.d.ts +2 -0
- package/iterate.d.ts +2 -0
- package/juxtr.d.ts +2 -0
- package/key-permutations.d.ts +2 -0
- package/length.d.ts +2 -0
- package/line.d.ts +2 -0
- package/lookup.d.ts +4 -0
- package/map-indexed.d.ts +2 -0
- package/map-keys.d.ts +2 -0
- package/map-nth.d.ts +2 -0
- package/map-vals.d.ts +2 -0
- package/map.d.ts +2 -0
- package/match-first.d.ts +7 -2
- package/match-last.d.ts +6 -10
- package/multiplex-obj.d.ts +2 -0
- package/multiplex.d.ts +4 -0
- package/norm-count.d.ts +2 -0
- package/norm-frequencies-auto.d.ts +2 -0
- package/norm-frequencies.d.ts +5 -0
- package/norm-range.d.ts +2 -0
- package/package.json +8 -8
- package/pad-last.d.ts +2 -0
- package/pad-sides.d.ts +9 -8
- package/page.d.ts +2 -0
- package/pairs.d.ts +2 -0
- package/palindrome.d.ts +2 -0
- package/partition-by.d.ts +2 -0
- package/partition-of.d.ts +2 -0
- package/partition-sort.d.ts +2 -0
- package/partition-sync.d.ts +5 -0
- package/partition-when.d.ts +2 -0
- package/partition.d.ts +2 -0
- package/peek.d.ts +2 -0
- package/permutations.d.ts +4 -0
- package/pluck.d.ts +2 -0
- package/range-nd.d.ts +2 -0
- package/rechunk.d.ts +2 -0
- package/repeat.d.ts +2 -0
- package/repeatedly.d.ts +2 -0
- package/repeatedly2d.d.ts +2 -0
- package/repeatedly3d.d.ts +2 -0
- package/reverse.d.ts +3 -1
- package/sample.d.ts +2 -0
- package/scan.d.ts +4 -0
- package/select-keys.d.ts +2 -0
- package/sliding-window.d.ts +2 -0
- package/step.d.ts +2 -0
- package/stream-shuffle.d.ts +3 -0
- package/stream-sort.d.ts +2 -0
- package/struct.d.ts +5 -3
- package/swizzle.d.ts +5 -3
- package/symmetric.d.ts +5 -3
- package/take-last.d.ts +2 -0
- package/take-nth.d.ts +2 -0
- package/take-while.d.ts +2 -0
- package/take.d.ts +2 -0
- package/toggle.d.ts +3 -1
- package/tween.d.ts +3 -0
- package/zip.d.ts +2 -0
package/CHANGELOG.md
CHANGED
package/api.d.ts
CHANGED
|
@@ -39,6 +39,11 @@ export interface Reducer<A, B> extends Array<any> {
|
|
|
39
39
|
*
|
|
40
40
|
* @example
|
|
41
41
|
* ```ts
|
|
42
|
+
* import {
|
|
43
|
+
* comp, drop, map, push, range, transduce
|
|
44
|
+
* type IXform
|
|
45
|
+
* } from "@thi.ng/transducers";
|
|
46
|
+
*
|
|
42
47
|
* class Mul implements IXform<number, number> {
|
|
43
48
|
* constructor(public factor = 10) {}
|
|
44
49
|
*
|
package/auto-obj.d.ts
CHANGED
package/cat.d.ts
CHANGED
|
@@ -12,12 +12,14 @@ import type { Transducer } from "./api.js";
|
|
|
12
12
|
* behavior allows a {@link mapcat} user functions to benefit from reduced
|
|
13
13
|
* results.
|
|
14
14
|
*
|
|
15
|
-
* Also see
|
|
16
|
-
* - {@link concat}
|
|
17
|
-
* - {@link mapcat}
|
|
15
|
+
* Also see {@link concat}, {@link mapcat}.
|
|
18
16
|
*
|
|
19
17
|
* @example
|
|
20
18
|
* ```ts
|
|
19
|
+
* import {
|
|
20
|
+
* cat, comp, iterator, map, mapcat, mapIndexed, reduced
|
|
21
|
+
* } from "@thi.ng/transducers";
|
|
22
|
+
*
|
|
21
23
|
* [...iterator(comp(map((x) => [x, x]), cat()), [1, 2, 3, 4])]
|
|
22
24
|
* // [ 1, 1, 2, 2, 3, 3, 4, 4 ]
|
|
23
25
|
*
|
package/choices.d.ts
CHANGED
|
@@ -4,14 +4,18 @@ import type { IRandom } from "@thi.ng/random";
|
|
|
4
4
|
* If `weights` is given, it must have at least the same size as `choices`. If
|
|
5
5
|
* omitted, each choice will have same probability.
|
|
6
6
|
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Internally uses
|
|
9
|
+
* [`weightedRandom()`](https://docs.thi.ng/umbrella/random/functions/weightedRandom.html).
|
|
10
|
+
*
|
|
7
11
|
* @example
|
|
8
12
|
* ```ts
|
|
13
|
+
* import { choices, frequencies, take, transduce } from "@thi.ng/transducers";
|
|
14
|
+
*
|
|
9
15
|
* transduce(take(1000), frequencies(), choices("abcd", [1, 0.5, 0.25, 0.125]))
|
|
10
16
|
* // Map { 'c' => 132, 'a' => 545, 'b' => 251, 'd' => 72 }
|
|
11
17
|
* ```
|
|
12
18
|
*
|
|
13
|
-
* [`weightedRandom()`](https://docs.thi.ng/umbrella/random/functions/weightedRandom.html)
|
|
14
|
-
*
|
|
15
19
|
* @param choices -
|
|
16
20
|
* @param weights -
|
|
17
21
|
*/
|
package/compr.d.ts
CHANGED
package/concat.d.ts
CHANGED
package/consume.d.ts
CHANGED
package/converge.d.ts
CHANGED
package/curve.d.ts
CHANGED
package/cycle.d.ts
CHANGED
package/dedupe.d.ts
CHANGED
package/deep-transform.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ import type { TransformSpec } from "./api.js";
|
|
|
19
19
|
*
|
|
20
20
|
* @example
|
|
21
21
|
* ```ts
|
|
22
|
+
* import { deepTransform } from "@thi.ng/transducers";
|
|
23
|
+
*
|
|
22
24
|
* // source object to be transformed
|
|
23
25
|
* src = {
|
|
24
26
|
* meta: {
|
|
@@ -33,11 +35,11 @@ import type { TransformSpec } from "./api.js";
|
|
|
33
35
|
* // deep transformation spec
|
|
34
36
|
* spec = [
|
|
35
37
|
* // root transform (called last)
|
|
36
|
-
* ({type, meta, title, body}) => ["div", {class: type}, title, meta, body],
|
|
38
|
+
* ({ type, meta, title, body }) => ["div", { class: type }, title, meta, body],
|
|
37
39
|
* // object of transform sub-specs
|
|
38
40
|
* {
|
|
39
41
|
* meta: [
|
|
40
|
-
* ({author, date}) => ["div.meta", author, `(${date})`],
|
|
42
|
+
* ({ author, date }) => ["div.meta", author, `(${date})`],
|
|
41
43
|
* {
|
|
42
44
|
* author: ({email, name}) => ["a", {href: `mailto:${email}`}, name],
|
|
43
45
|
* date: (d) => new Date(d).toLocaleString()
|
package/distinct.d.ts
CHANGED
package/dup.d.ts
CHANGED
package/every.d.ts
CHANGED
package/extend-sides.d.ts
CHANGED
package/filter-fuzzy.d.ts
CHANGED
package/flatten-with.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ export type MaybeIterable<T> = Nullable<Iterable<T>>;
|
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
16
|
* ```ts
|
|
17
|
+
* import { flattenWith } from "@thi.ng/transducers";
|
|
18
|
+
*
|
|
17
19
|
* // custom predicate which converts objects into key/val tuples,
|
|
18
20
|
* // returns iterables as is and null for everything else
|
|
19
21
|
* const pred = (x) =>
|
package/flatten.d.ts
CHANGED
package/group-binary.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ import type { Reducer } from "./api.js";
|
|
|
18
18
|
*
|
|
19
19
|
* @example
|
|
20
20
|
* ```ts
|
|
21
|
+
* import { groupBinary, reduce } from "@thi.ng/transducers";
|
|
22
|
+
*
|
|
21
23
|
* tree = reduce(
|
|
22
24
|
* groupBinary(4, x => x.id & 0xf),
|
|
23
25
|
* [{id: 3}, {id: 8}, {id: 15}, {id: 0}]
|
|
@@ -35,6 +37,8 @@ import type { Reducer } from "./api.js";
|
|
|
35
37
|
*
|
|
36
38
|
* @example
|
|
37
39
|
* ```ts
|
|
40
|
+
* import { groupBinary, identity, push, reduce } from "@thi.ng/transducers";
|
|
41
|
+
*
|
|
38
42
|
* tree = reduce(
|
|
39
43
|
* groupBinary(4, identity, ()=>[], push(), 0, 1),
|
|
40
44
|
* [1,2,3,4,5,6,7]
|
|
@@ -51,6 +55,8 @@ import type { Reducer } from "./api.js";
|
|
|
51
55
|
*
|
|
52
56
|
* @example
|
|
53
57
|
* ```ts
|
|
58
|
+
* import { frequencies, groupBinary, reduce } from "@thi.ng/transducers";
|
|
59
|
+
*
|
|
54
60
|
* tree = reduce(
|
|
55
61
|
* groupBinary(3, (x: string) => x.length, null, frequencies()),
|
|
56
62
|
* "aa bbb dddd ccccc bbb eeee fff".split(" ")
|
package/interpolate.d.ts
CHANGED
package/iterate.d.ts
CHANGED
package/juxtr.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ import type { Reducer } from "./api.js";
|
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* ```ts
|
|
15
|
+
* import { add, juxtR, reduce, reductions, str } from "@thi.ng/transducers";
|
|
16
|
+
*
|
|
15
17
|
* reduce(juxtR(add(), reductions(add()), str("-")), [1, 2, 3, 4]);
|
|
16
18
|
* // [ 10, [ 0, 1, 3, 6, 10 ], '1-2-3-4' ]
|
|
17
19
|
* ```
|
package/key-permutations.d.ts
CHANGED
package/length.d.ts
CHANGED
package/line.d.ts
CHANGED
package/lookup.d.ts
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @example
|
|
6
6
|
* ```ts
|
|
7
|
+
* import { lookup1d, map } from "@thi.ng/transducers";
|
|
8
|
+
*
|
|
7
9
|
* [...map(lookup1d([10, 20, 30]), [2,0,1])]
|
|
8
10
|
* // [ 30, 10, 20 ]
|
|
9
11
|
* ```
|
|
@@ -22,6 +24,8 @@ export declare const lookup1d: <T>(src: T[]) => (i: number) => T;
|
|
|
22
24
|
*
|
|
23
25
|
* @example
|
|
24
26
|
* ```ts
|
|
27
|
+
* import { lookup2d, map, range, range2d } from "@thi.ng/transducers";
|
|
28
|
+
*
|
|
25
29
|
* [...map(lookup2d([...range(9)], 3), range2d(2, -1, 0, 3))]
|
|
26
30
|
* // [ 2, 1, 0, 5, 4, 3, 8, 7, 6 ]
|
|
27
31
|
* ```
|
package/map-indexed.d.ts
CHANGED
package/map-keys.d.ts
CHANGED
package/map-nth.d.ts
CHANGED
package/map-vals.d.ts
CHANGED
package/map.d.ts
CHANGED
package/match-first.d.ts
CHANGED
|
@@ -5,7 +5,10 @@ import type { Transducer } from "./api.js";
|
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
7
|
* ```ts
|
|
8
|
+
* import { comp, filter, take } from "@thi.ng/transducers";
|
|
9
|
+
*
|
|
8
10
|
* comp(filter(pred), take(1))
|
|
11
|
+
* // [Function]
|
|
9
12
|
* ```
|
|
10
13
|
*
|
|
11
14
|
* Yields none or only the first value which passed the predicate check
|
|
@@ -14,6 +17,8 @@ import type { Transducer } from "./api.js";
|
|
|
14
17
|
*
|
|
15
18
|
* @example
|
|
16
19
|
* ```ts
|
|
20
|
+
* import { comp, map, matchFirst, push, transduce } from "@thi.ng/transducers";
|
|
21
|
+
*
|
|
17
22
|
* matchFirst((x) => x >= 5, [3, 1, 4, 2, 6, 5])
|
|
18
23
|
* // 6
|
|
19
24
|
*
|
|
@@ -22,10 +27,10 @@ import type { Transducer } from "./api.js";
|
|
|
22
27
|
* matchFirst((x) => x >= 5),
|
|
23
28
|
* map((x) => x * 10)
|
|
24
29
|
* ),
|
|
25
|
-
*
|
|
30
|
+
* push(),
|
|
26
31
|
* [3, 1, 4, 2, 6, 5]
|
|
27
32
|
* )
|
|
28
|
-
* // 60
|
|
33
|
+
* // [60]
|
|
29
34
|
* ```
|
|
30
35
|
*
|
|
31
36
|
* @param pred - predicate function
|
package/match-last.d.ts
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import type { Predicate } from "@thi.ng/api";
|
|
2
2
|
import type { Transducer } from "./api.js";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Similar to {@link matchFirst}, but matches yields none or only the **last**
|
|
5
|
+
* value which passed the predicate check. If `src` input is given, returns last
|
|
6
|
+
* match found (or `undefined`).
|
|
5
7
|
*
|
|
6
8
|
* @example
|
|
7
9
|
* ```ts
|
|
8
|
-
* comp
|
|
9
|
-
* ```
|
|
10
|
-
*
|
|
11
|
-
* Yields none or only the last value which passed the predicate check.
|
|
12
|
-
* If `src` input is given, returns last match found (or `undefined`).
|
|
10
|
+
* import { comp, map, matchLast, push, transduce } from "@thi.ng/transducers";
|
|
13
11
|
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
12
|
* matchLast((x) => x >= 5, [3, 1, 6, 5, 4, 2])
|
|
17
13
|
* // 5
|
|
18
14
|
*
|
|
@@ -21,8 +17,8 @@ import type { Transducer } from "./api.js";
|
|
|
21
17
|
* matchLast((x) => x >= 5),
|
|
22
18
|
* map((x) => x * 10)
|
|
23
19
|
* ),
|
|
24
|
-
*
|
|
25
|
-
* [3, 1,
|
|
20
|
+
* push(),
|
|
21
|
+
* [3, 1, 6, 5, 4, 2]
|
|
26
22
|
* )
|
|
27
23
|
* // 50
|
|
28
24
|
* ```
|
package/multiplex-obj.d.ts
CHANGED
package/multiplex.d.ts
CHANGED
|
@@ -22,6 +22,8 @@ import type { MultiplexTxLike, Transducer } from "./api.js";
|
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
24
|
* ```ts
|
|
25
|
+
* import { iterator, map, multiplex } from "@thi.ng/transducers";
|
|
26
|
+
*
|
|
25
27
|
* [...iterator(
|
|
26
28
|
* multiplex(
|
|
27
29
|
* map(x => x.charAt(0)),
|
|
@@ -36,6 +38,8 @@ import type { MultiplexTxLike, Transducer } from "./api.js";
|
|
|
36
38
|
*
|
|
37
39
|
* @example
|
|
38
40
|
* ```ts
|
|
41
|
+
* import { iterator, map, mapcat, multiplex } from "@thi.ng/transducers";
|
|
42
|
+
*
|
|
39
43
|
* [...iterator(
|
|
40
44
|
* multiplex(
|
|
41
45
|
* // override default unwrap behavior for this transducer
|
package/norm-count.d.ts
CHANGED
package/norm-frequencies.d.ts
CHANGED
|
@@ -4,8 +4,13 @@ import type { Reducer } from "./api.js";
|
|
|
4
4
|
* Similar to {@link frequencies}, but with each bin value normalized to given
|
|
5
5
|
* `norm`.
|
|
6
6
|
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Also see {@link normFrequenciesAuto}.
|
|
9
|
+
*
|
|
7
10
|
* @example
|
|
8
11
|
* ```ts
|
|
12
|
+
* import { normFrequencies } from "@thi.ng/transducers";
|
|
13
|
+
*
|
|
9
14
|
* const items = [1, 2, 3, 1, 1, 4, 2, 5, 1, 2];
|
|
10
15
|
*
|
|
11
16
|
* normFrequencies(10, items)
|
package/norm-range.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/transducers",
|
|
3
|
-
"version": "8.9.
|
|
3
|
+
"version": "8.9.7",
|
|
4
4
|
"description": "Lightweight transducer implementations for ES6 / TypeScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -39,14 +39,14 @@
|
|
|
39
39
|
"test": "bun test"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@thi.ng/api": "^8.9.
|
|
43
|
-
"@thi.ng/arrays": "^2.8.
|
|
42
|
+
"@thi.ng/api": "^8.9.26",
|
|
43
|
+
"@thi.ng/arrays": "^2.8.3",
|
|
44
44
|
"@thi.ng/checks": "^3.5.0",
|
|
45
|
-
"@thi.ng/compare": "^2.2.
|
|
46
|
-
"@thi.ng/compose": "^2.1.
|
|
45
|
+
"@thi.ng/compare": "^2.2.22",
|
|
46
|
+
"@thi.ng/compose": "^2.1.65",
|
|
47
47
|
"@thi.ng/errors": "^2.4.18",
|
|
48
|
-
"@thi.ng/math": "^5.10.
|
|
49
|
-
"@thi.ng/random": "^3.6.
|
|
48
|
+
"@thi.ng/math": "^5.10.3",
|
|
49
|
+
"@thi.ng/random": "^3.6.33"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@microsoft/api-extractor": "^7.40.1",
|
|
@@ -588,5 +588,5 @@
|
|
|
588
588
|
],
|
|
589
589
|
"year": 2016
|
|
590
590
|
},
|
|
591
|
-
"gitHead": "
|
|
591
|
+
"gitHead": "6e20f80dd9df1c8055ffa3c1e4d6f7598add0c0b\n"
|
|
592
592
|
}
|
package/pad-last.d.ts
CHANGED
package/pad-sides.d.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns iterator of `src` padded with value `x`, repeated
|
|
3
|
-
* `numLeft`/`numRight` times (default: 1). By default both sides are
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* `numLeft`/`numRight` times (default: 1). By default both sides are padded,
|
|
4
|
+
* but can be adjusted by setting either of them to zero. `numRight` defaults to
|
|
5
|
+
* same value as `numLeft`.
|
|
6
6
|
*
|
|
7
|
-
* @
|
|
8
|
-
* Essentially
|
|
7
|
+
* @remarks
|
|
8
|
+
* Essentially syntax sugar for code below. Also see {@link extendSides},
|
|
9
|
+
* {@link wrapSides}.
|
|
9
10
|
*
|
|
11
|
+
* @example
|
|
10
12
|
* ```ts
|
|
13
|
+
* import { concat, repeat } from "@thi.ng/transducers";
|
|
14
|
+
*
|
|
11
15
|
* // default
|
|
12
16
|
* concat(repeat(x, numLeft), src, repeat(x, numRight))
|
|
13
17
|
*
|
|
@@ -18,9 +22,6 @@
|
|
|
18
22
|
* concat(src, repeat(x, numRight))
|
|
19
23
|
* ```
|
|
20
24
|
*
|
|
21
|
-
* - {@link extendSides}
|
|
22
|
-
* - {@link wrapSides}
|
|
23
|
-
*
|
|
24
25
|
* @param src -
|
|
25
26
|
* @param x -
|
|
26
27
|
* @param numLeft -
|
package/page.d.ts
CHANGED
package/pairs.d.ts
CHANGED
package/palindrome.d.ts
CHANGED
package/partition-by.d.ts
CHANGED
package/partition-of.d.ts
CHANGED
package/partition-sort.d.ts
CHANGED
package/partition-sync.d.ts
CHANGED
|
@@ -69,6 +69,8 @@ export interface PartitionSyncOpts<T> {
|
|
|
69
69
|
*
|
|
70
70
|
* @example
|
|
71
71
|
* ```ts
|
|
72
|
+
* import { partitionSync } from "@thi.ng/transducers";
|
|
73
|
+
*
|
|
72
74
|
* src = [
|
|
73
75
|
* ["a", 1], ["a", 2], ["d", 100], ["b", 10],
|
|
74
76
|
* ["b", 11], ["c", 0], ["a", 3]
|
|
@@ -88,7 +90,10 @@ export interface PartitionSyncOpts<T> {
|
|
|
88
90
|
* available (with other values in the tuple remaining). Compare with
|
|
89
91
|
* above example:
|
|
90
92
|
*
|
|
93
|
+
* @example
|
|
91
94
|
* ```ts
|
|
95
|
+
* import { partitionSync } from "@thi.ng/transducers";
|
|
96
|
+
*
|
|
92
97
|
* // passing `false` to disable tuple reset
|
|
93
98
|
* [...partitionSync(
|
|
94
99
|
* ["a", "b"],
|
package/partition-when.d.ts
CHANGED
package/partition.d.ts
CHANGED
package/peek.d.ts
CHANGED
package/permutations.d.ts
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* ```ts
|
|
10
|
+
* import { permutations } from "@thi.ng/transducers";
|
|
11
|
+
*
|
|
10
12
|
* [...permutations("ab", range(3))]
|
|
11
13
|
* // [ ['a', 0], ['a', 1], ['a', 2],
|
|
12
14
|
* // ['b', 0], ['b', 1], ['b', 2] ]
|
|
@@ -36,6 +38,8 @@ export declare function permutations(...src: Iterable<any>[]): IterableIterator<
|
|
|
36
38
|
*
|
|
37
39
|
* @example
|
|
38
40
|
* ```ts
|
|
41
|
+
* import { permutationsN } from "@thi.ng/transducers";
|
|
42
|
+
*
|
|
39
43
|
* [...permutationsN(2)]
|
|
40
44
|
* // [ [0, 0], [0, 1], [1, 0], [1, 1] ]
|
|
41
45
|
*
|
package/pluck.d.ts
CHANGED
package/range-nd.d.ts
CHANGED
package/rechunk.d.ts
CHANGED
package/repeat.d.ts
CHANGED
package/repeatedly.d.ts
CHANGED
package/repeatedly2d.d.ts
CHANGED
package/repeatedly3d.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ import type { FnU3 } from "@thi.ng/api";
|
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```ts
|
|
9
|
+
* import { repeatedly3d } from "@thi.ng/transducers";
|
|
10
|
+
*
|
|
9
11
|
* [...repeatedly3d((x, y, z) => [(x+1)*10, (y+1)*100, (z+1)*1000], 2, 2, 2)]
|
|
10
12
|
* // [
|
|
11
13
|
* // [ 10, 100, 1000 ], [ 20, 100, 1000 ], [ 10, 200, 1000 ], [ 20, 200, 1000 ],
|
package/reverse.d.ts
CHANGED
package/sample.d.ts
CHANGED
package/scan.d.ts
CHANGED
|
@@ -12,6 +12,10 @@ import type { Reducer, Transducer } from "./api.js";
|
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* ```ts
|
|
15
|
+
* import {
|
|
16
|
+
* add, comp, last, length, multiplex, range, scan, transduce
|
|
17
|
+
* } from "@thi.ng/transducers";
|
|
18
|
+
*
|
|
15
19
|
* [...iterator(scan(add()), range(10))]
|
|
16
20
|
* // [ 0, 1, 3, 6, 10, 15, 21, 28, 36, 45 ]
|
|
17
21
|
*
|
package/select-keys.d.ts
CHANGED
package/sliding-window.d.ts
CHANGED
package/step.d.ts
CHANGED
package/stream-shuffle.d.ts
CHANGED
|
@@ -27,6 +27,9 @@ export interface StreamShuffleOpts {
|
|
|
27
27
|
*
|
|
28
28
|
* @example
|
|
29
29
|
* ```ts
|
|
30
|
+
* import { range, streamShuffle } from "@thi.ng/transducers";
|
|
31
|
+
* import { XsAdd } from "@thi.ng/random";
|
|
32
|
+
*
|
|
30
33
|
* [...streamShuffle(5, range(10))]
|
|
31
34
|
* // [ 3, 2, 5, 0, 8, 7, 1, 6, 4, 9 ]
|
|
32
35
|
*
|
package/stream-sort.d.ts
CHANGED
package/struct.d.ts
CHANGED
|
@@ -20,9 +20,11 @@ export interface StructField extends Array<any> {
|
|
|
20
20
|
*
|
|
21
21
|
* @example
|
|
22
22
|
* ```ts
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
23
|
+
* import { push, struct, transduce } from "@thi.ng/transducers";
|
|
24
|
+
*
|
|
25
|
+
* transduce(
|
|
26
|
+
* struct([["id", 1, (id) => id[0]], ["pos", 2], ["vel", 2], ["color", 4]]),
|
|
27
|
+
* push(),
|
|
26
28
|
* [0, 100, 200, -1, 0, 1, 0.5, 0, 1, 1, 0, 0, 5, 4, 0, 0, 1, 1]
|
|
27
29
|
* )
|
|
28
30
|
* // [ { color: [ 1, 0.5, 0, 1 ],
|
package/swizzle.d.ts
CHANGED
|
@@ -5,13 +5,15 @@ import type { Transducer } from "./api.js";
|
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
7
|
* ```ts
|
|
8
|
-
*
|
|
8
|
+
* import { swizzle } from "@thi.ng/transducers";
|
|
9
|
+
*
|
|
10
|
+
* [...swizzle([3, 0, 2, 1], [[1, 2, 3, 4], [10, 20, 30, 40]])]
|
|
9
11
|
* // [ [ 4, 1, 3, 2 ], [ 40, 10, 30, 20 ] ]
|
|
10
12
|
*
|
|
11
|
-
* [...swizzle([0,0,1,1], [[1,2,3,4], [10,20,30,40]])]
|
|
13
|
+
* [...swizzle([0, 0, 1, 1], [[1, 2, 3, 4], [10, 20, 30, 40]])]
|
|
12
14
|
* // [ [ 1, 1, 2, 2 ], [ 10, 10, 20, 20 ] ]
|
|
13
15
|
*
|
|
14
|
-
* [...swizzle(["z","x"], [{x: 1, y: 2, z: 3}])]
|
|
16
|
+
* [...swizzle(["z", "x"], [{x: 1, y: 2, z: 3}])]
|
|
15
17
|
* // [ [ 3, 1 ] ]
|
|
16
18
|
* ```
|
|
17
19
|
*
|
package/symmetric.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Yields an iterator of all `src` values, followed by the same values
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Yields an iterator of all `src` values, followed by the same values in
|
|
3
|
+
* reverse order. Efficiently builds the reversed order via an internal linked
|
|
4
|
+
* list.
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
7
|
* ```ts
|
|
8
|
+
* import { symmetric } from "@thi.ng/transducers";
|
|
9
|
+
*
|
|
8
10
|
* [...symmetric([1, 2, 3])]
|
|
9
11
|
* // [ 1, 2, 3, 3, 2, 1 ]
|
|
10
12
|
* ```
|
package/take-last.d.ts
CHANGED
package/take-nth.d.ts
CHANGED
package/take-while.d.ts
CHANGED
package/take.d.ts
CHANGED
package/toggle.d.ts
CHANGED
|
@@ -7,10 +7,12 @@ import type { Transducer } from "./api.js";
|
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* ```ts
|
|
10
|
+
* import { toggle } from "@thi.ng/transducers";
|
|
11
|
+
*
|
|
10
12
|
* [...toggle(1, 0, false, [1, 2, 3, 4])]
|
|
11
13
|
* // [ 1, 0, 1, 0 ]
|
|
12
14
|
*
|
|
13
|
-
* [...
|
|
15
|
+
* [...toggle("on", "off", true, [1, 2, 3, 4])]
|
|
14
16
|
* // [ 'off', 'on', 'off', 'on' ]
|
|
15
17
|
* ```
|
|
16
18
|
*
|
package/tween.d.ts
CHANGED
|
@@ -60,6 +60,8 @@ export interface TweenOpts<A, B, C> {
|
|
|
60
60
|
*
|
|
61
61
|
* @example
|
|
62
62
|
* ```ts
|
|
63
|
+
* import { tween } from "@thi.ng/transducers";
|
|
64
|
+
*
|
|
63
65
|
* [...tween({
|
|
64
66
|
* num: 10,
|
|
65
67
|
* min: 0,
|
|
@@ -76,6 +78,7 @@ export interface TweenOpts<A, B, C> {
|
|
|
76
78
|
*
|
|
77
79
|
* @example
|
|
78
80
|
* ```ts
|
|
81
|
+
* import { tween } from "@thi.ng/transducers";
|
|
79
82
|
* import { mix, smoothStep } from "@thi.ng/math"
|
|
80
83
|
*
|
|
81
84
|
* [...tween({
|