@tempots/std 0.24.0 → 0.25.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/README.md +2 -0
- package/array.cjs +1 -1
- package/array.js +95 -95
- package/async-result.cjs +1 -1
- package/async-result.d.ts +102 -0
- package/async-result.js +214 -32
- package/index.cjs +1 -1
- package/index.js +1 -1
- package/json.cjs +1 -1
- package/json.js +1 -1
- package/object.cjs +1 -1
- package/object.js +21 -18
- package/package.json +1 -1
- package/regexp.cjs +1 -1
- package/regexp.js +12 -10
- package/result-7Po2Mxhx.js +486 -0
- package/result-bSKKrSLB.cjs +1 -0
- package/result.cjs +1 -1
- package/result.d.ts +111 -0
- package/result.js +1 -1
- package/string.cjs +4 -4
- package/string.js +44 -43
- package/timer.cjs +1 -1
- package/timer.d.ts +3 -3
- package/timer.js +37 -23
- package/validation.cjs +1 -1
- package/validation.d.ts +89 -0
- package/validation.js +1 -1
- package/result-CGd0jCdl.js +0 -265
- package/result-CdwVhaAc.cjs +0 -1
package/async-result.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const s = {
|
|
2
2
|
/**
|
|
3
3
|
* Creates a loading state.
|
|
4
4
|
* @param previousValue - The previous value.
|
|
@@ -76,8 +76,8 @@ const u = {
|
|
|
76
76
|
* @returns The value if the result is a success; otherwise, the alternative value.
|
|
77
77
|
* @public
|
|
78
78
|
*/
|
|
79
|
-
getOrElse(e,
|
|
80
|
-
return
|
|
79
|
+
getOrElse(e, r) {
|
|
80
|
+
return s.isSuccess(e) ? e.value : r;
|
|
81
81
|
},
|
|
82
82
|
/**
|
|
83
83
|
* Gets the value if the result is a success; otherwise, returns the value from the alternative function.
|
|
@@ -87,8 +87,8 @@ const u = {
|
|
|
87
87
|
* @public
|
|
88
88
|
* function.
|
|
89
89
|
*/
|
|
90
|
-
getOrElseLazy(e,
|
|
91
|
-
return
|
|
90
|
+
getOrElseLazy(e, r) {
|
|
91
|
+
return s.isSuccess(e) ? e.value : r();
|
|
92
92
|
},
|
|
93
93
|
/**
|
|
94
94
|
* Gets the value if the result is a success; otherwise, returns `null`.
|
|
@@ -97,7 +97,7 @@ const u = {
|
|
|
97
97
|
* @public
|
|
98
98
|
*/
|
|
99
99
|
getOrNull(e) {
|
|
100
|
-
return
|
|
100
|
+
return s.isSuccess(e) ? e.value : null;
|
|
101
101
|
},
|
|
102
102
|
/**
|
|
103
103
|
* Gets the value if the result is a success; otherwise, returns `undefined`.
|
|
@@ -106,7 +106,7 @@ const u = {
|
|
|
106
106
|
* @public
|
|
107
107
|
*/
|
|
108
108
|
getOrUndefined(e) {
|
|
109
|
-
return
|
|
109
|
+
return s.isSuccess(e) ? e.value : void 0;
|
|
110
110
|
},
|
|
111
111
|
/**
|
|
112
112
|
* Gets the value of a `AsyncResult` if it is a `Success`, otherwise it throws the error contained in the `Failure`.
|
|
@@ -114,9 +114,9 @@ const u = {
|
|
|
114
114
|
* @returns The value of the `AsyncResult` if it is a `Success`.
|
|
115
115
|
*/
|
|
116
116
|
getUnsafe: (e) => {
|
|
117
|
-
if (
|
|
117
|
+
if (s.isSuccess(e))
|
|
118
118
|
return e.value;
|
|
119
|
-
throw
|
|
119
|
+
throw s.isFailure(e) ? e.error : new Error("Cannot get value from a not-asked or loading result");
|
|
120
120
|
},
|
|
121
121
|
/**
|
|
122
122
|
* Based on the state of the result, it picks the appropriate function to call and returns the result.
|
|
@@ -128,11 +128,36 @@ const u = {
|
|
|
128
128
|
* @public
|
|
129
129
|
*/
|
|
130
130
|
match: (e, {
|
|
131
|
-
success:
|
|
132
|
-
failure:
|
|
133
|
-
loading:
|
|
134
|
-
notAsked:
|
|
135
|
-
}) =>
|
|
131
|
+
success: r,
|
|
132
|
+
failure: u,
|
|
133
|
+
loading: a,
|
|
134
|
+
notAsked: c = a
|
|
135
|
+
}) => s.isSuccess(e) ? r(e.value) : s.isFailure(e) ? u(e.error) : s.isNotAsked(e) ? c() : a(e.previousValue),
|
|
136
|
+
/**
|
|
137
|
+
* Executes side effects based on the state of the result.
|
|
138
|
+
* Unlike `match`, all handlers are optional, allowing you to react only to specific states.
|
|
139
|
+
* @param r - The result.
|
|
140
|
+
* @param handlers - An object with optional handlers for each state.
|
|
141
|
+
* @returns The result that was passed in, allowing for chaining.
|
|
142
|
+
* @public
|
|
143
|
+
*/
|
|
144
|
+
effect: (e, r) => {
|
|
145
|
+
switch (e.type) {
|
|
146
|
+
case "AsyncSuccess":
|
|
147
|
+
r.success?.(e.value);
|
|
148
|
+
break;
|
|
149
|
+
case "AsyncFailure":
|
|
150
|
+
r.failure?.(e.error);
|
|
151
|
+
break;
|
|
152
|
+
case "Loading":
|
|
153
|
+
r.loading?.(e.previousValue);
|
|
154
|
+
break;
|
|
155
|
+
case "NotAsked":
|
|
156
|
+
r.notAsked?.();
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
return e;
|
|
160
|
+
},
|
|
136
161
|
/**
|
|
137
162
|
* When the result is a success, it applies the function to the value.
|
|
138
163
|
*
|
|
@@ -141,7 +166,7 @@ const u = {
|
|
|
141
166
|
* @returns The result that was passed in.
|
|
142
167
|
* @public
|
|
143
168
|
*/
|
|
144
|
-
whenSuccess: (e,
|
|
169
|
+
whenSuccess: (e, r) => (s.isSuccess(e) && r(e.value), e),
|
|
145
170
|
/**
|
|
146
171
|
* When the result is a failure, it applies the function to the error.
|
|
147
172
|
*
|
|
@@ -150,7 +175,7 @@ const u = {
|
|
|
150
175
|
* @returns The result that was passed in.
|
|
151
176
|
* @public
|
|
152
177
|
*/
|
|
153
|
-
whenFailure: (e,
|
|
178
|
+
whenFailure: (e, r) => (s.isFailure(e) && r(e.error), e),
|
|
154
179
|
/**
|
|
155
180
|
* Compares two results for equality.
|
|
156
181
|
* @param r1 - The first result.
|
|
@@ -158,23 +183,23 @@ const u = {
|
|
|
158
183
|
* @param options - The options to use for comparison. By default, uses strict equality.
|
|
159
184
|
* @returns `true` if the results are equal, `false` otherwise.
|
|
160
185
|
*/
|
|
161
|
-
equals: (e,
|
|
162
|
-
valueEquals: (
|
|
163
|
-
errorEquals: (
|
|
164
|
-
}) => e.type === "AsyncSuccess" &&
|
|
186
|
+
equals: (e, r, u = {
|
|
187
|
+
valueEquals: (a, c) => a === c,
|
|
188
|
+
errorEquals: (a, c) => a === c
|
|
189
|
+
}) => e.type === "AsyncSuccess" && r.type === "AsyncSuccess" ? u.valueEquals(e.value, r.value) : e.type === "AsyncFailure" && r.type === "AsyncFailure" ? u.errorEquals(e.error, r.error) : e.type === "Loading" && r.type === "Loading" ? u.valueEquals(e.previousValue, r.previousValue) : e.type === "NotAsked" && r.type === "NotAsked",
|
|
165
190
|
/**
|
|
166
191
|
* Combines multiple results into a single result.
|
|
167
192
|
* @param results - The results to combine.
|
|
168
193
|
* @returns A single result that is a success if all the input results are successes, otherwise a failure.
|
|
169
194
|
*/
|
|
170
195
|
all: (e) => {
|
|
171
|
-
const
|
|
172
|
-
for (const
|
|
173
|
-
if (
|
|
174
|
-
|
|
196
|
+
const r = [];
|
|
197
|
+
for (const u of e)
|
|
198
|
+
if (s.isSuccess(u))
|
|
199
|
+
r.push(u.value);
|
|
175
200
|
else
|
|
176
|
-
return
|
|
177
|
-
return
|
|
201
|
+
return u;
|
|
202
|
+
return s.success(r);
|
|
178
203
|
},
|
|
179
204
|
/**
|
|
180
205
|
* Converts a Promise to an AsyncResult.
|
|
@@ -183,13 +208,170 @@ const u = {
|
|
|
183
208
|
*/
|
|
184
209
|
ofPromise: async (e) => {
|
|
185
210
|
try {
|
|
186
|
-
const
|
|
187
|
-
return
|
|
188
|
-
} catch (
|
|
189
|
-
return
|
|
211
|
+
const r = await e;
|
|
212
|
+
return s.success(r);
|
|
213
|
+
} catch (r) {
|
|
214
|
+
return s.failure(r instanceof Error ? r : new Error(String(r)));
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
/**
|
|
218
|
+
* Maps the value of a successful `AsyncResult` to a new value using the provided function.
|
|
219
|
+
* For other states (NotAsked, Loading, Failure), the state is preserved.
|
|
220
|
+
* When mapping a Loading state with a previous value, the previous value is also mapped.
|
|
221
|
+
* @param result - The `AsyncResult` to map.
|
|
222
|
+
* @param fn - The mapping function to apply to the success value.
|
|
223
|
+
* @returns A new `AsyncResult` with the mapped value if successful, otherwise the original state.
|
|
224
|
+
* @public
|
|
225
|
+
*/
|
|
226
|
+
map: (e, r) => {
|
|
227
|
+
switch (e.type) {
|
|
228
|
+
case "AsyncSuccess":
|
|
229
|
+
return s.success(r(e.value));
|
|
230
|
+
case "NotAsked":
|
|
231
|
+
return s.notAsked;
|
|
232
|
+
case "AsyncFailure":
|
|
233
|
+
return s.failure(e.error);
|
|
234
|
+
case "Loading":
|
|
235
|
+
return s.loading(
|
|
236
|
+
e.previousValue != null ? r(e.previousValue) : void 0
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
/**
|
|
241
|
+
* Maps the value of a successful `AsyncResult` to a new `AsyncResult` using the provided function.
|
|
242
|
+
* This is useful for chaining operations that may also fail.
|
|
243
|
+
* @param result - The `AsyncResult` to flat map.
|
|
244
|
+
* @param fn - The mapping function that returns a new `AsyncResult`.
|
|
245
|
+
* @returns The result of the mapping function if successful, otherwise the original state.
|
|
246
|
+
* @public
|
|
247
|
+
*/
|
|
248
|
+
flatMap: (e, r) => {
|
|
249
|
+
switch (e.type) {
|
|
250
|
+
case "AsyncSuccess":
|
|
251
|
+
return r(e.value);
|
|
252
|
+
case "NotAsked":
|
|
253
|
+
return s.notAsked;
|
|
254
|
+
case "AsyncFailure":
|
|
255
|
+
return s.failure(e.error);
|
|
256
|
+
case "Loading":
|
|
257
|
+
return s.loading();
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
/**
|
|
261
|
+
* Maps the error of a failed `AsyncResult` to a new error using the provided function.
|
|
262
|
+
* For other states, the state is preserved.
|
|
263
|
+
* @param result - The `AsyncResult` to map the error of.
|
|
264
|
+
* @param fn - The mapping function to apply to the error.
|
|
265
|
+
* @returns A new `AsyncResult` with the mapped error if failed, otherwise the original state.
|
|
266
|
+
* @public
|
|
267
|
+
*/
|
|
268
|
+
mapError: (e, r) => {
|
|
269
|
+
switch (e.type) {
|
|
270
|
+
case "AsyncSuccess":
|
|
271
|
+
return s.success(e.value);
|
|
272
|
+
case "NotAsked":
|
|
273
|
+
return s.notAsked;
|
|
274
|
+
case "AsyncFailure":
|
|
275
|
+
return s.failure(r(e.error));
|
|
276
|
+
case "Loading":
|
|
277
|
+
return s.loading(e.previousValue);
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
/**
|
|
281
|
+
* Maps the error of a failed `AsyncResult` to a new `AsyncResult` using the provided function.
|
|
282
|
+
* This allows recovery from errors by returning a new successful result.
|
|
283
|
+
* @param result - The `AsyncResult` to recover from.
|
|
284
|
+
* @param fn - The recovery function that returns a new `AsyncResult`.
|
|
285
|
+
* @returns The result of the recovery function if failed, otherwise the original state.
|
|
286
|
+
* @public
|
|
287
|
+
*/
|
|
288
|
+
flatMapError: (e, r) => {
|
|
289
|
+
switch (e.type) {
|
|
290
|
+
case "AsyncSuccess":
|
|
291
|
+
return s.success(e.value);
|
|
292
|
+
case "NotAsked":
|
|
293
|
+
return s.notAsked;
|
|
294
|
+
case "AsyncFailure":
|
|
295
|
+
return r(e.error);
|
|
296
|
+
case "Loading":
|
|
297
|
+
return s.loading(e.previousValue);
|
|
190
298
|
}
|
|
191
|
-
}
|
|
299
|
+
},
|
|
300
|
+
/**
|
|
301
|
+
* Converts an `AsyncResult` to a `Result`, discarding the loading and not-asked states.
|
|
302
|
+
* Returns `undefined` if the result is not settled (i.e., NotAsked or Loading).
|
|
303
|
+
* @param result - The `AsyncResult` to convert.
|
|
304
|
+
* @returns A `Result` if the `AsyncResult` is settled, otherwise `undefined`.
|
|
305
|
+
* @public
|
|
306
|
+
*/
|
|
307
|
+
toResult: (e) => {
|
|
308
|
+
switch (e.type) {
|
|
309
|
+
case "AsyncSuccess":
|
|
310
|
+
return { type: "Success", value: e.value };
|
|
311
|
+
case "AsyncFailure":
|
|
312
|
+
return { type: "Failure", error: e.error };
|
|
313
|
+
case "NotAsked":
|
|
314
|
+
case "Loading":
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
/**
|
|
319
|
+
* Checks if the result is settled (either success or failure).
|
|
320
|
+
* @param r - The result.
|
|
321
|
+
* @returns `true` if the result is settled; otherwise, `false`.
|
|
322
|
+
* @public
|
|
323
|
+
*/
|
|
324
|
+
isSettled(e) {
|
|
325
|
+
return e.type === "AsyncSuccess" || e.type === "AsyncFailure";
|
|
326
|
+
},
|
|
327
|
+
/**
|
|
328
|
+
* Recovers from a failure by providing an alternative value.
|
|
329
|
+
* @param result - The `AsyncResult` to recover from.
|
|
330
|
+
* @param fn - The function that provides an alternative value given the error.
|
|
331
|
+
* @returns A successful `AsyncResult` with the alternative value if failed, otherwise the original state.
|
|
332
|
+
* @public
|
|
333
|
+
*/
|
|
334
|
+
recover: (e, r) => {
|
|
335
|
+
switch (e.type) {
|
|
336
|
+
case "AsyncSuccess":
|
|
337
|
+
return s.success(e.value);
|
|
338
|
+
case "NotAsked":
|
|
339
|
+
return s.notAsked;
|
|
340
|
+
case "AsyncFailure":
|
|
341
|
+
return s.success(r(e.error));
|
|
342
|
+
case "Loading":
|
|
343
|
+
return s.loading(e.previousValue);
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
/**
|
|
347
|
+
* Applies a function wrapped in an `AsyncResult` to a value wrapped in an `AsyncResult`.
|
|
348
|
+
* Useful for applying multiple arguments to a function in a safe way.
|
|
349
|
+
* @param resultFn - The `AsyncResult` containing the function.
|
|
350
|
+
* @param resultVal - The `AsyncResult` containing the value.
|
|
351
|
+
* @returns A new `AsyncResult` with the result of applying the function to the value.
|
|
352
|
+
* @public
|
|
353
|
+
*/
|
|
354
|
+
ap: (e, r) => s.isSuccess(e) && s.isSuccess(r) ? s.success(e.value(r.value)) : s.isFailure(e) ? s.failure(e.error) : s.isFailure(r) ? s.failure(r.error) : s.isLoading(e) || s.isLoading(r) ? s.loading() : s.notAsked,
|
|
355
|
+
/**
|
|
356
|
+
* Maps two `AsyncResult` values using a function.
|
|
357
|
+
* @param r1 - The first `AsyncResult`.
|
|
358
|
+
* @param r2 - The second `AsyncResult`.
|
|
359
|
+
* @param fn - The function to apply to both values.
|
|
360
|
+
* @returns A new `AsyncResult` with the result of applying the function to both values.
|
|
361
|
+
* @public
|
|
362
|
+
*/
|
|
363
|
+
map2: (e, r, u) => s.isSuccess(e) && s.isSuccess(r) ? s.success(u(e.value, r.value)) : s.isFailure(e) ? s.failure(e.error) : s.isFailure(r) ? s.failure(r.error) : s.isLoading(e) || s.isLoading(r) ? s.loading() : s.notAsked,
|
|
364
|
+
/**
|
|
365
|
+
* Maps three `AsyncResult` values using a function.
|
|
366
|
+
* @param r1 - The first `AsyncResult`.
|
|
367
|
+
* @param r2 - The second `AsyncResult`.
|
|
368
|
+
* @param r3 - The third `AsyncResult`.
|
|
369
|
+
* @param fn - The function to apply to all three values.
|
|
370
|
+
* @returns A new `AsyncResult` with the result of applying the function to all three values.
|
|
371
|
+
* @public
|
|
372
|
+
*/
|
|
373
|
+
map3: (e, r, u, a) => s.isSuccess(e) && s.isSuccess(r) && s.isSuccess(u) ? s.success(a(e.value, r.value, u.value)) : s.isFailure(e) ? s.failure(e.error) : s.isFailure(r) ? s.failure(r.error) : s.isFailure(u) ? s.failure(u.error) : s.isLoading(e) || s.isLoading(r) || s.isLoading(u) ? s.loading() : s.notAsked
|
|
192
374
|
};
|
|
193
375
|
export {
|
|
194
|
-
|
|
376
|
+
s as AsyncResult
|
|
195
377
|
};
|
package/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./array.cjs"),b=require("./async-result.cjs"),a=require("./bigint.cjs"),u=require("./boolean.cjs"),t=require("./date.cjs"),A=require("./deferred.cjs"),g=require("./equal.cjs"),p=require("./function.cjs"),l=require("./iterator.cjs"),y=require("./json.cjs"),m=require("./map.cjs"),i=require("./number.cjs"),s=require("./object.cjs"),S=require("./promise.cjs"),c=require("./random.cjs"),C=require("./regexp.cjs"),f=require("./result-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./array.cjs"),b=require("./async-result.cjs"),a=require("./bigint.cjs"),u=require("./boolean.cjs"),t=require("./date.cjs"),A=require("./deferred.cjs"),g=require("./equal.cjs"),p=require("./function.cjs"),l=require("./iterator.cjs"),y=require("./json.cjs"),m=require("./map.cjs"),i=require("./number.cjs"),s=require("./object.cjs"),S=require("./promise.cjs"),c=require("./random.cjs"),C=require("./regexp.cjs"),f=require("./result-bSKKrSLB.cjs"),n=require("./set.cjs"),e=require("./string.cjs"),d=require("./timer.cjs"),o=require("./url.cjs");exports.applyArrayDiffOperations=r.applyArrayDiffOperations;exports.areArraysEqual=r.areArraysEqual;exports.arrayDiffOperations=r.arrayDiffOperations;exports.arrayHasValues=r.arrayHasValues;exports.arrayHead=r.arrayHead;exports.arrayTail=r.arrayTail;exports.buildArray=r.buildArray;exports.chunk=r.chunk;exports.compareArrays=r.compareArrays;exports.fillArray=r.fillArray;exports.filterMapArray=r.filterMapArray;exports.filterNullsFromArray=r.filterNullsFromArray;exports.groupBy=r.groupBy;exports.isArrayEmpty=r.isArrayEmpty;exports.joinArrayWithConjunction=r.joinArrayWithConjunction;exports.partition=r.partition;exports.range=r.range;exports.rankArray=r.rankArray;exports.removeAllFromArray=r.removeAllFromArray;exports.removeAllFromArrayByPredicate=r.removeAllFromArrayByPredicate;exports.removeOneFromArray=r.removeOneFromArray;exports.removeOneFromArrayByPredicate=r.removeOneFromArrayByPredicate;exports.uniqueByPrimitive=r.uniqueByPrimitive;exports.AsyncResult=b.AsyncResult;exports.biAbs=a.biAbs;exports.biCeilDiv=a.biCeilDiv;exports.biCompare=a.biCompare;exports.biFloorDiv=a.biFloorDiv;exports.biGcd=a.biGcd;exports.biIsEven=a.biIsEven;exports.biIsNegative=a.biIsNegative;exports.biIsOdd=a.biIsOdd;exports.biIsOne=a.biIsOne;exports.biIsPositive=a.biIsPositive;exports.biIsPrime=a.biIsPrime;exports.biIsZero=a.biIsZero;exports.biLcm=a.biLcm;exports.biMax=a.biMax;exports.biMin=a.biMin;exports.biNextPrime=a.biNextPrime;exports.biPow=a.biPow;exports.biPrevPrime=a.biPrevPrime;exports.booleanToInt=u.booleanToInt;exports.canParseBoolean=u.canParseBoolean;exports.compareBooleans=u.compareBooleans;exports.parseBoolean=u.parseBoolean;exports.xorBoolean=u.xorBoolean;exports.addDays=t.addDays;exports.addHours=t.addHours;exports.addMinutes=t.addMinutes;exports.compareDates=t.compareDates;exports.diffInDays=t.diffInDays;exports.diffInHours=t.diffInHours;exports.endOfDay=t.endOfDay;exports.endOfWeek=t.endOfWeek;exports.isSameDay=t.isSameDay;exports.isSameHour=t.isSameHour;exports.isSameMinute=t.isSameMinute;exports.isSameMonth=t.isSameMonth;exports.isSameSecond=t.isSameSecond;exports.isSameWeek=t.isSameWeek;exports.isSameYear=t.isSameYear;exports.isValidDate=t.isValidDate;exports.isWeekend=t.isWeekend;exports.startOfDay=t.startOfDay;exports.startOfWeek=t.startOfWeek;exports.deferred=A.deferred;exports.deepEqual=g.deepEqual;exports.looseEqual=g.looseEqual;exports.strictEqual=g.strictEqual;exports.compose=p.compose;exports.curryLeft=p.curryLeft;exports.flip=p.flip;exports.identity=p.identity;exports.memoize=p.memoize;exports.negate=p.negate;exports.once=p.once;exports.partial=p.partial;exports.pipe=p.pipe;exports.chain=l.chain;exports.every=l.every;exports.filter=l.filter;exports.find=l.find;exports.map=l.map;exports.reduce=l.reduce;exports.skip=l.skip;exports.some=l.some;exports.take=l.take;exports.toArray=l.toArray;exports.isJSON=y.isJSON;exports.isJSONArray=y.isJSONArray;exports.isJSONObject=y.isJSONObject;exports.isJSONPrimitive=y.isJSONPrimitive;exports.parseJSON=y.parseJSON;exports.mapEntries=m.mapEntries;exports.mapFilter=m.mapFilter;exports.mapFromEntries=m.mapFromEntries;exports.mapGroupBy=m.mapGroupBy;exports.mapIsEmpty=m.mapIsEmpty;exports.mapKeys=m.mapKeys;exports.mapMap=m.mapMap;exports.mapMerge=m.mapMerge;exports.mapToObject=m.mapToObject;exports.mapValues=m.mapValues;exports.EPSILON=i.EPSILON;exports.angleDifference=i.angleDifference;exports.ceilTo=i.ceilTo;exports.clamp=i.clamp;exports.clampInt=i.clampInt;exports.clampSym=i.clampSym;exports.compareNumbers=i.compareNumbers;exports.floorTo=i.floorTo;exports.interpolate=i.interpolate;exports.interpolateAngle=i.interpolateAngle;exports.interpolateAngleCCW=i.interpolateAngleCCW;exports.interpolateAngleCW=i.interpolateAngleCW;exports.interpolateWidestAngle=i.interpolateWidestAngle;exports.nearEqual=i.nearEqual;exports.nearEqualAngles=i.nearEqualAngles;exports.nearZero=i.nearZero;exports.root=i.root;exports.roundTo=i.roundTo;exports.toHex=i.toHex;exports.widestAngleDifference=i.widestAngleDifference;exports.wrap=i.wrap;exports.wrapCircular=i.wrapCircular;exports.deepClone=s.deepClone;exports.isEmptyObject=s.isEmptyObject;exports.isObject=s.isObject;exports.mergeObjects=s.mergeObjects;exports.objectEntries=s.objectEntries;exports.objectFromEntries=s.objectFromEntries;exports.objectKeys=s.objectKeys;exports.objectValues=s.objectValues;exports.omit=s.omit;exports.pick=s.pick;exports.removeObjectFields=s.removeObjectFields;exports.sameObjectKeys=s.sameObjectKeys;exports.sleep=S.sleep;exports.randomBytes=c.randomBytes;exports.randomChoice=c.randomChoice;exports.randomChoices=c.randomChoices;exports.randomFloat=c.randomFloat;exports.randomHex=c.randomHex;exports.randomInt=c.randomInt;exports.randomUuid=c.randomUuid;exports.seedRandom=c.seedRandom;exports.shuffle=c.shuffle;exports.shuffled=c.shuffled;exports.mapRegExp=C.mapRegExp;exports.Result=f.Result;exports.Validation=f.Validation;exports.setDifference=n.setDifference;exports.setFilter=n.setFilter;exports.setFromArray=n.setFromArray;exports.setIntersection=n.setIntersection;exports.setIsEmpty=n.setIsEmpty;exports.setIsSubset=n.setIsSubset;exports.setIsSuperset=n.setIsSuperset;exports.setMap=n.setMap;exports.setSymmetricDifference=n.setSymmetricDifference;exports.setToArray=n.setToArray;exports.setUnion=n.setUnion;exports.canonicalizeNewlines=e.canonicalizeNewlines;exports.capitalize=e.capitalize;exports.capitalizeWords=e.capitalizeWords;exports.chunkString=e.chunkString;exports.collapseText=e.collapseText;exports.compareCaseInsensitive=e.compareCaseInsensitive;exports.compareStrings=e.compareStrings;exports.containsAllText=e.containsAllText;exports.containsAllTextCaseInsensitive=e.containsAllTextCaseInsensitive;exports.containsAnyText=e.containsAnyText;exports.containsAnyTextCaseInsensitive=e.containsAnyTextCaseInsensitive;exports.countStringOccurrences=e.countStringOccurrences;exports.dasherize=e.dasherize;exports.decodeBase64=e.decodeBase64;exports.deleteFirstFromString=e.deleteFirstFromString;exports.deleteStringAfter=e.deleteStringAfter;exports.deleteStringBefore=e.deleteStringBefore;exports.deleteSubstring=e.deleteSubstring;exports.ellipsis=e.ellipsis;exports.ellipsisMiddle=e.ellipsisMiddle;exports.encodeBase64=e.encodeBase64;exports.filterCharcodes=e.filterCharcodes;exports.filterChars=e.filterChars;exports.humanize=e.humanize;exports.ifEmptyString=e.ifEmptyString;exports.isAlpha=e.isAlpha;exports.isAlphaNum=e.isAlphaNum;exports.isBreakingWhitespace=e.isBreakingWhitespace;exports.isDigitsOnly=e.isDigitsOnly;exports.isEmptyString=e.isEmptyString;exports.isLowerCase=e.isLowerCase;exports.isSpaceAt=e.isSpaceAt;exports.isUpperCase=e.isUpperCase;exports.jsQuote=e.jsQuote;exports.lowerCaseFirst=e.lowerCaseFirst;exports.lpad=e.lpad;exports.mapChars=e.mapChars;exports.quote=e.quote;exports.randomStringSequence=e.randomStringSequence;exports.randomStringSequenceBase64=e.randomStringSequenceBase64;exports.randomSubString=e.randomSubString;exports.reverseString=e.reverseString;exports.rpad=e.rpad;exports.smartQuote=e.smartQuote;exports.splitStringOnFirst=e.splitStringOnFirst;exports.splitStringOnLast=e.splitStringOnLast;exports.splitStringOnce=e.splitStringOnce;exports.stringEndsWithAny=e.stringEndsWithAny;exports.stringHasContent=e.stringHasContent;exports.stringHashCode=e.stringHashCode;exports.stringStartsWithAny=e.stringStartsWithAny;exports.stringToCharcodes=e.stringToCharcodes;exports.stringsDifferAtIndex=e.stringsDifferAtIndex;exports.substringAfter=e.substringAfter;exports.substringAfterLast=e.substringAfterLast;exports.substringBefore=e.substringBefore;exports.substringBeforeLast=e.substringBeforeLast;exports.surroundString=e.surroundString;exports.textContainsCaseInsensitive=e.textContainsCaseInsensitive;exports.textEndsWithAnyCaseInsensitive=e.textEndsWithAnyCaseInsensitive;exports.textEndsWithCaseInsensitive=e.textEndsWithCaseInsensitive;exports.textStartsWithAnyCaseInsensitive=e.textStartsWithAnyCaseInsensitive;exports.textStartsWithCaseInsensitive=e.textStartsWithCaseInsensitive;exports.textToLines=e.textToLines;exports.trimChars=e.trimChars;exports.trimCharsLeft=e.trimCharsLeft;exports.trimCharsRight=e.trimCharsRight;exports.trimStringSlice=e.trimStringSlice;exports.underscore=e.underscore;exports.upperCaseFirst=e.upperCaseFirst;exports.wrapColumns=e.wrapColumns;exports.wrapLine=e.wrapLine;exports.debounce=d.debounce;exports.delayed=d.delayed;exports.delayedAnimationFrame=d.delayedAnimationFrame;exports.interval=d.interval;exports.intervalAnimationFrame=d.intervalAnimationFrame;exports.throttle=d.throttle;exports.buildUrl=o.buildUrl;exports.getBaseName=o.getBaseName;exports.getFileExtension=o.getFileExtension;exports.getFileName=o.getFileName;exports.getQueryParams=o.getQueryParams;exports.isValidUrl=o.isValidUrl;exports.joinPaths=o.joinPaths;exports.normalizePath=o.normalizePath;exports.parseUrl=o.parseUrl;exports.removeQueryParam=o.removeQueryParam;exports.setQueryParam=o.setQueryParam;
|
package/index.js
CHANGED
|
@@ -14,7 +14,7 @@ import { deepClone as jr, isEmptyObject as Nr, isObject as Tr, mergeObjects as k
|
|
|
14
14
|
import { sleep as Jr } from "./promise.js";
|
|
15
15
|
import { randomBytes as Kr, randomChoice as Gr, randomChoices as Zr, randomFloat as Yr, randomHex as Xr, randomInt as _r, randomUuid as $r, seedRandom as et, shuffle as rt, shuffled as tt } from "./random.js";
|
|
16
16
|
import { mapRegExp as at } from "./regexp.js";
|
|
17
|
-
import { R as nt, V as ot } from "./result-
|
|
17
|
+
import { R as nt, V as ot } from "./result-7Po2Mxhx.js";
|
|
18
18
|
import { setDifference as lt, setFilter as pt, setFromArray as dt, setIntersection as ct, setIsEmpty as ft, setIsSubset as yt, setIsSuperset as ut, setMap as gt, setSymmetricDifference as At, setToArray as St, setUnion as bt } from "./set.js";
|
|
19
19
|
import { canonicalizeNewlines as Ct, capitalize as ht, capitalizeWords as Ot, chunkString as It, collapseText as vt, compareCaseInsensitive as Et, compareStrings as Ft, containsAllText as Bt, containsAllTextCaseInsensitive as Dt, containsAnyText as Pt, containsAnyTextCaseInsensitive as Wt, countStringOccurrences as jt, dasherize as Nt, decodeBase64 as Tt, deleteFirstFromString as kt, deleteStringAfter as qt, deleteStringBefore as Lt, deleteSubstring as Mt, ellipsis as wt, ellipsisMiddle as Ht, encodeBase64 as zt, filterCharcodes as Vt, filterChars as Rt, humanize as Ut, ifEmptyString as Jt, isAlpha as Qt, isAlphaNum as Kt, isBreakingWhitespace as Gt, isDigitsOnly as Zt, isEmptyString as Yt, isLowerCase as Xt, isSpaceAt as _t, isUpperCase as $t, jsQuote as ei, lowerCaseFirst as ri, lpad as ti, mapChars as ii, quote as ai, randomStringSequence as si, randomStringSequenceBase64 as ni, randomSubString as oi, reverseString as mi, rpad as li, smartQuote as pi, splitStringOnFirst as di, splitStringOnLast as ci, splitStringOnce as fi, stringEndsWithAny as yi, stringHasContent as ui, stringHashCode as gi, stringStartsWithAny as Ai, stringToCharcodes as Si, stringsDifferAtIndex as bi, substringAfter as xi, substringAfterLast as Ci, substringBefore as hi, substringBeforeLast as Oi, surroundString as Ii, textContainsCaseInsensitive as vi, textEndsWithAnyCaseInsensitive as Ei, textEndsWithCaseInsensitive as Fi, textStartsWithAnyCaseInsensitive as Bi, textStartsWithCaseInsensitive as Di, textToLines as Pi, trimChars as Wi, trimCharsLeft as ji, trimCharsRight as Ni, trimStringSlice as Ti, underscore as ki, upperCaseFirst as qi, wrapColumns as Li, wrapLine as Mi } from "./string.js";
|
|
20
20
|
import { debounce as Hi, delayed as zi, delayedAnimationFrame as Vi, interval as Ri, intervalAnimationFrame as Ui, throttle as Ji } from "./timer.js";
|
package/json.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./result-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./result-bSKKrSLB.cjs"),e=r=>typeof r=="object"&&!Array.isArray(r)&&r!=null&&Object.values(r).every(t),i=r=>Array.isArray(r)&&r.every(t),t=r=>o(r)||e(r)||i(r),o=r=>typeof r=="string"||typeof r=="boolean"||typeof r=="number"||r==null,n=r=>{try{return s.Result.success(JSON.parse(r))}catch(c){return s.Result.failure(c)}};exports.isJSON=t;exports.isJSONArray=i;exports.isJSONObject=e;exports.isJSONPrimitive=o;exports.parseJSON=n;
|
package/json.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as t } from "./result-
|
|
1
|
+
import { R as t } from "./result-7Po2Mxhx.js";
|
|
2
2
|
const e = (r) => typeof r == "object" && !Array.isArray(r) && r != null && Object.values(r).every(s), c = (r) => Array.isArray(r) && r.every(s), s = (r) => i(r) || e(r) || c(r), i = (r) => typeof r == "string" || typeof r == "boolean" || typeof r == "number" || r == null, y = (r) => {
|
|
3
3
|
try {
|
|
4
4
|
return t.success(JSON.parse(r));
|
package/object.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=e=>Object.keys(e),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=e=>Object.keys(e),f=e=>Object.values(e),l=e=>Object.entries(e),u=e=>Object.fromEntries(e),O=(e,t)=>{const s=r(e),n=r(t);if(s.length!==n.length)return!1;for(const c of s)if(!(c in t))return!1;return!0},a=e=>e!=null&&Object.getPrototypeOf(e)===Object.prototype,y=(e,...t)=>{const s=new Set(t);return r(e).reduce((c,o)=>(s.has(o)||(c[o]=e[o]),c),{})},b=(e,t)=>Object.assign({},e,t),j=e=>Object.keys(e).length===0,m=(e,t)=>{const s={};for(const n of t)n in e&&(s[n]=e[n]);return s},p=(e,t)=>{const s={...e};for(const n of t)delete s[n];return s},i=e=>{if(e===null||typeof e!="object")return e;if(e instanceof Date)return new Date(e.getTime());if(e instanceof Array)return e.map(t=>i(t));if(typeof e=="object"){const t={};for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=i(e[s]));return t}return e};exports.deepClone=i;exports.isEmptyObject=j;exports.isObject=a;exports.mergeObjects=b;exports.objectEntries=l;exports.objectFromEntries=u;exports.objectKeys=r;exports.objectValues=f;exports.omit=p;exports.pick=m;exports.removeObjectFields=y;exports.sameObjectKeys=O;
|
package/object.js
CHANGED
|
@@ -1,45 +1,48 @@
|
|
|
1
|
-
const
|
|
2
|
-
const n =
|
|
1
|
+
const o = (e) => Object.keys(e), f = (e) => Object.values(e), l = (e) => Object.entries(e), u = (e) => Object.fromEntries(e), O = (e, t) => {
|
|
2
|
+
const n = o(e), s = o(t);
|
|
3
3
|
if (n.length !== s.length) return !1;
|
|
4
4
|
for (const r of n)
|
|
5
5
|
if (!(r in t)) return !1;
|
|
6
6
|
return !0;
|
|
7
|
-
},
|
|
7
|
+
}, a = (e) => e != null && Object.getPrototypeOf(e) === Object.prototype, p = (e, ...t) => {
|
|
8
|
+
const n = new Set(t);
|
|
9
|
+
return o(e).reduce((r, c) => (n.has(c) || (r[c] = e[c]), r), {});
|
|
10
|
+
}, y = (e, t) => Object.assign({}, e, t), k = (e) => Object.keys(e).length === 0, m = (e, t) => {
|
|
8
11
|
const n = {};
|
|
9
12
|
for (const s of t)
|
|
10
13
|
s in e && (n[s] = e[s]);
|
|
11
14
|
return n;
|
|
12
|
-
},
|
|
15
|
+
}, g = (e, t) => {
|
|
13
16
|
const n = { ...e };
|
|
14
17
|
for (const s of t)
|
|
15
18
|
delete n[s];
|
|
16
19
|
return n;
|
|
17
|
-
},
|
|
20
|
+
}, i = (e) => {
|
|
18
21
|
if (e === null || typeof e != "object")
|
|
19
22
|
return e;
|
|
20
23
|
if (e instanceof Date)
|
|
21
24
|
return new Date(e.getTime());
|
|
22
25
|
if (e instanceof Array)
|
|
23
|
-
return e.map((t) =>
|
|
26
|
+
return e.map((t) => i(t));
|
|
24
27
|
if (typeof e == "object") {
|
|
25
28
|
const t = {};
|
|
26
29
|
for (const n in e)
|
|
27
|
-
Object.prototype.hasOwnProperty.call(e, n) && (t[n] =
|
|
30
|
+
Object.prototype.hasOwnProperty.call(e, n) && (t[n] = i(e[n]));
|
|
28
31
|
return t;
|
|
29
32
|
}
|
|
30
33
|
return e;
|
|
31
34
|
};
|
|
32
35
|
export {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
i as deepClone,
|
|
37
|
+
k as isEmptyObject,
|
|
38
|
+
a as isObject,
|
|
39
|
+
y as mergeObjects,
|
|
40
|
+
l as objectEntries,
|
|
38
41
|
u as objectFromEntries,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
o as objectKeys,
|
|
43
|
+
f as objectValues,
|
|
44
|
+
g as omit,
|
|
45
|
+
m as pick,
|
|
46
|
+
p as removeObjectFields,
|
|
47
|
+
O as sameObjectKeys
|
|
45
48
|
};
|
package/package.json
CHANGED
package/regexp.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=(s,n,i)=>{const l=[];let g=0,e;if(n.global)for(n.lastIndex=0;(e=n.exec(s))!==null;)l.push(s.substring(g,e.index)),l.push(i(...e)),g=e.index+e[0].length;else{const u=new RegExp(n.source,n.flags+"g");for(;(e=u.exec(s))!==null;)l.push(s.substring(g,e.index)),l.push(i(...e)),g=e.index+e[0].length}return l.push(s.substring(g)),l.join("")};exports.mapRegExp=o;
|
package/regexp.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
const
|
|
1
|
+
const x = (s, n, i) => {
|
|
2
2
|
const e = [];
|
|
3
|
-
let
|
|
4
|
-
if (
|
|
5
|
-
for (
|
|
6
|
-
e.push(
|
|
7
|
-
else
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
let g = 0, l;
|
|
4
|
+
if (n.global)
|
|
5
|
+
for (n.lastIndex = 0; (l = n.exec(s)) !== null; )
|
|
6
|
+
e.push(s.substring(g, l.index)), e.push(i(...l)), g = l.index + l[0].length;
|
|
7
|
+
else {
|
|
8
|
+
const u = new RegExp(n.source, n.flags + "g");
|
|
9
|
+
for (; (l = u.exec(s)) !== null; )
|
|
10
|
+
e.push(s.substring(g, l.index)), e.push(i(...l)), g = l.index + l[0].length;
|
|
11
|
+
}
|
|
12
|
+
return e.push(s.substring(g)), e.join("");
|
|
11
13
|
};
|
|
12
14
|
export {
|
|
13
|
-
|
|
15
|
+
x as mapRegExp
|
|
14
16
|
};
|