@rimbu/common 2.0.0 → 2.0.1
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/dist/cjs/async-optlazy.cjs +60 -42
- package/dist/cjs/async-optlazy.cjs.map +1 -0
- package/dist/cjs/async-optlazy.d.cts +46 -0
- package/dist/cjs/collect.cjs +9 -31
- package/dist/cjs/collect.cjs.map +1 -0
- package/dist/cjs/collect.d.cts +29 -0
- package/dist/cjs/comp.cjs +518 -707
- package/dist/cjs/comp.cjs.map +1 -0
- package/dist/cjs/comp.d.cts +239 -0
- package/dist/cjs/eq.cjs +375 -203
- package/dist/cjs/eq.cjs.map +1 -0
- package/dist/cjs/err.cjs +57 -50
- package/dist/cjs/err.cjs.map +1 -0
- package/dist/cjs/index-range.cjs +105 -109
- package/dist/cjs/index-range.cjs.map +1 -0
- package/dist/cjs/index-range.d.cts +42 -0
- package/dist/cjs/index.cjs +9 -797
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +6 -0
- package/dist/cjs/internal.cjs +14 -797
- package/dist/cjs/internal.cjs.map +1 -0
- package/dist/cjs/internal.d.cts +11 -0
- package/dist/cjs/optlazy.cjs +44 -37
- package/dist/cjs/optlazy.cjs.map +1 -0
- package/dist/cjs/range.cjs +35 -49
- package/dist/cjs/range.cjs.map +1 -0
- package/dist/cjs/traverse-state.cjs +30 -46
- package/dist/cjs/traverse-state.cjs.map +1 -0
- package/dist/cjs/types.cjs +2 -17
- package/dist/cjs/types.cjs.map +1 -0
- package/dist/cjs/update.cjs +21 -32
- package/dist/cjs/update.cjs.map +1 -0
- package/dist/esm/eq.d.mts +196 -0
- package/dist/esm/err.d.mts +33 -0
- package/dist/esm/optlazy.d.mts +42 -0
- package/dist/esm/range.d.mts +35 -0
- package/dist/esm/traverse-state.d.mts +33 -0
- package/dist/esm/types.d.mts +31 -0
- package/dist/esm/update.d.mts +18 -0
- package/package.json +20 -13
- /package/dist/{types/eq.d.mts → cjs/eq.d.cts} +0 -0
- /package/dist/{types/err.d.mts → cjs/err.d.cts} +0 -0
- /package/dist/{types/optlazy.d.mts → cjs/optlazy.d.cts} +0 -0
- /package/dist/{types/range.d.mts → cjs/range.d.cts} +0 -0
- /package/dist/{types/traverse-state.d.mts → cjs/traverse-state.d.cts} +0 -0
- /package/dist/{types/types.d.mts → cjs/types.d.cts} +0 -0
- /package/dist/{types/update.d.mts → cjs/update.d.cts} +0 -0
- /package/dist/{types → esm}/async-optlazy.d.mts +0 -0
- /package/dist/{types → esm}/collect.d.mts +0 -0
- /package/dist/{types → esm}/comp.d.mts +0 -0
- /package/dist/{types → esm}/index-range.d.mts +0 -0
- /package/dist/{types → esm}/index.d.mts +0 -0
- /package/dist/{types → esm}/internal.d.mts +0 -0
|
@@ -1,44 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
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
|
-
((
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
+
}
|
package/dist/cjs/collect.cjs
CHANGED
|
@@ -1,33 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
((
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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>;
|