@rimbu/common 0.8.2 → 0.9.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 +26 -15
- package/dist/main/async-optlazy.js +6 -2
- package/dist/main/async-optlazy.js.map +1 -1
- package/dist/main/async-reducer.js +22 -22
- package/dist/main/async-reducer.js.map +1 -1
- package/dist/main/collect.js +1 -1
- package/dist/main/comp.js +29 -6
- package/dist/main/comp.js.map +1 -1
- package/dist/main/eq.js +27 -1
- package/dist/main/eq.js.map +1 -1
- package/dist/main/err.js +3 -1
- package/dist/main/err.js.map +1 -1
- package/dist/main/index-range.js +1 -1
- package/dist/main/index-range.js.map +1 -1
- package/dist/main/index.js +6 -1
- package/dist/main/index.js.map +1 -1
- package/dist/main/internal.js +13 -13
- package/dist/main/internal.js.map +1 -1
- package/dist/main/optlazy.js +4 -0
- package/dist/main/optlazy.js.map +1 -1
- package/dist/main/range.js.map +1 -1
- package/dist/main/reducer.js +75 -19
- package/dist/main/reducer.js.map +1 -1
- package/dist/main/update.js +3 -1
- package/dist/main/update.js.map +1 -1
- package/dist/module/async-optlazy.js +4 -0
- package/dist/module/async-optlazy.js.map +1 -1
- package/dist/module/async-reducer.js +12 -12
- package/dist/module/async-reducer.js.map +1 -1
- package/dist/module/collect.js +1 -1
- package/dist/module/comp.js +28 -5
- package/dist/module/comp.js.map +1 -1
- package/dist/module/eq.js +26 -0
- package/dist/module/eq.js.map +1 -1
- package/dist/module/err.js +2 -0
- package/dist/module/err.js.map +1 -1
- package/dist/module/index-range.js.map +1 -1
- package/dist/module/index.js +5 -0
- package/dist/module/index.js.map +1 -1
- package/dist/module/optlazy.js +4 -0
- package/dist/module/optlazy.js.map +1 -1
- package/dist/module/range.js.map +1 -1
- package/dist/module/reducer.js +75 -19
- package/dist/module/reducer.js.map +1 -1
- package/dist/module/update.js +3 -1
- package/dist/module/update.js.map +1 -1
- package/dist/types/async-optlazy.d.ts +4 -0
- package/dist/types/async-reducer.d.ts +37 -22
- package/dist/types/collect.d.ts +2 -2
- package/dist/types/comp.d.ts +32 -5
- package/dist/types/eq.d.ts +26 -0
- package/dist/types/err.d.ts +2 -0
- package/dist/types/index-range.d.ts +14 -13
- package/dist/types/index.d.ts +5 -0
- package/dist/types/optlazy.d.ts +4 -0
- package/dist/types/range.d.ts +11 -10
- package/dist/types/reducer.d.ts +100 -29
- package/dist/types/types.d.ts +0 -4
- package/dist/types/update.d.ts +3 -1
- package/package.json +6 -4
- package/src/async-optlazy.ts +4 -0
- package/src/async-reducer.ts +37 -22
- package/src/collect.ts +2 -2
- package/src/comp.ts +40 -13
- package/src/eq.ts +26 -0
- package/src/err.ts +2 -0
- package/src/index-range.ts +14 -13
- package/src/index.ts +6 -0
- package/src/optlazy.ts +4 -0
- package/src/range.ts +11 -10
- package/src/reducer.ts +107 -31
- package/src/types.ts +0 -5
- package/src/update.ts +3 -1
package/dist/types/comp.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export interface Comp<K> {
|
|
|
10
10
|
* @param value1 - the first value to compare
|
|
11
11
|
* @param value2 - the seconds value to compare
|
|
12
12
|
* @example
|
|
13
|
+
* ```ts
|
|
13
14
|
* const c = Comp.numberComp()
|
|
14
15
|
* console.log(c.compare(5, 5))
|
|
15
16
|
* // => 0
|
|
@@ -17,17 +18,20 @@ export interface Comp<K> {
|
|
|
17
18
|
* // => -2
|
|
18
19
|
* console.log(c.compare(5, 3))
|
|
19
20
|
* // => 2
|
|
21
|
+
* ```
|
|
20
22
|
*/
|
|
21
23
|
compare(value1: K, value2: K): number;
|
|
22
24
|
/**
|
|
23
25
|
* Returns true if this instance can compare given `obj`.
|
|
24
26
|
* @param obj - the object to check
|
|
25
27
|
* @example
|
|
28
|
+
* ```ts
|
|
26
29
|
* const c = Comp.numberComp()
|
|
27
30
|
* console.log(c.isComparable(5))
|
|
28
31
|
* // => true
|
|
29
32
|
* console.log(c.isComparable('a'))
|
|
30
33
|
* // => false
|
|
34
|
+
* ```
|
|
31
35
|
*/
|
|
32
36
|
isComparable(obj: any): obj is K;
|
|
33
37
|
}
|
|
@@ -39,19 +43,23 @@ export declare namespace Comp {
|
|
|
39
43
|
/**
|
|
40
44
|
* Returns a default number Comp instance that orders numbers naturally.
|
|
41
45
|
* @example
|
|
46
|
+
* ```ts
|
|
42
47
|
* const c = Comp.numberComp();
|
|
43
48
|
* console.log(c.compare(3, 5))
|
|
44
49
|
* // => -2
|
|
50
|
+
* ```
|
|
45
51
|
*/
|
|
46
52
|
function numberComp(): Comp<number>;
|
|
47
53
|
/**
|
|
48
54
|
* Returns a default boolean Comp instance that orders booleans according to false < true.
|
|
49
55
|
* @example
|
|
56
|
+
* ```ts
|
|
50
57
|
* const c = Comp.booleanComp();
|
|
51
58
|
* console.log(c.compare(false, true) < 0)
|
|
52
59
|
* // => true
|
|
53
60
|
* console.log(c.compare(true, true))
|
|
54
61
|
* // => 0
|
|
62
|
+
* ```
|
|
55
63
|
*/
|
|
56
64
|
function booleanComp(): Comp<boolean>;
|
|
57
65
|
/**
|
|
@@ -98,23 +106,27 @@ export declare namespace Comp {
|
|
|
98
106
|
* Returns a Comp instance for Iterable objects that orders the Iterables by comparing the elements with the given `itemComp` Comp instance.
|
|
99
107
|
* @param itemComp - (optional) the Comp instance to use to compare the Iterable's elements.
|
|
100
108
|
* @example
|
|
109
|
+
* ```ts
|
|
101
110
|
* const c = Comp.iterableComp();
|
|
102
111
|
* console.log(c.compare([1, 3, 2], [1, 3, 2]))
|
|
103
112
|
* // => 0
|
|
104
113
|
* console.log(c.compare([1, 2, 3, 4], [1, 3, 2]) < 0)
|
|
105
114
|
* // => true
|
|
115
|
+
* ```
|
|
106
116
|
*/
|
|
107
117
|
function iterableComp<T>(itemComp?: Comp<T>): Comp<Iterable<T>>;
|
|
108
118
|
/**
|
|
109
119
|
* Returns a Comp instance for objects that orders the object keys according to the given `keyComp`, and then compares the corresponding
|
|
110
|
-
* values using the given `valueComp`. Objects are then compared as follows
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
120
|
+
* values using the given `valueComp`. Objects are then compared as follows:<br/>
|
|
121
|
+
* starting with the smallest key of either object:<br/>
|
|
122
|
+
* - if only one of the objects has the key, the object with the key is considered to be larger than the other<br/>
|
|
123
|
+
* - if both objects have the key, the values are compared with `valueComp`. If the values are not equal, this result is returned.<br/>
|
|
124
|
+
*
|
|
125
|
+
* if the objects have the same keys with the same values, they are considered equal<br/>
|
|
115
126
|
* @param keyComp - (optional) the Comp instance used to order the object keys
|
|
116
127
|
* @param valueComp - (optional) the Comp instance used to order the object values
|
|
117
128
|
* @example
|
|
129
|
+
* ```ts
|
|
118
130
|
* const c = Comp.objectComp();
|
|
119
131
|
* console.log(c.compare({ a: 1 }, { a: 1 }))
|
|
120
132
|
* // => 0
|
|
@@ -126,6 +138,7 @@ export declare namespace Comp {
|
|
|
126
138
|
* // => true
|
|
127
139
|
* console.log(c.compare({ a: 1, b: 2 }, { b: 2, a: 1 }))
|
|
128
140
|
* // => 0
|
|
141
|
+
* ```
|
|
129
142
|
*/
|
|
130
143
|
function objectComp(options?: {
|
|
131
144
|
keyComp?: Comp<any>;
|
|
@@ -135,22 +148,26 @@ export declare namespace Comp {
|
|
|
135
148
|
* Returns a Comp instance that compares any value using default comparison functions, but never recursively compares
|
|
136
149
|
* Iterables or objects. In those cases, it will use the stringComp instance.
|
|
137
150
|
* @example
|
|
151
|
+
* ```ts
|
|
138
152
|
* const c = Comp.anyFlatComp();
|
|
139
153
|
* console.log(c.compare({ a: 1, b: 1 }, { b: 1, a: 1 }) < 0)
|
|
140
154
|
* // => true
|
|
141
155
|
* // First object is smaller because the objects are converted to a string with and then compares the resulting string.
|
|
156
|
+
* ```
|
|
142
157
|
*/
|
|
143
158
|
function anyFlatComp<T>(): Comp<T>;
|
|
144
159
|
/**
|
|
145
160
|
* Returns a Comp instance that compares any value using default comparison functions. For Iterables and objects, their elements are compared
|
|
146
161
|
* only one level deep for performance and to avoid infinite recursion.
|
|
147
162
|
* @example
|
|
163
|
+
* ```ts
|
|
148
164
|
* const c = Comp.anyShallowComp();
|
|
149
165
|
* console.log(c.compare({ a: 1, b: 1 }, { b: 1, a: 1 }))
|
|
150
166
|
* // => 0
|
|
151
167
|
* console.log(c.compare([{ a: 1, b: 1 }], [{ b: 1, a: 1 }]) < 0)
|
|
152
168
|
* // => true
|
|
153
169
|
* // First object is smaller because the objects are converted to a string and then compares the resulting string.
|
|
170
|
+
* ```
|
|
154
171
|
*/
|
|
155
172
|
function anyShallowComp<T>(): Comp<T>;
|
|
156
173
|
/**
|
|
@@ -158,11 +175,13 @@ export declare namespace Comp {
|
|
|
158
175
|
* recursively.
|
|
159
176
|
* @note can become slow with large nested arrays and objects, and circular structures can cause infinite loops
|
|
160
177
|
* @example
|
|
178
|
+
* ```ts
|
|
161
179
|
* const c = Comp.anyDeepComp();
|
|
162
180
|
* console.log(c.compare({ a: 1, b: 1 }, { b: 1, a: 1 }))
|
|
163
181
|
* // => 0
|
|
164
182
|
* console.log(c.compare([{ a: 1, b: 1 }], [{ b: 1, a: 1 }]))
|
|
165
183
|
* // => 0
|
|
184
|
+
* ```
|
|
166
185
|
*/
|
|
167
186
|
function anyDeepComp<T>(): Comp<T>;
|
|
168
187
|
/**
|
|
@@ -170,11 +189,13 @@ export declare namespace Comp {
|
|
|
170
189
|
* than any other value, and equal to another undefined.
|
|
171
190
|
* @param comp - the Comp instance to wrap
|
|
172
191
|
* @example
|
|
192
|
+
* ```ts
|
|
173
193
|
* const c = Comp.withUndefined(Comp.numberComp())
|
|
174
194
|
* console.log(c.compare(undefined, 5) < 0)
|
|
175
195
|
* // => true
|
|
176
196
|
* console.log(c.compare(undefined, undefined))
|
|
177
197
|
* // => 0
|
|
198
|
+
* ```
|
|
178
199
|
*/
|
|
179
200
|
function withUndefined<T>(comp: Comp<T>): Comp<T | undefined>;
|
|
180
201
|
/**
|
|
@@ -182,31 +203,37 @@ export declare namespace Comp {
|
|
|
182
203
|
* than any other value, and equal to another null.
|
|
183
204
|
* @param comp - the Comp instance to wrap
|
|
184
205
|
* @example
|
|
206
|
+
* ```ts
|
|
185
207
|
* const c = Comp.withNull(Comp.numberComp())
|
|
186
208
|
* console.log(c.compare(null, 5) < 0)
|
|
187
209
|
* // => true
|
|
188
210
|
* console.log(c.compare(null, null))
|
|
189
211
|
* // => 0
|
|
212
|
+
* ```
|
|
190
213
|
*/
|
|
191
214
|
function withNull<T>(comp: Comp<T>): Comp<T | null>;
|
|
192
215
|
/**
|
|
193
216
|
* Returns a Comp instance the reverses the order of the given `comp` instance.
|
|
194
217
|
* @param comp - the Comp instance to wrap
|
|
195
218
|
* @example
|
|
219
|
+
* ```ts
|
|
196
220
|
* const c = Comp.invert(Comp.numberComp())
|
|
197
221
|
* console.log(c.compare(3, 5) > 0)
|
|
198
222
|
* // => true
|
|
199
223
|
* console.log(c.compare(5, 5))
|
|
200
224
|
* // => 0
|
|
225
|
+
* ```
|
|
201
226
|
*/
|
|
202
227
|
function invert<T>(comp: Comp<T>): Comp<T>;
|
|
203
228
|
/**
|
|
204
229
|
* Returns an `Eq` equality instance thet will return true when the given `comp` comparable instance returns 0.
|
|
205
230
|
* @param comp - the `Comp` comparable instance to convert
|
|
206
231
|
* @example
|
|
232
|
+
* ```ts
|
|
207
233
|
* const eq = Comp.toEq(Comp.objectComp())
|
|
208
234
|
* console.log(eq({ a: 1, b: 2 }, { b: 2, a: 1 }))
|
|
209
235
|
* // => true
|
|
236
|
+
* ```
|
|
210
237
|
*/
|
|
211
238
|
function toEq<T>(comp: Comp<T>): Eq<T>;
|
|
212
239
|
}
|
package/dist/types/eq.d.ts
CHANGED
|
@@ -11,11 +11,13 @@ export declare namespace Eq {
|
|
|
11
11
|
/**
|
|
12
12
|
* An Eq instance that uses `Object.is` to determine if two objects are equal.
|
|
13
13
|
* @example
|
|
14
|
+
* ```ts
|
|
14
15
|
* const eq = Eq.objectIs
|
|
15
16
|
* console.log(eq(5, 5))
|
|
16
17
|
* // => true
|
|
17
18
|
* console.log(eq(5, 'a'))
|
|
18
19
|
* // => false
|
|
20
|
+
* ```
|
|
19
21
|
*/
|
|
20
22
|
const objectIs: Eq<any>;
|
|
21
23
|
/**
|
|
@@ -23,11 +25,13 @@ export declare namespace Eq {
|
|
|
23
25
|
* @typeparam T - the object type containing a valueOf function of type V
|
|
24
26
|
* @typeparam V - the valueOf result type
|
|
25
27
|
* @example
|
|
28
|
+
* ```ts
|
|
26
29
|
* const eq = Eq.valueOfEq()
|
|
27
30
|
* console.log(eq(new Number(5), new Number(5)))
|
|
28
31
|
* // => true
|
|
29
32
|
* console.log(eq(new Number(5), new Number(3)))
|
|
30
33
|
* // => false
|
|
34
|
+
* ```
|
|
31
35
|
*/
|
|
32
36
|
function valueOfEq<T extends {
|
|
33
37
|
valueOf(): V;
|
|
@@ -35,11 +39,13 @@ export declare namespace Eq {
|
|
|
35
39
|
/**
|
|
36
40
|
* Returns an Eq instance that compares Date objects according to their `valueOf` value.
|
|
37
41
|
* @example
|
|
42
|
+
* ```ts
|
|
38
43
|
* const eq = Eq.dateEq()
|
|
39
44
|
* console.log(eq(new Date(2020, 1, 1), new Date(2020, 1, 1))
|
|
40
45
|
* // => true
|
|
41
46
|
* console.log(eq(new Date(2020, 1, 1), new Date(2020, 2, 1))
|
|
42
47
|
* // => false
|
|
48
|
+
* ```
|
|
43
49
|
*/
|
|
44
50
|
function dateEq(): Eq<Date>;
|
|
45
51
|
/**
|
|
@@ -47,11 +53,13 @@ export declare namespace Eq {
|
|
|
47
53
|
* @typeparam T - the Iterable element type
|
|
48
54
|
* @param itemEq - (optional) the Eq instance to use to compare the Iterable's elements
|
|
49
55
|
* @example
|
|
56
|
+
* ```ts
|
|
50
57
|
* const eq = Eq.iterableEq();
|
|
51
58
|
* console.log(eq([1, 2, 3], [1, 2, 3])
|
|
52
59
|
* // => true
|
|
53
60
|
* console.log(eq([1, 2, 3], [1, 3, 2])
|
|
54
61
|
* // => false
|
|
62
|
+
* ```
|
|
55
63
|
*/
|
|
56
64
|
function iterableEq<T>(itemEq?: Eq<T>): Eq<Iterable<T>>;
|
|
57
65
|
/**
|
|
@@ -60,11 +68,13 @@ export declare namespace Eq {
|
|
|
60
68
|
* @typeparam - the object property value type
|
|
61
69
|
* @param valueEq - (optional) the Eq instance to use to compare property values
|
|
62
70
|
* @example
|
|
71
|
+
* ```ts
|
|
63
72
|
* const eq = Eq.objectEq()
|
|
64
73
|
* console.log(eq({ a: 1, b: { c: 2 }}, { b: { c: 2 }, a: 1 }))
|
|
65
74
|
* // => true
|
|
66
75
|
* console.log(eq({ a: 1, b: { c: 2 }}, { a: 1, b: { c: 3 }}))
|
|
67
76
|
* // => false
|
|
77
|
+
* ```
|
|
68
78
|
*/
|
|
69
79
|
function objectEq<V = any>(valueEq?: Eq<V>): Eq<Record<any, V>>;
|
|
70
80
|
/**
|
|
@@ -72,11 +82,13 @@ export declare namespace Eq {
|
|
|
72
82
|
* it will compare with Object.is.
|
|
73
83
|
* @typeparam T - the value type
|
|
74
84
|
* @example
|
|
85
|
+
* ```ts
|
|
75
86
|
* const eq = anyFlatEq()
|
|
76
87
|
* console.log(eq(1, 'a'))
|
|
77
88
|
* // => false
|
|
78
89
|
* console.log(eq({ a: 1, b: 2 }, { b: 2, a: 1 }))
|
|
79
90
|
* // => false
|
|
91
|
+
* ```
|
|
80
92
|
*/
|
|
81
93
|
function anyFlatEq<T = any>(): Eq<T>;
|
|
82
94
|
/**
|
|
@@ -85,6 +97,7 @@ export declare namespace Eq {
|
|
|
85
97
|
* with Object.is.
|
|
86
98
|
* @typeparam T - the value type
|
|
87
99
|
* @example
|
|
100
|
+
* ```ts
|
|
88
101
|
* const eq = anyFlatEq()
|
|
89
102
|
* console.log(eq(1, 'a'))
|
|
90
103
|
* // => false
|
|
@@ -92,6 +105,7 @@ export declare namespace Eq {
|
|
|
92
105
|
* // => true
|
|
93
106
|
* console.log(eq([{ a: 1, b: 2 }], [{ b: 2, a: 1 }]))
|
|
94
107
|
* // => false
|
|
108
|
+
* ```
|
|
95
109
|
*/
|
|
96
110
|
function anyShallowEq<T = any>(): Eq<T>;
|
|
97
111
|
/**
|
|
@@ -101,6 +115,7 @@ export declare namespace Eq {
|
|
|
101
115
|
* may cause infinite loops
|
|
102
116
|
* @typeparam T - the value type
|
|
103
117
|
* @example
|
|
118
|
+
* ```ts
|
|
104
119
|
* const eq = anyFlatEq()
|
|
105
120
|
* console.log(eq(1, 'a'))
|
|
106
121
|
* // => false
|
|
@@ -108,6 +123,7 @@ export declare namespace Eq {
|
|
|
108
123
|
* // => true
|
|
109
124
|
* console.log(eq([{ a: 1, b: 2 }], [{ b: 2, a: 1 }]))
|
|
110
125
|
* // => false
|
|
126
|
+
* ```
|
|
111
127
|
*/
|
|
112
128
|
function anyDeepEq<T = any>(): Eq<T>;
|
|
113
129
|
/**
|
|
@@ -115,42 +131,50 @@ export declare namespace Eq {
|
|
|
115
131
|
* @param locales - (optional) a locale or list of locales
|
|
116
132
|
* @param options - (optional) see String.localeCompare for details
|
|
117
133
|
* @example
|
|
134
|
+
* ```ts
|
|
118
135
|
* const eq = Eq.createStringCollatorEq()
|
|
119
136
|
* console.log(eq('a', 'a'))
|
|
120
137
|
* // => true
|
|
121
138
|
* console.log(eq('abc', 'aBc'))
|
|
122
139
|
* // => false
|
|
140
|
+
* ```
|
|
123
141
|
*/
|
|
124
142
|
function createStringCollatorEq(...args: ConstructorParameters<typeof Intl.Collator>): Eq<string>;
|
|
125
143
|
/**
|
|
126
144
|
* Returns an Eq instance that considers strings equal regardless of their case.
|
|
127
145
|
* @example
|
|
146
|
+
* ```ts
|
|
128
147
|
* const eq = Eq.stringCaseInsentitiveEq()
|
|
129
148
|
* console.log(eq('aB', 'Ab'))
|
|
130
149
|
* // => true
|
|
131
150
|
* console.log(eq('aBc', 'abB'))
|
|
132
151
|
* // => false
|
|
152
|
+
* ```
|
|
133
153
|
*/
|
|
134
154
|
function stringCaseInsentitiveEq(): Eq<string>;
|
|
135
155
|
/**
|
|
136
156
|
* Returns an Eq instance that considers strings equal when all their charcodes are equal.
|
|
137
157
|
* @example
|
|
158
|
+
* ```ts
|
|
138
159
|
* const eq = Eq.stringCharCodeEq()
|
|
139
160
|
* console.log(eq('a', 'a'))
|
|
140
161
|
* // => true
|
|
141
162
|
* console.log(eq('abc', 'aBc'))
|
|
142
163
|
* // => false
|
|
164
|
+
* ```
|
|
143
165
|
*/
|
|
144
166
|
function stringCharCodeEq(): Eq<string>;
|
|
145
167
|
function anyToStringEq(): Eq<any>;
|
|
146
168
|
/**
|
|
147
169
|
* Returns an Eq instance that considers values equal their JSON.stringify values are equal.
|
|
148
170
|
* @example
|
|
171
|
+
* ```ts
|
|
149
172
|
* const eq = Eq.anyJsonEq()
|
|
150
173
|
* console.log(eq({ a: 1, b: 2 }, { a: 1, b: 2 }))
|
|
151
174
|
* // => true
|
|
152
175
|
* console.log(eq({ a: 1, b: 2 }, { b: 2, a: 1 }))
|
|
153
176
|
* // => false
|
|
177
|
+
* ```
|
|
154
178
|
*/
|
|
155
179
|
function anyJsonEq(): Eq<any>;
|
|
156
180
|
/**
|
|
@@ -158,6 +182,7 @@ export declare namespace Eq {
|
|
|
158
182
|
* or if [A, B] equals [D, C]
|
|
159
183
|
* @param eq - (optional) an alternative `Eq` instance to use for the values in the tuple
|
|
160
184
|
* @example
|
|
185
|
+
* ```ts
|
|
161
186
|
* const eq = Eq.tupleSymmetric()
|
|
162
187
|
* console.log(eq([1, 2], [1, 2]))
|
|
163
188
|
* // => true
|
|
@@ -165,6 +190,7 @@ export declare namespace Eq {
|
|
|
165
190
|
* // => true
|
|
166
191
|
* console.log(eq([1, 3], [2, 1]))
|
|
167
192
|
* // => false
|
|
193
|
+
* ```
|
|
168
194
|
*/
|
|
169
195
|
function tupleSymmetric<T>(eq?: Eq<T>): Eq<readonly [T, T]>;
|
|
170
196
|
}
|
package/dist/types/err.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Throws an `Err.ForcedError` error when called.
|
|
3
3
|
* @example
|
|
4
|
+
* ```ts
|
|
4
5
|
* const emptyMap = HashMap.empty<number, string>()
|
|
5
6
|
* emptyMap.get(5, Err);
|
|
6
7
|
* // throws: Err.CustomError(message: 'Err: forced to throw error')
|
|
8
|
+
* ```
|
|
7
9
|
*/
|
|
8
10
|
export declare function Err(): never;
|
|
9
11
|
export declare namespace ErrBase {
|
|
@@ -2,19 +2,20 @@ import type { Range } from './internal';
|
|
|
2
2
|
/**
|
|
3
3
|
* A flexible range specification for numeric indices.
|
|
4
4
|
* If a start or end is defined, a tuple can be used where the second item is a boolean
|
|
5
|
-
* indicating whether that end is inclusive or exclusive
|
|
6
|
-
* An IndexRange can have one of the following forms
|
|
7
|
-
*
|
|
8
|
-
* - {
|
|
9
|
-
* - { start: number
|
|
10
|
-
* - { start: number,
|
|
11
|
-
* - { start: number, end:
|
|
12
|
-
* - { start: [number, boolean] }
|
|
13
|
-
* - { start: [number, boolean]
|
|
14
|
-
* - { start: [number, boolean],
|
|
15
|
-
* - { start: [number, boolean], end:
|
|
16
|
-
* - { end: number }
|
|
17
|
-
* - { end:
|
|
5
|
+
* indicating whether that end is inclusive or exclusive.<br/>
|
|
6
|
+
* An IndexRange can have one of the following forms:<br/>
|
|
7
|
+
* <br/>
|
|
8
|
+
* - { amount: number }<br/>
|
|
9
|
+
* - { start: number }<br/>
|
|
10
|
+
* - { start: number, amount: number }<br/>
|
|
11
|
+
* - { start: number, end: number }<br/>
|
|
12
|
+
* - { start: number, end: [number, boolean] }<br/>
|
|
13
|
+
* - { start: [number, boolean] }<br/>
|
|
14
|
+
* - { start: [number, boolean], amount: number }<br/>
|
|
15
|
+
* - { start: [number, boolean], end: number }<br/>
|
|
16
|
+
* - { start: [number, boolean], end: [number, boolean] }<br/>
|
|
17
|
+
* - { end: number }<br/>
|
|
18
|
+
* - { end: [number, boolean] }<br/>
|
|
18
19
|
*/
|
|
19
20
|
export declare type IndexRange = {
|
|
20
21
|
amount: number;
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/optlazy.d.ts
CHANGED
|
@@ -7,9 +7,11 @@ export declare type OptLazy<T> = T | (() => T);
|
|
|
7
7
|
* Returns the value contained in an `OptLazy` instance of type T.
|
|
8
8
|
* @param optLazy - the `OptLazy` value of type T
|
|
9
9
|
* @example
|
|
10
|
+
* ```ts
|
|
10
11
|
* OptLazy(1) // => 1
|
|
11
12
|
* OptLazy(() => 1) // => 1
|
|
12
13
|
* OptLazy(() => () => 1) // => () => 1
|
|
14
|
+
* ```
|
|
13
15
|
*/
|
|
14
16
|
export declare function OptLazy<T>(optLazy: OptLazy<T>): T;
|
|
15
17
|
/**
|
|
@@ -25,8 +27,10 @@ export declare type OptLazyOr<T, O> = T | ((none: O) => T | O);
|
|
|
25
27
|
* @param optLazyOr - a value or a function returning a value or otherwise the received value
|
|
26
28
|
* @param otherValue - the value to return if the optLazyOr does not return its own value
|
|
27
29
|
* @example
|
|
30
|
+
* ```ts
|
|
28
31
|
* OptLazyOr(1, 'a') // => 1
|
|
29
32
|
* OptLazyOr(() => 1, 'a') // => 1
|
|
30
33
|
* OptLazyOr((none) => none, 'a') // => 'a'
|
|
34
|
+
* ```
|
|
31
35
|
*/
|
|
32
36
|
export declare function OptLazyOr<T, O>(optLazyOr: OptLazyOr<T, O>, otherValue: O): T | O;
|
package/dist/types/range.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A range definition for any type of (orderable) value.
|
|
3
3
|
* If a start or end is defined, a tuple can be used where the second item is a boolean
|
|
4
|
-
* indicating whether that end is inclusive or exclusive
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* - { end:
|
|
8
|
-
* - {
|
|
9
|
-
* - { start: T
|
|
10
|
-
* - { start: T, end:
|
|
11
|
-
* - { start: [T, boolean] }
|
|
12
|
-
* - { start: [T, boolean]
|
|
13
|
-
* - { start: [T, boolean], end:
|
|
4
|
+
* indicating whether that end is inclusive (true) or exclusive (false).<br/>
|
|
5
|
+
* A Range of type T can have one of the following forms:<br/>
|
|
6
|
+
* <br/>
|
|
7
|
+
* - { end: T }<br/>
|
|
8
|
+
* - { end: [T, boolean] }<br/>
|
|
9
|
+
* - { start: T }<br/>
|
|
10
|
+
* - { start: T, end: T }<br/>
|
|
11
|
+
* - { start: T, end: [T, boolean] }<br/>
|
|
12
|
+
* - { start: [T, boolean] }<br/>
|
|
13
|
+
* - { start: [T, boolean], end: T }<br/>
|
|
14
|
+
* - { start: [T, boolean], end: [T, boolean] }<br/>
|
|
14
15
|
*/
|
|
15
16
|
export declare type Range<T> = {
|
|
16
17
|
start: T | [T, boolean];
|