@rimbu/common 2.0.4 → 2.0.5
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/package.json +3 -5
- package/dist/bun/async-optlazy.mts +0 -62
- package/dist/bun/collect.mts +0 -43
- package/dist/bun/comp.mts +0 -625
- package/dist/bun/eq.mts +0 -427
- package/dist/bun/err.mts +0 -46
- package/dist/bun/index-range.mts +0 -120
- package/dist/bun/index.mts +0 -13
- package/dist/bun/internal.mts +0 -11
- package/dist/bun/optlazy.mts +0 -57
- package/dist/bun/range.mts +0 -58
- package/dist/bun/traverse-state.mts +0 -59
- package/dist/bun/types.mts +0 -40
- package/dist/bun/update.mts +0 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rimbu/common",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
4
4
|
"description": "Common types and objects used in many other Rimbu packages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"common",
|
|
@@ -34,7 +34,6 @@
|
|
|
34
34
|
"types": "./dist/cjs/index.d.cts",
|
|
35
35
|
"exports": {
|
|
36
36
|
".": {
|
|
37
|
-
"bun": "./dist/bun/index.mts",
|
|
38
37
|
"import": {
|
|
39
38
|
"types": "./dist/esm/index.d.mts",
|
|
40
39
|
"default": "./dist/esm/index.mjs"
|
|
@@ -52,8 +51,7 @@
|
|
|
52
51
|
"scripts": {
|
|
53
52
|
"b": "duel",
|
|
54
53
|
"build": "yarn clean && yarn bundle",
|
|
55
|
-
"bundle": "yarn bundle:cjs && yarn bundle:esm
|
|
56
|
-
"bundle:bun": "node ../../config/bunnify.mjs -mode bun",
|
|
54
|
+
"bundle": "yarn bundle:cjs && yarn bundle:esm",
|
|
57
55
|
"bundle:cjs": "yarn bundle:cjs-prepare && yarn bundle:cjs-build && yarn bundle:cjs-clean",
|
|
58
56
|
"bundle:cjs-prepare": "node ../../config/bunnify.mjs -mode cjs",
|
|
59
57
|
"bundle:cjs-build": "tsc -p tsconfig.cjs.json",
|
|
@@ -77,5 +75,5 @@
|
|
|
77
75
|
"dependencies": {
|
|
78
76
|
"tslib": "^2.8.1"
|
|
79
77
|
},
|
|
80
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "15fd7c44f369838a47d42532bcd9771d65d6f660"
|
|
81
79
|
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import type { OptLazy } from './internal.mts';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* A type that is either a value T or a promise yielding a value of type T.
|
|
5
|
-
* @typeparam T - the value type
|
|
6
|
-
*/
|
|
7
|
-
export type MaybePromise<T> = T | Promise<T>;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* A potentially lazy and/or asynchronous value of type T.
|
|
11
|
-
* @typeparam T - the value type
|
|
12
|
-
* @typeparam A - (default: []) types of the argument array that can be passed in the lazy case
|
|
13
|
-
*/
|
|
14
|
-
export type AsyncOptLazy<T, A extends any[] = []> = OptLazy<MaybePromise<T>, A>;
|
|
15
|
-
|
|
16
|
-
export namespace AsyncOptLazy {
|
|
17
|
-
/**
|
|
18
|
-
* Returns the value or promised value contained in an `AsyncOptLazy` instance of type T.
|
|
19
|
-
* @param optLazy - the `AsyncOptLazy` value of type T
|
|
20
|
-
* @param args - when needed, the extra arguments to pass to the lazy invocation
|
|
21
|
-
* @typeparam T - the value type
|
|
22
|
-
* @typeparam A - (default: []) types of the argument array that can be passed in the lazy case
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* AsyncOptLazy.toMaybePromise(1) // => 1
|
|
26
|
-
* AsyncOptLazy.toMaybePromise(() => 1) // => 1
|
|
27
|
-
* AsyncOptLazy.toMaybePromise(() => () => 1) // => () => 1
|
|
28
|
-
* AsyncOptLazy.toMaybePromise(async () => 1) // => Promise(1)
|
|
29
|
-
* AsyncOptLazy.toMaybePromise(Promise.resolve(1)) // => Promise(1)
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
export function toMaybePromise<T, A extends any[] = []>(
|
|
33
|
-
optLazy: AsyncOptLazy<T, A>,
|
|
34
|
-
...args: A
|
|
35
|
-
): MaybePromise<T> {
|
|
36
|
-
if (optLazy instanceof Function) return optLazy(...args);
|
|
37
|
-
return optLazy;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Returns the value contained in an `AsyncOptLazy` instance of type T as a promise.
|
|
42
|
-
* @param optLazy - the `AsyncOptLazy` value of type T
|
|
43
|
-
* @param args - when needed, the extra arguments to pass to the lazy invocation
|
|
44
|
-
* @typeparam T - the value type
|
|
45
|
-
* @typeparam A - (default: []) types of the argument array that can be passed in the lazy case
|
|
46
|
-
* @example
|
|
47
|
-
* ```ts
|
|
48
|
-
* AsyncOptLazy.toPromise(1) // => Promise(1)
|
|
49
|
-
* AsyncOptLazy.toPromise(() => 1) // => Promise(1)
|
|
50
|
-
* AsyncOptLazy.toPromise(() => () => 1) // => Promise(() => 1)
|
|
51
|
-
* AsyncOptLazy.toPromise(async () => 1) // => Promise(1)
|
|
52
|
-
* AsyncOptLazy.toPromise(Promise.resolve(1)) // => Promise(1)
|
|
53
|
-
* ```
|
|
54
|
-
*/
|
|
55
|
-
export async function toPromise<T, A extends any[] = []>(
|
|
56
|
-
optLazy: AsyncOptLazy<T, A>,
|
|
57
|
-
...args: A
|
|
58
|
-
): Promise<T> {
|
|
59
|
-
if (optLazy instanceof Function) return optLazy(...args);
|
|
60
|
-
return optLazy;
|
|
61
|
-
}
|
|
62
|
-
}
|
package/dist/bun/collect.mts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { MaybePromise } from './internal.mts';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* A function used in `collect` methods to collect values from a collection. This is basically a single-pass map and filter.
|
|
5
|
-
* @param value - the input value
|
|
6
|
-
* @param index - the index of the input value
|
|
7
|
-
* @param skip - a token that can be returned to skip the value
|
|
8
|
-
* @param halt - a function that, when called, ensures no more values are passed
|
|
9
|
-
* @returns either a new value to collect, or the `skip` token indicating to skip the value
|
|
10
|
-
*/
|
|
11
|
-
export type CollectFun<T, R> = (
|
|
12
|
-
value: T,
|
|
13
|
-
index: number,
|
|
14
|
-
skip: CollectFun.Skip,
|
|
15
|
-
halt: () => void
|
|
16
|
-
) => R | CollectFun.Skip;
|
|
17
|
-
|
|
18
|
-
export namespace CollectFun {
|
|
19
|
-
/**
|
|
20
|
-
* Indicates, when returned from a collect function, to skip the value.
|
|
21
|
-
*/
|
|
22
|
-
export const Skip = Symbol('Skip');
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Indicates, when returned from a collect function, to skip the value.
|
|
26
|
-
*/
|
|
27
|
-
export type Skip = typeof Skip;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* A potentially asynchronous function used in `collect` methods to collect values from a collection. This is basically a single-pass map and filter.
|
|
32
|
-
* @param value - the input value
|
|
33
|
-
* @param index - the index of the input value
|
|
34
|
-
* @param skip - a token that can be returned to skip the value
|
|
35
|
-
* @param halt - a function that, when called, ensures no more values are passed
|
|
36
|
-
* @returns either a new value to collect, or the `skip` token indicating to skip the value
|
|
37
|
-
*/
|
|
38
|
-
export type AsyncCollectFun<T, R> = (
|
|
39
|
-
value: T,
|
|
40
|
-
index: number,
|
|
41
|
-
skip: CollectFun.Skip,
|
|
42
|
-
halt: () => void
|
|
43
|
-
) => MaybePromise<R | CollectFun.Skip>;
|