@thi.ng/transducers 9.1.0 → 9.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -1
- package/README.md +3 -2
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +13 -10
- package/sync-tuples.d.ts +31 -0
- package/sync-tuples.js +27 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-08-
|
|
3
|
+
- **Last updated**: 2024-08-19T13:45:57Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
## [9.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/transducers@9.2.0) (2024-08-19)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- add syncTuples() transducer ([d3b77bd](https://github.com/thi-ng/umbrella/commit/d3b77bd))
|
|
17
|
+
|
|
12
18
|
## [9.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/transducers@9.1.0) (2024-08-13)
|
|
13
19
|
|
|
14
20
|
#### 🚀 Features
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
> [!NOTE]
|
|
10
|
-
> This is one of
|
|
10
|
+
> This is one of 199 standalone projects, maintained as part
|
|
11
11
|
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
|
|
12
12
|
> and anti-framework.
|
|
13
13
|
>
|
|
@@ -150,7 +150,7 @@ For Node.js REPL:
|
|
|
150
150
|
const tx = await import("@thi.ng/transducers");
|
|
151
151
|
```
|
|
152
152
|
|
|
153
|
-
Package sizes (brotli'd, pre-treeshake): ESM:
|
|
153
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 9.05 KB
|
|
154
154
|
|
|
155
155
|
## Dependencies
|
|
156
156
|
|
|
@@ -991,6 +991,7 @@ transduce(map((x) => x*10), push(), range(4))
|
|
|
991
991
|
- [streamShuffle](https://github.com/thi-ng/umbrella/tree/develop/packages/transducers/src/stream-shuffle.ts)
|
|
992
992
|
- [streamSort](https://github.com/thi-ng/umbrella/tree/develop/packages/transducers/src/stream-sort.ts)
|
|
993
993
|
- [struct](https://github.com/thi-ng/umbrella/tree/develop/packages/transducers/src/struct.ts)
|
|
994
|
+
- [syncTuples](https://github.com/thi-ng/umbrella/tree/develop/packages/transducers/src/syncTuples.ts)
|
|
994
995
|
- [swizzle](https://github.com/thi-ng/umbrella/tree/develop/packages/transducers/src/swizzle.ts)
|
|
995
996
|
- [takeLast](https://github.com/thi-ng/umbrella/tree/develop/packages/transducers/src/take-last.ts)
|
|
996
997
|
- [takeNth](https://github.com/thi-ng/umbrella/tree/develop/packages/transducers/src/take-nth.ts)
|
package/index.d.ts
CHANGED
|
@@ -110,6 +110,7 @@ export * from "./sliding-window.js";
|
|
|
110
110
|
export * from "./stream-shuffle.js";
|
|
111
111
|
export * from "./stream-sort.js";
|
|
112
112
|
export * from "./struct.js";
|
|
113
|
+
export * from "./sync-tuples.js";
|
|
113
114
|
export * from "./swizzle.js";
|
|
114
115
|
export * from "./take-nth.js";
|
|
115
116
|
export * from "./take-last.js";
|
package/index.js
CHANGED
|
@@ -110,6 +110,7 @@ export * from "./sliding-window.js";
|
|
|
110
110
|
export * from "./stream-shuffle.js";
|
|
111
111
|
export * from "./stream-sort.js";
|
|
112
112
|
export * from "./struct.js";
|
|
113
|
+
export * from "./sync-tuples.js";
|
|
113
114
|
export * from "./swizzle.js";
|
|
114
115
|
export * from "./take-nth.js";
|
|
115
116
|
export * from "./take-last.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/transducers",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.2.0",
|
|
4
4
|
"description": "Collection of ~170 lightweight, composable transducers, reducers, generators, iterators for functional data transformations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -40,14 +40,14 @@
|
|
|
40
40
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@thi.ng/api": "^8.11.
|
|
44
|
-
"@thi.ng/arrays": "^2.
|
|
45
|
-
"@thi.ng/checks": "^3.6.
|
|
46
|
-
"@thi.ng/compare": "^2.4.
|
|
47
|
-
"@thi.ng/compose": "^3.0.
|
|
48
|
-
"@thi.ng/errors": "^2.5.
|
|
49
|
-
"@thi.ng/math": "^5.11.
|
|
50
|
-
"@thi.ng/random": "^4.0.
|
|
43
|
+
"@thi.ng/api": "^8.11.9",
|
|
44
|
+
"@thi.ng/arrays": "^2.10.0",
|
|
45
|
+
"@thi.ng/checks": "^3.6.11",
|
|
46
|
+
"@thi.ng/compare": "^2.4.1",
|
|
47
|
+
"@thi.ng/compose": "^3.0.12",
|
|
48
|
+
"@thi.ng/errors": "^2.5.15",
|
|
49
|
+
"@thi.ng/math": "^5.11.8",
|
|
50
|
+
"@thi.ng/random": "^4.0.3"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@microsoft/api-extractor": "^7.47.5",
|
|
@@ -527,6 +527,9 @@
|
|
|
527
527
|
"./symmetric": {
|
|
528
528
|
"default": "./symmetric.js"
|
|
529
529
|
},
|
|
530
|
+
"./sync-tuples": {
|
|
531
|
+
"default": "./sync-tuples.js"
|
|
532
|
+
},
|
|
530
533
|
"./take-last": {
|
|
531
534
|
"default": "./take-last.js"
|
|
532
535
|
},
|
|
@@ -596,5 +599,5 @@
|
|
|
596
599
|
],
|
|
597
600
|
"year": 2016
|
|
598
601
|
},
|
|
599
|
-
"gitHead": "
|
|
602
|
+
"gitHead": "bfbc227cf5ca2d3c2984b3d4713eebd6225cbd54\n"
|
|
600
603
|
}
|
package/sync-tuples.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Nullable } from "@thi.ng/api";
|
|
2
|
+
import type { Transducer } from "./api.js";
|
|
3
|
+
/**
|
|
4
|
+
* Transducer which receives fixed-`size` tuples of possibly nullish values and
|
|
5
|
+
* only emits tuples which are fully populated (with non-nullish values),
|
|
6
|
+
* keeping track of each component's last valid value and using those to fill
|
|
7
|
+
* empty components if needed.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* The following behavior is used:
|
|
11
|
+
* - 1st input: `[null,null]` => no output
|
|
12
|
+
* - 2nd input: `[0, null]` => no output
|
|
13
|
+
* - 3rd input: `[null, 1]` => `[0, 1]`
|
|
14
|
+
* - 4th input: `[1, 2]` => `[1, 2]`
|
|
15
|
+
* - 5th input: `[null, 3]` => `[1, 3]`
|
|
16
|
+
* - 6th input: `[]` => no output
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts tangle:../export/sync-tuples.ts
|
|
20
|
+
* import { syncTuples } from "@thi.ng/transducers";
|
|
21
|
+
*
|
|
22
|
+
* console.log(
|
|
23
|
+
* [...syncTuples(2, [[], [0], [0, 0], [1, 1], [, 2], []])]
|
|
24
|
+
* );
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @param size
|
|
28
|
+
*/
|
|
29
|
+
export declare function syncTuples<T>(size: number): Transducer<Nullable<T>[], T[]>;
|
|
30
|
+
export declare function syncTuples<T>(size: number, src: Iterable<Nullable<T>[]>): IterableIterator<T[]>;
|
|
31
|
+
//# sourceMappingURL=sync-tuples.d.ts.map
|
package/sync-tuples.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { __iter, iterator } from "./iterator.js";
|
|
2
|
+
function syncTuples(...args) {
|
|
3
|
+
const iter = __iter(syncTuples, args, iterator);
|
|
4
|
+
if (iter) return iter;
|
|
5
|
+
const size = args[0];
|
|
6
|
+
return ([init, complete, reduce]) => {
|
|
7
|
+
const prev = new Array(size);
|
|
8
|
+
return [
|
|
9
|
+
init,
|
|
10
|
+
complete,
|
|
11
|
+
(acc, x) => {
|
|
12
|
+
let partial = false;
|
|
13
|
+
let filled = true;
|
|
14
|
+
for (let i = 0; i < size; i++) {
|
|
15
|
+
if (x[i] != null) {
|
|
16
|
+
prev[i] = x[i];
|
|
17
|
+
partial = true;
|
|
18
|
+
} else if (prev[i] == null) filled = false;
|
|
19
|
+
}
|
|
20
|
+
return partial && filled ? reduce(acc, prev.slice()) : acc;
|
|
21
|
+
}
|
|
22
|
+
];
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
syncTuples
|
|
27
|
+
};
|