@takeshape/util 11.144.1 → 11.154.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/dist/common/clone.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export declare function deepCloneWith(obj: unknown, customizer: DeepCloneWithCus
|
|
|
35
35
|
export type CloneWithPathHelper = (value: unknown, key: string | number | undefined, parent: Record<string, unknown> | unknown[] | undefined, path: string[]) => unknown;
|
|
36
36
|
/**
|
|
37
37
|
* Clone any JSON serializable value and transform using a callback
|
|
38
|
-
* @param
|
|
38
|
+
* @param initialValue the value to clone
|
|
39
39
|
* @param customizer a callback that is called for every key/index
|
|
40
40
|
*/
|
|
41
|
-
export declare function deepCloneWithPath(
|
|
41
|
+
export declare function deepCloneWithPath(initialValue: unknown, customizer: CloneWithPathHelper): unknown;
|
package/dist/common/clone.js
CHANGED
|
@@ -71,10 +71,10 @@ export function deepCloneWith(obj, customizer) {
|
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
73
|
* Clone any JSON serializable value and transform using a callback
|
|
74
|
-
* @param
|
|
74
|
+
* @param initialValue the value to clone
|
|
75
75
|
* @param customizer a callback that is called for every key/index
|
|
76
76
|
*/
|
|
77
|
-
export function deepCloneWithPath(
|
|
77
|
+
export function deepCloneWithPath(initialValue, customizer) {
|
|
78
78
|
const clone = (value, key, parent, path) => {
|
|
79
79
|
const customizedValue = customizer(value, key, parent, path);
|
|
80
80
|
if (customizedValue === REMOVE) {
|
|
@@ -106,5 +106,5 @@ export function deepCloneWithPath(obj, customizer) {
|
|
|
106
106
|
}
|
|
107
107
|
return cloneValue;
|
|
108
108
|
};
|
|
109
|
-
return clone(
|
|
109
|
+
return clone(initialValue, undefined, undefined, []);
|
|
110
110
|
}
|
package/dist/common/sleep.d.ts
CHANGED
package/dist/common/sleep.js
CHANGED
|
@@ -3,3 +3,16 @@ export async function sleep(ms) {
|
|
|
3
3
|
setTimeout(resolve, ms);
|
|
4
4
|
});
|
|
5
5
|
}
|
|
6
|
+
export const cancelableSleep = (ms, signal) => {
|
|
7
|
+
return new Promise((resolve) => {
|
|
8
|
+
if (signal?.aborted) {
|
|
9
|
+
resolve(false);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const timeoutId = setTimeout(() => resolve(true), ms);
|
|
13
|
+
signal?.addEventListener('abort', () => {
|
|
14
|
+
clearTimeout(timeoutId);
|
|
15
|
+
resolve(false);
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
};
|
package/dist/common/strings.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ export declare function isIntegerLike(value: string | number): boolean;
|
|
|
17
17
|
export declare function encodePropertyName(value: string): string;
|
|
18
18
|
export declare function base64Encode(str: string): string;
|
|
19
19
|
export declare function base64Decode(str: string): string;
|
|
20
|
+
export declare function base64UrlEncode(str: string): string;
|
|
21
|
+
export declare function base64UrlDecode(str: string): string;
|
|
20
22
|
/**
|
|
21
23
|
* Replace {{key}} or {key} in a string with the value of the key in the data object.
|
|
22
24
|
*/
|
package/dist/common/strings.js
CHANGED
|
@@ -77,6 +77,12 @@ export function base64Encode(str) {
|
|
|
77
77
|
export function base64Decode(str) {
|
|
78
78
|
return isBrowser ? window.atob(str) : Buffer.from(str, 'base64').toString();
|
|
79
79
|
}
|
|
80
|
+
export function base64UrlEncode(str) {
|
|
81
|
+
return isBrowser ? window.btoa(str) : Buffer.from(str).toString('base64url');
|
|
82
|
+
}
|
|
83
|
+
export function base64UrlDecode(str) {
|
|
84
|
+
return isBrowser ? window.atob(str) : Buffer.from(str, 'base64url').toString();
|
|
85
|
+
}
|
|
80
86
|
/**
|
|
81
87
|
* Replace {{key}} or {key} in a string with the value of the key in the data object.
|
|
82
88
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takeshape/util",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.154.2",
|
|
4
4
|
"description": "Shared utilities",
|
|
5
5
|
"homepage": "https://www.takeshape.io",
|
|
6
6
|
"repository": {
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"tiny-invariant": "1.3.3",
|
|
46
46
|
"uint8array-extras": "1.4.0",
|
|
47
47
|
"url-parse": "1.5.3",
|
|
48
|
-
"@takeshape/prism": "11.
|
|
49
|
-
"@takeshape/routing": "11.
|
|
48
|
+
"@takeshape/prism": "11.154.2",
|
|
49
|
+
"@takeshape/routing": "11.154.2"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/classnames": "2.2.11",
|