@thi.ng/transducers 7.9.2 → 8.0.4
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 +354 -420
- package/README.md +242 -219
- package/{rfn/add.d.ts → add.d.ts} +1 -1
- package/{rfn/add.js → add.js} +1 -1
- package/api.d.ts +1 -1
- package/{iter/as-iterable.d.ts → as-iterable.d.ts} +0 -0
- package/{iter/as-iterable.js → as-iterable.js} +0 -0
- package/{rfn/assoc-map.d.ts → assoc-map.d.ts} +1 -1
- package/{rfn/assoc-map.js → assoc-map.js} +1 -1
- package/{rfn/assoc-obj.d.ts → assoc-obj.d.ts} +1 -1
- package/{rfn/assoc-obj.js → assoc-obj.js} +1 -1
- package/{rfn/auto-obj.d.ts → auto-obj.d.ts} +1 -1
- package/{rfn/auto-obj.js → auto-obj.js} +1 -1
- package/{xform/benchmark.d.ts → benchmark.d.ts} +1 -1
- package/{xform/benchmark.js → benchmark.js} +3 -3
- package/{xform/cat.d.ts → cat.d.ts} +1 -1
- package/{xform/cat.js → cat.js} +2 -2
- package/{iter/choices.d.ts → choices.d.ts} +1 -1
- package/{iter/choices.js → choices.js} +4 -3
- package/{func/comp.d.ts → comp.d.ts} +1 -1
- package/{func/comp.js → comp.js} +2 -2
- package/{func/compr.d.ts → compr.d.ts} +1 -1
- package/{func/compr.js → compr.js} +0 -0
- package/{iter/concat.d.ts → concat.d.ts} +0 -0
- package/{iter/concat.js → concat.js} +1 -1
- package/{rfn/conj.d.ts → conj.d.ts} +1 -1
- package/{rfn/conj.js → conj.js} +1 -1
- package/{xform/converge.d.ts → converge.d.ts} +2 -2
- package/{xform/converge.js → converge.js} +5 -5
- package/{xform/convolve.d.ts → convolve.d.ts} +1 -1
- package/{xform/convolve.js → convolve.js} +8 -8
- package/{rfn/count.d.ts → count.d.ts} +1 -1
- package/{rfn/count.js → count.js} +1 -1
- package/{iter/curve.d.ts → curve.d.ts} +0 -0
- package/{iter/curve.js → curve.js} +0 -0
- package/{iter/cycle.d.ts → cycle.d.ts} +0 -0
- package/{iter/cycle.js → cycle.js} +0 -0
- package/{xform/dedupe.d.ts → dedupe.d.ts} +2 -2
- package/{xform/dedupe.js → dedupe.js} +4 -4
- package/{func/deep-transform.d.ts → deep-transform.d.ts} +2 -2
- package/{func/deep-transform.js → deep-transform.js} +3 -3
- package/{xform/delayed.d.ts → delayed.d.ts} +1 -1
- package/{xform/delayed.js → delayed.js} +2 -2
- package/{xform/distinct.d.ts → distinct.d.ts} +1 -1
- package/{xform/distinct.js → distinct.js} +3 -3
- package/{rfn/div.d.ts → div.d.ts} +1 -1
- package/{rfn/div.js → div.js} +1 -1
- package/{xform/drop-nth.d.ts → drop-nth.d.ts} +1 -1
- package/{xform/drop-nth.js → drop-nth.js} +4 -4
- package/{xform/drop-while.d.ts → drop-while.d.ts} +1 -1
- package/{xform/drop-while.js → drop-while.js} +3 -3
- package/{xform/drop.d.ts → drop.d.ts} +1 -1
- package/{xform/drop.js → drop.js} +3 -3
- package/{iter/dup.d.ts → dup.d.ts} +0 -0
- package/dup.js +11 -0
- package/{xform/duplicate.d.ts → duplicate.d.ts} +1 -1
- package/{xform/duplicate.js → duplicate.js} +4 -4
- package/ensure.d.ts +3 -0
- package/{internal/ensure.js → ensure.js} +1 -1
- package/{rfn/every.d.ts → every.d.ts} +1 -1
- package/{rfn/every.js → every.js} +2 -2
- package/{iter/extend-sides.d.ts → extend-sides.d.ts} +0 -0
- package/{iter/extend-sides.js → extend-sides.js} +2 -2
- package/{rfn/fill.d.ts → fill.d.ts} +1 -1
- package/{rfn/fill.js → fill.js} +1 -1
- package/{xform/filter-fuzzy.d.ts → filter-fuzzy.d.ts} +1 -1
- package/{xform/filter-fuzzy.js → filter-fuzzy.js} +4 -4
- package/{xform/filter.d.ts → filter.d.ts} +1 -1
- package/{xform/filter.js → filter.js} +3 -3
- package/{xform/flatten-with.d.ts → flatten-with.d.ts} +1 -1
- package/{xform/flatten-with.js → flatten-with.js} +5 -4
- package/{xform/flatten.d.ts → flatten.d.ts} +1 -1
- package/flatten.js +5 -0
- package/{rfn/frequencies.d.ts → frequencies.d.ts} +1 -1
- package/frequencies.js +8 -0
- package/{rfn/group-binary.d.ts → group-binary.d.ts} +1 -1
- package/{rfn/group-binary.js → group-binary.js} +3 -3
- package/{rfn/group-by-map.d.ts → group-by-map.d.ts} +1 -1
- package/{rfn/group-by-map.js → group-by-map.js} +2 -2
- package/{rfn/group-by-obj.d.ts → group-by-obj.d.ts} +1 -1
- package/{rfn/group-by-obj.js → group-by-obj.js} +2 -2
- package/index.d.ts +145 -144
- package/index.js +149 -144
- package/{xform/indexed.d.ts → indexed.d.ts} +1 -1
- package/{xform/indexed.js → indexed.js} +3 -3
- package/{xform/interleave.d.ts → interleave.d.ts} +1 -1
- package/{xform/interleave.js → interleave.js} +4 -4
- package/internal/drain.d.ts +1 -1
- package/internal/drain.js +1 -1
- package/internal/group-opts.d.ts +1 -1
- package/internal/group-opts.js +6 -3
- package/internal/mathop.d.ts +1 -1
- package/internal/mathop.js +1 -1
- package/internal/sort-opts.d.ts +1 -1
- package/internal/sort-opts.js +6 -3
- package/{xform/interpolate-hermite.d.ts → interpolate-hermite.d.ts} +1 -1
- package/{xform/interpolate-hermite.js → interpolate-hermite.js} +2 -2
- package/{xform/interpolate-linear.d.ts → interpolate-linear.d.ts} +1 -1
- package/{xform/interpolate-linear.js → interpolate-linear.js} +2 -2
- package/{xform/interpolate.d.ts → interpolate.d.ts} +1 -1
- package/interpolate.js +12 -0
- package/{xform/interpose.d.ts → interpose.d.ts} +1 -1
- package/{xform/interpose.js → interpose.js} +4 -4
- package/{iter/iterate.d.ts → iterate.d.ts} +0 -0
- package/{iter/iterate.js → iterate.js} +0 -0
- package/iterator.d.ts +3 -3
- package/iterator.js +6 -6
- package/{func/juxtr.d.ts → juxtr.d.ts} +1 -1
- package/{func/juxtr.js → juxtr.js} +1 -1
- package/{xform/keep.d.ts → keep.d.ts} +7 -1
- package/{xform/keep.js → keep.js} +4 -4
- package/{iter/key-permutations.d.ts → key-permutations.d.ts} +0 -0
- package/{iter/key-permutations.js → key-permutations.js} +6 -6
- package/{func/key-selector.d.ts → key-selector.d.ts} +0 -0
- package/{func/key-selector.js → key-selector.js} +1 -1
- package/{iter/keys.d.ts → keys.d.ts} +0 -0
- package/{iter/keys.js → keys.js} +0 -0
- package/{xform/labeled.d.ts → labeled.d.ts} +1 -1
- package/labeled.js +9 -0
- package/{rfn/last.d.ts → last.d.ts} +1 -1
- package/{rfn/last.js → last.js} +2 -2
- package/{iter/line.d.ts → line.d.ts} +0 -0
- package/{iter/line.js → line.js} +2 -2
- package/{func/lookup.d.ts → lookup.d.ts} +0 -0
- package/{func/lookup.js → lookup.js} +0 -0
- package/{xform/map-deep.d.ts → map-deep.d.ts} +1 -1
- package/map-deep.js +9 -0
- package/{xform/map-indexed.d.ts → map-indexed.d.ts} +1 -1
- package/{xform/map-indexed.js → map-indexed.js} +3 -3
- package/{xform/map-keys.d.ts → map-keys.d.ts} +1 -1
- package/{xform/map-keys.js → map-keys.js} +3 -3
- package/{xform/map-nth.d.ts → map-nth.d.ts} +1 -1
- package/{xform/map-nth.js → map-nth.js} +3 -3
- package/{xform/map-vals.d.ts → map-vals.d.ts} +1 -1
- package/{xform/map-vals.js → map-vals.js} +3 -3
- package/{xform/map.d.ts → map.d.ts} +1 -1
- package/{xform/map.js → map.js} +3 -3
- package/{xform/mapcat-indexed.d.ts → mapcat-indexed.d.ts} +1 -1
- package/mapcat-indexed.js +8 -0
- package/{xform/mapcat.d.ts → mapcat.d.ts} +1 -1
- package/mapcat.js +8 -0
- package/{xform/match-first.d.ts → match-first.d.ts} +1 -1
- package/match-first.js +10 -0
- package/{xform/match-last.d.ts → match-last.d.ts} +1 -1
- package/match-last.js +10 -0
- package/{rfn/max-compare.d.ts → max-compare.d.ts} +1 -1
- package/{rfn/max-compare.js → max-compare.js} +2 -2
- package/{rfn/max-mag.d.ts → max-mag.d.ts} +1 -1
- package/{rfn/max-mag.js → max-mag.js} +1 -1
- package/{rfn/max.d.ts → max.d.ts} +1 -1
- package/{rfn/max.js → max.js} +1 -1
- package/{rfn/mean.d.ts → mean.d.ts} +1 -1
- package/{rfn/mean.js → mean.js} +1 -1
- package/{rfn/min-compare.d.ts → min-compare.d.ts} +1 -1
- package/{rfn/min-compare.js → min-compare.js} +2 -2
- package/{rfn/min-mag.d.ts → min-mag.d.ts} +1 -1
- package/{rfn/min-mag.js → min-mag.js} +1 -1
- package/{rfn/min-max.d.ts → min-max.d.ts} +1 -1
- package/{rfn/min-max.js → min-max.js} +3 -3
- package/{rfn/min.d.ts → min.d.ts} +1 -1
- package/{rfn/min.js → min.js} +1 -1
- package/{xform/moving-average.d.ts → moving-average.d.ts} +1 -1
- package/{xform/moving-average.js → moving-average.js} +4 -4
- package/{xform/moving-median.d.ts → moving-median.d.ts} +1 -1
- package/{xform/moving-median.js → moving-median.js} +6 -6
- package/{rfn/mul.d.ts → mul.d.ts} +1 -1
- package/{rfn/mul.js → mul.js} +1 -1
- package/{xform/multiplex-obj.d.ts → multiplex-obj.d.ts} +1 -1
- package/{xform/multiplex-obj.js → multiplex-obj.js} +5 -5
- package/{xform/multiplex.d.ts → multiplex.d.ts} +1 -1
- package/multiplex.js +6 -0
- package/{xform/noop.d.ts → noop.d.ts} +1 -1
- package/{xform/noop.js → noop.js} +0 -0
- package/{rfn/norm-count.d.ts → norm-count.d.ts} +1 -1
- package/{rfn/norm-count.js → norm-count.js} +1 -1
- package/{rfn/norm-frequencies-auto.d.ts → norm-frequencies-auto.d.ts} +1 -1
- package/{rfn/norm-frequencies-auto.js → norm-frequencies-auto.js} +2 -2
- package/{rfn/norm-frequencies.d.ts → norm-frequencies.d.ts} +1 -1
- package/{rfn/norm-frequencies.js → norm-frequencies.js} +4 -4
- package/{iter/norm-range.d.ts → norm-range.d.ts} +0 -0
- package/{iter/norm-range.js → norm-range.js} +1 -1
- package/package.json +470 -34
- package/{xform/pad-last.d.ts → pad-last.d.ts} +1 -1
- package/{xform/pad-last.js → pad-last.js} +3 -3
- package/{iter/pad-sides.d.ts → pad-sides.d.ts} +0 -0
- package/{iter/pad-sides.js → pad-sides.js} +2 -2
- package/{xform/page.d.ts → page.d.ts} +1 -1
- package/page.js +8 -0
- package/{iter/pairs.d.ts → pairs.d.ts} +0 -0
- package/{iter/pairs.js → pairs.js} +0 -0
- package/{iter/palindrome.d.ts → palindrome.d.ts} +0 -0
- package/palindrome.js +13 -0
- package/{xform/partition-by.d.ts → partition-by.d.ts} +2 -2
- package/{xform/partition-by.js → partition-by.js} +4 -4
- package/{xform/partition-of.d.ts → partition-of.d.ts} +1 -1
- package/{xform/partition-of.js → partition-of.js} +3 -3
- package/{xform/partition-sort.d.ts → partition-sort.d.ts} +1 -1
- package/partition-sort.js +13 -0
- package/{xform/partition-sync.d.ts → partition-sync.d.ts} +1 -1
- package/{xform/partition-sync.js → partition-sync.js} +15 -8
- package/{xform/partition-time.d.ts → partition-time.d.ts} +1 -1
- package/{xform/partition-time.js → partition-time.js} +3 -3
- package/{xform/partition-when.d.ts → partition-when.d.ts} +1 -1
- package/{xform/partition-when.js → partition-when.js} +3 -3
- package/{xform/partition.d.ts → partition.d.ts} +1 -1
- package/{xform/partition.js → partition.js} +2 -2
- package/{xform/peek.d.ts → peek.d.ts} +1 -1
- package/peek.js +5 -0
- package/{iter/permutations.d.ts → permutations.d.ts} +0 -0
- package/{iter/permutations.js → permutations.js} +3 -3
- package/{xform/pluck.d.ts → pluck.d.ts} +1 -1
- package/pluck.js +8 -0
- package/push-copy.d.ts +3 -0
- package/{rfn/push-copy.js → push-copy.js} +1 -1
- package/{rfn/push-sort.d.ts → push-sort.d.ts} +1 -1
- package/{rfn/push-sort.js → push-sort.js} +1 -1
- package/{rfn/push.d.ts → push.d.ts} +1 -1
- package/{rfn/push.js → push.js} +1 -1
- package/{iter/range-nd.d.ts → range-nd.d.ts} +0 -0
- package/{iter/range-nd.js → range-nd.js} +4 -4
- package/{iter/range.d.ts → range.d.ts} +2 -2
- package/{iter/range.js → range.js} +1 -1
- package/{iter/range2d.d.ts → range2d.d.ts} +0 -0
- package/{iter/range2d.js → range2d.js} +2 -2
- package/{iter/range3d.d.ts → range3d.d.ts} +0 -0
- package/{iter/range3d.js → range3d.js} +2 -2
- package/reduce.d.ts +1 -1
- package/reduce.js +5 -3
- package/{rfn/reductions.d.ts → reductions.d.ts} +1 -1
- package/{rfn/reductions.js → reductions.js} +2 -2
- package/{xform/rename.d.ts → rename.d.ts} +1 -1
- package/{xform/rename.js → rename.js} +8 -8
- package/renamer.d.ts +9 -0
- package/{func/renamer.js → renamer.js} +6 -0
- package/{iter/repeat.d.ts → repeat.d.ts} +0 -0
- package/{iter/repeat.js → repeat.js} +0 -0
- package/{iter/repeatedly.d.ts → repeatedly.d.ts} +0 -0
- package/{iter/repeatedly.js → repeatedly.js} +0 -0
- package/{iter/reverse.d.ts → reverse.d.ts} +0 -0
- package/{iter/reverse.js → reverse.js} +1 -1
- package/run.d.ts +2 -2
- package/run.js +2 -2
- package/{xform/sample.d.ts → sample.d.ts} +2 -2
- package/{xform/sample.js → sample.js} +4 -4
- package/{xform/scan.d.ts → scan.d.ts} +1 -1
- package/{xform/scan.js → scan.js} +3 -3
- package/{xform/select-keys.d.ts → select-keys.d.ts} +1 -1
- package/select-keys.js +9 -0
- package/{xform/side-effect.d.ts → side-effect.d.ts} +1 -1
- package/{xform/side-effect.js → side-effect.js} +1 -1
- package/{xform/sliding-window.d.ts → sliding-window.d.ts} +2 -2
- package/{xform/sliding-window.js → sliding-window.js} +4 -4
- package/{rfn/some.d.ts → some.d.ts} +1 -1
- package/{rfn/some.js → some.js} +2 -2
- package/{iter/sorted-keys.d.ts → sorted-keys.d.ts} +0 -0
- package/{iter/sorted-keys.js → sorted-keys.js} +1 -1
- package/step.d.ts +1 -1
- package/step.js +3 -3
- package/{rfn/str.d.ts → str.d.ts} +1 -1
- package/{rfn/str.js → str.js} +1 -1
- package/{xform/stream-shuffle.d.ts → stream-shuffle.d.ts} +1 -1
- package/{xform/stream-shuffle.js → stream-shuffle.js} +4 -4
- package/{xform/stream-sort.d.ts → stream-sort.d.ts} +1 -1
- package/{xform/stream-sort.js → stream-sort.js} +5 -5
- package/{xform/struct.d.ts → struct.d.ts} +1 -1
- package/{xform/struct.js → struct.js} +7 -7
- package/{rfn/sub.d.ts → sub.d.ts} +1 -1
- package/{rfn/sub.js → sub.js} +1 -1
- package/{xform/swizzle.d.ts → swizzle.d.ts} +1 -1
- package/swizzle.js +9 -0
- package/{iter/symmetric.d.ts → symmetric.d.ts} +0 -0
- package/{iter/symmetric.js → symmetric.js} +0 -0
- package/{xform/take-last.d.ts → take-last.d.ts} +1 -1
- package/{xform/take-last.js → take-last.js} +3 -3
- package/{xform/take-nth.d.ts → take-nth.d.ts} +1 -1
- package/{xform/take-nth.js → take-nth.js} +4 -4
- package/{xform/take-while.d.ts → take-while.d.ts} +1 -1
- package/{xform/take-while.js → take-while.js} +4 -4
- package/{xform/take.d.ts → take.d.ts} +1 -1
- package/{xform/take.js → take.js} +4 -4
- package/{xform/throttle-time.d.ts → throttle-time.d.ts} +1 -1
- package/{xform/throttle-time.js → throttle-time.js} +3 -3
- package/{xform/throttle.d.ts → throttle.d.ts} +1 -1
- package/{xform/throttle.js → throttle.js} +3 -3
- package/{xform/toggle.d.ts → toggle.d.ts} +1 -1
- package/{xform/toggle.js → toggle.js} +2 -2
- package/trace.d.ts +3 -0
- package/{xform/trace.js → trace.js} +1 -1
- package/transduce.d.ts +1 -1
- package/transduce.js +4 -4
- package/{iter/tween.d.ts → tween.d.ts} +0 -0
- package/{iter/tween.js → tween.js} +2 -2
- package/{iter/vals.d.ts → vals.d.ts} +0 -0
- package/{iter/vals.js → vals.js} +0 -0
- package/{xform/word-wrap.d.ts → word-wrap.d.ts} +1 -1
- package/{xform/word-wrap.js → word-wrap.js} +8 -4
- package/{iter/wrap-sides.d.ts → wrap-sides.d.ts} +0 -0
- package/{iter/wrap-sides.js → wrap-sides.js} +3 -3
- package/{iter/zip.d.ts → zip.d.ts} +0 -0
- package/{iter/zip.js → zip.js} +0 -0
- package/func/renamer.d.ts +0 -3
- package/internal/ensure.d.ts +0 -3
- package/iter/dup.js +0 -10
- package/iter/palindrome.js +0 -12
- package/lib/index.js +0 -2228
- package/lib/index.js.map +0 -1
- package/lib/index.umd.js +0 -1
- package/lib/index.umd.js.map +0 -1
- package/rfn/frequencies.js +0 -8
- package/rfn/push-copy.d.ts +0 -3
- package/xform/flatten.js +0 -5
- package/xform/interpolate.js +0 -13
- package/xform/labeled.js +0 -8
- package/xform/map-deep.js +0 -9
- package/xform/mapcat-indexed.js +0 -8
- package/xform/mapcat.js +0 -8
- package/xform/match-first.js +0 -10
- package/xform/match-last.js +0 -10
- package/xform/multiplex.js +0 -6
- package/xform/page.js +0 -8
- package/xform/partition-sort.js +0 -13
- package/xform/peek.js +0 -5
- package/xform/pluck.js +0 -8
- package/xform/select-keys.js +0 -9
- package/xform/swizzle.js +0 -9
- package/xform/trace.d.ts +0 -3
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
import { isArray } from "@thi.ng/checks";
|
|
2
|
-
import { identity } from "@thi.ng/compose";
|
|
3
|
-
import { illegalState } from "@thi.ng/errors";
|
|
4
|
-
import {
|
|
5
|
-
import { isReduced } from "
|
|
1
|
+
import { isArray } from "@thi.ng/checks/is-array";
|
|
2
|
+
import { identity } from "@thi.ng/compose/identity";
|
|
3
|
+
import { illegalState } from "@thi.ng/errors/illegal-state";
|
|
4
|
+
import { __iter, iterator } from "./iterator.js";
|
|
5
|
+
import { isReduced } from "./reduced.js";
|
|
6
6
|
export function partitionSync(...args) {
|
|
7
|
-
const iter =
|
|
7
|
+
const iter = __iter(partitionSync, args, iterator);
|
|
8
8
|
if (iter)
|
|
9
9
|
return iter;
|
|
10
|
-
const { key, mergeOnly, reset, all, backPressure } =
|
|
10
|
+
const { key, mergeOnly, reset, all, backPressure } = {
|
|
11
|
+
key: identity,
|
|
12
|
+
mergeOnly: false,
|
|
13
|
+
reset: true,
|
|
14
|
+
all: true,
|
|
15
|
+
backPressure: 0,
|
|
16
|
+
...args[1],
|
|
17
|
+
};
|
|
11
18
|
const requiredKeys = isArray(args[0])
|
|
12
19
|
? new Set(args[0])
|
|
13
20
|
: args[0];
|
|
@@ -43,7 +50,7 @@ export function partitionSync(...args) {
|
|
|
43
50
|
currKeys.clear();
|
|
44
51
|
}
|
|
45
52
|
else {
|
|
46
|
-
curr =
|
|
53
|
+
curr = { ...curr };
|
|
47
54
|
}
|
|
48
55
|
}
|
|
49
56
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isIterable } from "@thi.ng/checks";
|
|
2
|
-
import { iterator } from "
|
|
3
|
-
import { partitionBy } from "./partition-by";
|
|
1
|
+
import { isIterable } from "@thi.ng/checks/is-iterable";
|
|
2
|
+
import { iterator } from "./iterator.js";
|
|
3
|
+
import { partitionBy } from "./partition-by.js";
|
|
4
4
|
export function partitionTime(period, src) {
|
|
5
5
|
return isIterable(src)
|
|
6
6
|
? iterator(partitionTime(period), src)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Predicate } from "@thi.ng/api";
|
|
2
|
-
import type { Transducer } from "
|
|
2
|
+
import type { Transducer } from "./api.js";
|
|
3
3
|
/**
|
|
4
4
|
* Transducer. Applies given predicate `pred` to each incoming value and
|
|
5
5
|
* collects values until the return value of the `fn` is truthy. Once this
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isReduced } from "
|
|
1
|
+
import { __iter, iterator } from "./iterator.js";
|
|
2
|
+
import { isReduced } from "./reduced.js";
|
|
3
3
|
export function partitionWhen(...args) {
|
|
4
|
-
return (
|
|
4
|
+
return (__iter(partitionWhen, args, iterator) ||
|
|
5
5
|
(([init, complete, reduce]) => {
|
|
6
6
|
const pred = args[0];
|
|
7
7
|
const f = args[1] === true ? pred() : pred;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __iter, iterator } from "./iterator.js";
|
|
2
2
|
export function partition(...args) {
|
|
3
|
-
const iter =
|
|
3
|
+
const iter = __iter(partition, args, iterator);
|
|
4
4
|
if (iter) {
|
|
5
5
|
return iter;
|
|
6
6
|
}
|
package/peek.js
ADDED
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ensureArrayLike } from "@thi.ng/arrays";
|
|
2
|
-
import { illegalArgs } from "@thi.ng/errors";
|
|
3
|
-
import { range } from "./range";
|
|
1
|
+
import { ensureArrayLike } from "@thi.ng/arrays/ensure-array";
|
|
2
|
+
import { illegalArgs } from "@thi.ng/errors/illegal-arguments";
|
|
3
|
+
import { range } from "./range.js";
|
|
4
4
|
export function* permutations(...src) {
|
|
5
5
|
const n = src.length - 1;
|
|
6
6
|
if (n < 0) {
|
package/pluck.js
ADDED
package/push-copy.d.ts
ADDED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { reducer } from "
|
|
1
|
+
import { reducer } from "./reduce.js";
|
|
2
2
|
export const pushCopy = () => reducer(() => [], (acc, x) => ((acc = acc.slice()).push(x), acc));
|
package/{rfn/push.js → push.js}
RENAMED
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { map } from "
|
|
2
|
-
import { permutations } from "./permutations";
|
|
3
|
-
import { range } from "./range";
|
|
4
|
-
import { zip } from "./zip";
|
|
1
|
+
import { map } from "./map.js";
|
|
2
|
+
import { permutations } from "./permutations.js";
|
|
3
|
+
import { range } from "./range.js";
|
|
4
|
+
import { zip } from "./zip.js";
|
|
5
5
|
/**
|
|
6
6
|
* If called with one vector, yields an iterator for the n-dimensional
|
|
7
7
|
* interval: `[[0, 0,...] .. [x, y,...])`. If called with two vectors,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { IReducible, ReductionFn } from "
|
|
2
|
-
import { Reduced } from "
|
|
1
|
+
import type { IReducible, ReductionFn } from "./api.js";
|
|
2
|
+
import { Reduced } from "./reduced.js";
|
|
3
3
|
export declare function range(): Range;
|
|
4
4
|
export declare function range(to: number): Range;
|
|
5
5
|
export declare function range(from: number, to: number): Range;
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { illegalArity } from "@thi.ng/errors";
|
|
2
|
-
import { range } from "./range";
|
|
1
|
+
import { illegalArity } from "@thi.ng/errors/illegal-arity";
|
|
2
|
+
import { range } from "./range.js";
|
|
3
3
|
export function* range2d(...args) {
|
|
4
4
|
let fromX, toX, stepX;
|
|
5
5
|
let fromY, toY, stepY;
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { illegalArity } from "@thi.ng/errors";
|
|
2
|
-
import { range } from "./range";
|
|
1
|
+
import { illegalArity } from "@thi.ng/errors/illegal-arity";
|
|
2
|
+
import { range } from "./range.js";
|
|
3
3
|
export function* range3d(...args) {
|
|
4
4
|
let fromX, toX, stepX;
|
|
5
5
|
let fromY, toY, stepY;
|
package/reduce.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Fn0, FnAny } from "@thi.ng/api";
|
|
2
|
-
import type { IReducible, Reducer, ReductionFn } from "./api";
|
|
2
|
+
import type { IReducible, Reducer, ReductionFn } from "./api.js";
|
|
3
3
|
export declare function reduce<A, B>(rfn: Reducer<A, B>, xs: Iterable<B>): A;
|
|
4
4
|
export declare function reduce<A, B>(rfn: Reducer<A, B>, acc: A, xs: Iterable<B>): A;
|
|
5
5
|
export declare function reduce<A, B>(rfn: Reducer<A, B>, xs: IReducible<A, B>): A;
|
package/reduce.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { implementsFunction
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { implementsFunction } from "@thi.ng/checks/implements-function";
|
|
2
|
+
import { isArrayLike } from "@thi.ng/checks/is-arraylike";
|
|
3
|
+
import { isIterable } from "@thi.ng/checks/is-iterable";
|
|
4
|
+
import { illegalArity } from "@thi.ng/errors/illegal-arity";
|
|
5
|
+
import { isReduced, unreduced } from "./reduced.js";
|
|
4
6
|
const parseArgs = (args) => args.length === 2
|
|
5
7
|
? [undefined, args[1]]
|
|
6
8
|
: args.length === 3
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Reducer } from "
|
|
1
|
+
import type { Reducer } from "./api.js";
|
|
2
2
|
export declare function reductions<A, B>(rfn: Reducer<A, B>): Reducer<A[], B>;
|
|
3
3
|
export declare function reductions<A, B>(rfn: Reducer<A, B>, xs: Iterable<B>): A[];
|
|
4
4
|
//# sourceMappingURL=reductions.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { reduce } from "
|
|
2
|
-
import { isReduced, reduced } from "
|
|
1
|
+
import { reduce } from "./reduce.js";
|
|
2
|
+
import { isReduced, reduced } from "./reduced.js";
|
|
3
3
|
export function reductions(rfn, xs) {
|
|
4
4
|
const [init, complete, _reduce] = rfn;
|
|
5
5
|
return xs
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IObjectOf } from "@thi.ng/api";
|
|
2
|
-
import type { Reducer, Transducer } from "
|
|
2
|
+
import type { Reducer, Transducer } from "./api.js";
|
|
3
3
|
export declare function rename<A, B>(kmap: IObjectOf<PropertyKey> | Array<PropertyKey>, rfn?: Reducer<B, [PropertyKey, A]>): Transducer<A[], B>;
|
|
4
4
|
export declare function rename<A, B>(kmap: IObjectOf<PropertyKey> | Array<PropertyKey>, rfn: Reducer<B, [PropertyKey, A]>, src: Iterable<A[]>): IterableIterator<B>;
|
|
5
5
|
//# sourceMappingURL=rename.d.ts.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { isArray } from "@thi.ng/checks";
|
|
2
|
-
import { comp } from "
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { isArray } from "@thi.ng/checks/is-array";
|
|
2
|
+
import { comp } from "./comp.js";
|
|
3
|
+
import { filter } from "./filter.js";
|
|
4
|
+
import { __iter } from "./iterator.js";
|
|
5
|
+
import { map } from "./map.js";
|
|
6
|
+
import { renamer } from "./renamer.js";
|
|
7
|
+
import { transduce } from "./transduce.js";
|
|
8
8
|
export function rename(...args) {
|
|
9
|
-
const iter = args.length > 2 &&
|
|
9
|
+
const iter = args.length > 2 && __iter(rename, args);
|
|
10
10
|
if (iter) {
|
|
11
11
|
return iter;
|
|
12
12
|
}
|
package/renamer.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IObjectOf } from "@thi.ng/api";
|
|
2
|
+
/**
|
|
3
|
+
* Higher order helper function for {@link rename} transducer. Takes an object
|
|
4
|
+
* of key mappings and returns function applying these mapping/renames.
|
|
5
|
+
*
|
|
6
|
+
* @param kmap
|
|
7
|
+
*/
|
|
8
|
+
export declare const renamer: (kmap: IObjectOf<PropertyKey>) => (x: any) => any;
|
|
9
|
+
//# sourceMappingURL=renamer.d.ts.map
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Higher order helper function for {@link rename} transducer. Takes an object
|
|
3
|
+
* of key mappings and returns function applying these mapping/renames.
|
|
4
|
+
*
|
|
5
|
+
* @param kmap
|
|
6
|
+
*/
|
|
1
7
|
export const renamer = (kmap) => {
|
|
2
8
|
const ks = Object.keys(kmap);
|
|
3
9
|
const [a2, b2, c2] = ks;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/run.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Fn } from "@thi.ng/api";
|
|
2
|
-
import type { IReducible, TxLike } from "./api";
|
|
1
|
+
import type { Fn } from "@thi.ng/api";
|
|
2
|
+
import type { IReducible, TxLike } from "./api.js";
|
|
3
3
|
/**
|
|
4
4
|
* Transforms `xs` with given transducer and optional side effect
|
|
5
5
|
* without any reduction step. If `fx` is given it will be called with
|
package/run.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NO_OP } from "@thi.ng/api";
|
|
2
|
-
import { transduce } from "./transduce";
|
|
1
|
+
import { NO_OP } from "@thi.ng/api/api";
|
|
2
|
+
import { transduce } from "./transduce.js";
|
|
3
3
|
const NO_OP_REDUCER = [NO_OP, NO_OP, NO_OP];
|
|
4
4
|
export function run(tx, ...args) {
|
|
5
5
|
if (args.length === 1) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IRandom } from "@thi.ng/random";
|
|
2
|
-
import type { Transducer } from "
|
|
1
|
+
import type { IRandom } from "@thi.ng/random";
|
|
2
|
+
import type { Transducer } from "./api.js";
|
|
3
3
|
/**
|
|
4
4
|
* Transducer which only yields values with given `prob` probability
|
|
5
5
|
* (0.0 .. 1.0 range). Supports custom PRNGs via
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { SYSTEM } from "@thi.ng/random";
|
|
2
|
-
import { compR } from "
|
|
3
|
-
import {
|
|
1
|
+
import { SYSTEM } from "@thi.ng/random/system";
|
|
2
|
+
import { compR } from "./compr.js";
|
|
3
|
+
import { __iter } from "./iterator.js";
|
|
4
4
|
export function sample(...args) {
|
|
5
|
-
const iter =
|
|
5
|
+
const iter = __iter(sample, args);
|
|
6
6
|
if (iter) {
|
|
7
7
|
return iter;
|
|
8
8
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ensureReduced, isReduced, unreduced } from "
|
|
1
|
+
import { __iter, iterator } from "./iterator.js";
|
|
2
|
+
import { ensureReduced, isReduced, unreduced } from "./reduced.js";
|
|
3
3
|
export function scan(...args) {
|
|
4
|
-
return ((args.length > 2 &&
|
|
4
|
+
return ((args.length > 2 && __iter(scan, args, iterator)) ||
|
|
5
5
|
(([inito, completeo, reduceo]) => {
|
|
6
6
|
const [initi, completei, reducei] = args[0];
|
|
7
7
|
let acc = args.length > 1 && args[1] != null ? args[1] : initi();
|
package/select-keys.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { isIterable } from "@thi.ng/checks/is-iterable";
|
|
2
|
+
import { keySelector } from "./key-selector.js";
|
|
3
|
+
import { iterator1 } from "./iterator.js";
|
|
4
|
+
import { map } from "./map.js";
|
|
5
|
+
export function selectKeys(keys, src) {
|
|
6
|
+
return isIterable(src)
|
|
7
|
+
? iterator1(selectKeys(keys), src)
|
|
8
|
+
: map(keySelector(keys));
|
|
9
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Fn } from "@thi.ng/api";
|
|
2
|
-
import type { Transducer } from "
|
|
2
|
+
import type { Transducer } from "./api.js";
|
|
3
3
|
/**
|
|
4
4
|
* Helper transducer. Applies given `fn` to each input value, presumably
|
|
5
5
|
* for side effects. Discards function's result and yields original
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MaybeDeref } from "@thi.ng/api";
|
|
2
|
-
import type { Transducer } from "
|
|
1
|
+
import { MaybeDeref } from "@thi.ng/api/deref";
|
|
2
|
+
import type { Transducer } from "./api.js";
|
|
3
3
|
/**
|
|
4
4
|
* Sliding window transducer, similar to `partition(size, 1)`, but
|
|
5
5
|
* supports initially partially filled windows, if `partial` is set to
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { deref } from "@thi.ng/api";
|
|
2
|
-
import { compR } from "
|
|
3
|
-
import {
|
|
1
|
+
import { deref } from "@thi.ng/api/deref";
|
|
2
|
+
import { compR } from "./compr.js";
|
|
3
|
+
import { __iter } from "./iterator.js";
|
|
4
4
|
export function slidingWindow(...args) {
|
|
5
|
-
const iter =
|
|
5
|
+
const iter = __iter(slidingWindow, args);
|
|
6
6
|
if (iter)
|
|
7
7
|
return iter;
|
|
8
8
|
const size = args[0];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Predicate } from "@thi.ng/api";
|
|
2
|
-
import type { Reducer } from "
|
|
2
|
+
import type { Reducer } from "./api.js";
|
|
3
3
|
/**
|
|
4
4
|
* Similar to {@link (every:1)} reducer, but only requires at least 1 value to
|
|
5
5
|
* succeed predicate test (and then immediately terminates with `true`
|
package/{rfn/some.js → some.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $$reduce, reducer } from "
|
|
2
|
-
import { reduced } from "
|
|
1
|
+
import { $$reduce, reducer } from "./reduce.js";
|
|
2
|
+
import { reduced } from "./reduced.js";
|
|
3
3
|
export function some(...args) {
|
|
4
4
|
const res = $$reduce(some, args);
|
|
5
5
|
if (res !== undefined) {
|
|
File without changes
|
package/step.d.ts
CHANGED
package/step.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ensureTransducer } from "./
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { ensureTransducer } from "./ensure.js";
|
|
2
|
+
import { push } from "./push.js";
|
|
3
|
+
import { isReduced } from "./reduced.js";
|
|
4
4
|
/**
|
|
5
5
|
* Single-step transducer execution wrapper.
|
|
6
6
|
* Returns array if transducer produces multiple results
|
package/{rfn/str.js → str.js}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { shuffle } from "@thi.ng/arrays";
|
|
2
|
-
import {
|
|
3
|
-
import { isReduced } from "
|
|
1
|
+
import { shuffle } from "@thi.ng/arrays/shuffle";
|
|
2
|
+
import { __iter, iterator } from "./iterator.js";
|
|
3
|
+
import { isReduced } from "./reduced.js";
|
|
4
4
|
export function streamShuffle(...args) {
|
|
5
|
-
return (
|
|
5
|
+
return (__iter(streamShuffle, args, iterator) ||
|
|
6
6
|
(([init, complete, reduce]) => {
|
|
7
7
|
const n = args[0];
|
|
8
8
|
const maxSwaps = args[1] || n;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { binarySearch } from "@thi.ng/arrays";
|
|
2
|
-
import { __drain } from "
|
|
3
|
-
import { __sortOpts } from "
|
|
4
|
-
import {
|
|
1
|
+
import { binarySearch } from "@thi.ng/arrays/binary-search";
|
|
2
|
+
import { __drain } from "./internal/drain.js";
|
|
3
|
+
import { __sortOpts } from "./internal/sort-opts.js";
|
|
4
|
+
import { __iter, iterator } from "./iterator.js";
|
|
5
5
|
export function streamSort(...args) {
|
|
6
|
-
const iter =
|
|
6
|
+
const iter = __iter(streamSort, args, iterator);
|
|
7
7
|
if (iter) {
|
|
8
8
|
return iter;
|
|
9
9
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { isIterable } from "@thi.ng/checks";
|
|
2
|
-
import { comp } from "
|
|
3
|
-
import { iterator } from "
|
|
4
|
-
import { mapKeys } from "./map-keys";
|
|
5
|
-
import { partition } from "./partition";
|
|
6
|
-
import { partitionOf } from "./partition-of";
|
|
7
|
-
import { rename } from "./rename";
|
|
1
|
+
import { isIterable } from "@thi.ng/checks/is-iterable";
|
|
2
|
+
import { comp } from "./comp.js";
|
|
3
|
+
import { iterator } from "./iterator.js";
|
|
4
|
+
import { mapKeys } from "./map-keys.js";
|
|
5
|
+
import { partition } from "./partition.js";
|
|
6
|
+
import { partitionOf } from "./partition-of.js";
|
|
7
|
+
import { rename } from "./rename.js";
|
|
8
8
|
export function struct(fields, src) {
|
|
9
9
|
return isIterable(src)
|
|
10
10
|
? iterator(struct(fields), src)
|
package/{rfn/sub.js → sub.js}
RENAMED