@archtx/utils 6.0.0 → 6.1.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/dist/exports.d.ts +29 -29
- package/dist/exports.js +29 -29
- package/dist/exports.js.map +1 -1
- package/dist/src/array-values-or-undefined.d.ts +1 -0
- package/dist/src/array-values-or-undefined.js +6 -0
- package/dist/src/array-values-or-undefined.js.map +1 -0
- package/dist/src/bool-or-undefined.d.ts +1 -0
- package/dist/src/bool-or-undefined.js +2 -0
- package/dist/src/bool-or-undefined.js.map +1 -0
- package/dist/src/constants/millisecond-time.d.ts +7 -0
- package/dist/src/constants/millisecond-time.js +8 -0
- package/dist/src/constants/millisecond-time.js.map +1 -0
- package/dist/src/constants/second-time.d.ts +6 -0
- package/dist/src/constants/second-time.js +7 -0
- package/dist/src/constants/second-time.js.map +1 -0
- package/dist/src/datetime/iso-string.d.ts +2 -0
- package/dist/src/datetime/iso-string.js +10 -0
- package/dist/src/datetime/iso-string.js.map +1 -0
- package/dist/src/deep-clone.d.ts +1 -0
- package/dist/src/deep-clone.js +27 -0
- package/dist/src/deep-clone.js.map +1 -0
- package/dist/src/deep-equal.d.ts +7 -0
- package/dist/src/deep-equal.js +52 -0
- package/dist/src/deep-equal.js.map +1 -0
- package/dist/src/deep-equal.test.d.ts +1 -0
- package/dist/src/deep-equal.test.js +97 -0
- package/dist/src/deep-equal.test.js.map +1 -0
- package/dist/src/deep-freeze.d.ts +7 -0
- package/dist/src/deep-freeze.js +20 -0
- package/dist/src/deep-freeze.js.map +1 -0
- package/dist/src/deep-merge.d.ts +1 -0
- package/dist/src/deep-merge.js +27 -0
- package/dist/src/deep-merge.js.map +1 -0
- package/dist/src/ensure-array.d.ts +16 -0
- package/dist/src/ensure-array.js +26 -0
- package/dist/src/ensure-array.js.map +1 -0
- package/dist/src/format-decimal.d.ts +1 -0
- package/dist/src/format-decimal.js +9 -0
- package/dist/src/format-decimal.js.map +1 -0
- package/dist/src/is-hex-color.d.ts +1 -0
- package/dist/src/is-hex-color.js +4 -0
- package/dist/src/is-hex-color.js.map +1 -0
- package/dist/src/is-prod.d.ts +1 -0
- package/dist/src/is-prod.js +2 -0
- package/dist/src/is-prod.js.map +1 -0
- package/dist/src/make-uuid.test.d.ts +1 -0
- package/dist/src/make-uuid.test.js +23 -0
- package/dist/src/make-uuid.test.js.map +1 -0
- package/dist/src/object-diff-paths.d.ts +9 -0
- package/dist/src/object-diff-paths.js +39 -0
- package/dist/src/object-diff-paths.js.map +1 -0
- package/dist/src/object-diff-paths.test.d.ts +1 -0
- package/dist/src/object-diff-paths.test.js +141 -0
- package/dist/src/object-diff-paths.test.js.map +1 -0
- package/dist/src/object-values-to-dot-notation.d.ts +1 -0
- package/dist/src/object-values-to-dot-notation.js +23 -0
- package/dist/src/object-values-to-dot-notation.js.map +1 -0
- package/dist/src/object-values-to-dot-notation.test.d.ts +1 -0
- package/dist/src/object-values-to-dot-notation.test.js +21 -0
- package/dist/src/object-values-to-dot-notation.test.js.map +1 -0
- package/dist/src/object.d.ts +7 -0
- package/dist/src/object.js +19 -0
- package/dist/src/object.js.map +1 -0
- package/dist/src/random-color.d.ts +1 -0
- package/dist/src/random-color.js +4 -0
- package/dist/src/random-color.js.map +1 -0
- package/dist/src/sanitize-obj-props.d.ts +1 -0
- package/dist/src/sanitize-obj-props.js +5 -0
- package/dist/src/sanitize-obj-props.js.map +1 -0
- package/dist/src/sleep.d.ts +1 -0
- package/dist/src/sleep.js +6 -0
- package/dist/src/sleep.js.map +1 -0
- package/dist/src/strings/is-email.d.ts +1 -0
- package/dist/src/strings/is-email.js +5 -0
- package/dist/src/strings/is-email.js.map +1 -0
- package/dist/src/strings/is-url.d.ts +1 -0
- package/dist/src/strings/is-url.js +10 -0
- package/dist/src/strings/is-url.js.map +1 -0
- package/dist/src/strings/make-uuid.d.ts +16 -0
- package/dist/src/strings/make-uuid.js +25 -0
- package/dist/src/strings/make-uuid.js.map +1 -0
- package/dist/src/strings/obfuscate-string.d.ts +21 -0
- package/dist/src/strings/obfuscate-string.js +46 -0
- package/dist/src/strings/obfuscate-string.js.map +1 -0
- package/dist/src/strings/pluralize.d.ts +5 -0
- package/dist/src/strings/pluralize.js +17 -0
- package/dist/src/strings/pluralize.js.map +1 -0
- package/dist/src/strings/reproducible-hash.d.ts +5 -0
- package/dist/src/strings/reproducible-hash.js +23 -0
- package/dist/src/strings/reproducible-hash.js.map +1 -0
- package/dist/src/timeout.d.ts +8 -0
- package/dist/src/timeout.js +14 -0
- package/dist/src/timeout.js.map +1 -0
- package/dist/src/undefined-default.d.ts +1 -0
- package/dist/src/undefined-default.js +2 -0
- package/dist/src/undefined-default.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +11 -6
package/dist/exports.d.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
export * from './constants/millisecond-time.js';
|
|
2
|
-
export * from './constants/second-time.js';
|
|
3
|
-
export * from './array-values-or-undefined.js';
|
|
4
|
-
export * from './bool-or-undefined.js';
|
|
5
|
-
export * from './deep-clone.js';
|
|
6
|
-
export * from './deep-equal.js';
|
|
7
|
-
export * from './deep-freeze.js';
|
|
8
|
-
export * from './deep-merge.js';
|
|
9
|
-
export * from './ensure-array.js';
|
|
10
|
-
export * from './format-decimal.js';
|
|
11
|
-
export * from './is-hex-color.js';
|
|
12
|
-
export * from './is-prod.js';
|
|
13
|
-
export * from './object.js';
|
|
14
|
-
export * from './object-diff-paths.js';
|
|
15
|
-
export * from './object-values-to-dot-notation.js';
|
|
16
|
-
export * from './random-color.js';
|
|
17
|
-
export * from './sanitize-obj-props.js';
|
|
18
|
-
export * from './sleep.js';
|
|
19
|
-
export * from './timeout.js';
|
|
20
|
-
export * from './undefined-default.js';
|
|
21
|
-
export * from './strings/is-email.js';
|
|
22
|
-
export * from './strings/is-url.js';
|
|
23
|
-
export * from './strings/make-uuid.js';
|
|
24
|
-
export * from './strings/obfuscate-string.js';
|
|
25
|
-
export * from './strings/pluralize.js';
|
|
26
|
-
export * from './strings/reproducible-hash.js';
|
|
27
|
-
export * from './constants/millisecond-time.js';
|
|
28
|
-
export * from './constants/second-time.js';
|
|
29
|
-
export * from './datetime/iso-string.js';
|
|
1
|
+
export * from './src/constants/millisecond-time.js';
|
|
2
|
+
export * from './src/constants/second-time.js';
|
|
3
|
+
export * from './src/array-values-or-undefined.js';
|
|
4
|
+
export * from './src/bool-or-undefined.js';
|
|
5
|
+
export * from './src/deep-clone.js';
|
|
6
|
+
export * from './src/deep-equal.js';
|
|
7
|
+
export * from './src/deep-freeze.js';
|
|
8
|
+
export * from './src/deep-merge.js';
|
|
9
|
+
export * from './src/ensure-array.js';
|
|
10
|
+
export * from './src/format-decimal.js';
|
|
11
|
+
export * from './src/is-hex-color.js';
|
|
12
|
+
export * from './src/is-prod.js';
|
|
13
|
+
export * from './src/object.js';
|
|
14
|
+
export * from './src/object-diff-paths.js';
|
|
15
|
+
export * from './src/object-values-to-dot-notation.js';
|
|
16
|
+
export * from './src/random-color.js';
|
|
17
|
+
export * from './src/sanitize-obj-props.js';
|
|
18
|
+
export * from './src/sleep.js';
|
|
19
|
+
export * from './src/timeout.js';
|
|
20
|
+
export * from './src/undefined-default.js';
|
|
21
|
+
export * from './src/strings/is-email.js';
|
|
22
|
+
export * from './src/strings/is-url.js';
|
|
23
|
+
export * from './src/strings/make-uuid.js';
|
|
24
|
+
export * from './src/strings/obfuscate-string.js';
|
|
25
|
+
export * from './src/strings/pluralize.js';
|
|
26
|
+
export * from './src/strings/reproducible-hash.js';
|
|
27
|
+
export * from './src/constants/millisecond-time.js';
|
|
28
|
+
export * from './src/constants/second-time.js';
|
|
29
|
+
export * from './src/datetime/iso-string.js';
|
package/dist/exports.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
export * from './constants/millisecond-time.js';
|
|
2
|
-
export * from './constants/second-time.js';
|
|
3
|
-
export * from './array-values-or-undefined.js';
|
|
4
|
-
export * from './bool-or-undefined.js';
|
|
5
|
-
export * from './deep-clone.js';
|
|
6
|
-
export * from './deep-equal.js';
|
|
7
|
-
export * from './deep-freeze.js';
|
|
8
|
-
export * from './deep-merge.js';
|
|
9
|
-
export * from './ensure-array.js';
|
|
10
|
-
export * from './format-decimal.js';
|
|
11
|
-
export * from './is-hex-color.js';
|
|
12
|
-
export * from './is-prod.js';
|
|
13
|
-
export * from './object.js';
|
|
14
|
-
export * from './object-diff-paths.js';
|
|
15
|
-
export * from './object-values-to-dot-notation.js';
|
|
16
|
-
export * from './random-color.js';
|
|
17
|
-
export * from './sanitize-obj-props.js';
|
|
18
|
-
export * from './sleep.js';
|
|
19
|
-
export * from './timeout.js';
|
|
20
|
-
export * from './undefined-default.js';
|
|
1
|
+
export * from './src/constants/millisecond-time.js';
|
|
2
|
+
export * from './src/constants/second-time.js';
|
|
3
|
+
export * from './src/array-values-or-undefined.js';
|
|
4
|
+
export * from './src/bool-or-undefined.js';
|
|
5
|
+
export * from './src/deep-clone.js';
|
|
6
|
+
export * from './src/deep-equal.js';
|
|
7
|
+
export * from './src/deep-freeze.js';
|
|
8
|
+
export * from './src/deep-merge.js';
|
|
9
|
+
export * from './src/ensure-array.js';
|
|
10
|
+
export * from './src/format-decimal.js';
|
|
11
|
+
export * from './src/is-hex-color.js';
|
|
12
|
+
export * from './src/is-prod.js';
|
|
13
|
+
export * from './src/object.js';
|
|
14
|
+
export * from './src/object-diff-paths.js';
|
|
15
|
+
export * from './src/object-values-to-dot-notation.js';
|
|
16
|
+
export * from './src/random-color.js';
|
|
17
|
+
export * from './src/sanitize-obj-props.js';
|
|
18
|
+
export * from './src/sleep.js';
|
|
19
|
+
export * from './src/timeout.js';
|
|
20
|
+
export * from './src/undefined-default.js';
|
|
21
21
|
// strings
|
|
22
|
-
export * from './strings/is-email.js';
|
|
23
|
-
export * from './strings/is-url.js';
|
|
24
|
-
export * from './strings/make-uuid.js';
|
|
25
|
-
export * from './strings/obfuscate-string.js';
|
|
26
|
-
export * from './strings/pluralize.js';
|
|
27
|
-
export * from './strings/reproducible-hash.js';
|
|
22
|
+
export * from './src/strings/is-email.js';
|
|
23
|
+
export * from './src/strings/is-url.js';
|
|
24
|
+
export * from './src/strings/make-uuid.js';
|
|
25
|
+
export * from './src/strings/obfuscate-string.js';
|
|
26
|
+
export * from './src/strings/pluralize.js';
|
|
27
|
+
export * from './src/strings/reproducible-hash.js';
|
|
28
28
|
// utils
|
|
29
|
-
export * from './constants/millisecond-time.js';
|
|
30
|
-
export * from './constants/second-time.js';
|
|
31
|
-
export * from './datetime/iso-string.js';
|
|
29
|
+
export * from './src/constants/millisecond-time.js';
|
|
30
|
+
export * from './src/constants/second-time.js';
|
|
31
|
+
export * from './src/datetime/iso-string.js';
|
|
32
32
|
//# sourceMappingURL=exports.js.map
|
package/dist/exports.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../
|
|
1
|
+
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../exports.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAA;AACnD,cAAc,gCAAgC,CAAA;AAC9C,cAAc,oCAAoC,CAAA;AAClD,cAAc,4BAA4B,CAAA;AAC1C,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AACpC,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,yBAAyB,CAAA;AACvC,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,4BAA4B,CAAA;AAC1C,cAAc,wCAAwC,CAAA;AACtD,cAAc,uBAAuB,CAAA;AACrC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,cAAc,4BAA4B,CAAA;AAE1C,UAAU;AACV,cAAc,2BAA2B,CAAA;AACzC,cAAc,yBAAyB,CAAA;AACvC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,mCAAmC,CAAA;AACjD,cAAc,4BAA4B,CAAA;AAC1C,cAAc,oCAAoC,CAAA;AAElD,QAAQ;AACR,cAAc,qCAAqC,CAAA;AACnD,cAAc,gCAAgC,CAAA;AAC9C,cAAc,8BAA8B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function arrayValuesOrUndefined<T>(arr?: T[]): T[] | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-values-or-undefined.js","sourceRoot":"","sources":["../../src/array-values-or-undefined.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,sBAAsB,CAAI,GAAS;IACjD,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM;QAAE,OAAO,GAAG,CAAA;IAEhD,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const boolOrUndefined: (value?: boolean) => boolean | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bool-or-undefined.js","sourceRoot":"","sources":["../../src/bool-or-undefined.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAe,EAAE,EAAE,CACjD,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const ONE_MIN_MILLI = 60000;
|
|
2
|
+
export declare const ONE_HR_MILLI: number;
|
|
3
|
+
export declare const ONE_DAY_MILLI: number;
|
|
4
|
+
export declare const ONE_WEEK_MILLI: number;
|
|
5
|
+
export declare const ONE_MONTH_MILLI: number;
|
|
6
|
+
export declare const FIVE_MIN_MILLI: number;
|
|
7
|
+
export declare const TEN_MIN_MILLI: number;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const ONE_MIN_MILLI = 60_000;
|
|
2
|
+
export const ONE_HR_MILLI = 60_000 * 60;
|
|
3
|
+
export const ONE_DAY_MILLI = ONE_HR_MILLI * 24;
|
|
4
|
+
export const ONE_WEEK_MILLI = ONE_DAY_MILLI * 7;
|
|
5
|
+
export const ONE_MONTH_MILLI = ONE_WEEK_MILLI * 4.3;
|
|
6
|
+
export const FIVE_MIN_MILLI = ONE_MIN_MILLI * 5;
|
|
7
|
+
export const TEN_MIN_MILLI = ONE_MIN_MILLI * 10;
|
|
8
|
+
//# sourceMappingURL=millisecond-time.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"millisecond-time.js","sourceRoot":"","sources":["../../../src/constants/millisecond-time.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAA;AACnC,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,GAAG,EAAE,CAAA;AACvC,MAAM,CAAC,MAAM,aAAa,GAAG,YAAY,GAAG,EAAE,CAAA;AAC9C,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,GAAG,CAAC,CAAA;AAC/C,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,GAAG,GAAG,CAAA;AACnD,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,GAAG,CAAC,CAAA;AAC/C,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,GAAG,EAAE,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const ONE_HR_SECONDS: number;
|
|
2
|
+
export declare const ONE_DAY_SECONDS: number;
|
|
3
|
+
export declare const ONE_WEEK_SECONDS: number;
|
|
4
|
+
export declare const ONE_MONTH_SECONDS: number;
|
|
5
|
+
export declare const FIVE_MIN_SECONDS: number;
|
|
6
|
+
export declare const TEN_MIN_SECONDS: number;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const ONE_HR_SECONDS = 60 * 60;
|
|
2
|
+
export const ONE_DAY_SECONDS = ONE_HR_SECONDS * 24;
|
|
3
|
+
export const ONE_WEEK_SECONDS = ONE_DAY_SECONDS * 7;
|
|
4
|
+
export const ONE_MONTH_SECONDS = ONE_WEEK_SECONDS * 4.3;
|
|
5
|
+
export const FIVE_MIN_SECONDS = 60 * 5;
|
|
6
|
+
export const TEN_MIN_SECONDS = 60 * 10;
|
|
7
|
+
//# sourceMappingURL=second-time.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"second-time.js","sourceRoot":"","sources":["../../../src/constants/second-time.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,GAAG,EAAE,CAAA;AACrC,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,GAAG,EAAE,CAAA;AAClD,MAAM,CAAC,MAAM,gBAAgB,GAAG,eAAe,GAAG,CAAC,CAAA;AACnD,MAAM,CAAC,MAAM,iBAAiB,GAAG,gBAAgB,GAAG,GAAG,CAAA;AACvD,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,GAAG,CAAC,CAAA;AACtC,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,GAAG,EAAE,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function dateISOString(date) {
|
|
2
|
+
if (typeof date === 'string') {
|
|
3
|
+
return new Date(date).toISOString();
|
|
4
|
+
}
|
|
5
|
+
if (typeof date === 'number') {
|
|
6
|
+
return new Date(date).toISOString();
|
|
7
|
+
}
|
|
8
|
+
return date.toISOString();
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=iso-string.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iso-string.js","sourceRoot":"","sources":["../../../src/datetime/iso-string.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,aAAa,CAAC,IAA4B;IACxD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAA;IACrC,CAAC;IACD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAA;IACrC,CAAC;IACD,OAAO,IAAI,CAAC,WAAW,EAAE,CAAA;AAC3B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function deepClone<T>(o: T): T;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// courtesy of unknown author found online in a benchmark test
|
|
2
|
+
export function deepClone(o) {
|
|
3
|
+
let newO;
|
|
4
|
+
let i;
|
|
5
|
+
if (typeof o !== 'object') {
|
|
6
|
+
return o;
|
|
7
|
+
}
|
|
8
|
+
if (!o) {
|
|
9
|
+
return o;
|
|
10
|
+
}
|
|
11
|
+
if (Array.isArray(o)) {
|
|
12
|
+
newO = [];
|
|
13
|
+
for (i = 0; i < o.length; i += 1) {
|
|
14
|
+
newO[i] = deepClone(o[i]);
|
|
15
|
+
}
|
|
16
|
+
return newO;
|
|
17
|
+
}
|
|
18
|
+
newO = {};
|
|
19
|
+
for (i in o) {
|
|
20
|
+
if (o.hasOwnProperty(i)) {
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
newO[i] = deepClone(o[i]);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return newO;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=deep-clone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deep-clone.js","sourceRoot":"","sources":["../../src/deep-clone.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,MAAM,UAAU,SAAS,CAAI,CAAI;IAC/B,IAAI,IAAS,CAAA;IACb,IAAI,CAAM,CAAA;IAEV,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,CAAC,CAAA;IACV,CAAC;IACD,IAAI,CAAC,CAAC,EAAE,CAAC;QACP,OAAO,CAAC,CAAA;IACV,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QACrB,IAAI,GAAG,EAAE,CAAA;QAET,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,IAAI,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QAC3B,CAAC;QAED,OAAO,IAAS,CAAA;IAClB,CAAC;IAED,IAAI,GAAG,EAAE,CAAA;IAET,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACZ,IAAI,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;YACxB,aAAa;YACb,IAAI,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QAC3B,CAAC;IACH,CAAC;IAED,OAAO,IAAS,CAAA;AAClB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if all primitive values are equal.
|
|
3
|
+
*
|
|
4
|
+
* @param a
|
|
5
|
+
* @param b
|
|
6
|
+
*/
|
|
7
|
+
export function deepEqual(a, b) {
|
|
8
|
+
if (a === b)
|
|
9
|
+
return true;
|
|
10
|
+
if (a && b && typeof a === 'object' && typeof b === 'object') {
|
|
11
|
+
if (Array.isArray(a)) {
|
|
12
|
+
if (a.length !== b.length)
|
|
13
|
+
return false;
|
|
14
|
+
for (const [i, item] of a.entries()) {
|
|
15
|
+
if (!deepEqual(item, b[i]))
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
else if (a instanceof Map && b instanceof Map) {
|
|
21
|
+
if (a.size !== b.size)
|
|
22
|
+
return false;
|
|
23
|
+
for (const [key, value] of a.entries()) {
|
|
24
|
+
if (!b.has(key) || !deepEqual(value, b.get(key)))
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
else if (a instanceof Set && b instanceof Set) {
|
|
30
|
+
if (a.size !== b.size)
|
|
31
|
+
return false;
|
|
32
|
+
for (const item of a) {
|
|
33
|
+
if (!b.has(item))
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
const aKeys = Object.keys(a);
|
|
39
|
+
const bKeys = Object.keys(b);
|
|
40
|
+
if (aKeys.length !== bKeys.length)
|
|
41
|
+
return false;
|
|
42
|
+
for (const key of aKeys) {
|
|
43
|
+
if (!(key in b) ||
|
|
44
|
+
!deepEqual(a[key], b[key])) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
return Number.isNaN(a) && Number.isNaN(b);
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=deep-equal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deep-equal.js","sourceRoot":"","sources":["../../src/deep-equal.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,CAAM,EAAE,CAAM;IACtC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IAExB,IAAI,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC7D,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;YACrB,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;gBAAE,OAAO,KAAK,CAAA;YACvC,KAAK,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC;gBACpC,IAAI,CAAC,SAAS,CAAC,IAAI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CAA6B,CAAC,GAAG,CAAC,CACpC,EACD,CAAC;gBACD,OAAO,KAAK,CAAA;YACd,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC;IAED,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AAC3C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import assert from 'assert';
|
|
2
|
+
import { deepEqual } from './deep-equal.js';
|
|
3
|
+
describe('deep equal', () => {
|
|
4
|
+
it('different types', () => {
|
|
5
|
+
const o1 = 1;
|
|
6
|
+
const o2 = true;
|
|
7
|
+
const diff = deepEqual(o1, o2);
|
|
8
|
+
assert.deepEqual(diff, false);
|
|
9
|
+
});
|
|
10
|
+
it('empty objects', () => {
|
|
11
|
+
const o1 = {};
|
|
12
|
+
const o2 = {};
|
|
13
|
+
const diff = deepEqual(o1, o2);
|
|
14
|
+
assert.deepEqual(diff, true);
|
|
15
|
+
});
|
|
16
|
+
it('a single object entry is different', () => {
|
|
17
|
+
const o1 = {
|
|
18
|
+
a: {
|
|
19
|
+
b: {
|
|
20
|
+
c: { s: 't' },
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
const o2 = { ...o1, a: { ...o1.a, b: { ...o1.a.b, d: 'e' } } };
|
|
25
|
+
const diff = deepEqual(o1, o2);
|
|
26
|
+
assert.deepEqual(diff, false);
|
|
27
|
+
});
|
|
28
|
+
it('null vs undefined', () => {
|
|
29
|
+
const o1 = {
|
|
30
|
+
foo: null,
|
|
31
|
+
};
|
|
32
|
+
const o2 = {
|
|
33
|
+
foo: undefined,
|
|
34
|
+
};
|
|
35
|
+
const diff = deepEqual(o1, o2);
|
|
36
|
+
assert.deepEqual(diff, false);
|
|
37
|
+
});
|
|
38
|
+
it('entries are missing/different from each objects', () => {
|
|
39
|
+
const o1 = {
|
|
40
|
+
a: {
|
|
41
|
+
b: {
|
|
42
|
+
fn: () => 4,
|
|
43
|
+
arr: [1, 2, 3],
|
|
44
|
+
c: {
|
|
45
|
+
s: 't',
|
|
46
|
+
y: 'g',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
const o2 = {
|
|
52
|
+
...o1,
|
|
53
|
+
a: {
|
|
54
|
+
...o1.a,
|
|
55
|
+
b: {
|
|
56
|
+
...o1.a.b,
|
|
57
|
+
fn: () => 4,
|
|
58
|
+
arr: [1, 2, 3, 4, 5],
|
|
59
|
+
c: { s: 'e', t: 'e' },
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
const diff = deepEqual(o1, o2);
|
|
64
|
+
assert.deepEqual(diff, false);
|
|
65
|
+
});
|
|
66
|
+
it('nested arrays', () => {
|
|
67
|
+
const o1 = {
|
|
68
|
+
a: {
|
|
69
|
+
arr: [
|
|
70
|
+
1,
|
|
71
|
+
[{ one: 1, two: 1 }],
|
|
72
|
+
{
|
|
73
|
+
foo: 'bar',
|
|
74
|
+
},
|
|
75
|
+
4,
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
const o2 = {
|
|
80
|
+
...o1,
|
|
81
|
+
a: {
|
|
82
|
+
...o1.a,
|
|
83
|
+
arr: [
|
|
84
|
+
1,
|
|
85
|
+
[{ one: 2, two: 2 }],
|
|
86
|
+
{
|
|
87
|
+
foo: 'bar',
|
|
88
|
+
},
|
|
89
|
+
4,
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
const diff = deepEqual(o1, o2);
|
|
94
|
+
assert.deepEqual(diff, false);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
//# sourceMappingURL=deep-equal.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deep-equal.test.js","sourceRoot":"","sources":["../../src/de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AC;oBACD,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;oBACpB;wBACE,GAAG,EAAE,KAAK;qBACX;oBACD,CAAC;iBACF;aACF;SACF,CAAA;QACD,MAAM,EAAE,GAAG;YACT,GAAG,EAAE;YACL,CAAC,EAAE;gBACD,GAAG,EAAE,CAAC,CAAC;gBACP,GAAG,EAAE;oBACH,CAAC;oBACD,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;oBACpB;wBACE,GAAG,EAAE,KAAK;qBACX;oBACD,CAAC;iBACF;aACF;SACF,CAAA;QAED,MAAM,IAAI,GAAG,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;QAE9B,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IAC/B,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursively freeze an object.
|
|
3
|
+
*
|
|
4
|
+
* @param object Target object to freeze
|
|
5
|
+
* @param clone When true, the object itself and all nested objects are cloned so that the original object is not frozen
|
|
6
|
+
*/
|
|
7
|
+
export declare function deepFreeze(object: any, clone?: boolean): any;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursively freeze an object.
|
|
3
|
+
*
|
|
4
|
+
* @param object Target object to freeze
|
|
5
|
+
* @param clone When true, the object itself and all nested objects are cloned so that the original object is not frozen
|
|
6
|
+
*/
|
|
7
|
+
export function deepFreeze(object, clone = true) {
|
|
8
|
+
// Retrieve the property names defined on object
|
|
9
|
+
const propNames = Object.getOwnPropertyNames(object);
|
|
10
|
+
// Freeze properties before freezing self
|
|
11
|
+
for (const name of propNames) {
|
|
12
|
+
const value = object[name];
|
|
13
|
+
// 'null' will equal 'object' bitches.
|
|
14
|
+
if (value && typeof value === 'object') {
|
|
15
|
+
deepFreeze(value, clone);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return Object.freeze(clone ? { ...object } : object);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=deep-freeze.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deep-freeze.js","sourceRoot":"","sources":["../../src/deep-freeze.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,MAAW,EAAE,KAAK,GAAG,IAAI;IAClD,gDAAgD;IAChD,MAAM,SAAS,GAAG,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAA;IAEpD,yCAAyC;IAEzC,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;QAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;QAE1B,sCAAsC;QACtC,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YACvC,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;QAC1B,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;AACtD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function deepMerge<T extends Record<any, any>>(target: T, ...sources: Record<any, any>[]): T;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
function isObject(item) {
|
|
2
|
+
return item && typeof item === 'object' && !Array.isArray(item);
|
|
3
|
+
}
|
|
4
|
+
export function deepMerge(target, ...sources) {
|
|
5
|
+
if (!sources.length)
|
|
6
|
+
return target;
|
|
7
|
+
const source = sources.shift();
|
|
8
|
+
if (isObject(target) && isObject(source)) {
|
|
9
|
+
for (const key in source) {
|
|
10
|
+
if (isObject(source[key])) {
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
if (!target[key]) {
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
Object.assign(target, { [key]: {} });
|
|
15
|
+
}
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
deepMerge(target[key], source[key]);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
Object.assign(target, { [key]: source[key] });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return deepMerge(target, ...sources);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=deep-merge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deep-merge.js","sourceRoot":"","sources":["../../src/deep-merge.ts"],"names":[],"mappings":"AAAA,SAAS,QAAQ,CAAC,IAAS;IACzB,OAAO,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;AACjE,CAAC;AAED,MAAM,UAAU,SAAS,CACvB,MAAS,EACT,GAAG,OAA2B;IAE9B,IAAI,CAAC,OAAO,CAAC,MAAM;QAAE,OAAO,MAAM,CAAA;IAElC,MAAM,MAAM,GAAQ,OAAO,CAAC,KAAK,EAAE,CAAA;IAEnC,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACzC,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;YACzB,IAAI,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBAC1B,aAAa;gBACb,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;oBACjB,aAAa;oBACb,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;gBACtC,CAAC;gBAED,aAAa;gBACb,SAAS,CAAI,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;YACxC,CAAC;iBAAM,CAAC;gBACN,aAAa;gBACb,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;YAC/C,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAI,MAAM,EAAE,GAAG,OAAO,CAAC,CAAA;AACzC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ensures that the given array contains unique truthy values.
|
|
3
|
+
*
|
|
4
|
+
* @param {T[]} arr - The array to ensure uniqueness and truthiness.
|
|
5
|
+
* @return {T[]} - The resulting array with unique truthy values.
|
|
6
|
+
*/
|
|
7
|
+
export declare function ensureUniqArrayWithTruthyValues<T>(arr?: T[]): T[];
|
|
8
|
+
/**
|
|
9
|
+
* Ensures that the input is an array or undefined. If the input is already an array with values,
|
|
10
|
+
* it will return the input array as is. If the input is a value other than undefined, it will wrap
|
|
11
|
+
* the value in an array and return it. If the input is undefined, it will return undefined.
|
|
12
|
+
*
|
|
13
|
+
* @param {T[] | T} arr - The input value that needs to be checked.
|
|
14
|
+
* @returns {T[] | undefined} - An array or undefined based on the input value.
|
|
15
|
+
*/
|
|
16
|
+
export declare function ensureArrayValuesOrUndefined<T>(arr?: T[] | T): T[] | undefined;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { uniq } from 'lodash-es';
|
|
2
|
+
/**
|
|
3
|
+
* Ensures that the given array contains unique truthy values.
|
|
4
|
+
*
|
|
5
|
+
* @param {T[]} arr - The array to ensure uniqueness and truthiness.
|
|
6
|
+
* @return {T[]} - The resulting array with unique truthy values.
|
|
7
|
+
*/
|
|
8
|
+
export function ensureUniqArrayWithTruthyValues(arr) {
|
|
9
|
+
return (Array.isArray(arr) ? uniq(arr) : []).filter((x) => !!x);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Ensures that the input is an array or undefined. If the input is already an array with values,
|
|
13
|
+
* it will return the input array as is. If the input is a value other than undefined, it will wrap
|
|
14
|
+
* the value in an array and return it. If the input is undefined, it will return undefined.
|
|
15
|
+
*
|
|
16
|
+
* @param {T[] | T} arr - The input value that needs to be checked.
|
|
17
|
+
* @returns {T[] | undefined} - An array or undefined based on the input value.
|
|
18
|
+
*/
|
|
19
|
+
export function ensureArrayValuesOrUndefined(arr) {
|
|
20
|
+
if (Array.isArray(arr) && arr.length)
|
|
21
|
+
return arr;
|
|
22
|
+
if (typeof arr !== 'undefined')
|
|
23
|
+
return [arr];
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=ensure-array.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensure-array.js","sourceRoot":"","sources":["../../src/ensure-array.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC;;;;;GAKG;AACH,MAAM,UAAU,+BAA+B,CAAI,GAAS;IAC1D,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACjE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,4BAA4B,CAC1C,GAAa;IAEb,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM;QAAE,OAAO,GAAG,CAAA;IAChD,IAAI,OAAO,GAAG,KAAK,WAAW;QAAE,OAAO,CAAC,GAAG,CAAQ,CAAA;IAEnD,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatDecimal(value: number, maxDecimals?: number): number;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function formatDecimal(value, maxDecimals = 2) {
|
|
2
|
+
if (typeof value === 'number' && value % 1 !== 0) {
|
|
3
|
+
// The number is a decimal, round it to 2 decimal places
|
|
4
|
+
return +value.toFixed(maxDecimals);
|
|
5
|
+
}
|
|
6
|
+
// The value is not a decimal number, return it as is
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=format-decimal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-decimal.js","sourceRoot":"","sources":["../../src/format-decimal.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,aAAa,CAAC,KAAa,EAAE,WAAW,GAAG,CAAC;IAC1D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,wDAAwD;QACxD,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;IACpC,CAAC;IAED,qDAAqD;IACrD,OAAO,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isHexColor(str: string): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-hex-color.js","sourceRoot":"","sources":["../../src/is-hex-color.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,OAAO,wBAAwB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC3C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isProd: () => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-prod.js","sourceRoot":"","sources":["../../src/is-prod.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { describe, test, expect } from 'vitest';
|
|
2
|
+
import { makeUuid } from './strings/make-uuid.js';
|
|
3
|
+
describe('makeUuid()', () => {
|
|
4
|
+
test('it works', () => {
|
|
5
|
+
const uuid = makeUuid();
|
|
6
|
+
expect(typeof uuid).toBe('string');
|
|
7
|
+
expect(uuid.length).toBeGreaterThan(10);
|
|
8
|
+
});
|
|
9
|
+
test('it accepts a prefix', () => {
|
|
10
|
+
const uuid = makeUuid('pRfiX');
|
|
11
|
+
const uuid2 = makeUuid('-0.*--');
|
|
12
|
+
const uuid3 = makeUuid(' - nospacesallowed - ');
|
|
13
|
+
expect(uuid).toContain('pRfiX');
|
|
14
|
+
expect(uuid2).toContain('-0--');
|
|
15
|
+
expect(uuid3).toContain('-nospacesallowed-');
|
|
16
|
+
expect(uuid.length).toBeGreaterThan(16);
|
|
17
|
+
});
|
|
18
|
+
test('it accepts an organizationId and is always appended to the uuid', () => {
|
|
19
|
+
const uuid = makeUuid('prefix', { postfix: 'abc123' });
|
|
20
|
+
expect(uuid.substr(uuid.length - 6)).toBe('abc123');
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=make-uuid.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make-uuid.test.js","sourceRoot":"","sources":["../../src/make-uuid.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAC,IAAI,EAAC,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAEjD,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE;QACpB,MAAM,IAAI,GAAG,QAAQ,EAAE,CAAA;QAEvB,MAAM,CAAC,OAAO,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAClC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,e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