@thi.ng/bidir-index 1.2.0 → 1.3.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,12 @@ 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
+ ## [1.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/bidir-index@1.3.0) (2025-06-09)
15
+
16
+ #### 🚀 Features
17
+
18
+ - add `.addAllUnique()` & `.getAllUnique()` ([175e3dc](https://github.com/thi-ng/umbrella/commit/175e3dc))
19
+
14
20
  ## [1.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/bidir-index@1.2.0) (2025-04-30)
15
21
 
16
22
  #### 🚀 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
  >
@@ -67,7 +67,7 @@ For Node.js REPL:
67
67
  const bi = await import("@thi.ng/bidir-index");
68
68
  ```
69
69
 
70
- Package sizes (brotli'd, pre-treeshake): ESM: 854 bytes
70
+ Package sizes (brotli'd, pre-treeshake): ESM: 884 bytes
71
71
 
72
72
  ## Dependencies
73
73
 
package/bidir-index.d.ts CHANGED
@@ -64,6 +64,13 @@ export declare class BidirIndex<T> {
64
64
  * @param keys
65
65
  */
66
66
  addAll(keys: Iterable<T>): number[];
67
+ /**
68
+ * Similar to {@link BidirIndex.addAll}, but returns indexed key IDs as ES6
69
+ * Set, thereby removing any duplicates present in `keys`.
70
+ *
71
+ * @param keys
72
+ */
73
+ addAllUnique(keys: Iterable<T>): Set<number>;
67
74
  /**
68
75
  * Removes bi-directional mapping for given `key` from the index. Returns
69
76
  * true if successful.
@@ -99,6 +106,14 @@ export declare class BidirIndex<T> {
99
106
  * @param fail
100
107
  */
101
108
  getAll(keys: Iterable<T>, fail?: boolean): number[];
109
+ /**
110
+ * Similar to {@link BidirIndex.getAll}, but returns result as ES6 Set,
111
+ * thereby removing any duplicates in `keys`.
112
+ *
113
+ * @param keys
114
+ * @param fail
115
+ */
116
+ getAllUnique(keys: Iterable<T>, fail?: boolean): Set<number>;
102
117
  /**
103
118
  * Returns array of matching keys for all given IDs. If `fail` is true
104
119
  * (default: false), throws error if any of the given IDs is
package/bidir-index.js CHANGED
@@ -97,6 +97,19 @@ class BidirIndex {
97
97
  }
98
98
  return res;
99
99
  }
100
+ /**
101
+ * Similar to {@link BidirIndex.addAll}, but returns indexed key IDs as ES6
102
+ * Set, thereby removing any duplicates present in `keys`.
103
+ *
104
+ * @param keys
105
+ */
106
+ addAllUnique(keys) {
107
+ const res = /* @__PURE__ */ new Set();
108
+ for (let k of keys) {
109
+ res.add(this.add(k));
110
+ }
111
+ return res;
112
+ }
100
113
  /**
101
114
  * Removes bi-directional mapping for given `key` from the index. Returns
102
115
  * true if successful.
@@ -142,6 +155,16 @@ class BidirIndex {
142
155
  getAll(keys, fail = false) {
143
156
  return __iterate(this.fwd, keys, fail);
144
157
  }
158
+ /**
159
+ * Similar to {@link BidirIndex.getAll}, but returns result as ES6 Set,
160
+ * thereby removing any duplicates in `keys`.
161
+ *
162
+ * @param keys
163
+ * @param fail
164
+ */
165
+ getAllUnique(keys, fail = false) {
166
+ return new Set(__iterate(this.fwd, keys, fail));
167
+ }
145
168
  /**
146
169
  * Returns array of matching keys for all given IDs. If `fail` is true
147
170
  * (default: false), throws error if any of the given IDs is
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/bidir-index",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Bi-directional index mapping arbitrary keys to numeric IDs & vice versa",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -39,8 +39,8 @@
39
39
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
40
40
  },
41
41
  "devDependencies": {
42
- "esbuild": "^0.25.3",
43
- "typedoc": "^0.28.3",
42
+ "esbuild": "^0.25.5",
43
+ "typedoc": "^0.28.5",
44
44
  "typescript": "^5.8.3"
45
45
  },
46
46
  "keywords": [
@@ -89,5 +89,5 @@
89
89
  ],
90
90
  "year": 2022
91
91
  },
92
- "gitHead": "4354686a6fb1f82c09ea48f92f87786191b231a0\n"
92
+ "gitHead": "93cdcd8db4d4669561a7f0ebc47697bdbfd04214\n"
93
93
  }