@rimbu/common 2.0.2 → 2.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/README.md CHANGED
@@ -1,122 +1,339 @@
1
1
  <p align="center">
2
- <img src="https://github.com/rimbu-org/rimbu/raw/main/assets/rimbu_logo.svg" />
2
+ <img src="https://github.com/rimbu-org/rimbu/raw/main/assets/rimbu_logo.svg" height="96" alt="Rimbu Logo" />
3
3
  </p>
4
4
 
5
- [![npm version](https://badge.fury.io/js/@rimbu%2Fcommon.svg)](https://www.npmjs.com/package/@rimbu/common) [![Deno](https://shield.deno.dev/x/rimbu)](http://deno.land/x/rimbu)
5
+ <div align="center">
6
6
 
7
- ![Licence](https://img.shields.io/github/license/rimbu-org/rimbu)
7
+ [![npm version](https://badge.fury.io/js/@rimbu%2Fcommon.svg)](https://www.npmjs.com/package/@rimbu/common)
8
+ ![License](https://img.shields.io/github/license/rimbu-org/rimbu)
9
+ ![Types Included](https://img.shields.io/badge/TypeScript-ready-blue)
10
+ ![Node](https://img.shields.io/badge/Node-18+-6DA55F?logo=node.js&logoColor=white)
11
+ ![Bun](https://img.shields.io/badge/Bun-%23000000.svg)
12
+ ![ESM + CJS](https://img.shields.io/badge/modules-ESM%20%2B%20CJS-informational)
8
13
 
9
- # @rimbu/common
14
+ </div>
10
15
 
11
- Welcome to `@rimbu/common`! This package exports essential types and utilities that are widely used across various Rimbu packages. It provides a robust foundation for building efficient and reliable applications.
16
+ # `@rimbu/common`
12
17
 
13
- ### Overview of most important Exported Types:
18
+ **Shared utility types and helpers for the Rimbu ecosystem.**
14
19
 
15
- | Name | Description |
16
- | --------------- | ----------------------------------------------------------------------------------------------------- |
17
- | `CollectFun` | Types and values used in various `collect` methods within collections. |
18
- | `Comp` | Interface and default implementations of comparison functions for ordering/sorting values. |
19
- | `Eq` | Interface and default implementations of equality functions for checking value equality. |
20
- | `Err` | Functions to easily create error-throwing behavior as fallback values. |
21
- | `FastIterable` | An `Iterable` implementation that offers better performance than standard iterables. |
22
- | `IndexRange` | Utilities for selecting index ranges in indexed collections. |
23
- | `OptLazy` | A utility to provide values that can optionally be lazy. |
24
- | `Range` | Utility types to specify ranges for comparable types. |
25
- | `Reducer` | An API to create reusable logic pieces that process data streams, which can be processed in parallel. |
26
- | `TraverseState` | A utility for loops to maintain traversal state. |
27
- | `Update` | A standard way to update a value. |
20
+ `@rimbu/common` provides the low-level **building blocks** used throughout Rimbu:
28
21
 
29
- ### Documentation
22
+ - **Equality & comparison** helpers (`Eq`, `Comp`) for consistent value semantics.
23
+ - **Range & index utilities** (`Range`, `IndexRange`) for working with slices and windows.
24
+ - **Lazy values & updates** (`OptLazy`, `OptLazyOr`, `AsyncOptLazy`, `Update`) for ergonomic APIs.
25
+ - **Traversal helpers** (`CollectFun`, `TraverseState`) for efficient collection operations.
26
+ - **Type-level utilities** (`SuperOf`, `SubOf`, `RelatedTo`, `ArrayNonEmpty`, `StringNonEmpty`, `ToJSON`) for stronger TypeScript modelling.
30
27
 
31
- For complete documentation, please visit the [Rimbu Docs](https://rimbu.org), or directly explore the [Rimbu Common API Docs](https://rimbu.org/api/rimbu/common).
28
+ Use this package directly in your own code, or consume it indirectly when using other Rimbu packages.
32
29
 
33
- ### Try It Out
30
+ ---
34
31
 
35
- Experience `@rimbu/common` in action! [Try Out Rimbu](https://codesandbox.io/s/github/vitoke/rimbu-sandbox/tree/main?previewwindow=console&view=split&editorsize=65&moduleview=1&module=/src/index.ts) on CodeSandBox.
32
+ ## Table of Contents
36
33
 
37
- ## Installation
34
+ 1. [Why `@rimbu/common`?](#why-rimbucommon)
35
+ 2. [Feature Highlights](#feature-highlights)
36
+ 3. [Quick Start](#quick-start)
37
+ 4. [Core Concepts & Types](#core-concepts--types)
38
+ 5. [Working with Equality & Comparison](#working-with-equality--comparison)
39
+ 6. [Lazy Values, Updates & Async](#lazy-values-updates--async)
40
+ 7. [Ranges & Indices](#ranges--indices)
41
+ 8. [Type Utilities](#type-utilities)
42
+ 9. [Installation](#installation)
43
+ 10. [Ecosystem & Links](#ecosystem--links)
44
+ 11. [Contributing](#contributing)
45
+ 12. [License](#license)
38
46
 
39
- ### Compabitity
47
+ ---
40
48
 
41
- - [`Node` ![NodeJS](https://img.shields.io/badge/node.js-6DA55F?logo=node.js&logoColor=white)](https://nodejs.org)
42
- - [`Deno` ![Deno JS](https://img.shields.io/badge/deno%20js-000000?logo=deno&logoColor=white)](https://deno.com/runtime)
43
- - [`Bun` ![Bun](https://img.shields.io/badge/Bun-%23000000.svg?logoColor=white)](https://bun.sh/)
44
- - `Web` ![HTML5](https://img.shields.io/badge/html5-%23E34F26.svg?logoColor=white)
49
+ ## Why `@rimbu/common`?
45
50
 
46
- ### Package Managers
51
+ Many Rimbu collections (and your own APIs) need **consistent behaviour** for:
47
52
 
48
- **Yarn:**
53
+ - Comparing values (e.g. custom sort orders, structural vs reference equality).
54
+ - Handling optional or deferred values (lazy evaluation, async computations).
55
+ - Working with index or value ranges in a uniform way.
56
+ - Expressing richer type relationships in TypeScript.
49
57
 
50
- ```sh
51
- yarn add @rimbu/common
58
+ Instead of re‑implementing these patterns, `@rimbu/common` provides:
59
+
60
+ - **Well-tested primitives** shared across all Rimbu packages.
61
+ - **Reusable utilities** you can depend on directly in your own libraries and apps.
62
+ - **Type-safe building blocks** that integrate smoothly with the rest of the Rimbu ecosystem.
63
+
64
+ ---
65
+
66
+ ## Feature Highlights
67
+
68
+ - **Pluggable equality & comparison** – `Eq` and `Comp` instances for primitives, objects, iterables, JSON, case-insensitive strings, and more.
69
+ - **Lazy & async helpers** – `OptLazy`, `OptLazyOr`, `AsyncOptLazy`, `MaybePromise` to keep APIs flexible without sacrificing clarity.
70
+ - **Declarative ranges** – `Range<T>` and `IndexRange` to describe open/closed and offset-based ranges in a single, typed shape.
71
+ - **Traversal utilities** – `CollectFun` and `TraverseState` for customizable, short‑circuitable traversals.
72
+ - **Type-level helpers** – utilities like `ArrayNonEmpty`, `StringNonEmpty`, and `ToJSON` to express invariants and serializable shapes.
73
+
74
+ ---
75
+
76
+ ## Quick Start
77
+
78
+ ```ts
79
+ import { Eq, Comp, OptLazy, Update } from '@rimbu/common';
80
+
81
+ // Equality: deep structural comparison
82
+ const eq = Eq.anyDeepEq<Record<string, unknown>>();
83
+ console.log(eq({ a: 1, b: 2 }, { b: 2, a: 1 }));
84
+ // => true
85
+
86
+ // Comparison: natural number ordering
87
+ const numComp = Comp.numberComp();
88
+ console.log(numComp.compare(3, 5) < 0);
89
+ // => true
90
+
91
+ // Lazy values: compute only when needed
92
+ const lazyValue = OptLazy(() => 1 + 2);
93
+ console.log(lazyValue); // 3
94
+
95
+ // Updates: accept either a value or an updater function
96
+ const next = Update(1, (v) => v + 1);
97
+ console.log(next); // 2
52
98
  ```
53
99
 
54
- **npm:**
100
+ Try Rimbu (including `@rimbu/common`) live in the browser using the
101
+ [Rimbu Sandbox on CodeSandbox](https://codesandbox.io/s/github/vitoke/rimbu-sandbox/tree/main?previewwindow=console&view=split&editorsize=65&moduleview=1&module=/src/index.ts).
55
102
 
56
- ```sh
57
- npm install @rimbu/common
103
+ ---
104
+
105
+ ## Core Concepts & Types
106
+
107
+ ### Exported Types & Utilities
108
+
109
+ | Name | Description |
110
+ | ------------------ | -------------------------------------------------------------------------------------------------- |
111
+ | `CollectFun` | Types used by `collect`-style functions to map/filter in a single pass with skip & halt support. |
112
+ | `AsyncCollectFun` | Asynchronous version of `CollectFun`, returning `MaybePromise` of a collected value or skip token. |
113
+ | `Comp` | Interface and implementations for comparing values (ordering / sorting). |
114
+ | `Eq` | Interface and implementations for checking value equality. |
115
+ | `Err`, `ErrBase` | Helpers to throw consistent custom errors from fallback handlers. |
116
+ | `IndexRange` | Range specification for numeric indices (e.g. slicing arrays or collections). |
117
+ | `Range<T>` | Range specification for ordered values of type `T`. |
118
+ | `OptLazy` | A value or a function returning a value (lazy). |
119
+ | `OptLazyOr` | Like `OptLazy`, but can return a provided default value instead. |
120
+ | `AsyncOptLazy` | Potentially lazy and/or async values built on `OptLazy` + `MaybePromise`. |
121
+ | `MaybePromise<T>` | A value of type `T` or a `Promise<T>`. |
122
+ | `TraverseState` | Object to track progress & early termination in traversals. |
123
+ | `Update` | Value or updater function used to derive a new value from the old one. |
124
+ | `SuperOf`, `SubOf` | Type utilities for expressing upper/lower bounds between types. |
125
+ | `RelatedTo` | Type utility accepting related types where one extends the other. |
126
+ | `ArrayNonEmpty` | Tuple type representing non-empty arrays. |
127
+ | `StringNonEmpty` | Type representing non-empty string types. |
128
+ | `ToJSON` | Helper interface for JSON-serializable wrapper objects. |
129
+
130
+ See the full [Common API reference](https://rimbu.org/api/rimbu/common) for all members and overloads.
131
+
132
+ ---
133
+
134
+ ## Working with Equality & Comparison
135
+
136
+ ### Equality with `Eq`
137
+
138
+ ```ts
139
+ import { Eq } from '@rimbu/common';
140
+
141
+ // Deep structural equality
142
+ const deepEq = Eq.anyDeepEq<Record<string, unknown>>();
143
+ console.log(deepEq({ a: 1, b: 2 }, { b: 2, a: 1 }));
144
+ // => true
145
+
146
+ // Shallow equality: one level into objects / iterables
147
+ const shallowEq = Eq.anyShallowEq<Record<string, unknown>>();
148
+ console.log(shallowEq({ a: 1, b: 2 }, { b: 2, a: 1 }));
149
+ // => true
150
+
151
+ // Flat equality: composed values compared using Object.is
152
+ const flatEq = Eq.anyFlatEq<Record<string, unknown>>();
153
+ console.log(flatEq({ a: 1, b: 2 }, { b: 2, a: 1 }));
154
+ // => false
155
+
156
+ // Case-insensitive string equality
157
+ const ci = Eq.stringCaseInsentitiveEq();
158
+ console.log(ci('AbC', 'aBc'));
159
+ // => true
58
160
  ```
59
161
 
60
- **Bun:**
162
+ ### Comparison with `Comp`
61
163
 
62
- ```sh
63
- bun add @rimbu/common
164
+ ```ts
165
+ import { Comp } from '@rimbu/common';
166
+
167
+ // Numbers: natural ordering with special handling for NaN and infinities
168
+ const numberComp = Comp.numberComp();
169
+ numberComp.compare(3, 5); // < 0
170
+
171
+ // Strings: locale-aware comparison
172
+ const stringComp = Comp.stringComp('en');
173
+ stringComp.compare('a', 'b'); // < 0
174
+
175
+ // Deep comparison of arbitrary values
176
+ const anyDeepComp = Comp.anyDeepComp<unknown>();
177
+ anyDeepComp.compare({ a: 1 }, { a: 1 }); // 0
178
+
179
+ // Convert a comparison into an equality function
180
+ const objectEq = Comp.toEq(Comp.objectComp());
181
+ console.log(objectEq({ a: 1, b: 2 }, { b: 2, a: 1 }));
182
+ // => true
64
183
  ```
65
184
 
66
- ### Deno Setup
185
+ ---
67
186
 
68
- Create or edit `import_map.json` in your project root:
187
+ ## Lazy Values, Updates & Async
69
188
 
70
- ```json
71
- {
72
- "imports": {
73
- "@rimbu/": "https://deno.land/x/rimbu@x.y.z/"
74
- }
75
- }
189
+ ### `OptLazy` and `OptLazyOr`
190
+
191
+ ```ts
192
+ import { OptLazy, OptLazyOr } from '@rimbu/common';
193
+
194
+ // Eager or lazy values
195
+ OptLazy(1); // => 1
196
+ OptLazy(() => 1); // => 1
197
+
198
+ // With a default "other" value
199
+ OptLazyOr(1, 'a'); // => 1
200
+ OptLazyOr(() => 1, 'a'); // => 1
201
+ OptLazyOr((none) => none, 'a'); // => 'a'
76
202
  ```
77
203
 
78
- _Replace `x.y.z` with the desired version._
204
+ ### `Update`
79
205
 
80
- In this way you can use relative imports from Rimbu in your code, like so:
206
+ ```ts
207
+ import { Update } from '@rimbu/common';
208
+
209
+ Update(1, 2); // => 2
210
+ Update(1, () => 10); // => 10
211
+ Update(1, (v) => v + 1); // => 2
212
+ ```
213
+
214
+ ### `AsyncOptLazy` and `MaybePromise`
81
215
 
82
216
  ```ts
83
- import { List } from '@rimbu/core/mod.ts';
84
- import { HashMap } from '@rimbu/hashed/mod.ts';
217
+ import { AsyncOptLazy } from '@rimbu/common';
218
+
219
+ // Get a value or promised value
220
+ await AsyncOptLazy.toPromise(1); // Promise(1)
221
+ await AsyncOptLazy.toPromise(() => 1); // Promise(1)
222
+ await AsyncOptLazy.toPromise(async () => 1); // Promise(1)
223
+ await AsyncOptLazy.toPromise(Promise.resolve(1)); // Promise(1)
85
224
  ```
86
225
 
87
- Note that for sub-packages, due to conversion limitations it is needed to import the `index.ts` instead of `mod.ts`, like so:
226
+ ---
227
+
228
+ ## Ranges & Indices
229
+
230
+ ### `Range<T>`
88
231
 
89
232
  ```ts
90
- import { HashMap } from '@rimbu/hashed/map/index.ts';
233
+ import { Range } from '@rimbu/common';
234
+
235
+ // Inclusive start, exclusive end
236
+ const r1: Range<number> = { start: [0, true], end: [10, false] };
237
+
238
+ // Only end (inclusive by default)
239
+ const r2: Range<number> = { end: 5 };
240
+
241
+ // Normalize for easier handling
242
+ const normalized = Range.getNormalizedRange(r1);
243
+ // => { start: [0, true], end: [10, false] }
91
244
  ```
92
245
 
93
- To run your script (let's assume the entry point is in `src/main.ts`):
246
+ ### `IndexRange`
94
247
 
95
- `deno run --import-map import_map.json src/main.ts`
248
+ ```ts
249
+ import { IndexRange } from '@rimbu/common';
250
+
251
+ const ir: IndexRange = { start: [0, true], amount: 3 };
96
252
 
97
- ## Usage
253
+ // Extract concrete indices for a given length
254
+ IndexRange.getIndicesFor(ir, 10); // [0, 2]
255
+ ```
256
+
257
+ ---
258
+
259
+ ## Type Utilities
98
260
 
99
261
  ```ts
100
- import { Eq } from '@rimbu/common';
262
+ import type {
263
+ SuperOf,
264
+ SubOf,
265
+ RelatedTo,
266
+ ArrayNonEmpty,
267
+ StringNonEmpty,
268
+ ToJSON,
269
+ } from '@rimbu/common';
270
+
271
+ type A = SuperOf<string, 'a' | 'b'>; // string
272
+ type B = SubOf<'a' | 'b', string>; // 'a' | 'b'
273
+ type R = RelatedTo<'a', string>; // 'a' | string
274
+
275
+ type NonEmptyNumbers = ArrayNonEmpty<number>; // [number, ...number[]]
276
+ type NonEmptyString = StringNonEmpty<'a' | ''>; // 'a'
277
+
278
+ interface UserJSON extends ToJSON<{ id: number }, 'User'> {}
279
+ ```
101
280
 
102
- console.log(Eq.stringCaseInsentitive()('abc', 'AbC'));
103
- // => true
281
+ ---
282
+
283
+ ## Installation
284
+
285
+ ### Node / Bun / npm / Yarn
286
+
287
+ ```sh
288
+ npm install @rimbu/common
289
+ # or
290
+ yarn add @rimbu/common
291
+ # or
292
+ bun add @rimbu/common
293
+ # or
294
+ deno add npm:@rimbu/common
104
295
  ```
105
296
 
106
- ## Author
297
+ Then:
107
298
 
108
- Created and maintained by [Arvid Nicolaas](https://github.com/vitoke).
299
+ ```ts
300
+ import { Eq } from '@rimbu/common/mod.ts';
301
+ ```
109
302
 
110
- ## Contributing
303
+ ### Browser / ESM
111
304
 
112
- We welcome contributions! Please read our [Contributing guide](https://github.com/rimbu-org/rimbu/blob/main/CONTRIBUTING.md).
305
+ `@rimbu/common` ships both **ESM** and **CJS** builds. Use it with any modern bundler
306
+ (Vite, Webpack, esbuild, Bun, etc.) or directly in Node ESM projects.
113
307
 
114
- ## Contributors
308
+ ---
115
309
 
116
- <img src = "https://contrib.rocks/image?repo=rimbu-org/rimbu"/>
310
+ ## Ecosystem & Links
311
+
312
+ - Part of the broader **Rimbu** collection ecosystem – interoperates with `@rimbu/collection-types`,
313
+ `@rimbu/hashed`, `@rimbu/ordered`, `@rimbu/stream`, and more.
314
+ - Main documentation: [rimbu.org](https://rimbu.org)
315
+ - Package docs: [Common docs](https://rimbu.org/docs/common/overview)
316
+ - API reference: [Common API](https://rimbu.org/api/rimbu/common)
317
+
318
+ ---
319
+
320
+ ## Contributing
321
+
322
+ We welcome contributions! See the
323
+ [Contributing guide](https://github.com/rimbu-org/rimbu/blob/main/CONTRIBUTING.md) for details.
324
+
325
+ <img src="https://contrib.rocks/image?repo=rimbu-org/rimbu" alt="Contributors" />
117
326
 
118
327
  _Made with [contributors-img](https://contrib.rocks)._
119
328
 
329
+ ---
330
+
120
331
  ## License
121
332
 
122
- This project is licensed under the MIT License. See the [LICENSE](./LICENSE) for details.
333
+ MIT © Rimbu contributors. See [LICENSE](./LICENSE) for details.
334
+
335
+ ---
336
+
337
+ ## Attributions
338
+
339
+ Created and maintained by [Arvid Nicolaas](https://github.com/vitoke). Logo © Rimbu.
package/dist/bun/eq.mts CHANGED
@@ -4,6 +4,15 @@
4
4
  export type Eq<T> = (v1: T, v2: T) => boolean;
5
5
 
6
6
  export namespace Eq {
7
+ /**
8
+ * Converts any given `value` to a string representation that is stable for equality
9
+ * and ordering comparisons.
10
+ *
11
+ * For primitive values and objects with a custom `toString` implementation, it uses
12
+ * `String(value)`. For plain objects with the default `Object.prototype.toString`
13
+ * implementation, it uses `JSON.stringify(value)` instead.
14
+ * @param value - the value to convert
15
+ */
7
16
  export function convertAnyToString(value: any): string {
8
17
  if (
9
18
  typeof value !== 'object' ||
@@ -146,7 +155,7 @@ export namespace Eq {
146
155
  /**
147
156
  * Returns an Eq instance that checks equality of objects containing property values of type V by iteratively
148
157
  * applying given `valueEq` to each of the object's property values.
149
- * @typeparam - the object property value type
158
+ * @typeparam V - the object property value type
150
159
  * @param valueEq - (optional) the Eq instance to use to compare property values
151
160
  * @example
152
161
  * ```ts
@@ -228,7 +237,7 @@ export namespace Eq {
228
237
  * @typeparam T - the value type
229
238
  * @example
230
239
  * ```ts
231
- * const eq = anyFlatEq()
240
+ * const eq = Eq.anyFlatEq()
232
241
  * console.log(eq(1, 'a'))
233
242
  * // => false
234
243
  * console.log(eq({ a: 1, b: 2 }, { b: 2, a: 1 }))
@@ -246,7 +255,7 @@ export namespace Eq {
246
255
  * @typeparam T - the value type
247
256
  * @example
248
257
  * ```ts
249
- * const eq = anyFlatEq()
258
+ * const eq = Eq.anyShallowEq()
250
259
  * console.log(eq(1, 'a'))
251
260
  * // => false
252
261
  * console.log(eq({ a: 1, b: 2 }, { b: 2, a: 1 }))
@@ -267,7 +276,7 @@ export namespace Eq {
267
276
  * @typeparam T - the value type
268
277
  * @example
269
278
  * ```ts
270
- * const eq = anyFlatEq()
279
+ * const eq = Eq.anyDeepEq()
271
280
  * console.log(eq(1, 'a'))
272
281
  * // => false
273
282
  * console.log(eq({ a: 1, b: 2 }, { b: 2, a: 1 }))
@@ -359,6 +368,18 @@ export namespace Eq {
359
368
  const _anyToStringEq: Eq<any> = (v1, v2) =>
360
369
  convertAnyToString(v1) === convertAnyToString(v2);
361
370
 
371
+ /**
372
+ * Returns an Eq instance that considers two values equal when their string
373
+ * representations, as returned by `Eq.convertAnyToString`, are equal.
374
+ * @example
375
+ * ```ts
376
+ * const eq = Eq.anyToStringEq()
377
+ * console.log(eq({ a: 1 }, { a: 1 }))
378
+ * // => true
379
+ * console.log(eq({ a: 1 }, { a: 2 }))
380
+ * // => false
381
+ * ```
382
+ */
362
383
  export function anyToStringEq(): Eq<any> {
363
384
  return _anyToStringEq;
364
385
  }
package/dist/bun/err.mts CHANGED
@@ -1,10 +1,10 @@
1
1
  /**
2
- * Throws an `Err.ForcedError` error when called.
2
+ * Throws an `ErrBase.ForcedError` error when called.
3
3
  * @example
4
4
  * ```ts
5
5
  * const emptyMap = HashMap.empty<number, string>()
6
6
  * emptyMap.get(5, Err);
7
- * // throws: Err.CustomError(message: 'Err: forced to throw error')
7
+ * // throws: ErrBase.ForcedError(message: 'Err: Forced to throw error')
8
8
  * ```
9
9
  */
10
10
  export function Err(): never {
@@ -23,6 +23,9 @@ export namespace ErrBase {
23
23
  }
24
24
  }
25
25
 
26
+ /**
27
+ * Error type that is thrown by `Err` and the functions returned by `ErrBase.msg`.
28
+ */
26
29
  export class ForcedError extends CustomError {}
27
30
 
28
31
  /**
@@ -32,7 +35,7 @@ export namespace ErrBase {
32
35
  * ```ts
33
36
  * const emptyMap = HashMap.empty<number, string>()
34
37
  * emptyMap.get(5, ErrBase.msg('not found'));
35
- * // throws: Err.CustomError(message: 'not found')
38
+ * // throws: ErrBase.ForcedError(message: 'not found')
36
39
  * ```
37
40
  */
38
41
  export function msg(message: string): () => never {
@@ -1,7 +1,13 @@
1
1
  /**
2
2
  * @packageDocumentation
3
3
  *
4
- * The `@rimbu/common` package provides many commonly used types and utilities that can also be of use to Rimbu users.<br/>
4
+ * The `@rimbu/common` package provides shared equality and comparison helpers, range and index
5
+ * utilities, lazy and async value helpers, traversal utilities, and rich type‑level helpers used
6
+ * throughout the Rimbu ecosystem.<br/>
7
+ * Use it when you need well‑tested primitives like `Eq`, `Comp`, `Range`, `OptLazy`, `AsyncOptLazy`,
8
+ * or advanced type utilities in your own code, or when building on top of other Rimbu packages.<br/>
9
+ * See the [Common docs](https://rimbu.org/docs/common/overview) and
10
+ * [API reference](https://rimbu.org/api/rimbu/common) for more information.
5
11
  */
6
12
 
7
13
  export * from './internal.mts';
package/dist/cjs/eq.cjs CHANGED
@@ -4,6 +4,15 @@ exports.Eq = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var Eq;
6
6
  (function (Eq) {
7
+ /**
8
+ * Converts any given `value` to a string representation that is stable for equality
9
+ * and ordering comparisons.
10
+ *
11
+ * For primitive values and objects with a custom `toString` implementation, it uses
12
+ * `String(value)`. For plain objects with the default `Object.prototype.toString`
13
+ * implementation, it uses `JSON.stringify(value)` instead.
14
+ * @param value - the value to convert
15
+ */
7
16
  function convertAnyToString(value) {
8
17
  if (typeof value !== 'object' ||
9
18
  null === value ||
@@ -135,7 +144,7 @@ var Eq;
135
144
  /**
136
145
  * Returns an Eq instance that checks equality of objects containing property values of type V by iteratively
137
146
  * applying given `valueEq` to each of the object's property values.
138
- * @typeparam - the object property value type
147
+ * @typeparam V - the object property value type
139
148
  * @param valueEq - (optional) the Eq instance to use to compare property values
140
149
  * @example
141
150
  * ```ts
@@ -206,7 +215,7 @@ var Eq;
206
215
  * @typeparam T - the value type
207
216
  * @example
208
217
  * ```ts
209
- * const eq = anyFlatEq()
218
+ * const eq = Eq.anyFlatEq()
210
219
  * console.log(eq(1, 'a'))
211
220
  * // => false
212
221
  * console.log(eq({ a: 1, b: 2 }, { b: 2, a: 1 }))
@@ -224,7 +233,7 @@ var Eq;
224
233
  * @typeparam T - the value type
225
234
  * @example
226
235
  * ```ts
227
- * const eq = anyFlatEq()
236
+ * const eq = Eq.anyShallowEq()
228
237
  * console.log(eq(1, 'a'))
229
238
  * // => false
230
239
  * console.log(eq({ a: 1, b: 2 }, { b: 2, a: 1 }))
@@ -245,7 +254,7 @@ var Eq;
245
254
  * @typeparam T - the value type
246
255
  * @example
247
256
  * ```ts
248
- * const eq = anyFlatEq()
257
+ * const eq = Eq.anyDeepEq()
249
258
  * console.log(eq(1, 'a'))
250
259
  * // => false
251
260
  * console.log(eq({ a: 1, b: 2 }, { b: 2, a: 1 }))
@@ -333,6 +342,18 @@ var Eq;
333
342
  var _anyToStringEq = function (v1, v2) {
334
343
  return convertAnyToString(v1) === convertAnyToString(v2);
335
344
  };
345
+ /**
346
+ * Returns an Eq instance that considers two values equal when their string
347
+ * representations, as returned by `Eq.convertAnyToString`, are equal.
348
+ * @example
349
+ * ```ts
350
+ * const eq = Eq.anyToStringEq()
351
+ * console.log(eq({ a: 1 }, { a: 1 }))
352
+ * // => true
353
+ * console.log(eq({ a: 1 }, { a: 2 }))
354
+ * // => false
355
+ * ```
356
+ */
336
357
  function anyToStringEq() {
337
358
  return _anyToStringEq;
338
359
  }
@@ -1 +1 @@
1
- {"version":3,"file":"eq.cjs","sourceRoot":"","sources":["../../_cjs_prepare/eq.cts"],"names":[],"mappings":";;;;AAKA,IAAiB,EAAE,CAgZlB;AAhZD,WAAiB,EAAE;IACjB,SAAgB,kBAAkB,CAAC,KAAU;QAC3C,IACE,OAAO,KAAK,KAAK,QAAQ;YACzB,IAAI,KAAK,KAAK;YACd,CAAC,CAAC,UAAU,IAAI,KAAK,CAAC;YACtB,OAAO,KAAK,CAAC,QAAQ,KAAK,UAAU;YACpC,KAAK,CAAC,QAAQ,KAAK,MAAM,CAAC,SAAS,CAAC,QAAQ,EAC5C,CAAC;YACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAZe,qBAAkB,qBAYjC,CAAA;IAED,IAAM,UAAU,GAAY,WAAW,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CAAC;IANe,iBAAc,iBAM7B,CAAA;AACH,CAAC,EAragB,EAAE,kBAAF,EAAE,QAqalB"}
package/dist/cjs/eq.d.cts CHANGED
@@ -3,6 +3,15 @@
3
3
  */
4
4
  export type Eq<T> = (v1: T, v2: T) => boolean;
5
5
  export declare namespace Eq {
6
+ /**
7
+ * Converts any given `value` to a string representation that is stable for equality
8
+ * and ordering comparisons.
9
+ *
10
+ * For primitive values and objects with a custom `toString` implementation, it uses
11
+ * `String(value)`. For plain objects with the default `Object.prototype.toString`
12
+ * implementation, it uses `JSON.stringify(value)` instead.
13
+ * @param value - the value to convert
14
+ */
6
15
  function convertAnyToString(value: any): string;
7
16
  /**
8
17
  * Returns the default Eq instance, which is the Eq.anyDeepEq() instance.
@@ -65,7 +74,7 @@ export declare namespace Eq {
65
74
  /**
66
75
  * Returns an Eq instance that checks equality of objects containing property values of type V by iteratively
67
76
  * applying given `valueEq` to each of the object's property values.
68
- * @typeparam - the object property value type
77
+ * @typeparam V - the object property value type
69
78
  * @param valueEq - (optional) the Eq instance to use to compare property values
70
79
  * @example
71
80
  * ```ts
@@ -83,7 +92,7 @@ export declare namespace Eq {
83
92
  * @typeparam T - the value type
84
93
  * @example
85
94
  * ```ts
86
- * const eq = anyFlatEq()
95
+ * const eq = Eq.anyFlatEq()
87
96
  * console.log(eq(1, 'a'))
88
97
  * // => false
89
98
  * console.log(eq({ a: 1, b: 2 }, { b: 2, a: 1 }))
@@ -98,7 +107,7 @@ export declare namespace Eq {
98
107
  * @typeparam T - the value type
99
108
  * @example
100
109
  * ```ts
101
- * const eq = anyFlatEq()
110
+ * const eq = Eq.anyShallowEq()
102
111
  * console.log(eq(1, 'a'))
103
112
  * // => false
104
113
  * console.log(eq({ a: 1, b: 2 }, { b: 2, a: 1 }))
@@ -116,7 +125,7 @@ export declare namespace Eq {
116
125
  * @typeparam T - the value type
117
126
  * @example
118
127
  * ```ts
119
- * const eq = anyFlatEq()
128
+ * const eq = Eq.anyDeepEq()
120
129
  * console.log(eq(1, 'a'))
121
130
  * // => false
122
131
  * console.log(eq({ a: 1, b: 2 }, { b: 2, a: 1 }))
@@ -164,6 +173,18 @@ export declare namespace Eq {
164
173
  * ```
165
174
  */
166
175
  function stringCharCodeEq(): Eq<string>;
176
+ /**
177
+ * Returns an Eq instance that considers two values equal when their string
178
+ * representations, as returned by `Eq.convertAnyToString`, are equal.
179
+ * @example
180
+ * ```ts
181
+ * const eq = Eq.anyToStringEq()
182
+ * console.log(eq({ a: 1 }, { a: 1 }))
183
+ * // => true
184
+ * console.log(eq({ a: 1 }, { a: 2 }))
185
+ * // => false
186
+ * ```
187
+ */
167
188
  function anyToStringEq(): Eq<any>;
168
189
  /**
169
190
  * Returns an Eq instance that considers values equal their JSON.stringify values are equal.
package/dist/cjs/err.cjs CHANGED
@@ -4,12 +4,12 @@ exports.ErrBase = void 0;
4
4
  exports.Err = Err;
5
5
  var tslib_1 = require("tslib");
6
6
  /**
7
- * Throws an `Err.ForcedError` error when called.
7
+ * Throws an `ErrBase.ForcedError` error when called.
8
8
  * @example
9
9
  * ```ts
10
10
  * const emptyMap = HashMap.empty<number, string>()
11
11
  * emptyMap.get(5, Err);
12
- * // throws: Err.CustomError(message: 'Err: forced to throw error')
12
+ * // throws: ErrBase.ForcedError(message: 'Err: Forced to throw error')
13
13
  * ```
14
14
  */
15
15
  function Err() {
@@ -34,6 +34,9 @@ var ErrBase;
34
34
  return CustomError;
35
35
  }());
36
36
  ErrBase.CustomError = CustomError;
37
+ /**
38
+ * Error type that is thrown by `Err` and the functions returned by `ErrBase.msg`.
39
+ */
37
40
  var ForcedError = /** @class */ (function (_super) {
38
41
  tslib_1.__extends(ForcedError, _super);
39
42
  function ForcedError() {
@@ -49,7 +52,7 @@ var ErrBase;
49
52
  * ```ts
50
53
  * const emptyMap = HashMap.empty<number, string>()
51
54
  * emptyMap.get(5, ErrBase.msg('not found'));
52
- * // throws: Err.CustomError(message: 'not found')
55
+ * // throws: ErrBase.ForcedError(message: 'not found')
53
56
  * ```
54
57
  */
55
58
  function msg(message) {
@@ -1 +1 @@
1
- {"version":3,"file":"err.cjs","sourceRoot":"","sources":["../../_cjs_prepare/err.cts"],"names":[],"mappings":";;;AASA,kBAEC;;AAXD;;;;;;;;GAQG;AACH,SAAgB,GAAG;IACjB,OAAO,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,EAAE,CAAC;AACrD,CAAC;AAED,IAAiB,OAAO,CA6BvB;AA7BD,WAAiB,OAAO;IACtB;;OAEG;IACH;QACE,qBAAqB,OAAe;YAAf,YAAO,GAAP,OAAO,CAAQ;QAAG,CAAC;QAExC,sBAAI,6BAAI;iBAAR;gBACE,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;YAC/B,CAAC;;;WAAA;QACH,kBAAC;IAAD,CAAC,AAND,IAMC;IANqB,mBAAW,cAMhC,CAAA;IAED;QAAiC,uCAAW;QAA5C;;QAA8C,CAAC;QAAD,kBAAC;IAAD,CAAC,AAA/C,CAAiC,WAAW,GAAG;IAAlC,mBAAW,cAAuB,CAAA;IAE/C;;;;;;;;;OASG;IACH,SAAgB,GAAG,CAAC,OAAe;QACjC,OAAO;YACL,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACzC,CAAC,CAAC;IACJ,CAAC;IAJe,WAAG,MAIlB,CAAA;AACH,CAAC,EA7BgB,OAAO,uBAAP,OAAO,QA6BvB"}
1
+ {"version":3,"file":"err.cjs","sourceRoot":"","sources":["../../_cjs_prepare/err.cts"],"names":[],"mappings":";;;AASA,kBAEC;;AAXD;;;;;;;;GAQG;AACH,SAAgB,GAAG;IACjB,OAAO,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,EAAE,CAAC;AACrD,CAAC;AAED,IAAiB,OAAO,CAgCvB;AAhCD,WAAiB,OAAO;IACtB;;OAEG;IACH;QACE,qBAAqB,OAAe;YAAf,YAAO,GAAP,OAAO,CAAQ;QAAG,CAAC;QAExC,sBAAI,6BAAI;iBAAR;gBACE,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;YAC/B,CAAC;;;WAAA;QACH,kBAAC;IAAD,CAAC,AAND,IAMC;IANqB,mBAAW,cAMhC,CAAA;IAED;;OAEG;IACH;QAAiC,uCAAW;QAA5C;;QAA8C,CAAC;QAAD,kBAAC;IAAD,CAAC,AAA/C,CAAiC,WAAW,GAAG;IAAlC,mBAAW,cAAuB,CAAA;IAE/C;;;;;;;;;OASG;IACH,SAAgB,GAAG,CAAC,OAAe;QACjC,OAAO;YACL,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACzC,CAAC,CAAC;IACJ,CAAC;IAJe,WAAG,MAIlB,CAAA;AACH,CAAC,EAhCgB,OAAO,uBAAP,OAAO,QAgCvB"}
@@ -1,10 +1,10 @@
1
1
  /**
2
- * Throws an `Err.ForcedError` error when called.
2
+ * Throws an `ErrBase.ForcedError` error when called.
3
3
  * @example
4
4
  * ```ts
5
5
  * const emptyMap = HashMap.empty<number, string>()
6
6
  * emptyMap.get(5, Err);
7
- * // throws: Err.CustomError(message: 'Err: forced to throw error')
7
+ * // throws: ErrBase.ForcedError(message: 'Err: Forced to throw error')
8
8
  * ```
9
9
  */
10
10
  export declare function Err(): never;
@@ -17,6 +17,9 @@ export declare namespace ErrBase {
17
17
  constructor(message: string);
18
18
  get name(): string;
19
19
  }
20
+ /**
21
+ * Error type that is thrown by `Err` and the functions returned by `ErrBase.msg`.
22
+ */
20
23
  class ForcedError extends CustomError {
21
24
  }
22
25
  /**
@@ -26,7 +29,7 @@ export declare namespace ErrBase {
26
29
  * ```ts
27
30
  * const emptyMap = HashMap.empty<number, string>()
28
31
  * emptyMap.get(5, ErrBase.msg('not found'));
29
- * // throws: Err.CustomError(message: 'not found')
32
+ * // throws: ErrBase.ForcedError(message: 'not found')
30
33
  * ```
31
34
  */
32
35
  function msg(message: string): () => never;
@@ -2,7 +2,13 @@
2
2
  /**
3
3
  * @packageDocumentation
4
4
  *
5
- * The `@rimbu/common` package provides many commonly used types and utilities that can also be of use to Rimbu users.<br/>
5
+ * The `@rimbu/common` package provides shared equality and comparison helpers, range and index
6
+ * utilities, lazy and async value helpers, traversal utilities, and rich type‑level helpers used
7
+ * throughout the Rimbu ecosystem.<br/>
8
+ * Use it when you need well‑tested primitives like `Eq`, `Comp`, `Range`, `OptLazy`, `AsyncOptLazy`,
9
+ * or advanced type utilities in your own code, or when building on top of other Rimbu packages.<br/>
10
+ * See the [Common docs](https://rimbu.org/docs/common/overview) and
11
+ * [API reference](https://rimbu.org/api/rimbu/common) for more information.
6
12
  */
7
13
  Object.defineProperty(exports, "__esModule", { value: true });
8
14
  var tslib_1 = require("tslib");
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../_cjs_prepare/index.cts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,yDAA+B"}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../_cjs_prepare/index.cts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAEH,yDAA+B"}
@@ -1,6 +1,12 @@
1
1
  /**
2
2
  * @packageDocumentation
3
3
  *
4
- * The `@rimbu/common` package provides many commonly used types and utilities that can also be of use to Rimbu users.<br/>
4
+ * The `@rimbu/common` package provides shared equality and comparison helpers, range and index
5
+ * utilities, lazy and async value helpers, traversal utilities, and rich type‑level helpers used
6
+ * throughout the Rimbu ecosystem.<br/>
7
+ * Use it when you need well‑tested primitives like `Eq`, `Comp`, `Range`, `OptLazy`, `AsyncOptLazy`,
8
+ * or advanced type utilities in your own code, or when building on top of other Rimbu packages.<br/>
9
+ * See the [Common docs](https://rimbu.org/docs/common/overview) and
10
+ * [API reference](https://rimbu.org/api/rimbu/common) for more information.
5
11
  */
6
12
  export * from './internal.cjs';
package/dist/esm/eq.d.mts CHANGED
@@ -3,6 +3,15 @@
3
3
  */
4
4
  export type Eq<T> = (v1: T, v2: T) => boolean;
5
5
  export declare namespace Eq {
6
+ /**
7
+ * Converts any given `value` to a string representation that is stable for equality
8
+ * and ordering comparisons.
9
+ *
10
+ * For primitive values and objects with a custom `toString` implementation, it uses
11
+ * `String(value)`. For plain objects with the default `Object.prototype.toString`
12
+ * implementation, it uses `JSON.stringify(value)` instead.
13
+ * @param value - the value to convert
14
+ */
6
15
  function convertAnyToString(value: any): string;
7
16
  /**
8
17
  * Returns the default Eq instance, which is the Eq.anyDeepEq() instance.
@@ -65,7 +74,7 @@ export declare namespace Eq {
65
74
  /**
66
75
  * Returns an Eq instance that checks equality of objects containing property values of type V by iteratively
67
76
  * applying given `valueEq` to each of the object's property values.
68
- * @typeparam - the object property value type
77
+ * @typeparam V - the object property value type
69
78
  * @param valueEq - (optional) the Eq instance to use to compare property values
70
79
  * @example
71
80
  * ```ts
@@ -83,7 +92,7 @@ export declare namespace Eq {
83
92
  * @typeparam T - the value type
84
93
  * @example
85
94
  * ```ts
86
- * const eq = anyFlatEq()
95
+ * const eq = Eq.anyFlatEq()
87
96
  * console.log(eq(1, 'a'))
88
97
  * // => false
89
98
  * console.log(eq({ a: 1, b: 2 }, { b: 2, a: 1 }))
@@ -98,7 +107,7 @@ export declare namespace Eq {
98
107
  * @typeparam T - the value type
99
108
  * @example
100
109
  * ```ts
101
- * const eq = anyFlatEq()
110
+ * const eq = Eq.anyShallowEq()
102
111
  * console.log(eq(1, 'a'))
103
112
  * // => false
104
113
  * console.log(eq({ a: 1, b: 2 }, { b: 2, a: 1 }))
@@ -116,7 +125,7 @@ export declare namespace Eq {
116
125
  * @typeparam T - the value type
117
126
  * @example
118
127
  * ```ts
119
- * const eq = anyFlatEq()
128
+ * const eq = Eq.anyDeepEq()
120
129
  * console.log(eq(1, 'a'))
121
130
  * // => false
122
131
  * console.log(eq({ a: 1, b: 2 }, { b: 2, a: 1 }))
@@ -164,6 +173,18 @@ export declare namespace Eq {
164
173
  * ```
165
174
  */
166
175
  function stringCharCodeEq(): Eq<string>;
176
+ /**
177
+ * Returns an Eq instance that considers two values equal when their string
178
+ * representations, as returned by `Eq.convertAnyToString`, are equal.
179
+ * @example
180
+ * ```ts
181
+ * const eq = Eq.anyToStringEq()
182
+ * console.log(eq({ a: 1 }, { a: 1 }))
183
+ * // => true
184
+ * console.log(eq({ a: 1 }, { a: 2 }))
185
+ * // => false
186
+ * ```
187
+ */
167
188
  function anyToStringEq(): Eq<any>;
168
189
  /**
169
190
  * Returns an Eq instance that considers values equal their JSON.stringify values are equal.
package/dist/esm/eq.mjs CHANGED
@@ -1,5 +1,14 @@
1
1
  export var Eq;
2
2
  (function (Eq) {
3
+ /**
4
+ * Converts any given `value` to a string representation that is stable for equality
5
+ * and ordering comparisons.
6
+ *
7
+ * For primitive values and objects with a custom `toString` implementation, it uses
8
+ * `String(value)`. For plain objects with the default `Object.prototype.toString`
9
+ * implementation, it uses `JSON.stringify(value)` instead.
10
+ * @param value - the value to convert
11
+ */
3
12
  function convertAnyToString(value) {
4
13
  if (typeof value !== 'object' ||
5
14
  null === value ||
@@ -129,7 +138,7 @@ export var Eq;
129
138
  /**
130
139
  * Returns an Eq instance that checks equality of objects containing property values of type V by iteratively
131
140
  * applying given `valueEq` to each of the object's property values.
132
- * @typeparam - the object property value type
141
+ * @typeparam V - the object property value type
133
142
  * @param valueEq - (optional) the Eq instance to use to compare property values
134
143
  * @example
135
144
  * ```ts
@@ -200,7 +209,7 @@ export var Eq;
200
209
  * @typeparam T - the value type
201
210
  * @example
202
211
  * ```ts
203
- * const eq = anyFlatEq()
212
+ * const eq = Eq.anyFlatEq()
204
213
  * console.log(eq(1, 'a'))
205
214
  * // => false
206
215
  * console.log(eq({ a: 1, b: 2 }, { b: 2, a: 1 }))
@@ -218,7 +227,7 @@ export var Eq;
218
227
  * @typeparam T - the value type
219
228
  * @example
220
229
  * ```ts
221
- * const eq = anyFlatEq()
230
+ * const eq = Eq.anyShallowEq()
222
231
  * console.log(eq(1, 'a'))
223
232
  * // => false
224
233
  * console.log(eq({ a: 1, b: 2 }, { b: 2, a: 1 }))
@@ -239,7 +248,7 @@ export var Eq;
239
248
  * @typeparam T - the value type
240
249
  * @example
241
250
  * ```ts
242
- * const eq = anyFlatEq()
251
+ * const eq = Eq.anyDeepEq()
243
252
  * console.log(eq(1, 'a'))
244
253
  * // => false
245
254
  * console.log(eq({ a: 1, b: 2 }, { b: 2, a: 1 }))
@@ -319,6 +328,18 @@ export var Eq;
319
328
  }
320
329
  Eq.stringCharCodeEq = stringCharCodeEq;
321
330
  const _anyToStringEq = (v1, v2) => convertAnyToString(v1) === convertAnyToString(v2);
331
+ /**
332
+ * Returns an Eq instance that considers two values equal when their string
333
+ * representations, as returned by `Eq.convertAnyToString`, are equal.
334
+ * @example
335
+ * ```ts
336
+ * const eq = Eq.anyToStringEq()
337
+ * console.log(eq({ a: 1 }, { a: 1 }))
338
+ * // => true
339
+ * console.log(eq({ a: 1 }, { a: 2 }))
340
+ * // => false
341
+ * ```
342
+ */
322
343
  function anyToStringEq() {
323
344
  return _anyToStringEq;
324
345
  }
@@ -1 +1 @@
1
- {"version":3,"file":"eq.mjs","sourceRoot":"","sources":["../../src/eq.mts"],"names":[],"mappings":"AAKA,MAAM,KAAW,EAAE,CAgZlB;AAhZD,WAAiB,EAAE;IACjB,SAAgB,kBAAkB,CAAC,KAAU;QAC3C,IACE,OAAO,KAAK,KAAK,QAAQ;YACzB,IAAI,KAAK,KAAK;YACd,CAAC,CAAC,UAAU,IAAI,KAAK,CAAC;YACtB,OAAO,KAAK,CAAC,QAAQ,KAAK,UAAU;YACpC,KAAK,CAAC,QAAQ,KAAK,MAAM,CAAC,SAAS,CAAC,QAAQ,EAC5C,CAAC;YACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAZe,qBAAkB,qBAYjC,CAAA;IAED,MAAM,UAAU,GAAY,WAAW,CAAC,MAAM,CAAC,CAAC;IAChD,MAAM,aAAa,G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IAC3B,CAAC;IAFe,mBAAgB,mBAE/B,CAAA;IAED,MAAM,cAAc,GAAY,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CACzC,kBAAkB,CAAC,EAAE,CAAC,KAAK,kBAAkB,CAAC,EAAE,CAAC,CAAC;IAEpD;;;;;;;;;;;OAWG;IACH,SAAgB,aAAa;QAC3B,OAAO,cAAc,CAAC;IACxB,CAAC;IAFe,gBAAa,gBAE5B,CAAA;IAED,MAAM,UAAU,GAAY,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CACrC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAE5C;;;;;;;;;;OAUG;IACH,SAAgB,SAAS;QACvB,OAAO,UAAU,CAAC;IACpB,CAAC;IAFe,YAAS,YAExB,CAAA;IAED;;;;;;;;;;;;;;OAcG;IACH,SAAgB,cAAc,CAC5B,KAAY,SAAS,EAAE;QAEvB,OAAO,CAAC,IAAqB,EAAE,IAAqB,EAAW,EAAE,CAC/D,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9C,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACnD,CAAC;IANe,iBAAc,iBAM7B,CAAA;AACH,CAAC,EAragB,EAAE,KAAF,EAAE,QAqalB"}
@@ -1,10 +1,10 @@
1
1
  /**
2
- * Throws an `Err.ForcedError` error when called.
2
+ * Throws an `ErrBase.ForcedError` error when called.
3
3
  * @example
4
4
  * ```ts
5
5
  * const emptyMap = HashMap.empty<number, string>()
6
6
  * emptyMap.get(5, Err);
7
- * // throws: Err.CustomError(message: 'Err: forced to throw error')
7
+ * // throws: ErrBase.ForcedError(message: 'Err: Forced to throw error')
8
8
  * ```
9
9
  */
10
10
  export declare function Err(): never;
@@ -17,6 +17,9 @@ export declare namespace ErrBase {
17
17
  constructor(message: string);
18
18
  get name(): string;
19
19
  }
20
+ /**
21
+ * Error type that is thrown by `Err` and the functions returned by `ErrBase.msg`.
22
+ */
20
23
  class ForcedError extends CustomError {
21
24
  }
22
25
  /**
@@ -26,7 +29,7 @@ export declare namespace ErrBase {
26
29
  * ```ts
27
30
  * const emptyMap = HashMap.empty<number, string>()
28
31
  * emptyMap.get(5, ErrBase.msg('not found'));
29
- * // throws: Err.CustomError(message: 'not found')
32
+ * // throws: ErrBase.ForcedError(message: 'not found')
30
33
  * ```
31
34
  */
32
35
  function msg(message: string): () => never;
package/dist/esm/err.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  /**
2
- * Throws an `Err.ForcedError` error when called.
2
+ * Throws an `ErrBase.ForcedError` error when called.
3
3
  * @example
4
4
  * ```ts
5
5
  * const emptyMap = HashMap.empty<number, string>()
6
6
  * emptyMap.get(5, Err);
7
- * // throws: Err.CustomError(message: 'Err: forced to throw error')
7
+ * // throws: ErrBase.ForcedError(message: 'Err: Forced to throw error')
8
8
  * ```
9
9
  */
10
10
  export function Err() {
@@ -24,6 +24,9 @@ export var ErrBase;
24
24
  }
25
25
  }
26
26
  ErrBase.CustomError = CustomError;
27
+ /**
28
+ * Error type that is thrown by `Err` and the functions returned by `ErrBase.msg`.
29
+ */
27
30
  class ForcedError extends CustomError {
28
31
  }
29
32
  ErrBase.ForcedError = ForcedError;
@@ -34,7 +37,7 @@ export var ErrBase;
34
37
  * ```ts
35
38
  * const emptyMap = HashMap.empty<number, string>()
36
39
  * emptyMap.get(5, ErrBase.msg('not found'));
37
- * // throws: Err.CustomError(message: 'not found')
40
+ * // throws: ErrBase.ForcedError(message: 'not found')
38
41
  * ```
39
42
  */
40
43
  function msg(message) {
@@ -1 +1 @@
1
- {"version":3,"file":"err.mjs","sourceRoot":"","sources":["../../src/err.mts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,UAAU,GAAG;IACjB,OAAO,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,EAAE,CAAC;AACrD,CAAC;AAED,MAAM,KAAW,OAAO,CA6BvB;AA7BD,WAAiB,OAAO;IACtB;;OAEG;IACH,MAAsB,WAAW;QAC/B,YAAqB,OAAe;YAAf,YAAO,GAAP,OAAO,CAAQ;QAAG,CAAC;QAExC,IAAI,IAAI;YACN,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAC/B,CAAC;KACF;IANqB,mBAAW,cAMhC,CAAA;IAED,MAAa,WAAY,SAAQ,WAAW;KAAG;IAAlC,mBAAW,cAAuB,CAAA;IAE/C;;;;;;;;;OASG;IACH,SAAgB,GAAG,CAAC,OAAe;QACjC,OAAO;YACL,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACzC,CAAC,CAAC;IACJ,CAAC;IAJe,WAAG,MAIlB,CAAA;AACH,CAAC,EA7BgB,OAAO,KAAP,OAAO,QA6BvB"}
1
+ {"version":3,"file":"err.mjs","sourceRoot":"","sources":["../../src/err.mts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,UAAU,GAAG;IACjB,OAAO,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,EAAE,CAAC;AACrD,CAAC;AAED,MAAM,KAAW,OAAO,CAgCvB;AAhCD,WAAiB,OAAO;IACtB;;OAEG;IACH,MAAsB,WAAW;QAC/B,YAAqB,OAAe;YAAf,YAAO,GAAP,OAAO,CAAQ;QAAG,CAAC;QAExC,IAAI,IAAI;YACN,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAC/B,CAAC;KACF;IANqB,mBAAW,cAMhC,CAAA;IAED;;OAEG;IACH,MAAa,WAAY,SAAQ,WAAW;KAAG;IAAlC,mBAAW,cAAuB,CAAA;IAE/C;;;;;;;;;OASG;IACH,SAAgB,GAAG,CAAC,OAAe;QACjC,OAAO;YACL,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACzC,CAAC,CAAC;IACJ,CAAC;IAJe,WAAG,MAIlB,CAAA;AACH,CAAC,EAhCgB,OAAO,KAAP,OAAO,QAgCvB"}
@@ -1,6 +1,12 @@
1
1
  /**
2
2
  * @packageDocumentation
3
3
  *
4
- * The `@rimbu/common` package provides many commonly used types and utilities that can also be of use to Rimbu users.<br/>
4
+ * The `@rimbu/common` package provides shared equality and comparison helpers, range and index
5
+ * utilities, lazy and async value helpers, traversal utilities, and rich type‑level helpers used
6
+ * throughout the Rimbu ecosystem.<br/>
7
+ * Use it when you need well‑tested primitives like `Eq`, `Comp`, `Range`, `OptLazy`, `AsyncOptLazy`,
8
+ * or advanced type utilities in your own code, or when building on top of other Rimbu packages.<br/>
9
+ * See the [Common docs](https://rimbu.org/docs/common/overview) and
10
+ * [API reference](https://rimbu.org/api/rimbu/common) for more information.
5
11
  */
6
12
  export * from './internal.mjs';
@@ -1,7 +1,13 @@
1
1
  /**
2
2
  * @packageDocumentation
3
3
  *
4
- * The `@rimbu/common` package provides many commonly used types and utilities that can also be of use to Rimbu users.<br/>
4
+ * The `@rimbu/common` package provides shared equality and comparison helpers, range and index
5
+ * utilities, lazy and async value helpers, traversal utilities, and rich type‑level helpers used
6
+ * throughout the Rimbu ecosystem.<br/>
7
+ * Use it when you need well‑tested primitives like `Eq`, `Comp`, `Range`, `OptLazy`, `AsyncOptLazy`,
8
+ * or advanced type utilities in your own code, or when building on top of other Rimbu packages.<br/>
9
+ * See the [Common docs](https://rimbu.org/docs/common/overview) and
10
+ * [API reference](https://rimbu.org/api/rimbu/common) for more information.
5
11
  */
6
12
  export * from './internal.mjs';
7
13
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/index.mts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/index.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,cAAc,gBAAgB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rimbu/common",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "Common types and objects used in many other Rimbu packages",
5
5
  "keywords": [
6
6
  "common",
@@ -52,17 +52,12 @@
52
52
  "scripts": {
53
53
  "b": "duel",
54
54
  "build": "yarn clean && yarn bundle",
55
- "build:deno": "yarn bundle:deno-prepare && yarn bundle:deno-convert && yarn bundle:deno-move && yarn bundle:deno-clean",
56
55
  "bundle": "yarn bundle:cjs && yarn bundle:esm && yarn bundle:bun",
57
56
  "bundle:bun": "node ../../config/bunnify.mjs -mode bun",
58
57
  "bundle:cjs": "yarn bundle:cjs-prepare && yarn bundle:cjs-build && yarn bundle:cjs-clean",
59
58
  "bundle:cjs-prepare": "node ../../config/bunnify.mjs -mode cjs",
60
59
  "bundle:cjs-build": "tsc -p tsconfig.cjs.json",
61
60
  "bundle:cjs-clean": "rimraf _cjs_prepare",
62
- "bundle:deno-prepare": "node ../../config/prepare-denoify.mjs",
63
- "bundle:deno-convert": "denoify --src _deno_prepare/src",
64
- "bundle:deno-move": "rimraf ../../deno_dist/common && mv deno_dist ../../deno_dist/common",
65
- "bundle:deno-clean": "rimraf _deno_prepare",
66
61
  "bundle:esm": "tsc --p tsconfig.esm.json",
67
62
  "clean": "rimraf dist",
68
63
  "extract-api": "tsx ../../config/api-extractor.ts config/api-extractor.main.json",
@@ -80,7 +75,7 @@
80
75
  "access": "public"
81
76
  },
82
77
  "dependencies": {
83
- "tslib": "^2.6.2"
78
+ "tslib": "^2.8.1"
84
79
  },
85
- "gitHead": "f18ddf964507dbd10790da3cd4deef8f455a178e"
80
+ "gitHead": "bc6bc82af86461c423ba459d6d9809efdd5ffd61"
86
81
  }
package/src/eq.mts CHANGED
@@ -4,6 +4,15 @@
4
4
  export type Eq<T> = (v1: T, v2: T) => boolean;
5
5
 
6
6
  export namespace Eq {
7
+ /**
8
+ * Converts any given `value` to a string representation that is stable for equality
9
+ * and ordering comparisons.
10
+ *
11
+ * For primitive values and objects with a custom `toString` implementation, it uses
12
+ * `String(value)`. For plain objects with the default `Object.prototype.toString`
13
+ * implementation, it uses `JSON.stringify(value)` instead.
14
+ * @param value - the value to convert
15
+ */
7
16
  export function convertAnyToString(value: any): string {
8
17
  if (
9
18
  typeof value !== 'object' ||
@@ -146,7 +155,7 @@ export namespace Eq {
146
155
  /**
147
156
  * Returns an Eq instance that checks equality of objects containing property values of type V by iteratively
148
157
  * applying given `valueEq` to each of the object's property values.
149
- * @typeparam - the object property value type
158
+ * @typeparam V - the object property value type
150
159
  * @param valueEq - (optional) the Eq instance to use to compare property values
151
160
  * @example
152
161
  * ```ts
@@ -228,7 +237,7 @@ export namespace Eq {
228
237
  * @typeparam T - the value type
229
238
  * @example
230
239
  * ```ts
231
- * const eq = anyFlatEq()
240
+ * const eq = Eq.anyFlatEq()
232
241
  * console.log(eq(1, 'a'))
233
242
  * // => false
234
243
  * console.log(eq({ a: 1, b: 2 }, { b: 2, a: 1 }))
@@ -246,7 +255,7 @@ export namespace Eq {
246
255
  * @typeparam T - the value type
247
256
  * @example
248
257
  * ```ts
249
- * const eq = anyFlatEq()
258
+ * const eq = Eq.anyShallowEq()
250
259
  * console.log(eq(1, 'a'))
251
260
  * // => false
252
261
  * console.log(eq({ a: 1, b: 2 }, { b: 2, a: 1 }))
@@ -267,7 +276,7 @@ export namespace Eq {
267
276
  * @typeparam T - the value type
268
277
  * @example
269
278
  * ```ts
270
- * const eq = anyFlatEq()
279
+ * const eq = Eq.anyDeepEq()
271
280
  * console.log(eq(1, 'a'))
272
281
  * // => false
273
282
  * console.log(eq({ a: 1, b: 2 }, { b: 2, a: 1 }))
@@ -359,6 +368,18 @@ export namespace Eq {
359
368
  const _anyToStringEq: Eq<any> = (v1, v2) =>
360
369
  convertAnyToString(v1) === convertAnyToString(v2);
361
370
 
371
+ /**
372
+ * Returns an Eq instance that considers two values equal when their string
373
+ * representations, as returned by `Eq.convertAnyToString`, are equal.
374
+ * @example
375
+ * ```ts
376
+ * const eq = Eq.anyToStringEq()
377
+ * console.log(eq({ a: 1 }, { a: 1 }))
378
+ * // => true
379
+ * console.log(eq({ a: 1 }, { a: 2 }))
380
+ * // => false
381
+ * ```
382
+ */
362
383
  export function anyToStringEq(): Eq<any> {
363
384
  return _anyToStringEq;
364
385
  }
package/src/err.mts CHANGED
@@ -1,10 +1,10 @@
1
1
  /**
2
- * Throws an `Err.ForcedError` error when called.
2
+ * Throws an `ErrBase.ForcedError` error when called.
3
3
  * @example
4
4
  * ```ts
5
5
  * const emptyMap = HashMap.empty<number, string>()
6
6
  * emptyMap.get(5, Err);
7
- * // throws: Err.CustomError(message: 'Err: forced to throw error')
7
+ * // throws: ErrBase.ForcedError(message: 'Err: Forced to throw error')
8
8
  * ```
9
9
  */
10
10
  export function Err(): never {
@@ -23,6 +23,9 @@ export namespace ErrBase {
23
23
  }
24
24
  }
25
25
 
26
+ /**
27
+ * Error type that is thrown by `Err` and the functions returned by `ErrBase.msg`.
28
+ */
26
29
  export class ForcedError extends CustomError {}
27
30
 
28
31
  /**
@@ -32,7 +35,7 @@ export namespace ErrBase {
32
35
  * ```ts
33
36
  * const emptyMap = HashMap.empty<number, string>()
34
37
  * emptyMap.get(5, ErrBase.msg('not found'));
35
- * // throws: Err.CustomError(message: 'not found')
38
+ * // throws: ErrBase.ForcedError(message: 'not found')
36
39
  * ```
37
40
  */
38
41
  export function msg(message: string): () => never {
package/src/index.mts CHANGED
@@ -1,7 +1,13 @@
1
1
  /**
2
2
  * @packageDocumentation
3
3
  *
4
- * The `@rimbu/common` package provides many commonly used types and utilities that can also be of use to Rimbu users.<br/>
4
+ * The `@rimbu/common` package provides shared equality and comparison helpers, range and index
5
+ * utilities, lazy and async value helpers, traversal utilities, and rich type‑level helpers used
6
+ * throughout the Rimbu ecosystem.<br/>
7
+ * Use it when you need well‑tested primitives like `Eq`, `Comp`, `Range`, `OptLazy`, `AsyncOptLazy`,
8
+ * or advanced type utilities in your own code, or when building on top of other Rimbu packages.<br/>
9
+ * See the [Common docs](https://rimbu.org/docs/common/overview) and
10
+ * [API reference](https://rimbu.org/api/rimbu/common) for more information.
5
11
  */
6
12
 
7
13
  export * from './internal.mjs';