@rimbu/common 2.0.1 → 2.0.2

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
@@ -8,62 +8,64 @@
8
8
 
9
9
  # @rimbu/common
10
10
 
11
- This package exports common types and objects used in many other Rimbu packages.
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.
12
12
 
13
- Here is a brief overview:
13
+ ### Overview of most important Exported Types:
14
14
 
15
- | Name | Description |
16
- | --------------- | -------------------------------------------------------------------------------------------------------- |
17
- | `CollectFun` | types and values used in various `collect` methods in the collection. |
18
- | `Comp` | an interface and default implementations of comparison functions to order/sort values. |
19
- | `Eq` | an interface and default implementations of equality functions to check value equality |
20
- | `Err` | functions to easily create error throwing behavior as fallback values |
21
- | `FastIterable` | an `Iterable` implementation that can be more performant than usual iterables |
22
- | `IndexRange` | utilities to select 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 pieces of logic that process streams of data that can be processed in parallel |
26
- | `TraverseState` | a utility for loops to maintain the traversal state |
27
- | `Update` | a standard way to update a value |
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. |
28
28
 
29
- Other than these values, there are a number of utility types that are exported that are also used throughout the collection.
29
+ ### Documentation
30
30
 
31
- For complete documentation please visit the _[Rimbu Docs](https://rimbu.org)_, or directly see the _[Rimbu Common API Docs](https://rimbu.org/api/rimbu/common)_.
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).
32
32
 
33
- Or [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) in CodeSandBox.
33
+ ### Try It Out
34
+
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.
34
36
 
35
37
  ## Installation
36
38
 
37
39
  ### Compabitity
38
40
 
39
- - [`Node >= 16` ![NodeJS](https://img.shields.io/badge/node.js-6DA55F?logo=node.js&logoColor=white)](https://nodejs.org)
41
+ - [`Node` ![NodeJS](https://img.shields.io/badge/node.js-6DA55F?logo=node.js&logoColor=white)](https://nodejs.org)
40
42
  - [`Deno` ![Deno JS](https://img.shields.io/badge/deno%20js-000000?logo=deno&logoColor=white)](https://deno.com/runtime)
41
- - [`Bun >= 0.6.0` ![Bun](https://img.shields.io/badge/Bun-%23000000.svg?logoColor=white)](https://bun.sh/)
43
+ - [`Bun` ![Bun](https://img.shields.io/badge/Bun-%23000000.svg?logoColor=white)](https://bun.sh/)
42
44
  - `Web` ![HTML5](https://img.shields.io/badge/html5-%23E34F26.svg?logoColor=white)
43
45
 
44
- ### Yarn / NPM / Bun
45
-
46
- For convenience, all main types are also exported through [`@rimbu/core`](../core).
47
-
48
- To install this package only:
49
-
50
- For `yarn`:
46
+ ### Package Managers
51
47
 
52
- > `yarn add @rimbu/common`
48
+ **Yarn:**
53
49
 
54
- For `npm`:
50
+ ```sh
51
+ yarn add @rimbu/common
52
+ ```
55
53
 
56
- > `npm i @rimbu/common`
54
+ **npm:**
57
55
 
58
- For `bun`:
56
+ ```sh
57
+ npm install @rimbu/common
58
+ ```
59
59
 
60
- > `bun add @rimbu/common`
60
+ **Bun:**
61
61
 
62
- ### Deno
62
+ ```sh
63
+ bun add @rimbu/common
64
+ ```
63
65
 
64
- For Deno, the following approach is recommended:
66
+ ### Deno Setup
65
67
 
66
- In the root folder of your project, create or edit a file called `import_map.json` with the following contents (where you should replace `x.y.z` with the desired version of Rimbu):
68
+ Create or edit `import_map.json` in your project root:
67
69
 
68
70
  ```json
69
71
  {
@@ -73,7 +75,7 @@ In the root folder of your project, create or edit a file called `import_map.jso
73
75
  }
74
76
  ```
75
77
 
76
- **Note: The trailing slashes are important!**
78
+ _Replace `x.y.z` with the desired version._
77
79
 
78
80
  In this way you can use relative imports from Rimbu in your code, like so:
79
81
 
@@ -103,20 +105,18 @@ console.log(Eq.stringCaseInsentitive()('abc', 'AbC'));
103
105
 
104
106
  ## Author
105
107
 
106
- [Arvid Nicolaas](https://github.com/vitoke)
108
+ Created and maintained by [Arvid Nicolaas](https://github.com/vitoke).
107
109
 
108
110
  ## Contributing
109
111
 
110
- Feel very welcome to contribute to further improve Rimbu. Please read our [Contributing guide](https://github.com/rimbu-org/rimbu/blob/main/CONTRIBUTING.md).
112
+ We welcome contributions! Please read our [Contributing guide](https://github.com/rimbu-org/rimbu/blob/main/CONTRIBUTING.md).
111
113
 
112
114
  ## Contributors
113
115
 
114
116
  <img src = "https://contrib.rocks/image?repo=rimbu-org/rimbu"/>
115
117
 
116
- Made with [contributors-img](https://contrib.rocks).
118
+ _Made with [contributors-img](https://contrib.rocks)._
117
119
 
118
120
  ## License
119
121
 
120
- Licensed under the MIT License, Copyright © 2020-present Arvid Nicolaas.
121
-
122
- See [LICENSE](./LICENSE) for more information.
122
+ This project is licensed under the MIT License. See the [LICENSE](./LICENSE) for details.
package/dist/bun/err.mts CHANGED
@@ -18,7 +18,7 @@ export namespace ErrBase {
18
18
  export abstract class CustomError {
19
19
  constructor(readonly message: string) {}
20
20
 
21
- get name() {
21
+ get name(): string {
22
22
  return this.constructor.name;
23
23
  }
24
24
  }
package/dist/cjs/err.cjs CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ErrBase = exports.Err = void 0;
3
+ exports.ErrBase = void 0;
4
+ exports.Err = Err;
4
5
  var tslib_1 = require("tslib");
5
6
  /**
6
7
  * Throws an `Err.ForcedError` error when called.
@@ -14,7 +15,6 @@ var tslib_1 = require("tslib");
14
15
  function Err() {
15
16
  return ErrBase.msg('Err: Forced to throw error')();
16
17
  }
17
- exports.Err = Err;
18
18
  var ErrBase;
19
19
  (function (ErrBase) {
20
20
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"err.cjs","sourceRoot":"","sources":["../../_cjs_prepare/err.cts"],"names":[],"mappings":";;;;AAAA;;;;;;;;GAQG;AACH,SAAgB,GAAG;IACjB,OAAO,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,EAAE,CAAC;AACrD,CAAC;AAFD,kBAEC;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,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,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OptLazyOr = exports.OptLazy = void 0;
3
+ exports.OptLazy = OptLazy;
4
+ exports.OptLazyOr = OptLazyOr;
4
5
  var tslib_1 = require("tslib");
5
6
  /**
6
7
  * Returns the value contained in an `OptLazy` instance of type T.
@@ -24,7 +25,6 @@ function OptLazy(optLazy) {
24
25
  return optLazy.apply(void 0, tslib_1.__spreadArray([], tslib_1.__read(args), false));
25
26
  return optLazy;
26
27
  }
27
- exports.OptLazy = OptLazy;
28
28
  /**
29
29
  * Returns the value contained in an `OptLazyOr` instance of type T, or the given
30
30
  * `otherValue` if the lazy function returns it.
@@ -44,5 +44,4 @@ function OptLazyOr(optLazyOr, otherValue) {
44
44
  return optLazyOr(otherValue);
45
45
  return optLazyOr;
46
46
  }
47
- exports.OptLazyOr = OptLazyOr;
48
47
  //# sourceMappingURL=optlazy.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"optlazy.cjs","sourceRoot":"","sources":["../../_cjs_prepare/optlazy.cts"],"names":[],"mappings":";;;;AAOA;;;;;;;;;;;;GAYG;AACH,SAAgB,OAAO,CACrB,OAAsB;IACtB,cAAU;SAAV,UAAU,EAAV,qBAAU,EAAV,IAAU;QAAV,6BAAU;;IAEV,IAAI,OAAO,YAAY,QAAQ;QAAE,OAAO,OAAO,wDAAI,IAAI,WAAE;IACzD,OAAO,OAAO,CAAC;AACjB,CAAC;AAND,0BAMC;AAUD;;;;;;;;;;;;;GAaG;AACH,SAAgB,SAAS,CACvB,SAA0B,EAC1B,UAAa;IAEb,IAAI,SAAS,YAAY,QAAQ;QAAE,OAAO,SAAS,CAAC,UAAU,CAAC,CAAC;IAChE,OAAO,SAAS,CAAC;AACnB,CAAC;AAND,8BAMC"}
1
+ {"version":3,"file":"optlazy.cjs","sourceRoot":"","sources":["../../_cjs_prepare/optlazy.cts"],"names":[],"mappings":";;AAoBA,0BAMC;AAwBD,8BAMC;;AAjDD;;;;;;;;;;;;GAYG;AACH,SAAgB,OAAO,CACrB,OAAsB;IACtB,cAAU;SAAV,UAAU,EAAV,qBAAU,EAAV,IAAU;QAAV,6BAAU;;IAEV,IAAI,OAAO,YAAY,QAAQ;QAAE,OAAO,OAAO,wDAAI,IAAI,WAAE;IACzD,OAAO,OAAO,CAAC;AACjB,CAAC;AAUD;;;;;;;;;;;;;GAaG;AACH,SAAgB,SAAS,CACvB,SAA0B,EAC1B,UAAa;IAEb,IAAI,SAAS,YAAY,QAAQ;QAAE,OAAO,SAAS,CAAC,UAAU,CAAC,CAAC;IAChE,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TraverseState = void 0;
3
+ exports.TraverseState = TraverseState;
4
4
  var TraverseStateImpl = /** @class */ (function () {
5
5
  function TraverseStateImpl(startIndex) {
6
6
  var _this = this;
@@ -29,5 +29,4 @@ function TraverseState(startIndex) {
29
29
  if (startIndex === void 0) { startIndex = 0; }
30
30
  return new TraverseStateImpl(startIndex);
31
31
  }
32
- exports.TraverseState = TraverseState;
33
32
  //# sourceMappingURL=traverse-state.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"traverse-state.cjs","sourceRoot":"","sources":["../../_cjs_prepare/traverse-state.cts"],"names":[],"mappings":";;;AA6BA;IAIE,2BAAqB,UAAkB;QAAvC,iBAEC;QAFoB,eAAU,GAAV,UAAU,CAAQ;QAFvC,WAAM,GAAG,KAAK,CAAC;QAUN,SAAI,GAAG;YACd,KAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACrB,CAAC,CAAC;QATA,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC;IACjC,CAAC;IAED,qCAAS,GAAT;QACE,OAAO,IAAI,CAAC,YAAY,EAAE,CAAC;IAC7B,CAAC;IAMD,iCAAK,GAAL;QACE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC;QACpC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IACH,wBAAC;AAAD,CAAC,AApBD,IAoBC;AAED;;;;GAIG;AACH,SAAgB,aAAa,CAAC,UAAc;IAAd,2BAAA,EAAA,cAAc;IAC1C,OAAO,IAAI,iBAAiB,CAAC,UAAU,CAAC,CAAC;AAC3C,CAAC;AAFD,sCAEC"}
1
+ {"version":3,"file":"traverse-state.cjs","sourceRoot":"","sources":["../../_cjs_prepare/traverse-state.cts"],"names":[],"mappings":";;AAwDA,sCAEC;AA7BD;IAIE,2BAAqB,UAAkB;QAAvC,iBAEC;QAFoB,eAAU,GAAV,UAAU,CAAQ;QAFvC,WAAM,GAAG,KAAK,CAAC;QAUN,SAAI,GAAG;YACd,KAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACrB,CAAC,CAAC;QATA,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC;IACjC,CAAC;IAED,qCAAS,GAAT;QACE,OAAO,IAAI,CAAC,YAAY,EAAE,CAAC;IAC7B,CAAC;IAMD,iCAAK,GAAL;QACE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC;QACpC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IACH,wBAAC;AAAD,CAAC,AApBD,IAoBC;AAED;;;;GAIG;AACH,SAAgB,aAAa,CAAC,UAAc;IAAd,2BAAA,EAAA,cAAc;IAC1C,OAAO,IAAI,iBAAiB,CAAC,UAAU,CAAC,CAAC;AAC3C,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Update = void 0;
3
+ exports.Update = Update;
4
4
  /**
5
5
  * Returns the result of given `update` parameter, where it can either directly give a new value,
6
6
  * or it is a function receiving the given `value`, and returns a new value.
@@ -20,5 +20,4 @@ function Update(value, update) {
20
20
  }
21
21
  return update;
22
22
  }
23
- exports.Update = Update;
24
23
  //# sourceMappingURL=update.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"update.cjs","sourceRoot":"","sources":["../../_cjs_prepare/update.cts"],"names":[],"mappings":";;;AAKA;;;;;;;;;;;;GAYG;AACH,SAAgB,MAAM,CAAI,KAAQ,EAAE,MAAiB;IACnD,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE,CAAC;QACjC,OAAQ,MAA0B,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AALD,wBAKC"}
1
+ {"version":3,"file":"update.cjs","sourceRoot":"","sources":["../../_cjs_prepare/update.cts"],"names":[],"mappings":";;AAkBA,wBAKC;AAlBD;;;;;;;;;;;;GAYG;AACH,SAAgB,MAAM,CAAI,KAAQ,EAAE,MAAiB;IACnD,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE,CAAC;QACjC,OAAQ,MAA0B,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rimbu/common",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "Common types and objects used in many other Rimbu packages",
5
5
  "keywords": [
6
6
  "common",
@@ -34,6 +34,7 @@
34
34
  "types": "./dist/cjs/index.d.cts",
35
35
  "exports": {
36
36
  ".": {
37
+ "bun": "./dist/bun/index.mts",
37
38
  "import": {
38
39
  "types": "./dist/esm/index.d.mts",
39
40
  "default": "./dist/esm/index.mjs"
@@ -41,8 +42,7 @@
41
42
  "require": {
42
43
  "types": "./dist/cjs/index.d.cts",
43
44
  "default": "./dist/cjs/index.cjs"
44
- },
45
- "bun": "./dist/bun/index.mts"
45
+ }
46
46
  }
47
47
  },
48
48
  "files": [
@@ -65,7 +65,7 @@
65
65
  "bundle:deno-clean": "rimraf _deno_prepare",
66
66
  "bundle:esm": "tsc --p tsconfig.esm.json",
67
67
  "clean": "rimraf dist",
68
- "extract-api": "ts-node ../../config/api-extractor.ts config/api-extractor.main.json",
68
+ "extract-api": "tsx ../../config/api-extractor.ts config/api-extractor.main.json",
69
69
  "format": "yarn format:base --write",
70
70
  "format:base": "prettier \"{!CHANGELOG.md}|**/**/*.{ts,tsx,js,mts,mjs,json,md}\"",
71
71
  "format:check": "yarn format:base --check",
@@ -82,5 +82,5 @@
82
82
  "dependencies": {
83
83
  "tslib": "^2.6.2"
84
84
  },
85
- "gitHead": "b7ed656d2c55d1a715d6a3f52e364e68cb98c759"
85
+ "gitHead": "f18ddf964507dbd10790da3cd4deef8f455a178e"
86
86
  }
package/src/err.mts CHANGED
@@ -18,7 +18,7 @@ export namespace ErrBase {
18
18
  export abstract class CustomError {
19
19
  constructor(readonly message: string) {}
20
20
 
21
- get name() {
21
+ get name(): string {
22
22
  return this.constructor.name;
23
23
  }
24
24
  }