@thi.ng/transducers 9.3.0 → 9.4.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2025-04-30T12:52:32Z
3
+ - **Last updated**: 2025-06-09T17:24:08Z
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.
@@ -11,6 +11,18 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
11
11
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
12
12
  and/or version bumps of transitive dependencies.
13
13
 
14
+ ## [9.4.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/transducers@9.4.0) (2025-06-09)
15
+
16
+ #### 🚀 Features
17
+
18
+ - add join() transducer ([3bbc88d](https://github.com/thi-ng/umbrella/commit/3bbc88d))
19
+
20
+ ### [9.3.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/transducers@9.3.1) (2025-05-28)
21
+
22
+ #### 🩹 Bug fixes
23
+
24
+ - fix [#500](https://github.com/thi-ng/umbrella/issues/500), update initial timestamp handling in `throttleTime()` ([6a8d88e](https://github.com/thi-ng/umbrella/commit/6a8d88e))
25
+
14
26
  ## [9.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/transducers@9.3.0) (2025-04-30)
15
27
 
16
28
  #### 🚀 Features
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  [![Mastodon Follow](https://img.shields.io/mastodon/follow/109331703950160316?domain=https%3A%2F%2Fmastodon.thi.ng&style=social)](https://mastodon.thi.ng/@toxi)
8
8
 
9
9
  > [!NOTE]
10
- > This is one of 206 standalone projects, maintained as part
10
+ > This is one of 209 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: 9.16 KB
153
+ Package sizes (brotli'd, pre-treeshake): ESM: 9.21 KB
154
154
 
155
155
  ## Dependencies
156
156
 
package/frequencies.d.ts CHANGED
@@ -1,5 +1,9 @@
1
1
  import type { Fn } from "@thi.ng/api";
2
2
  import type { Reducer } from "./api.js";
3
+ /**
4
+ * Reducer. Computes histogram of given inputs. Returns a Map with unique inputs
5
+ * as keys and their occurrences as values.
6
+ */
3
7
  export declare function frequencies<A>(): Reducer<A, Map<A, number>>;
4
8
  export declare function frequencies<A>(src: Iterable<A>): Map<A, number>;
5
9
  export declare function frequencies<A, B>(key: Fn<A, B>): Reducer<A, Map<B, number>>;
package/index.d.ts CHANGED
@@ -72,6 +72,7 @@ export * from "./interpolate.js";
72
72
  export * from "./interpolate-hermite.js";
73
73
  export * from "./interpolate-linear.js";
74
74
  export * from "./interpose.js";
75
+ export * from "./join.js";
75
76
  export * from "./keep.js";
76
77
  export * from "./labeled.js";
77
78
  export * from "./length.js";
package/index.js CHANGED
@@ -72,6 +72,7 @@ export * from "./interpolate.js";
72
72
  export * from "./interpolate-hermite.js";
73
73
  export * from "./interpolate-linear.js";
74
74
  export * from "./interpose.js";
75
+ export * from "./join.js";
75
76
  export * from "./keep.js";
76
77
  export * from "./labeled.js";
77
78
  export * from "./length.js";
package/join.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ import type { Transducer } from "./api.js";
2
+ /**
3
+ * Transducer which accepts iterables as value and joins each into a string
4
+ * using given separator.
5
+ *
6
+ * @example
7
+ * ```ts tangle:../export/join.ts
8
+ * import { join } from "@thi.ng/transducers";
9
+ *
10
+ * console.log([...join("/", [[1, 2, 3], [4, 5]])]);
11
+ * // [ '1/2/3', '4/5' ]
12
+ * ```
13
+ *
14
+ * @param sep
15
+ */
16
+ export declare function join(sep?: string): Transducer<Iterable<any>, string>;
17
+ export declare function join(sep: string, src?: Iterable<Iterable<any>>): IterableIterator<string>;
18
+ //# sourceMappingURL=join.d.ts.map
package/join.js ADDED
@@ -0,0 +1,16 @@
1
+ import { isIterable } from "@thi.ng/checks/is-iterable";
2
+ import { iterator1 } from "./iterator.js";
3
+ import { compR } from "./compr.js";
4
+ import { ensureArray } from "@thi.ng/arrays/ensure-array";
5
+ function join(sep = "", src) {
6
+ return isIterable(src) ? iterator1(join(sep), src) : (rfn) => {
7
+ const r = rfn[2];
8
+ return compR(
9
+ rfn,
10
+ (acc, x) => r(acc, ensureArray(x).join(sep))
11
+ );
12
+ };
13
+ }
14
+ export {
15
+ join
16
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/transducers",
3
- "version": "9.3.0",
3
+ "version": "9.4.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",
@@ -43,19 +43,19 @@
43
43
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
44
44
  },
45
45
  "dependencies": {
46
- "@thi.ng/api": "^8.11.27",
47
- "@thi.ng/arrays": "^2.11.0",
48
- "@thi.ng/checks": "^3.7.7",
49
- "@thi.ng/compare": "^2.4.19",
50
- "@thi.ng/compose": "^3.0.30",
51
- "@thi.ng/errors": "^2.5.33",
52
- "@thi.ng/math": "^5.11.27",
53
- "@thi.ng/random": "^4.1.18",
54
- "@thi.ng/timestamp": "^1.1.12"
46
+ "@thi.ng/api": "^8.11.29",
47
+ "@thi.ng/arrays": "^2.11.2",
48
+ "@thi.ng/checks": "^3.7.9",
49
+ "@thi.ng/compare": "^2.4.21",
50
+ "@thi.ng/compose": "^3.0.32",
51
+ "@thi.ng/errors": "^2.5.35",
52
+ "@thi.ng/math": "^5.11.29",
53
+ "@thi.ng/random": "^4.1.20",
54
+ "@thi.ng/timestamp": "^1.1.14"
55
55
  },
56
56
  "devDependencies": {
57
- "esbuild": "^0.25.3",
58
- "typedoc": "^0.28.3",
57
+ "esbuild": "^0.25.5",
58
+ "typedoc": "^0.28.5",
59
59
  "typescript": "^5.8.3"
60
60
  },
61
61
  "keywords": [
@@ -267,6 +267,9 @@
267
267
  "./iterator": {
268
268
  "default": "./iterator.js"
269
269
  },
270
+ "./join": {
271
+ "default": "./join.js"
272
+ },
270
273
  "./juxtr": {
271
274
  "default": "./juxtr.js"
272
275
  },
@@ -606,5 +609,5 @@
606
609
  ],
607
610
  "year": 2016
608
611
  },
609
- "gitHead": "4354686a6fb1f82c09ea48f92f87786191b231a0\n"
612
+ "gitHead": "93cdcd8db4d4669561a7f0ebc47697bdbfd04214\n"
610
613
  }
package/throttle-time.js CHANGED
@@ -4,7 +4,7 @@ import { iterator1 } from "./iterator.js";
4
4
  import { throttle } from "./throttle.js";
5
5
  function throttleTime(delay, src) {
6
6
  return isIterable(src) ? iterator1(throttleTime(delay), src) : throttle(() => {
7
- let prev = 0;
7
+ let prev = now();
8
8
  return () => {
9
9
  const t = now();
10
10
  return timeDiff(prev, t) >= delay ? (prev = t, true) : false;