@rimbu/common 2.0.0 → 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.
Files changed (56) hide show
  1. package/README.md +42 -42
  2. package/dist/bun/err.mts +1 -1
  3. package/dist/cjs/async-optlazy.cjs +60 -42
  4. package/dist/cjs/async-optlazy.cjs.map +1 -0
  5. package/dist/cjs/async-optlazy.d.cts +46 -0
  6. package/dist/cjs/collect.cjs +9 -31
  7. package/dist/cjs/collect.cjs.map +1 -0
  8. package/dist/cjs/collect.d.cts +29 -0
  9. package/dist/cjs/comp.cjs +518 -707
  10. package/dist/cjs/comp.cjs.map +1 -0
  11. package/dist/cjs/comp.d.cts +239 -0
  12. package/dist/cjs/eq.cjs +375 -203
  13. package/dist/cjs/eq.cjs.map +1 -0
  14. package/dist/cjs/err.cjs +57 -50
  15. package/dist/cjs/err.cjs.map +1 -0
  16. package/dist/cjs/index-range.cjs +105 -109
  17. package/dist/cjs/index-range.cjs.map +1 -0
  18. package/dist/cjs/index-range.d.cts +42 -0
  19. package/dist/cjs/index.cjs +9 -797
  20. package/dist/cjs/index.cjs.map +1 -0
  21. package/dist/cjs/index.d.cts +6 -0
  22. package/dist/cjs/internal.cjs +14 -797
  23. package/dist/cjs/internal.cjs.map +1 -0
  24. package/dist/cjs/internal.d.cts +11 -0
  25. package/dist/cjs/optlazy.cjs +43 -37
  26. package/dist/cjs/optlazy.cjs.map +1 -0
  27. package/dist/cjs/range.cjs +35 -49
  28. package/dist/cjs/range.cjs.map +1 -0
  29. package/dist/cjs/traverse-state.cjs +29 -46
  30. package/dist/cjs/traverse-state.cjs.map +1 -0
  31. package/dist/cjs/types.cjs +2 -17
  32. package/dist/cjs/types.cjs.map +1 -0
  33. package/dist/cjs/update.cjs +20 -32
  34. package/dist/cjs/update.cjs.map +1 -0
  35. package/dist/esm/eq.d.mts +196 -0
  36. package/dist/esm/err.d.mts +33 -0
  37. package/dist/esm/optlazy.d.mts +42 -0
  38. package/dist/esm/range.d.mts +35 -0
  39. package/dist/esm/traverse-state.d.mts +33 -0
  40. package/dist/esm/types.d.mts +31 -0
  41. package/dist/esm/update.d.mts +18 -0
  42. package/package.json +19 -12
  43. package/src/err.mts +1 -1
  44. /package/dist/{types/eq.d.mts → cjs/eq.d.cts} +0 -0
  45. /package/dist/{types/err.d.mts → cjs/err.d.cts} +0 -0
  46. /package/dist/{types/optlazy.d.mts → cjs/optlazy.d.cts} +0 -0
  47. /package/dist/{types/range.d.mts → cjs/range.d.cts} +0 -0
  48. /package/dist/{types/traverse-state.d.mts → cjs/traverse-state.d.cts} +0 -0
  49. /package/dist/{types/types.d.mts → cjs/types.d.cts} +0 -0
  50. /package/dist/{types/update.d.mts → cjs/update.d.cts} +0 -0
  51. /package/dist/{types → esm}/async-optlazy.d.mts +0 -0
  52. /package/dist/{types → esm}/collect.d.mts +0 -0
  53. /package/dist/{types → esm}/comp.d.mts +0 -0
  54. /package/dist/{types → esm}/index-range.d.mts +0 -0
  55. /package/dist/{types → esm}/index.d.mts +0 -0
  56. /package/dist/{types → esm}/internal.d.mts +0 -0
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
  }
@@ -1,44 +1,62 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/async-optlazy.mts
21
- var async_optlazy_exports = {};
22
- __export(async_optlazy_exports, {
23
- AsyncOptLazy: () => AsyncOptLazy
24
- });
25
- module.exports = __toCommonJS(async_optlazy_exports);
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AsyncOptLazy = void 0;
4
+ var tslib_1 = require("tslib");
26
5
  var AsyncOptLazy;
27
- ((AsyncOptLazy2) => {
28
- function toMaybePromise(optLazy, ...args) {
29
- if (optLazy instanceof Function)
30
- return optLazy(...args);
31
- return optLazy;
32
- }
33
- AsyncOptLazy2.toMaybePromise = toMaybePromise;
34
- async function toPromise(optLazy, ...args) {
35
- if (optLazy instanceof Function)
36
- return optLazy(...args);
37
- return optLazy;
38
- }
39
- AsyncOptLazy2.toPromise = toPromise;
40
- })(AsyncOptLazy || (AsyncOptLazy = {}));
41
- // Annotate the CommonJS export names for ESM import in node:
42
- 0 && (module.exports = {
43
- AsyncOptLazy
44
- });
6
+ (function (AsyncOptLazy) {
7
+ /**
8
+ * Returns the value or promised value contained in an `AsyncOptLazy` instance of type T.
9
+ * @param optLazy - the `AsyncOptLazy` value of type T
10
+ * @param args - when needed, the extra arguments to pass to the lazy invocation
11
+ * @typeparam T - the value type
12
+ * @typeparam A - (default: []) types of the argument array that can be passed in the lazy case
13
+ * @example
14
+ * ```ts
15
+ * AsyncOptLazy.toMaybePromise(1) // => 1
16
+ * AsyncOptLazy.toMaybePromise(() => 1) // => 1
17
+ * AsyncOptLazy.toMaybePromise(() => () => 1) // => () => 1
18
+ * AsyncOptLazy.toMaybePromise(async () => 1) // => Promise(1)
19
+ * AsyncOptLazy.toMaybePromise(Promise.resolve(1)) // => Promise(1)
20
+ * ```
21
+ */
22
+ function toMaybePromise(optLazy) {
23
+ var args = [];
24
+ for (var _i = 1; _i < arguments.length; _i++) {
25
+ args[_i - 1] = arguments[_i];
26
+ }
27
+ if (optLazy instanceof Function)
28
+ return optLazy.apply(void 0, tslib_1.__spreadArray([], tslib_1.__read(args), false));
29
+ return optLazy;
30
+ }
31
+ AsyncOptLazy.toMaybePromise = toMaybePromise;
32
+ /**
33
+ * Returns the value contained in an `AsyncOptLazy` instance of type T as a promise.
34
+ * @param optLazy - the `AsyncOptLazy` value of type T
35
+ * @param args - when needed, the extra arguments to pass to the lazy invocation
36
+ * @typeparam T - the value type
37
+ * @typeparam A - (default: []) types of the argument array that can be passed in the lazy case
38
+ * @example
39
+ * ```ts
40
+ * AsyncOptLazy.toPromise(1) // => Promise(1)
41
+ * AsyncOptLazy.toPromise(() => 1) // => Promise(1)
42
+ * AsyncOptLazy.toPromise(() => () => 1) // => Promise(() => 1)
43
+ * AsyncOptLazy.toPromise(async () => 1) // => Promise(1)
44
+ * AsyncOptLazy.toPromise(Promise.resolve(1)) // => Promise(1)
45
+ * ```
46
+ */
47
+ function toPromise(optLazy) {
48
+ var args = [];
49
+ for (var _i = 1; _i < arguments.length; _i++) {
50
+ args[_i - 1] = arguments[_i];
51
+ }
52
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
53
+ return tslib_1.__generator(this, function (_a) {
54
+ if (optLazy instanceof Function)
55
+ return [2 /*return*/, optLazy.apply(void 0, tslib_1.__spreadArray([], tslib_1.__read(args), false))];
56
+ return [2 /*return*/, optLazy];
57
+ });
58
+ });
59
+ }
60
+ AsyncOptLazy.toPromise = toPromise;
61
+ })(AsyncOptLazy || (exports.AsyncOptLazy = AsyncOptLazy = {}));
62
+ //# sourceMappingURL=async-optlazy.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-optlazy.cjs","sourceRoot":"","sources":["../../_cjs_prepare/async-optlazy.cts"],"names":[],"mappings":";;;;AAeA,IAAiB,YAAY,CA8C5B;AA9CD,WAAiB,YAAY;IAC3B;;;;;;;;;;;;;;OAcG;IACH,SAAgB,cAAc,CAC5B,OAA2B;QAC3B,cAAU;aAAV,UAAU,EAAV,qBAAU,EAAV,IAAU;YAAV,6BAAU;;QAEV,IAAI,OAAO,YAAY,QAAQ;YAAE,OAAO,OAAO,wDAAI,IAAI,WAAE;QACzD,OAAO,OAAO,CAAC;IACjB,CAAC;IANe,2BAAc,iBAM7B,CAAA;IAED;;;;;;;;;;;;;;OAcG;IACH,SAAsB,SAAS,CAC7B,OAA2B;QAC3B,cAAU;aAAV,UAAU,EAAV,qBAAU,EAAV,IAAU;YAAV,6BAAU;;;;gBAEV,IAAI,OAAO,YAAY,QAAQ;oBAAE,sBAAO,OAAO,wDAAI,IAAI,YAAE;gBACzD,sBAAO,OAAO,EAAC;;;KAChB;IANqB,sBAAS,YAM9B,CAAA;AACH,CAAC,EA9CgB,YAAY,4BAAZ,YAAY,QA8C5B"}
@@ -0,0 +1,46 @@
1
+ import type { OptLazy } from './internal.cjs';
2
+ /**
3
+ * A type that is either a value T or a promise yielding a value of type T.
4
+ * @typeparam T - the value type
5
+ */
6
+ export type MaybePromise<T> = T | Promise<T>;
7
+ /**
8
+ * A potentially lazy and/or asynchronous value of type T.
9
+ * @typeparam T - the value type
10
+ * @typeparam A - (default: []) types of the argument array that can be passed in the lazy case
11
+ */
12
+ export type AsyncOptLazy<T, A extends any[] = []> = OptLazy<MaybePromise<T>, A>;
13
+ export declare namespace AsyncOptLazy {
14
+ /**
15
+ * Returns the value or promised value contained in an `AsyncOptLazy` instance of type T.
16
+ * @param optLazy - the `AsyncOptLazy` value of type T
17
+ * @param args - when needed, the extra arguments to pass to the lazy invocation
18
+ * @typeparam T - the value type
19
+ * @typeparam A - (default: []) types of the argument array that can be passed in the lazy case
20
+ * @example
21
+ * ```ts
22
+ * AsyncOptLazy.toMaybePromise(1) // => 1
23
+ * AsyncOptLazy.toMaybePromise(() => 1) // => 1
24
+ * AsyncOptLazy.toMaybePromise(() => () => 1) // => () => 1
25
+ * AsyncOptLazy.toMaybePromise(async () => 1) // => Promise(1)
26
+ * AsyncOptLazy.toMaybePromise(Promise.resolve(1)) // => Promise(1)
27
+ * ```
28
+ */
29
+ function toMaybePromise<T, A extends any[] = []>(optLazy: AsyncOptLazy<T, A>, ...args: A): MaybePromise<T>;
30
+ /**
31
+ * Returns the value contained in an `AsyncOptLazy` instance of type T as a promise.
32
+ * @param optLazy - the `AsyncOptLazy` value of type T
33
+ * @param args - when needed, the extra arguments to pass to the lazy invocation
34
+ * @typeparam T - the value type
35
+ * @typeparam A - (default: []) types of the argument array that can be passed in the lazy case
36
+ * @example
37
+ * ```ts
38
+ * AsyncOptLazy.toPromise(1) // => Promise(1)
39
+ * AsyncOptLazy.toPromise(() => 1) // => Promise(1)
40
+ * AsyncOptLazy.toPromise(() => () => 1) // => Promise(() => 1)
41
+ * AsyncOptLazy.toPromise(async () => 1) // => Promise(1)
42
+ * AsyncOptLazy.toPromise(Promise.resolve(1)) // => Promise(1)
43
+ * ```
44
+ */
45
+ function toPromise<T, A extends any[] = []>(optLazy: AsyncOptLazy<T, A>, ...args: A): Promise<T>;
46
+ }
@@ -1,33 +1,11 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/collect.mts
21
- var collect_exports = {};
22
- __export(collect_exports, {
23
- CollectFun: () => CollectFun
24
- });
25
- module.exports = __toCommonJS(collect_exports);
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CollectFun = void 0;
26
4
  var CollectFun;
27
- ((CollectFun2) => {
28
- CollectFun2.Skip = Symbol("Skip");
29
- })(CollectFun || (CollectFun = {}));
30
- // Annotate the CommonJS export names for ESM import in node:
31
- 0 && (module.exports = {
32
- CollectFun
33
- });
5
+ (function (CollectFun) {
6
+ /**
7
+ * Indicates, when returned from a collect function, to skip the value.
8
+ */
9
+ CollectFun.Skip = Symbol('Skip');
10
+ })(CollectFun || (exports.CollectFun = CollectFun = {}));
11
+ //# sourceMappingURL=collect.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collect.cjs","sourceRoot":"","sources":["../../_cjs_prepare/collect.cts"],"names":[],"mappings":";;;AAiBA,IAAiB,UAAU,CAU1B;AAVD,WAAiB,UAAU;IACzB;;OAEG;IACU,eAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;AAMrC,CAAC,EAVgB,UAAU,0BAAV,UAAU,QAU1B"}
@@ -0,0 +1,29 @@
1
+ import type { MaybePromise } from './internal.cjs';
2
+ /**
3
+ * A function used in `collect` methods to collect values from a collection. This is basically a single-pass map and filter.
4
+ * @param value - the input value
5
+ * @param index - the index of the input value
6
+ * @param skip - a token that can be returned to skip the value
7
+ * @param halt - a function that, when called, ensures no more values are passed
8
+ * @returns either a new value to collect, or the `skip` token indicating to skip the value
9
+ */
10
+ export type CollectFun<T, R> = (value: T, index: number, skip: CollectFun.Skip, halt: () => void) => R | CollectFun.Skip;
11
+ export declare namespace CollectFun {
12
+ /**
13
+ * Indicates, when returned from a collect function, to skip the value.
14
+ */
15
+ const Skip: unique symbol;
16
+ /**
17
+ * Indicates, when returned from a collect function, to skip the value.
18
+ */
19
+ type Skip = typeof Skip;
20
+ }
21
+ /**
22
+ * A potentially asynchronous function used in `collect` methods to collect values from a collection. This is basically a single-pass map and filter.
23
+ * @param value - the input value
24
+ * @param index - the index of the input value
25
+ * @param skip - a token that can be returned to skip the value
26
+ * @param halt - a function that, when called, ensures no more values are passed
27
+ * @returns either a new value to collect, or the `skip` token indicating to skip the value
28
+ */
29
+ export type AsyncCollectFun<T, R> = (value: T, index: number, skip: CollectFun.Skip, halt: () => void) => MaybePromise<R | CollectFun.Skip>;