@thi.ng/transducers 8.3.25 → 8.3.27
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/README.md +9 -19
- package/api.d.ts +5 -5
- package/cat.d.ts +9 -9
- package/cat.js +9 -9
- package/choices.d.ts +4 -4
- package/choices.js +4 -4
- package/conj.d.ts +1 -1
- package/converge.d.ts +9 -9
- package/convolve.d.ts +3 -3
- package/curve.d.ts +8 -8
- package/curve.js +8 -8
- package/deep-transform.d.ts +8 -9
- package/deep-transform.js +8 -9
- package/delayed.d.ts +3 -4
- package/delayed.js +3 -4
- package/fill.d.ts +4 -5
- package/filter-fuzzy.d.ts +8 -6
- package/flatten-with.d.ts +1 -1
- package/group-binary.d.ts +13 -15
- package/group-binary.js +13 -15
- package/interpolate-hermite.d.ts +9 -9
- package/interpolate-linear.d.ts +4 -4
- package/interpolate.d.ts +12 -12
- package/labeled.d.ts +1 -1
- package/line.d.ts +6 -6
- package/line.js +6 -6
- package/map-indexed.d.ts +2 -2
- package/map-nth.d.ts +4 -5
- package/map-vals.d.ts +7 -7
- package/mapcat-indexed.d.ts +3 -3
- package/mapcat.d.ts +4 -4
- package/match-first.d.ts +1 -1
- package/moving-average.d.ts +6 -7
- package/moving-median.d.ts +4 -4
- package/multiplex-obj.d.ts +1 -1
- package/multiplex.d.ts +5 -5
- package/noop.d.ts +3 -3
- package/noop.js +3 -3
- package/package.json +19 -15
- package/page.d.ts +4 -5
- package/pairs.d.ts +3 -3
- package/pairs.js +3 -3
- package/partition-sort.d.ts +2 -2
- package/partition-time.d.ts +6 -7
- package/peek.d.ts +3 -2
- package/push-sort.d.ts +3 -3
- package/range.d.ts +3 -3
- package/range.js +3 -3
- package/sample.d.ts +1 -1
- package/scan.d.ts +1 -1
- package/select-keys.d.ts +4 -4
- package/some.d.ts +3 -3
- package/sorted-keys.d.ts +4 -3
- package/sorted-keys.js +4 -3
- package/stream-sort.d.ts +3 -3
- package/swizzle.d.ts +5 -4
- package/throttle-time.d.ts +5 -6
- package/throttle.d.ts +9 -9
- package/tween.d.ts +24 -26
- package/tween.js +24 -26
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<!-- This file is generated - DO NOT EDIT! -->
|
|
2
2
|
|
|
3
|
-
# 
|
|
3
|
+
# 
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@thi.ng/transducers)
|
|
6
6
|

|
|
7
|
-
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
This project is part of the
|
|
10
10
|
[@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo.
|
|
@@ -55,13 +55,11 @@ This project is part of the
|
|
|
55
55
|
- [Generators / Iterators](#generators--iterators)
|
|
56
56
|
- [Reducers](#reducers)
|
|
57
57
|
- [Authors](#authors)
|
|
58
|
-
- [Maintainer](#maintainer)
|
|
59
|
-
- [Contributors](#contributors)
|
|
60
58
|
- [License](#license)
|
|
61
59
|
|
|
62
60
|
## About
|
|
63
61
|
|
|
64
|
-
Lightweight transducer implementations for ES6 / TypeScript
|
|
62
|
+
Lightweight transducer implementations for ES6 / TypeScript
|
|
65
63
|
|
|
66
64
|
This library provides altogether ~130 transducers, reducers, sequence
|
|
67
65
|
generators (ES6 generators/iterators) and additional supporting
|
|
@@ -171,11 +169,8 @@ ES module import:
|
|
|
171
169
|
|
|
172
170
|
For Node.js REPL:
|
|
173
171
|
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
node --experimental-repl-await
|
|
177
|
-
|
|
178
|
-
> const transducers = await import("@thi.ng/transducers");
|
|
172
|
+
```js
|
|
173
|
+
const transducers = await import("@thi.ng/transducers");
|
|
179
174
|
```
|
|
180
175
|
|
|
181
176
|
Package sizes (brotli'd, pre-treeshake): ESM: 8.64 KB
|
|
@@ -1006,14 +1001,9 @@ and return a reduced result (as if it would be called via `reduce()`).
|
|
|
1006
1001
|
|
|
1007
1002
|
## Authors
|
|
1008
1003
|
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
-
|
|
1012
|
-
|
|
1013
|
-
### Contributors
|
|
1014
|
-
|
|
1015
|
-
- Alberto ([@nkint](https://github.com/nkint))
|
|
1016
|
-
- Gavin Cannizzaro ([@gavinpc-mindgrub](https://github.com/gavinpc-mindgrub))
|
|
1004
|
+
- [Karsten Schmidt](https://thi.ng) (Main author)
|
|
1005
|
+
- [Gavin Cannizzaro](https://github.com/gavinpc-mindgrub)
|
|
1006
|
+
- [@nkint](https://github.com/nkint)
|
|
1017
1007
|
|
|
1018
1008
|
If this project contributes to an academic publication, please cite it as:
|
|
1019
1009
|
|
|
@@ -1028,4 +1018,4 @@ If this project contributes to an academic publication, please cite it as:
|
|
|
1028
1018
|
|
|
1029
1019
|
## License
|
|
1030
1020
|
|
|
1031
|
-
© 2016 - 2022 Karsten Schmidt // Apache
|
|
1021
|
+
© 2016 - 2022 Karsten Schmidt // Apache License 2.0
|
package/api.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Comparator, Fn, IObjectOf } from "@thi.ng/api";
|
|
2
2
|
import type { Reduced } from "./reduced.js";
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
3
|
+
export type Transducer<A, B> = (rfn: Reducer<any, B>) => Reducer<any, A>;
|
|
4
|
+
export type TxLike<A, B> = Transducer<A, B> | IXform<A, B>;
|
|
5
|
+
export type ReductionFn<A, B> = (acc: A, x: B) => A | Reduced<A>;
|
|
6
6
|
export interface Reducer<A, B> extends Array<any> {
|
|
7
7
|
[0]: () => A;
|
|
8
8
|
[1]: (acc: A) => A;
|
|
@@ -49,8 +49,8 @@ export interface IXform<A, B> {
|
|
|
49
49
|
export interface IReducible<A, B> {
|
|
50
50
|
$reduce(rfn: ReductionFn<A, B>, acc: A): A | Reduced<A>;
|
|
51
51
|
}
|
|
52
|
-
export
|
|
53
|
-
export
|
|
52
|
+
export type TransformFn = (x: any) => any;
|
|
53
|
+
export type TransformSubSpec = IObjectOf<TransformSpec | TransformFn>;
|
|
54
54
|
export interface TransformSpec extends Array<any> {
|
|
55
55
|
[0]: TransformFn;
|
|
56
56
|
[1]?: TransformSubSpec;
|
package/cat.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import type { Nullable } from "@thi.ng/api";
|
|
2
2
|
import type { Transducer } from "./api.js";
|
|
3
3
|
/**
|
|
4
|
-
* Transducer to concatenate iterable values. Iterates over each input
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Transducer to concatenate iterable values. Iterates over each input and emits
|
|
5
|
+
* individual values down stream, therefore removing one level of nesting from
|
|
6
|
+
* the input.
|
|
7
7
|
*
|
|
8
8
|
* @remarks
|
|
9
|
-
* If, during processing, the transducer is given a wrapped reduced
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
9
|
+
* If, during processing, the transducer is given a wrapped reduced input
|
|
10
|
+
* iterable, it will still be processed as normal, but then immediately triggers
|
|
11
|
+
* early termination by wrapping its own result in {@link reduced}. E.g. this
|
|
12
|
+
* behavior allows a {@link mapcat} user functions to benefit from reduced
|
|
13
|
+
* results.
|
|
14
14
|
*
|
|
15
15
|
* Also see:
|
|
16
16
|
* - {@link concat}
|
|
17
|
-
* - {@link
|
|
17
|
+
* - {@link mapcat}
|
|
18
18
|
*
|
|
19
19
|
* @example
|
|
20
20
|
* ```ts
|
package/cat.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { compR } from "./compr.js";
|
|
2
2
|
import { ensureReduced, isReduced, unreduced } from "./reduced.js";
|
|
3
3
|
/**
|
|
4
|
-
* Transducer to concatenate iterable values. Iterates over each input
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Transducer to concatenate iterable values. Iterates over each input and emits
|
|
5
|
+
* individual values down stream, therefore removing one level of nesting from
|
|
6
|
+
* the input.
|
|
7
7
|
*
|
|
8
8
|
* @remarks
|
|
9
|
-
* If, during processing, the transducer is given a wrapped reduced
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
9
|
+
* If, during processing, the transducer is given a wrapped reduced input
|
|
10
|
+
* iterable, it will still be processed as normal, but then immediately triggers
|
|
11
|
+
* early termination by wrapping its own result in {@link reduced}. E.g. this
|
|
12
|
+
* behavior allows a {@link mapcat} user functions to benefit from reduced
|
|
13
|
+
* results.
|
|
14
14
|
*
|
|
15
15
|
* Also see:
|
|
16
16
|
* - {@link concat}
|
|
17
|
-
* - {@link
|
|
17
|
+
* - {@link mapcat}
|
|
18
18
|
*
|
|
19
19
|
* @example
|
|
20
20
|
* ```ts
|
package/choices.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { IRandom } from "@thi.ng/random";
|
|
2
2
|
/**
|
|
3
|
-
* Returns an infinite iterator of random choices and their (optional)
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* Returns an infinite iterator of random choices and their (optional) weights.
|
|
4
|
+
* If `weights` is given, it must have at least the same size as `choices`. If
|
|
5
|
+
* omitted, each choice will have same probability.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```ts
|
|
@@ -10,7 +10,7 @@ import type { IRandom } from "@thi.ng/random";
|
|
|
10
10
|
* // Map { 'c' => 132, 'a' => 545, 'b' => 251, 'd' => 72 }
|
|
11
11
|
* ```
|
|
12
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* [`weightedRandom()`](https://docs.thi.ng/umbrella/random/functions/weightedRandom.html)
|
|
14
14
|
*
|
|
15
15
|
* @param choices -
|
|
16
16
|
* @param weights -
|
package/choices.js
CHANGED
|
@@ -3,9 +3,9 @@ import { SYSTEM } from "@thi.ng/random/system";
|
|
|
3
3
|
import { weightedRandom } from "@thi.ng/random/weighted-random";
|
|
4
4
|
import { repeatedly } from "./repeatedly.js";
|
|
5
5
|
/**
|
|
6
|
-
* Returns an infinite iterator of random choices and their (optional)
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* Returns an infinite iterator of random choices and their (optional) weights.
|
|
7
|
+
* If `weights` is given, it must have at least the same size as `choices`. If
|
|
8
|
+
* omitted, each choice will have same probability.
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
11
|
* ```ts
|
|
@@ -13,7 +13,7 @@ import { repeatedly } from "./repeatedly.js";
|
|
|
13
13
|
* // Map { 'c' => 132, 'a' => 545, 'b' => 251, 'd' => 72 }
|
|
14
14
|
* ```
|
|
15
15
|
*
|
|
16
|
-
*
|
|
16
|
+
* [`weightedRandom()`](https://docs.thi.ng/umbrella/random/functions/weightedRandom.html)
|
|
17
17
|
*
|
|
18
18
|
* @param choices -
|
|
19
19
|
* @param weights -
|
package/conj.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Reducer } from "./api.js";
|
|
2
2
|
/**
|
|
3
|
-
* Reducer. Like {@link
|
|
3
|
+
* Reducer. Like {@link push}, but for ES6 Sets.
|
|
4
4
|
*/
|
|
5
5
|
export declare function conj<T>(): Reducer<Set<T>, T>;
|
|
6
6
|
export declare function conj<T>(xs: Iterable<T>): Set<T>;
|
package/converge.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import type { Predicate2 } from "@thi.ng/api";
|
|
2
2
|
import type { Transducer } from "./api.js";
|
|
3
3
|
/**
|
|
4
|
-
* Transducer which for each input `x` (apart from the very first one)
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* Transducer which for each input `x` (apart from the very first one) applies
|
|
5
|
+
* given predicate `pred` to previous input and `x`. Only passes values
|
|
6
|
+
* downstream as long as the predicate returns a falsy result. Once the result
|
|
7
|
+
* is truthy, `x` is considered converged and the transformation is terminated
|
|
8
|
+
* (by emitting a {@link reduced} value).
|
|
9
9
|
*
|
|
10
10
|
* @remarks
|
|
11
|
-
* This can be used to limit processing of inputs only as long as
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* This can be used to limit processing of inputs only as long as there're
|
|
12
|
+
* noticeable changes (according to the predicate) and then stop the transducer
|
|
13
|
+
* pipeline once results have converged.
|
|
14
14
|
*
|
|
15
|
-
* See also: {@link
|
|
15
|
+
* See also: {@link takeWhile}
|
|
16
16
|
*
|
|
17
17
|
* @example
|
|
18
18
|
* ```ts
|
package/convolve.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Fn0 } from "@thi.ng/api";
|
|
2
2
|
import type { Reducer, Transducer } from "./api.js";
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
3
|
+
export type ConvolutionKernel1D = [number, number][];
|
|
4
|
+
export type ConvolutionKernel2D = [number, [number, number]][];
|
|
5
|
+
export type ConvolutionKernel3D = [number, [number, number, number]][];
|
|
6
6
|
export interface ConvolutionOpts<K> {
|
|
7
7
|
/**
|
|
8
8
|
* Current cell states
|
package/curve.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Iterator producing an exponential curve (with adjustable curvature)
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Iterator producing an exponential curve (with adjustable curvature) between
|
|
3
|
+
* `start` and `end` values over `num` steps. This is the exponential equivalent
|
|
4
|
+
* of {@link line}.
|
|
5
5
|
*
|
|
6
6
|
* @remarks
|
|
7
|
-
* Since `start` is the first value emitted, the `end` value is only
|
|
8
|
-
*
|
|
7
|
+
* Since `start` is the first value emitted, the `end` value is only reached in
|
|
8
|
+
* the `num+1`th step.
|
|
9
9
|
*
|
|
10
|
-
* The curvature can be controlled via the logarithmic `rate` param.
|
|
11
|
-
*
|
|
10
|
+
* The curvature can be controlled via the logarithmic `rate` param. Recommended
|
|
11
|
+
* range [0.0001 - 10000] (curved -> linear). Default: 0.1
|
|
12
12
|
*
|
|
13
13
|
* Similar functionality (w/ more options) is availble here:
|
|
14
|
-
*
|
|
14
|
+
* [`curve()`](https://docs.thi.ng/umbrella/dsp/functions/curve.html).
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* ```ts
|
package/curve.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Iterator producing an exponential curve (with adjustable curvature)
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Iterator producing an exponential curve (with adjustable curvature) between
|
|
3
|
+
* `start` and `end` values over `num` steps. This is the exponential equivalent
|
|
4
|
+
* of {@link line}.
|
|
5
5
|
*
|
|
6
6
|
* @remarks
|
|
7
|
-
* Since `start` is the first value emitted, the `end` value is only
|
|
8
|
-
*
|
|
7
|
+
* Since `start` is the first value emitted, the `end` value is only reached in
|
|
8
|
+
* the `num+1`th step.
|
|
9
9
|
*
|
|
10
|
-
* The curvature can be controlled via the logarithmic `rate` param.
|
|
11
|
-
*
|
|
10
|
+
* The curvature can be controlled via the logarithmic `rate` param. Recommended
|
|
11
|
+
* range [0.0001 - 10000] (curved -> linear). Default: 0.1
|
|
12
12
|
*
|
|
13
13
|
* Similar functionality (w/ more options) is availble here:
|
|
14
|
-
*
|
|
14
|
+
* [`curve()`](https://docs.thi.ng/umbrella/dsp/functions/curve.html).
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* ```ts
|
package/deep-transform.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { TransformSpec } from "./api.js";
|
|
2
2
|
/**
|
|
3
|
-
* Higher-order deep object transformer used by {@link
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
3
|
+
* Higher-order deep object transformer used by {@link mapDeep}. Accepts a
|
|
4
|
+
* nested `spec` array reflecting same key structure as the object to be mapped,
|
|
5
|
+
* but with functions or sub-specs as their values. Returns a new function,
|
|
6
|
+
* which when called, recursively applies nested transformers in post-order
|
|
7
|
+
* traversal (child transformers are run first) and returns the result of the
|
|
8
|
+
* root transformer.
|
|
9
9
|
*
|
|
10
10
|
* @remarks
|
|
11
11
|
* The transform specs are given as arrays in this format:
|
|
@@ -14,9 +14,8 @@ import type { TransformSpec } from "./api.js";
|
|
|
14
14
|
* [tx-function, { key1: [tx-function, {...}], key2: tx-fn }]
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
|
-
* If a key in the spec has no further sub maps, its transform function
|
|
18
|
-
*
|
|
19
|
-
* structure.
|
|
17
|
+
* If a key in the spec has no further sub maps, its transform function can be
|
|
18
|
+
* given directly without having to wrap it into the usual array structure.
|
|
20
19
|
*
|
|
21
20
|
* @example
|
|
22
21
|
* ```ts
|
package/deep-transform.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { isFunction } from "@thi.ng/checks/is-function";
|
|
2
2
|
/**
|
|
3
|
-
* Higher-order deep object transformer used by {@link
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
3
|
+
* Higher-order deep object transformer used by {@link mapDeep}. Accepts a
|
|
4
|
+
* nested `spec` array reflecting same key structure as the object to be mapped,
|
|
5
|
+
* but with functions or sub-specs as their values. Returns a new function,
|
|
6
|
+
* which when called, recursively applies nested transformers in post-order
|
|
7
|
+
* traversal (child transformers are run first) and returns the result of the
|
|
8
|
+
* root transformer.
|
|
9
9
|
*
|
|
10
10
|
* @remarks
|
|
11
11
|
* The transform specs are given as arrays in this format:
|
|
@@ -14,9 +14,8 @@ import { isFunction } from "@thi.ng/checks/is-function";
|
|
|
14
14
|
* [tx-function, { key1: [tx-function, {...}], key2: tx-fn }]
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
|
-
* If a key in the spec has no further sub maps, its transform function
|
|
18
|
-
*
|
|
19
|
-
* structure.
|
|
17
|
+
* If a key in the spec has no further sub maps, its transform function can be
|
|
18
|
+
* given directly without having to wrap it into the usual array structure.
|
|
20
19
|
*
|
|
21
20
|
* @example
|
|
22
21
|
* ```ts
|
package/delayed.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { Transducer } from "./api.js";
|
|
2
2
|
/**
|
|
3
|
-
* Yields transducer which wraps incoming values in promises, which each
|
|
4
|
-
*
|
|
3
|
+
* Yields transducer which wraps incoming values in promises, which each resolve
|
|
4
|
+
* after specified delay time (in ms).
|
|
5
5
|
*
|
|
6
6
|
* @remarks
|
|
7
|
-
* Only to be used in async contexts and NOT with {@link
|
|
8
|
-
* directly.
|
|
7
|
+
* Only to be used in async contexts and NOT with {@link transduce} directly.
|
|
9
8
|
*
|
|
10
9
|
* @param t -
|
|
11
10
|
*/
|
package/delayed.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { delayed as _delayed } from "@thi.ng/compose/delayed";
|
|
2
2
|
import { map } from "./map.js";
|
|
3
3
|
/**
|
|
4
|
-
* Yields transducer which wraps incoming values in promises, which each
|
|
5
|
-
*
|
|
4
|
+
* Yields transducer which wraps incoming values in promises, which each resolve
|
|
5
|
+
* after specified delay time (in ms).
|
|
6
6
|
*
|
|
7
7
|
* @remarks
|
|
8
|
-
* Only to be used in async contexts and NOT with {@link
|
|
9
|
-
* directly.
|
|
8
|
+
* Only to be used in async contexts and NOT with {@link transduce} directly.
|
|
10
9
|
*
|
|
11
10
|
* @param t -
|
|
12
11
|
*/
|
package/fill.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { NumericArray } from "@thi.ng/api";
|
|
2
2
|
import type { Reducer } from "./api.js";
|
|
3
3
|
/**
|
|
4
|
-
* Reducer which starts filling array with results from given `start`
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Reducer which starts filling array with results from given `start` index
|
|
5
|
+
* (default: 0). Use {@link fillN} for typed array targets (same impl, but
|
|
6
|
+
* provides correct result type).
|
|
7
7
|
*
|
|
8
8
|
* @param start -
|
|
9
9
|
*/
|
|
@@ -11,8 +11,7 @@ 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
|
/**
|
|
14
|
-
* Like {@link
|
|
15
|
-
* arrays).
|
|
14
|
+
* Like {@link fill} reducer, but for numeric arrays (incl. typed arrays).
|
|
16
15
|
*
|
|
17
16
|
* @param start -
|
|
18
17
|
*/
|
package/filter-fuzzy.d.ts
CHANGED
|
@@ -11,14 +11,16 @@ export interface FilterFuzzyOpts<A, B> {
|
|
|
11
11
|
equiv: Predicate2<any>;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
* Returns transducer which calls
|
|
15
|
-
*
|
|
14
|
+
* Returns transducer which calls
|
|
15
|
+
* [`fuzzyMatch()`](https://docs.thi.ng/umbrella/arrays/functions/fuzzyMatch.html)
|
|
16
|
+
* for each value and discards all non-matching values.
|
|
16
17
|
*
|
|
17
18
|
* @remarks
|
|
18
|
-
* The `key` option function can be used to extract/produce the actual
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* by
|
|
19
|
+
* The `key` option function can be used to extract/produce the actual value
|
|
20
|
+
* used for the search. The `equiv` option predicate can be used to customize
|
|
21
|
+
* item equality checking. Uses
|
|
22
|
+
* [`equiv()`](https://docs.thi.ng/umbrella/equiv/functions/equiv.html) by
|
|
23
|
+
* default.
|
|
22
24
|
*
|
|
23
25
|
* @example
|
|
24
26
|
* ```ts
|
package/flatten-with.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DeepArrayValue, Fn, Nullable } from "@thi.ng/api";
|
|
2
2
|
import type { Transducer } from "./api.js";
|
|
3
|
-
|
|
3
|
+
type MaybeIterable<T> = Nullable<Iterable<T>>;
|
|
4
4
|
/**
|
|
5
5
|
* Transducer. Takes a function `fn` which will be applied to each input
|
|
6
6
|
* value. If the function returns an ES6 Iterable, the result will be
|
package/group-binary.d.ts
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import type { Fn, Fn0, IObjectOf } from "@thi.ng/api";
|
|
2
2
|
import type { Reducer } from "./api.js";
|
|
3
3
|
/**
|
|
4
|
-
* Creates a bottom-up, unbalanced binary tree of desired depth and
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* `0 .. (2^bits) - 1` range).
|
|
4
|
+
* Creates a bottom-up, unbalanced binary tree of desired depth and choice of
|
|
5
|
+
* data structures. Any value can be indexed, as long as a numeric
|
|
6
|
+
* representation (key) can be obtained. This numeric key is produced by the
|
|
7
|
+
* supplied `key` function. IMPORTANT: the returned values MUST be unsigned and
|
|
8
|
+
* less than the provided bit length (i.e. `0 .. (2^bits) - 1` range).
|
|
10
9
|
*
|
|
11
|
-
* By default the tree is constructed using plain objects for branches,
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
10
|
+
* By default the tree is constructed using plain objects for branches, with
|
|
11
|
+
* left branches stored as "l" and right ones as "r". The original values are
|
|
12
|
+
* stored at the lowest tree level using a customizable nested reducer. By
|
|
13
|
+
* default leaves are collected in arrays (using the {@link push} reducer), but
|
|
14
|
+
* any suitable reducer can be used (e.g. {@link conj} to collect values into
|
|
15
|
+
* sets).
|
|
17
16
|
*
|
|
18
17
|
* Index by lowest 4-bits of ID value:
|
|
19
18
|
*
|
|
@@ -48,7 +47,7 @@ import type { Reducer } from "./api.js";
|
|
|
48
47
|
* // [ [ 6 ], [ 7 ] ]
|
|
49
48
|
* ```
|
|
50
49
|
*
|
|
51
|
-
* Using {@link
|
|
50
|
+
* Using {@link frequencies} as leaf reducer:
|
|
52
51
|
*
|
|
53
52
|
* @example
|
|
54
53
|
* ```ts
|
|
@@ -68,8 +67,7 @@ import type { Reducer } from "./api.js";
|
|
|
68
67
|
*
|
|
69
68
|
* @param bits - index range (always from 0)
|
|
70
69
|
* @param key - key function
|
|
71
|
-
* @param branch - function to create a new branch container (object or
|
|
72
|
-
* array)
|
|
70
|
+
* @param branch - function to create a new branch container (object or array)
|
|
73
71
|
* @param leaf - reducer for leaf collection
|
|
74
72
|
* @param left - key for storing left branches (e.g. `0` for arrays)
|
|
75
73
|
* @param right - key for storing right branches (e.g. `1` for arrays)
|
package/group-binary.js
CHANGED
|
@@ -2,19 +2,18 @@ import { groupByObj } from "./group-by-obj.js";
|
|
|
2
2
|
import { push } from "./push.js";
|
|
3
3
|
const branchPred = (key, b, l, r) => (x) => key(x) & b ? r : l;
|
|
4
4
|
/**
|
|
5
|
-
* Creates a bottom-up, unbalanced binary tree of desired depth and
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* `0 .. (2^bits) - 1` range).
|
|
5
|
+
* Creates a bottom-up, unbalanced binary tree of desired depth and choice of
|
|
6
|
+
* data structures. Any value can be indexed, as long as a numeric
|
|
7
|
+
* representation (key) can be obtained. This numeric key is produced by the
|
|
8
|
+
* supplied `key` function. IMPORTANT: the returned values MUST be unsigned and
|
|
9
|
+
* less than the provided bit length (i.e. `0 .. (2^bits) - 1` range).
|
|
11
10
|
*
|
|
12
|
-
* By default the tree is constructed using plain objects for branches,
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
11
|
+
* By default the tree is constructed using plain objects for branches, with
|
|
12
|
+
* left branches stored as "l" and right ones as "r". The original values are
|
|
13
|
+
* stored at the lowest tree level using a customizable nested reducer. By
|
|
14
|
+
* default leaves are collected in arrays (using the {@link push} reducer), but
|
|
15
|
+
* any suitable reducer can be used (e.g. {@link conj} to collect values into
|
|
16
|
+
* sets).
|
|
18
17
|
*
|
|
19
18
|
* Index by lowest 4-bits of ID value:
|
|
20
19
|
*
|
|
@@ -49,7 +48,7 @@ const branchPred = (key, b, l, r) => (x) => key(x) & b ? r : l;
|
|
|
49
48
|
* // [ [ 6 ], [ 7 ] ]
|
|
50
49
|
* ```
|
|
51
50
|
*
|
|
52
|
-
* Using {@link
|
|
51
|
+
* Using {@link frequencies} as leaf reducer:
|
|
53
52
|
*
|
|
54
53
|
* @example
|
|
55
54
|
* ```ts
|
|
@@ -69,8 +68,7 @@ const branchPred = (key, b, l, r) => (x) => key(x) & b ? r : l;
|
|
|
69
68
|
*
|
|
70
69
|
* @param bits - index range (always from 0)
|
|
71
70
|
* @param key - key function
|
|
72
|
-
* @param branch - function to create a new branch container (object or
|
|
73
|
-
* array)
|
|
71
|
+
* @param branch - function to create a new branch container (object or array)
|
|
74
72
|
* @param leaf - reducer for leaf collection
|
|
75
73
|
* @param left - key for storing left branches (e.g. `0` for arrays)
|
|
76
74
|
* @param right - key for storing right branches (e.g. `1` for arrays)
|
package/interpolate-hermite.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import type { Transducer } from "./api.js";
|
|
2
2
|
/**
|
|
3
|
-
* Pre-configured version of {@link
|
|
4
|
-
*
|
|
3
|
+
* Pre-configured version of {@link interpolate} for numeric values and using
|
|
4
|
+
* cubic hermite interpolation.
|
|
5
5
|
*
|
|
6
6
|
* @remarks
|
|
7
7
|
* The number of samples per interval is configurable. No values will be
|
|
8
8
|
* produced if there're less than 4 inputs.
|
|
9
9
|
*
|
|
10
|
-
* Note: Due to the nature of hermite interpolation, the very first and
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
10
|
+
* Note: Due to the nature of hermite interpolation, the very first and last
|
|
11
|
+
* input are only used to compute the curve tangents, but will not appear in the
|
|
12
|
+
* output. Use the {@link extendSides} iterator to transform the input so that
|
|
13
|
+
* these values are duplicated and so are used as part of an interpolation
|
|
14
|
+
* interval.
|
|
15
15
|
*
|
|
16
16
|
* See also:
|
|
17
|
-
* - {@link
|
|
18
|
-
* - {@link
|
|
17
|
+
* - {@link interpolate}
|
|
18
|
+
* - {@link interpolateLinear}
|
|
19
19
|
* - {@link extendSides}
|
|
20
20
|
*
|
|
21
21
|
* @param n -
|
package/interpolate-linear.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { Transducer } from "./api.js";
|
|
2
2
|
/**
|
|
3
|
-
* Pre-configured version of {@link
|
|
4
|
-
*
|
|
3
|
+
* Pre-configured version of {@link interpolate} for numeric values and using
|
|
4
|
+
* pairwise linear interpolation.
|
|
5
5
|
*
|
|
6
6
|
* @remarks
|
|
7
7
|
* The number of samples per interval is configurable. No values will be
|
|
8
8
|
* produced if there're less than 2 inputs.
|
|
9
9
|
*
|
|
10
10
|
* See also:
|
|
11
|
-
* - {@link
|
|
12
|
-
* - {@link
|
|
11
|
+
* - {@link interpolate}
|
|
12
|
+
* - {@link interpolateHermite}
|
|
13
13
|
*
|
|
14
14
|
* @param n -
|
|
15
15
|
*/
|