@thi.ng/transducers 8.3.26 → 8.3.28
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 +1 -1
- 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/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/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/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 +11 -11
- 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
|
@@ -59,7 +59,7 @@ This project is part of the
|
|
|
59
59
|
|
|
60
60
|
## About
|
|
61
61
|
|
|
62
|
-
Lightweight transducer implementations for ES6 / TypeScript
|
|
62
|
+
Lightweight transducer implementations for ES6 / TypeScript.
|
|
63
63
|
|
|
64
64
|
This library provides altogether ~130 transducers, reducers, sequence
|
|
65
65
|
generators (ES6 generators/iterators) and additional supporting
|
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/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/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
|
*/
|
package/interpolate.d.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import type { Fn2 } from "@thi.ng/api";
|
|
2
2
|
import type { Transducer } from "./api.js";
|
|
3
3
|
/**
|
|
4
|
-
* Higher order interpolation transducer. The resulting transducer forms
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Higher order interpolation transducer. The resulting transducer forms a
|
|
5
|
+
* sliding window and calls `fn` (the given interpolation function) `n` times
|
|
6
|
+
* with the current window and a normalized time value to produce the requested
|
|
7
|
+
* number of interpolated values per interval.
|
|
8
8
|
*
|
|
9
9
|
* @remarks
|
|
10
|
-
* If the optional `src` iterable is given, `interpolate` returns an
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* If the optional `src` iterable is given, `interpolate` returns an iterator of
|
|
11
|
+
* interpolated values. No values will be produced if the number of inputs is
|
|
12
|
+
* less than given `window` size.
|
|
13
13
|
*
|
|
14
|
-
* Note: The *very last* input value can never be fully reached and
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* Note: The *very last* input value can never be fully reached and might need
|
|
15
|
+
* to be explicitly duplicated in the input, e.g. via the {@link extendSides}
|
|
16
|
+
* iterator...
|
|
17
17
|
*
|
|
18
18
|
* See also:
|
|
19
|
-
* - {@link
|
|
20
|
-
* - {@link
|
|
19
|
+
* - {@link interpolateHermite}
|
|
20
|
+
* - {@link interpolateLinear}
|
|
21
21
|
* - {@link extendSides}
|
|
22
22
|
*
|
|
23
23
|
* @example
|
package/line.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Iterator yielding `steps` + 1 interpolated values on a line in the
|
|
3
|
-
*
|
|
2
|
+
* Iterator yielding `steps` + 1 interpolated values on a line in the closed
|
|
3
|
+
* `[start .. end]` interval.
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
|
-
* This is similar to {@link range}, but potentially provides more
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* This is similar to {@link range}, but potentially provides more precise
|
|
7
|
+
* values (by avoiding the accumulation of floating point errors during
|
|
8
|
+
* iteration).
|
|
9
9
|
*
|
|
10
10
|
* Similar functionality (w/ more options) is availble here:
|
|
11
|
-
*
|
|
11
|
+
* [`line()`](https://docs.thi.ng/umbrella/dsp/functions/line.html).
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* ```ts
|
package/line.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { map } from "./map.js";
|
|
2
2
|
import { normRange } from "./norm-range.js";
|
|
3
3
|
/**
|
|
4
|
-
* Iterator yielding `steps` + 1 interpolated values on a line in the
|
|
5
|
-
*
|
|
4
|
+
* Iterator yielding `steps` + 1 interpolated values on a line in the closed
|
|
5
|
+
* `[start .. end]` interval.
|
|
6
6
|
*
|
|
7
7
|
* @remarks
|
|
8
|
-
* This is similar to {@link range}, but potentially provides more
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* This is similar to {@link range}, but potentially provides more precise
|
|
9
|
+
* values (by avoiding the accumulation of floating point errors during
|
|
10
|
+
* iteration).
|
|
11
11
|
*
|
|
12
12
|
* Similar functionality (w/ more options) is availble here:
|
|
13
|
-
*
|
|
13
|
+
* [`line()`](https://docs.thi.ng/umbrella/dsp/functions/line.html).
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
16
|
* ```ts
|
package/map-indexed.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Fn2 } from "@thi.ng/api";
|
|
2
2
|
import type { Transducer } from "./api.js";
|
|
3
3
|
/**
|
|
4
|
-
* Transducer. Similar to {@link
|
|
5
|
-
*
|
|
4
|
+
* Transducer. Similar to {@link map}, but given `fn` takes two arguments:
|
|
5
|
+
* `index` and `value` to transform.
|
|
6
6
|
*
|
|
7
7
|
* @remarks
|
|
8
8
|
* An optional start index `offset` can be provided (default 0).
|
package/map-nth.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { Fn } from "@thi.ng/api";
|
|
2
2
|
import type { Transducer } from "./api.js";
|
|
3
3
|
/**
|
|
4
|
-
* Transducer. Similar to {@link
|
|
5
|
-
*
|
|
6
|
-
* downstream.
|
|
4
|
+
* Transducer. Similar to {@link map}, but only transforms every `n`-th input
|
|
5
|
+
* value and passes intermediate values unchanged downstream.
|
|
7
6
|
*
|
|
8
7
|
* @remarks
|
|
9
|
-
* The optional `offset` arg can be used to adjust the
|
|
10
|
-
*
|
|
8
|
+
* The optional `offset` arg can be used to adjust the number of inputs before
|
|
9
|
+
* the first transformation occurs (default 0).
|
|
11
10
|
*
|
|
12
11
|
* @example
|
|
13
12
|
* ```ts
|