@oscarpalmer/atoms 0.158.0 → 0.160.0
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/array/difference.js +2 -0
- package/dist/array/exists.js +2 -0
- package/dist/array/filter.js +2 -0
- package/dist/array/find.js +2 -0
- package/dist/array/flatten.js +2 -0
- package/dist/array/from.js +2 -0
- package/dist/array/get.js +2 -0
- package/dist/array/group-by.js +2 -0
- package/dist/array/index-of.js +2 -0
- package/dist/array/index.js +2 -1
- package/dist/array/insert.js +2 -0
- package/dist/array/intersection.js +2 -0
- package/dist/array/partition.js +2 -0
- package/dist/array/position.js +58 -0
- package/dist/array/push.js +2 -0
- package/dist/array/select.js +2 -0
- package/dist/array/slice.js +2 -0
- package/dist/array/sort.js +2 -0
- package/dist/array/splice.js +2 -0
- package/dist/array/to-map.js +2 -0
- package/dist/array/to-record.js +2 -0
- package/dist/array/to-set.js +2 -0
- package/dist/array/toggle.js +2 -0
- package/dist/array/union.js +2 -0
- package/dist/array/unique.js +2 -0
- package/dist/array/update.js +2 -0
- package/dist/atoms.full.js +223 -162
- package/dist/beacon.js +2 -0
- package/dist/color/constants.js +35 -33
- package/dist/color/index.js +2 -0
- package/dist/color/instance.js +2 -0
- package/dist/color/misc/alpha.js +2 -0
- package/dist/color/misc/get.js +2 -0
- package/dist/color/misc/index.js +2 -0
- package/dist/color/misc/is.js +2 -0
- package/dist/color/misc/state.js +2 -0
- package/dist/color/space/hex.js +2 -0
- package/dist/color/space/hsl.js +2 -0
- package/dist/color/space/rgb.js +2 -0
- package/dist/function/assert.js +2 -0
- package/dist/function/index.js +2 -0
- package/dist/function/memoize.js +2 -0
- package/dist/function/once.js +2 -0
- package/dist/function/retry.js +2 -0
- package/dist/function/work.js +2 -0
- package/dist/index.js +5 -4
- package/dist/internal/array/callbacks.js +2 -0
- package/dist/internal/array/chunk.js +2 -0
- package/dist/internal/array/compact.js +2 -0
- package/dist/internal/array/find.js +6 -4
- package/dist/internal/array/group.js +2 -0
- package/dist/internal/array/insert.js +2 -0
- package/dist/internal/array/sets.js +8 -6
- package/dist/internal/array/shuffle.js +3 -1
- package/dist/internal/array/update.js +2 -0
- package/dist/internal/function/misc.js +2 -0
- package/dist/internal/function/timer.js +5 -3
- package/dist/internal/is.js +2 -0
- package/dist/internal/math/aggregate.js +2 -0
- package/dist/internal/number.js +2 -0
- package/dist/internal/random.js +2 -0
- package/dist/internal/result.js +2 -0
- package/dist/internal/sized.js +2 -0
- package/dist/internal/string.js +2 -0
- package/dist/internal/value/compare.js +2 -0
- package/dist/internal/value/equal.js +2 -0
- package/dist/internal/value/get.js +2 -0
- package/dist/internal/value/handlers.js +2 -0
- package/dist/internal/value/has.js +2 -0
- package/dist/internal/value/misc.js +2 -0
- package/dist/internal/value/partial.js +2 -0
- package/dist/internal/value/set.js +2 -0
- package/dist/is.js +2 -0
- package/dist/logger.js +2 -0
- package/dist/math.js +2 -0
- package/dist/promise/delay.js +3 -1
- package/dist/promise/helpers.js +8 -1
- package/dist/promise/index.js +9 -3
- package/dist/promise/misc.js +3 -1
- package/dist/promise/models.js +14 -12
- package/dist/promise/timed.js +3 -1
- package/dist/query.js +2 -0
- package/dist/queue.js +2 -0
- package/dist/random.js +2 -0
- package/dist/result/index.js +5 -3
- package/dist/result/match.js +2 -0
- package/dist/result/misc.js +2 -0
- package/dist/result/work/flow.js +2 -0
- package/dist/result/work/pipe.js +2 -0
- package/dist/sized/map.js +2 -0
- package/dist/sized/set.js +2 -0
- package/dist/string/case.js +2 -0
- package/dist/string/index.js +2 -0
- package/dist/string/match.js +2 -0
- package/dist/string/template.js +2 -0
- package/dist/value/clone.js +3 -1
- package/dist/value/diff.js +2 -0
- package/dist/value/merge.js +2 -0
- package/dist/value/omit.js +2 -0
- package/dist/value/pick.js +2 -0
- package/dist/value/smush.js +3 -1
- package/dist/value/unsmush.js +3 -1
- package/package.json +3 -3
- package/src/array/index.ts +1 -0
- package/src/array/position.ts +303 -0
- package/src/internal/array/sets.ts +3 -3
- package/src/internal/array/shuffle.ts +1 -1
- package/src/promise/helpers.ts +13 -3
- package/src/promise/index.ts +89 -19
- package/src/promise/misc.ts +1 -4
- package/src/promise/models.ts +18 -12
- package/src/value/clone.ts +1 -1
- package/src/value/smush.ts +1 -1
- package/src/value/unsmush.ts +1 -1
- package/types/array/index.d.ts +1 -0
- package/types/array/position.d.ts +117 -0
- package/types/promise/helpers.d.ts +3 -1
- package/types/promise/index.d.ts +52 -5
- package/types/promise/misc.d.ts +1 -1
- package/types/promise/models.d.ts +15 -11
package/dist/promise/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { CancelablePromise, PROMISE_ABORT_OPTIONS, PROMISE_EVENT_NAME, PROMISE_MESSAGE_EXPECTATION_ATTEMPT, PROMISE_MESSAGE_EXPECTATION_PROMISES, PROMISE_STRATEGY_DEFAULT, PROMISE_TYPE_FULFILLED, PROMISE_TYPE_REJECTED, PromiseTimeoutError } from "./models.js";
|
|
2
|
-
import { getPromiseOptions, getPromisesOptions, isFulfilled, isRejected } from "./helpers.js";
|
|
3
1
|
import { toPromise } from "../result/misc.js";
|
|
2
|
+
import { CancelablePromise, PROMISE_ABORT_OPTIONS, PROMISE_EVENT_NAME, PROMISE_MESSAGE_EXPECTATION_ATTEMPT, PROMISE_MESSAGE_EXPECTATION_PROMISES, PROMISE_STRATEGY_DEFAULT, PROMISE_TYPE_FULFILLED, PROMISE_TYPE_REJECTED, PromiseTimeoutError } from "./models.js";
|
|
4
3
|
import { cancelable, handleResult, settlePromise, toResult } from "./misc.js";
|
|
4
|
+
import { getPromiseOptions, getPromisesOptions, getResultsFromPromises, isFulfilled, isRejected } from "./helpers.js";
|
|
5
5
|
import { getTimedPromise, timed } from "./timed.js";
|
|
6
6
|
import { delay } from "./delay.js";
|
|
7
|
+
//#region src/promise/index.ts
|
|
7
8
|
async function attemptPromise(value, options) {
|
|
8
9
|
const isFunction = typeof value === "function";
|
|
9
10
|
if (!isFunction && !(value instanceof Promise)) return Promise.reject(new TypeError(PROMISE_MESSAGE_EXPECTATION_ATTEMPT));
|
|
@@ -35,7 +36,7 @@ async function promises(items, options) {
|
|
|
35
36
|
if (!Array.isArray(items)) return Promise.reject(new TypeError(PROMISE_MESSAGE_EXPECTATION_PROMISES));
|
|
36
37
|
const actual = items.filter((item) => item instanceof Promise);
|
|
37
38
|
const { length } = actual;
|
|
38
|
-
if (length === 0) return
|
|
39
|
+
if (length === 0) return Promise.reject(new TypeError(PROMISE_MESSAGE_EXPECTATION_PROMISES));
|
|
39
40
|
const complete = strategy === PROMISE_STRATEGY_DEFAULT;
|
|
40
41
|
function abort() {
|
|
41
42
|
handlers.reject(signal.reason);
|
|
@@ -70,4 +71,9 @@ async function promises(items, options) {
|
|
|
70
71
|
}));
|
|
71
72
|
});
|
|
72
73
|
}
|
|
74
|
+
promises.result = resultPromises;
|
|
75
|
+
async function resultPromises(items, signal) {
|
|
76
|
+
return promises(items, signal).then(getResultsFromPromises);
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
73
79
|
export { CancelablePromise, PromiseTimeoutError, attemptPromise, cancelable, delay, toPromise as fromResult, isFulfilled, isRejected, promises, timed, toResult };
|
package/dist/promise/misc.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { CancelablePromise, PROMISE_EVENT_NAME, PROMISE_MESSAGE_EXPECTATION_RESULT } from "./models.js";
|
|
2
1
|
import { error, ok } from "../result/misc.js";
|
|
2
|
+
import { CancelablePromise, PROMISE_EVENT_NAME, PROMISE_MESSAGE_EXPECTATION_RESULT } from "./models.js";
|
|
3
|
+
//#region src/promise/misc.ts
|
|
3
4
|
/**
|
|
4
5
|
* Create a cancelable promise
|
|
5
6
|
* @param executor Executor function for the promise
|
|
@@ -33,4 +34,5 @@ async function toResult(value) {
|
|
|
33
34
|
if (!(actual instanceof Promise)) return Promise.reject(new TypeError(PROMISE_MESSAGE_EXPECTATION_RESULT));
|
|
34
35
|
return actual.then((result) => ok(result)).catch((reason) => error(reason));
|
|
35
36
|
}
|
|
37
|
+
//#endregion
|
|
36
38
|
export { cancelable, handleResult, settlePromise, toResult };
|
package/dist/promise/models.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/promise/models.ts
|
|
1
2
|
var CancelablePromise = class extends Promise {
|
|
2
3
|
#rejector;
|
|
3
4
|
constructor(executor) {
|
|
@@ -22,16 +23,17 @@ var PromiseTimeoutError = class extends Error {
|
|
|
22
23
|
this.name = PROMISE_ERROR_NAME;
|
|
23
24
|
}
|
|
24
25
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
var PROMISE_ABORT_OPTIONS = { once: true };
|
|
27
|
+
var PROMISE_ERROR_NAME = "PromiseTimeoutError";
|
|
28
|
+
var PROMISE_EVENT_NAME = "abort";
|
|
29
|
+
var PROMISE_MESSAGE_EXPECTATION_ATTEMPT = "Attempt expected a function or a promise";
|
|
30
|
+
var PROMISE_MESSAGE_EXPECTATION_PROMISES = "Promises expected an array of promises";
|
|
31
|
+
var PROMISE_MESSAGE_EXPECTATION_RESULT = "toResult expected a Promise";
|
|
32
|
+
var PROMISE_MESSAGE_EXPECTATION_TIMED = "Timed function expected a Promise";
|
|
33
|
+
var PROMISE_MESSAGE_TIMEOUT = "Promise timed out";
|
|
34
|
+
var PROMISE_STRATEGY_ALL = new Set(["complete", "first"]);
|
|
35
|
+
var PROMISE_STRATEGY_DEFAULT = "complete";
|
|
36
|
+
var PROMISE_TYPE_FULFILLED = "fulfilled";
|
|
37
|
+
var PROMISE_TYPE_REJECTED = "rejected";
|
|
38
|
+
//#endregion
|
|
37
39
|
export { CancelablePromise, PROMISE_ABORT_OPTIONS, PROMISE_ERROR_NAME, PROMISE_EVENT_NAME, PROMISE_MESSAGE_EXPECTATION_ATTEMPT, PROMISE_MESSAGE_EXPECTATION_PROMISES, PROMISE_MESSAGE_EXPECTATION_RESULT, PROMISE_MESSAGE_EXPECTATION_TIMED, PROMISE_MESSAGE_TIMEOUT, PROMISE_STRATEGY_ALL, PROMISE_STRATEGY_DEFAULT, PROMISE_TYPE_FULFILLED, PROMISE_TYPE_REJECTED, PromiseTimeoutError };
|
package/dist/promise/timed.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { TIMER_WAIT, getTimer } from "../internal/function/timer.js";
|
|
2
2
|
import { PROMISE_ABORT_OPTIONS, PROMISE_EVENT_NAME, PROMISE_MESSAGE_EXPECTATION_TIMED, PromiseTimeoutError } from "./models.js";
|
|
3
|
-
import { getPromiseOptions } from "./helpers.js";
|
|
4
3
|
import { settlePromise } from "./misc.js";
|
|
4
|
+
import { getPromiseOptions } from "./helpers.js";
|
|
5
|
+
//#region src/promise/timed.ts
|
|
5
6
|
async function getTimedPromise(promise, time, signal) {
|
|
6
7
|
function abort() {
|
|
7
8
|
timer.cancel();
|
|
@@ -27,4 +28,5 @@ async function timed(promise, options) {
|
|
|
27
28
|
if (signal?.aborted ?? false) return Promise.reject(signal.reason);
|
|
28
29
|
return time > 0 ? getTimedPromise(promise, time, signal) : promise;
|
|
29
30
|
}
|
|
31
|
+
//#endregion
|
|
30
32
|
export { getTimedPromise, timed };
|
package/dist/query.js
CHANGED
|
@@ -2,6 +2,7 @@ import { isPlainObject } from "./internal/is.js";
|
|
|
2
2
|
import { ignoreKey, join, tryDecode, tryEncode } from "./internal/string.js";
|
|
3
3
|
import { getNumber } from "./internal/number.js";
|
|
4
4
|
import { setValue } from "./internal/value/set.js";
|
|
5
|
+
//#region src/query.ts
|
|
5
6
|
/**
|
|
6
7
|
* Convert a query string to a plain _(nested)_ object
|
|
7
8
|
* @param query Query string to convert
|
|
@@ -68,4 +69,5 @@ var TYPES = new Set([
|
|
|
68
69
|
"number",
|
|
69
70
|
"string"
|
|
70
71
|
]);
|
|
72
|
+
//#endregion
|
|
71
73
|
export { fromQuery, toQuery };
|
package/dist/queue.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/queue.ts
|
|
1
2
|
var Queue = class {
|
|
2
3
|
#callback;
|
|
3
4
|
#handled = [];
|
|
@@ -205,4 +206,5 @@ var MESSAGE_CALLBACK = "A Queue requires a callback function";
|
|
|
205
206
|
var MESSAGE_CLEAR = "Queue was cleared";
|
|
206
207
|
var MESSAGE_MAXIMUM = "Queue has reached its maximum size";
|
|
207
208
|
var MESSAGE_REMOVE = "Item removed from queue";
|
|
209
|
+
//#endregion
|
|
208
210
|
export { QueueError, queue };
|
package/dist/random.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getRandomFloat, getRandomInteger } from "./internal/random.js";
|
|
2
2
|
import { shuffle } from "./internal/array/shuffle.js";
|
|
3
3
|
import { join } from "./internal/string.js";
|
|
4
|
+
//#region src/random.ts
|
|
4
5
|
/**
|
|
5
6
|
* Get a random boolean
|
|
6
7
|
* @returns Random boolean
|
|
@@ -55,4 +56,5 @@ var ALPHABET = "abcdefghijklmnopqrstuvwxyz";
|
|
|
55
56
|
var BOOLEAN_MODIFIER = .5;
|
|
56
57
|
var HEX_CHARACTERS = "0123456789ABCDEF";
|
|
57
58
|
var HEX_MAXIMUM = 15;
|
|
59
|
+
//#endregion
|
|
58
60
|
export { getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems };
|
package/dist/result/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { isError, isOk, isResult } from "../internal/result.js";
|
|
2
|
-
import { error, getError, ok, toPromise, unwrap } from "./misc.js";
|
|
3
|
-
import { toResult } from "../promise/misc.js";
|
|
4
|
-
import { attemptPromise } from "../promise/index.js";
|
|
5
2
|
import { matchResult } from "./match.js";
|
|
3
|
+
import { error, getError, ok, toPromise, unwrap } from "./misc.js";
|
|
6
4
|
import { attemptFlow } from "./work/flow.js";
|
|
7
5
|
import { attemptPipe } from "./work/pipe.js";
|
|
6
|
+
import { toResult } from "../promise/misc.js";
|
|
7
|
+
import { attemptPromise } from "../promise/index.js";
|
|
8
|
+
//#region src/result/index.ts
|
|
8
9
|
async function asyncAttempt(value, err) {
|
|
9
10
|
try {
|
|
10
11
|
let result = typeof value === "function" ? value() : await value;
|
|
@@ -26,4 +27,5 @@ attempt.flow = attemptFlow;
|
|
|
26
27
|
attempt.match = matchResult;
|
|
27
28
|
attempt.pipe = attemptPipe;
|
|
28
29
|
attempt.promise = attemptPromise;
|
|
30
|
+
//#endregion
|
|
29
31
|
export { attempt, error, toResult as fromPromise, isError, isOk, isResult, ok, toPromise, unwrap };
|
package/dist/result/match.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isOk, isResult } from "../internal/result.js";
|
|
2
|
+
//#region src/result/match.ts
|
|
2
3
|
async function asyncMatchResult(result, first, error) {
|
|
3
4
|
let value;
|
|
4
5
|
if (typeof result === "function") value = await result();
|
|
@@ -22,4 +23,5 @@ function matchResult(result, first, error) {
|
|
|
22
23
|
}
|
|
23
24
|
matchResult.async = asyncMatchResult;
|
|
24
25
|
var MESSAGE_RESULT = "`result.match` expected a Result or a function that returns a Result";
|
|
26
|
+
//#endregion
|
|
25
27
|
export { matchResult };
|
package/dist/result/misc.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isOk, isResult } from "../internal/result.js";
|
|
2
|
+
//#region src/result/misc.ts
|
|
2
3
|
function error(value, original) {
|
|
3
4
|
return getError(value, original);
|
|
4
5
|
}
|
|
@@ -37,4 +38,5 @@ function unwrap(value, defaultValue) {
|
|
|
37
38
|
return isOk(value) ? value.value : defaultValue;
|
|
38
39
|
}
|
|
39
40
|
var MESSAGE_PROMISE_RESULT = "toPromise expected to receive a Result";
|
|
41
|
+
//#endregion
|
|
40
42
|
export { error, getError, ok, toPromise, unwrap };
|
package/dist/result/work/flow.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isError, isOk } from "../../internal/result.js";
|
|
2
2
|
import { flow } from "../../function/work.js";
|
|
3
3
|
import { attempt } from "../index.js";
|
|
4
|
+
//#region src/result/work/flow.ts
|
|
4
5
|
function attemptAsyncFlow(...fns) {
|
|
5
6
|
let Flow;
|
|
6
7
|
return (...args) => attempt.async(() => {
|
|
@@ -22,4 +23,5 @@ function attemptFlow(...fns) {
|
|
|
22
23
|
});
|
|
23
24
|
}
|
|
24
25
|
attemptFlow.async = attemptAsyncFlow;
|
|
26
|
+
//#endregion
|
|
25
27
|
export { attemptFlow };
|
package/dist/result/work/pipe.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isError, isOk } from "../../internal/result.js";
|
|
2
2
|
import { pipe } from "../../function/work.js";
|
|
3
3
|
import { attempt } from "../index.js";
|
|
4
|
+
//#region src/result/work/pipe.ts
|
|
4
5
|
async function attemptAsyncPipe(initial, first, ...seconds) {
|
|
5
6
|
return attempt.async(() => {
|
|
6
7
|
if (isError(initial)) throw initial.error;
|
|
@@ -18,4 +19,5 @@ function attemptPipe(initial, first, ...seconds) {
|
|
|
18
19
|
});
|
|
19
20
|
}
|
|
20
21
|
attemptPipe.async = attemptAsyncPipe;
|
|
22
|
+
//#endregion
|
|
21
23
|
export { attemptPipe };
|
package/dist/sized/map.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getSizedMaximum } from "../internal/sized.js";
|
|
2
|
+
//#region src/sized/map.ts
|
|
2
3
|
/**
|
|
3
4
|
* A Map with a maximum size
|
|
4
5
|
*
|
|
@@ -45,4 +46,5 @@ var SizedMap = class extends Map {
|
|
|
45
46
|
return super.set(key, value);
|
|
46
47
|
}
|
|
47
48
|
};
|
|
49
|
+
//#endregion
|
|
48
50
|
export { SizedMap };
|
package/dist/sized/set.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getSizedMaximum } from "../internal/sized.js";
|
|
2
|
+
//#region src/sized/set.ts
|
|
2
3
|
/**
|
|
3
4
|
* - A Set with a maximum size
|
|
4
5
|
* - Behavior is similar to a _LRU_-cache, where the oldest values are removed
|
|
@@ -51,4 +52,5 @@ var SizedSet = class extends Set {
|
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
};
|
|
55
|
+
//#endregion
|
|
54
56
|
export { SizedSet };
|
package/dist/string/case.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { join, words } from "../internal/string.js";
|
|
2
2
|
import { memoize } from "../function/memoize.js";
|
|
3
|
+
//#region src/string/case.ts
|
|
3
4
|
/**
|
|
4
5
|
* Convert a string to camel case _(thisIsCamelCase)_
|
|
5
6
|
* @param value String to convert
|
|
@@ -111,4 +112,5 @@ var EXPRESSION_ACRONYM = /(\p{Lu}*)(\p{Lu})(\p{Ll}+)/gu;
|
|
|
111
112
|
var REPLACEMENT_CAMEL_CASE = "$1-$2";
|
|
112
113
|
var memoizedCapitalize;
|
|
113
114
|
var memoizedTitleCase;
|
|
115
|
+
//#endregion
|
|
114
116
|
export { camelCase, capitalize, kebabCase, lowerCase, pascalCase, snakeCase, titleCase, upperCase };
|
package/dist/string/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getString, join, words } from "../internal/string.js";
|
|
2
|
+
//#region src/string/index.ts
|
|
2
3
|
/**
|
|
3
4
|
* Get a new UUID-string _(version 4)_
|
|
4
5
|
* @returns UUID string
|
|
@@ -54,4 +55,5 @@ function truncate(value, length, suffix) {
|
|
|
54
55
|
const truncatedLength = length - actualSuffixLength;
|
|
55
56
|
return `${value.slice(0, truncatedLength)}${actualSuffix}`;
|
|
56
57
|
}
|
|
58
|
+
//#endregion
|
|
57
59
|
export { getString, getUuid, join, parse, trim, truncate, words };
|
package/dist/string/match.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { memoize } from "../function/memoize.js";
|
|
2
|
+
//#region src/string/match.ts
|
|
2
3
|
/**
|
|
3
4
|
* Check if a string ends with a specified substring
|
|
4
5
|
* @param haystack String to look in
|
|
@@ -38,4 +39,5 @@ function startsWith(haystack, needle, ignoreCase) {
|
|
|
38
39
|
return match("startsWith", haystack, needle, ignoreCase === true);
|
|
39
40
|
}
|
|
40
41
|
var matchMemoizers = {};
|
|
42
|
+
//#endregion
|
|
41
43
|
export { endsWith, includes, startsWith };
|
package/dist/string/template.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isPlainObject } from "../internal/is.js";
|
|
2
2
|
import { getString } from "../internal/string.js";
|
|
3
3
|
import { getValue } from "../internal/value/get.js";
|
|
4
|
+
//#region src/string/template.ts
|
|
4
5
|
function getTemplateOptions(input) {
|
|
5
6
|
const options = isPlainObject(input) ? input : {};
|
|
6
7
|
return {
|
|
@@ -44,4 +45,5 @@ function template(value, variables, options) {
|
|
|
44
45
|
}
|
|
45
46
|
template.initialize = initializeTemplater;
|
|
46
47
|
var EXPRESSION_VARIABLE = /{{([\s\S]+?)}}/g;
|
|
48
|
+
//#endregion
|
|
47
49
|
export { template };
|
package/dist/value/clone.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isArrayOrPlainObject, isTypedArray } from "../internal/is.js";
|
|
2
2
|
import { getSelfHandlers } from "../internal/value/handlers.js";
|
|
3
|
+
//#region src/value/clone.ts
|
|
3
4
|
function clone(value) {
|
|
4
5
|
return cloneValue(value, 0, /* @__PURE__ */ new WeakMap());
|
|
5
6
|
}
|
|
@@ -59,7 +60,7 @@ function cloneNode(node, depth, references) {
|
|
|
59
60
|
return cloned;
|
|
60
61
|
}
|
|
61
62
|
function clonePlainObject(value, depth, references) {
|
|
62
|
-
if (depth >= MAX_CLONE_DEPTH) return Array.isArray(value) ?
|
|
63
|
+
if (depth >= MAX_CLONE_DEPTH) return Array.isArray(value) ? value.slice() : { ...value };
|
|
63
64
|
const cloned = Array.isArray(value) ? [] : {};
|
|
64
65
|
const keys = [...Object.keys(value), ...Object.getOwnPropertySymbols(value)];
|
|
65
66
|
const { length } = keys;
|
|
@@ -117,4 +118,5 @@ function tryStructuredClone(value, depth, references) {
|
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
120
|
var MAX_CLONE_DEPTH = 100;
|
|
121
|
+
//#endregion
|
|
120
122
|
export { clone };
|
package/dist/value/diff.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isArrayOrPlainObject } from "../internal/is.js";
|
|
2
2
|
import { join } from "../internal/string.js";
|
|
3
3
|
import { equal } from "../internal/value/equal.js";
|
|
4
|
+
//#region src/value/diff.ts
|
|
4
5
|
/**
|
|
5
6
|
* Find the differences between two values
|
|
6
7
|
* @param first First value
|
|
@@ -97,4 +98,5 @@ function setChanges(parameters) {
|
|
|
97
98
|
const diffsLength = diffs.length;
|
|
98
99
|
for (let diffIndex = 0; diffIndex < diffsLength; diffIndex += 1) changes.push(diffs[diffIndex]);
|
|
99
100
|
}
|
|
101
|
+
//#endregion
|
|
100
102
|
export { diff };
|
package/dist/value/merge.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isArrayOrPlainObject } from "../internal/is.js";
|
|
2
2
|
import { join } from "../internal/string.js";
|
|
3
|
+
//#region src/value/merge.ts
|
|
3
4
|
function getMergeOptions(options) {
|
|
4
5
|
const actual = {
|
|
5
6
|
replaceableObjects: void 0,
|
|
@@ -56,4 +57,5 @@ function mergeValues(values, options, validate, prefix) {
|
|
|
56
57
|
const actual = validate ? values.filter(isArrayOrPlainObject) : values;
|
|
57
58
|
return actual.length > 1 ? mergeObjects(actual, options, prefix) : actual[0] ?? {};
|
|
58
59
|
}
|
|
60
|
+
//#endregion
|
|
59
61
|
export { merge };
|
package/dist/value/omit.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { partial } from "../internal/value/partial.js";
|
|
2
|
+
//#region src/value/omit.ts
|
|
2
3
|
/**
|
|
3
4
|
* Create a new object without the specified keys
|
|
4
5
|
* @param value Original object
|
|
@@ -8,4 +9,5 @@ import { partial } from "../internal/value/partial.js";
|
|
|
8
9
|
function omit(value, keys) {
|
|
9
10
|
return partial(value, keys, true);
|
|
10
11
|
}
|
|
12
|
+
//#endregion
|
|
11
13
|
export { omit };
|
package/dist/value/pick.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { partial } from "../internal/value/partial.js";
|
|
2
|
+
//#region src/value/pick.ts
|
|
2
3
|
/**
|
|
3
4
|
* Create a new object with only the specified keys
|
|
4
5
|
* @param value Original object
|
|
@@ -8,4 +9,5 @@ import { partial } from "../internal/value/partial.js";
|
|
|
8
9
|
function pick(value, keys) {
|
|
9
10
|
return partial(value, keys, false);
|
|
10
11
|
}
|
|
12
|
+
//#endregion
|
|
11
13
|
export { pick };
|
package/dist/value/smush.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isArrayOrPlainObject } from "../internal/is.js";
|
|
2
2
|
import { join } from "../internal/string.js";
|
|
3
|
+
//#region src/value/smush.ts
|
|
3
4
|
function flattenObject(value, depth, smushed, prefix) {
|
|
4
5
|
if (depth >= MAX_DEPTH) return {};
|
|
5
6
|
if (smushed.has(value)) return smushed.get(value);
|
|
@@ -11,7 +12,7 @@ function flattenObject(value, depth, smushed, prefix) {
|
|
|
11
12
|
const val = value[key];
|
|
12
13
|
if (isArrayOrPlainObject(val)) {
|
|
13
14
|
const prefixedKey = join([prefix, key], ".");
|
|
14
|
-
flattened[prefixedKey] = Array.isArray(val) ?
|
|
15
|
+
flattened[prefixedKey] = Array.isArray(val) ? val.slice() : { ...val };
|
|
15
16
|
const nested = flattenObject(val, depth + 1, smushed, prefixedKey);
|
|
16
17
|
const nestedKeys = Object.keys(nested);
|
|
17
18
|
const nestedLength = nestedKeys.length;
|
|
@@ -33,4 +34,5 @@ function smush(value) {
|
|
|
33
34
|
return typeof value === "object" && value !== null ? flattenObject(value, 0, /* @__PURE__ */ new WeakMap()) : {};
|
|
34
35
|
}
|
|
35
36
|
var MAX_DEPTH = 100;
|
|
37
|
+
//#endregion
|
|
36
38
|
export { smush };
|
package/dist/value/unsmush.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isArrayOrPlainObject } from "../internal/is.js";
|
|
2
2
|
import { setValue } from "../internal/value/set.js";
|
|
3
|
+
//#region src/value/unsmush.ts
|
|
3
4
|
function getKeys(value) {
|
|
4
5
|
const keys = Object.keys(value);
|
|
5
6
|
const { length } = keys;
|
|
@@ -27,9 +28,10 @@ function unsmush(value) {
|
|
|
27
28
|
const key = keys[index].value;
|
|
28
29
|
const val = value[key];
|
|
29
30
|
let next = val;
|
|
30
|
-
if (isArrayOrPlainObject(val)) next = Array.isArray(val) ?
|
|
31
|
+
if (isArrayOrPlainObject(val)) next = Array.isArray(val) ? val.slice() : { ...val };
|
|
31
32
|
setValue(unsmushed, key, next);
|
|
32
33
|
}
|
|
33
34
|
return unsmushed;
|
|
34
35
|
}
|
|
36
|
+
//#endregion
|
|
35
37
|
export { unsmush };
|
package/package.json
CHANGED
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"jsdom": "^28.1",
|
|
11
11
|
"oxfmt": "^0.36",
|
|
12
12
|
"oxlint": "^1.51",
|
|
13
|
-
"rolldown": "1.0.0-rc.
|
|
13
|
+
"rolldown": "1.0.0-rc.8",
|
|
14
14
|
"tslib": "^2.8",
|
|
15
15
|
"typescript": "^5.9",
|
|
16
|
-
"vite": "8.0.0-beta.
|
|
16
|
+
"vite": "8.0.0-beta.17",
|
|
17
17
|
"vitest": "^4"
|
|
18
18
|
},
|
|
19
19
|
"exports": {
|
|
@@ -184,5 +184,5 @@
|
|
|
184
184
|
},
|
|
185
185
|
"type": "module",
|
|
186
186
|
"types": "./types/index.d.ts",
|
|
187
|
-
"version": "0.
|
|
187
|
+
"version": "0.160.0"
|
|
188
188
|
}
|
package/src/array/index.ts
CHANGED