@stryke/helpers 0.10.12 → 0.10.14
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/CHANGELOG.md +24 -0
- package/dist/arg-identity.cjs +1 -0
- package/dist/arg-identity.d.cts.map +1 -1
- package/dist/arg-identity.d.mts.map +1 -1
- package/dist/deep-clone.cjs +4 -5
- package/dist/deep-clone.d.cts.map +1 -1
- package/dist/deep-clone.d.mts.map +1 -1
- package/dist/deep-clone.mjs +1 -3
- package/dist/deep-clone.mjs.map +1 -1
- package/dist/deep-merge.cjs +7 -6
- package/dist/deep-merge.d.cts.map +1 -1
- package/dist/deep-merge.d.mts.map +1 -1
- package/dist/deep-merge.mjs +3 -3
- package/dist/deep-merge.mjs.map +1 -1
- package/dist/filter-empty.cjs +3 -2
- package/dist/filter-empty.d.cts.map +1 -1
- package/dist/filter-empty.d.mts.map +1 -1
- package/dist/filter-empty.mjs +1 -1
- package/dist/flatten-object.cjs +3 -3
- package/dist/flatten-object.d.cts +1 -2
- package/dist/flatten-object.d.cts.map +1 -1
- package/dist/flatten-object.d.mts +1 -2
- package/dist/flatten-object.d.mts.map +1 -1
- package/dist/flatten-object.mjs +1 -2
- package/dist/flatten-object.mjs.map +1 -1
- package/dist/get-field.cjs +5 -12
- package/dist/get-field.d.cts.map +1 -1
- package/dist/get-field.d.mts.map +1 -1
- package/dist/get-field.mjs +2 -10
- package/dist/get-field.mjs.map +1 -1
- package/dist/get-ordered-by.cjs +1 -0
- package/dist/get-ordered-by.d.cts.map +1 -1
- package/dist/get-ordered-by.d.mts.map +1 -1
- package/dist/get-unique.cjs +1 -0
- package/dist/get-unique.d.cts.map +1 -1
- package/dist/get-unique.d.mts.map +1 -1
- package/dist/identity.cjs +1 -0
- package/dist/identity.d.cts.map +1 -1
- package/dist/identity.d.mts.map +1 -1
- package/dist/index.cjs +1 -0
- package/dist/is-equal.cjs +5 -4
- package/dist/is-equal.d.cts.map +1 -1
- package/dist/is-equal.d.mts.map +1 -1
- package/dist/is-equal.mjs +2 -2
- package/dist/lru-cache.cjs +1 -0
- package/dist/lru-cache.d.cts.map +1 -1
- package/dist/lru-cache.d.mts.map +1 -1
- package/dist/match-sorter.cjs +1 -0
- package/dist/match-sorter.d.cts.map +1 -1
- package/dist/match-sorter.d.mts.map +1 -1
- package/dist/match-sorter.mjs.map +1 -1
- package/dist/memoize.cjs +1 -0
- package/dist/memoize.d.cts.map +1 -1
- package/dist/memoize.d.mts.map +1 -1
- package/dist/memoize.mjs.map +1 -1
- package/dist/noop.cjs +1 -0
- package/dist/noop.d.cts.map +1 -1
- package/dist/noop.d.mts.map +1 -1
- package/dist/omit.cjs +1 -0
- package/dist/omit.d.cts.map +1 -1
- package/dist/omit.d.mts.map +1 -1
- package/dist/pick.cjs +1 -0
- package/dist/pick.d.cts.map +1 -1
- package/dist/pick.d.mts.map +1 -1
- package/dist/remove-accents.cjs +1 -0
- package/dist/remove-accents.d.cts.map +1 -1
- package/dist/remove-accents.d.mts.map +1 -1
- package/dist/remove-accents.mjs.map +1 -1
- package/dist/remove-empty-items.cjs +1 -0
- package/dist/remove-empty-items.d.cts.map +1 -1
- package/dist/remove-empty-items.d.mts.map +1 -1
- package/dist/set-field.cjs +5 -4
- package/dist/set-field.d.cts +1 -2
- package/dist/set-field.d.cts.map +1 -1
- package/dist/set-field.d.mts +1 -2
- package/dist/set-field.d.mts.map +1 -1
- package/dist/set-field.mjs +2 -2
- package/dist/set-field.mjs.map +1 -1
- package/dist/to-deep-key.cjs +5 -4
- package/dist/to-deep-key.d.cts.map +1 -1
- package/dist/to-deep-key.d.mts.map +1 -1
- package/dist/to-deep-key.mjs +2 -2
- package/dist/to-path.cjs +1 -0
- package/dist/to-path.d.cts.map +1 -1
- package/dist/to-path.d.mts.map +1 -1
- package/dist/to-path.mjs.map +1 -1
- package/dist/unflatten-object.cjs +1 -0
- package/dist/unflatten-object.d.cts +1 -2
- package/dist/unflatten-object.d.cts.map +1 -1
- package/dist/unflatten-object.d.mts +1 -2
- package/dist/unflatten-object.d.mts.map +1 -1
- package/dist/union.cjs +1 -0
- package/dist/union.d.cts.map +1 -1
- package/dist/union.d.mts.map +1 -1
- package/package.json +51 -46
- package/dist/convert/src/index.cjs +0 -5
- package/dist/convert/src/index.mjs +0 -7
- package/dist/convert/src/parse-type-definition.cjs +0 -1
- package/dist/convert/src/parse-type-definition.mjs +0 -3
- package/dist/convert/src/string-to-utf8-array.cjs +0 -5
- package/dist/convert/src/string-to-utf8-array.mjs +0 -6
- package/dist/convert/src/string-to-utf8-array.mjs.map +0 -1
- package/dist/convert/src/to-bool.cjs +0 -1
- package/dist/convert/src/to-bool.mjs +0 -3
- package/dist/convert/src/to-string-key.cjs +0 -15
- package/dist/convert/src/to-string-key.mjs +0 -15
- package/dist/convert/src/to-string-key.mjs.map +0 -1
- package/dist/convert/src/utf8-array-to-string.cjs +0 -5
- package/dist/convert/src/utf8-array-to-string.mjs +0 -6
- package/dist/convert/src/utf8-array-to-string.mjs.map +0 -1
- package/dist/type-checks/src/get-object-tag.cjs +0 -15
- package/dist/type-checks/src/get-object-tag.mjs +0 -15
- package/dist/type-checks/src/get-object-tag.mjs.map +0 -1
- package/dist/type-checks/src/index.cjs +0 -21
- package/dist/type-checks/src/index.mjs +0 -23
- package/dist/type-checks/src/is-buffer.cjs +0 -13
- package/dist/type-checks/src/is-buffer.mjs +0 -14
- package/dist/type-checks/src/is-buffer.mjs.map +0 -1
- package/dist/type-checks/src/is-collection.cjs +0 -1
- package/dist/type-checks/src/is-collection.mjs +0 -3
- package/dist/type-checks/src/is-deep-key.cjs +0 -34
- package/dist/type-checks/src/is-deep-key.mjs +0 -34
- package/dist/type-checks/src/is-deep-key.mjs.map +0 -1
- package/dist/type-checks/src/is-empty.cjs +0 -20
- package/dist/type-checks/src/is-empty.mjs +0 -21
- package/dist/type-checks/src/is-empty.mjs.map +0 -1
- package/dist/type-checks/src/is-function.cjs +0 -27
- package/dist/type-checks/src/is-function.mjs +0 -26
- package/dist/type-checks/src/is-function.mjs.map +0 -1
- package/dist/type-checks/src/is-mergeable-object.cjs +0 -14
- package/dist/type-checks/src/is-mergeable-object.mjs +0 -15
- package/dist/type-checks/src/is-mergeable-object.mjs.map +0 -1
- package/dist/type-checks/src/is-non-null-object.cjs +0 -16
- package/dist/type-checks/src/is-non-null-object.mjs +0 -17
- package/dist/type-checks/src/is-non-null-object.mjs.map +0 -1
- package/dist/type-checks/src/is-null.cjs +0 -12
- package/dist/type-checks/src/is-null.mjs +0 -12
- package/dist/type-checks/src/is-null.mjs.map +0 -1
- package/dist/type-checks/src/is-number.cjs +0 -18
- package/dist/type-checks/src/is-number.mjs +0 -18
- package/dist/type-checks/src/is-number.mjs.map +0 -1
- package/dist/type-checks/src/is-object-index.cjs +0 -25
- package/dist/type-checks/src/is-object-index.mjs +0 -25
- package/dist/type-checks/src/is-object-index.mjs.map +0 -1
- package/dist/type-checks/src/is-object.cjs +0 -19
- package/dist/type-checks/src/is-object.mjs +0 -20
- package/dist/type-checks/src/is-object.mjs.map +0 -1
- package/dist/type-checks/src/is-plain-object.cjs +0 -64
- package/dist/type-checks/src/is-plain-object.mjs +0 -64
- package/dist/type-checks/src/is-plain-object.mjs.map +0 -1
- package/dist/type-checks/src/is-primitive.cjs +0 -12
- package/dist/type-checks/src/is-primitive.mjs +0 -12
- package/dist/type-checks/src/is-primitive.mjs.map +0 -1
- package/dist/type-checks/src/is-react-element.cjs +0 -8
- package/dist/type-checks/src/is-react-element.mjs +0 -8
- package/dist/type-checks/src/is-react-element.mjs.map +0 -1
- package/dist/type-checks/src/is-set-string.cjs +0 -20
- package/dist/type-checks/src/is-set-string.mjs +0 -21
- package/dist/type-checks/src/is-set-string.mjs.map +0 -1
- package/dist/type-checks/src/is-set.cjs +0 -19
- package/dist/type-checks/src/is-set.mjs +0 -20
- package/dist/type-checks/src/is-set.mjs.map +0 -1
- package/dist/type-checks/src/is-string.cjs +0 -12
- package/dist/type-checks/src/is-string.mjs +0 -12
- package/dist/type-checks/src/is-string.mjs.map +0 -1
- package/dist/type-checks/src/is-typed-array.cjs +0 -8
- package/dist/type-checks/src/is-typed-array.mjs +0 -8
- package/dist/type-checks/src/is-typed-array.mjs.map +0 -1
- package/dist/type-checks/src/is-undefined.cjs +0 -8
- package/dist/type-checks/src/is-undefined.mjs +0 -8
- package/dist/type-checks/src/is-undefined.mjs.map +0 -1
- package/dist/type-checks/src/property-exists.cjs +0 -31
- package/dist/type-checks/src/property-exists.mjs +0 -31
- package/dist/type-checks/src/property-exists.mjs.map +0 -1
- package/dist/type-checks/src/type-detect.cjs +0 -15
- package/dist/type-checks/src/type-detect.mjs +0 -17
- package/dist/type-checks/src/type-detect.mjs.map +0 -1
- package/dist/types/src/base.d.cts +0 -8
- package/dist/types/src/base.d.cts.map +0 -1
- package/dist/types/src/base.d.mts +0 -8
- package/dist/types/src/base.d.mts.map +0 -1
- package/dist/types/src/json.d.cts +0 -28
- package/dist/types/src/json.d.cts.map +0 -1
- package/dist/types/src/json.d.mts +0 -28
- package/dist/types/src/json.d.mts.map +0 -1
- package/dist/types/src/object.d.cts +0 -125
- package/dist/types/src/object.d.cts.map +0 -1
- package/dist/types/src/object.d.mts +0 -125
- package/dist/types/src/object.d.mts.map +0 -1
- package/dist/types/src/string.d.cts +0 -6
- package/dist/types/src/string.d.cts.map +0 -1
- package/dist/types/src/string.d.mts +0 -6
- package/dist/types/src/string.d.mts.map +0 -1
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const require_is_string = require('./is-string.cjs');
|
|
2
|
-
const require_is_set = require('./is-set.cjs');
|
|
3
|
-
|
|
4
|
-
//#region ../type-checks/src/is-set-string.ts
|
|
5
|
-
/**
|
|
6
|
-
* Determine if the type is string and is not empty (length greater than zero)
|
|
7
|
-
*
|
|
8
|
-
* @param value - The value to type check
|
|
9
|
-
* @returns An indicator specifying if the value provided is of type `string` and length greater than zero
|
|
10
|
-
*/
|
|
11
|
-
const isSetString = (value) => {
|
|
12
|
-
try {
|
|
13
|
-
return require_is_set.isSet(value) && require_is_string.isString(value) && value.length > 0;
|
|
14
|
-
} catch {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
exports.isSetString = isSetString;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { isString } from "./is-string.mjs";
|
|
2
|
-
import { isSet } from "./is-set.mjs";
|
|
3
|
-
|
|
4
|
-
//#region ../type-checks/src/is-set-string.ts
|
|
5
|
-
/**
|
|
6
|
-
* Determine if the type is string and is not empty (length greater than zero)
|
|
7
|
-
*
|
|
8
|
-
* @param value - The value to type check
|
|
9
|
-
* @returns An indicator specifying if the value provided is of type `string` and length greater than zero
|
|
10
|
-
*/
|
|
11
|
-
const isSetString = (value) => {
|
|
12
|
-
try {
|
|
13
|
-
return isSet(value) && isString(value) && value.length > 0;
|
|
14
|
-
} catch {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
export { isSetString };
|
|
21
|
-
//# sourceMappingURL=is-set-string.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-set-string.mjs","names":[],"sources":["../../../../type-checks/src/is-set-string.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isSet } from \"./is-set\";\nimport { isString } from \"./is-string\";\n\n/**\n * Determine if the type is string and is not empty (length greater than zero)\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `string` and length greater than zero\n */\nexport const isSetString = (value: unknown): value is NonNullable<string> => {\n try {\n return isSet(value) && isString(value) && value.length > 0;\n } catch {\n return false;\n }\n};\n"],"mappings":";;;;;;;;;;AA2BA,MAAa,eAAe,UAAiD;AAC3E,KAAI;AACF,SAAO,MAAM,MAAM,IAAI,SAAS,MAAM,IAAI,MAAM,SAAS;SACnD;AACN,SAAO"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const require_is_empty = require('./is-empty.cjs');
|
|
2
|
-
|
|
3
|
-
//#region ../type-checks/src/is-set.ts
|
|
4
|
-
/**
|
|
5
|
-
* The inverse of the `isEmpty` function
|
|
6
|
-
*
|
|
7
|
-
* @param value - The value to type check
|
|
8
|
-
* @returns An indicator specifying if the value provided is **NOT** of type `null` or `undefined`
|
|
9
|
-
*/
|
|
10
|
-
const isSet = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
return !require_is_empty.isEmpty(value);
|
|
13
|
-
} catch {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
exports.isSet = isSet;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { isEmpty } from "./is-empty.mjs";
|
|
2
|
-
|
|
3
|
-
//#region ../type-checks/src/is-set.ts
|
|
4
|
-
/**
|
|
5
|
-
* The inverse of the `isEmpty` function
|
|
6
|
-
*
|
|
7
|
-
* @param value - The value to type check
|
|
8
|
-
* @returns An indicator specifying if the value provided is **NOT** of type `null` or `undefined`
|
|
9
|
-
*/
|
|
10
|
-
const isSet = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
return !isEmpty(value);
|
|
13
|
-
} catch {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
export { isSet };
|
|
20
|
-
//# sourceMappingURL=is-set.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-set.mjs","names":[],"sources":["../../../../type-checks/src/is-set.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isEmpty } from \"./is-empty\";\n\n/**\n * The inverse of the `isEmpty` function\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is **NOT** of type `null` or `undefined`\n */\nexport const isSet = (value: unknown): value is NonNullable<unknown> => {\n try {\n return !isEmpty(value);\n } catch {\n return false;\n }\n};\n"],"mappings":";;;;;;;;;AA0BA,MAAa,SAAS,UAAkD;AACtE,KAAI;AACF,SAAO,CAAC,QAAQ,MAAM;SAChB;AACN,SAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-string.mjs","names":[],"sources":["../../../../type-checks/src/is-string.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const isString = (value: unknown): value is string => {\n try {\n return typeof value === \"string\";\n } catch {\n return false;\n }\n};\n"],"mappings":";AAkBA,MAAa,YAAY,UAAoC;AAC3D,KAAI;AACF,SAAO,OAAO,UAAU;SAClB;AACN,SAAO"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region ../type-checks/src/is-typed-array.ts
|
|
3
|
-
function isTypedArray(obj) {
|
|
4
|
-
return obj instanceof Uint8Array || obj instanceof Uint8ClampedArray || obj instanceof Uint16Array || obj instanceof Uint32Array || obj instanceof BigUint64Array || obj instanceof Int8Array || obj instanceof Int16Array || obj instanceof Int32Array || obj instanceof BigInt64Array || obj instanceof Float32Array || obj instanceof Float64Array;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
//#endregion
|
|
8
|
-
exports.isTypedArray = isTypedArray;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
//#region ../type-checks/src/is-typed-array.ts
|
|
2
|
-
function isTypedArray(obj) {
|
|
3
|
-
return obj instanceof Uint8Array || obj instanceof Uint8ClampedArray || obj instanceof Uint16Array || obj instanceof Uint32Array || obj instanceof BigUint64Array || obj instanceof Int8Array || obj instanceof Int16Array || obj instanceof Int32Array || obj instanceof BigInt64Array || obj instanceof Float32Array || obj instanceof Float64Array;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
//#endregion
|
|
7
|
-
export { isTypedArray };
|
|
8
|
-
//# sourceMappingURL=is-typed-array.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-typed-array.mjs","names":[],"sources":["../../../../type-checks/src/is-typed-array.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport function isTypedArray(\n obj: any\n): obj is\n | Uint8Array\n | Uint8ClampedArray\n | Uint16Array\n | Uint32Array\n | BigUint64Array\n | Int8Array\n | Int16Array\n | Int32Array\n | BigInt64Array\n | Float32Array\n | Float64Array {\n return (\n obj instanceof Uint8Array ||\n obj instanceof Uint8ClampedArray ||\n obj instanceof Uint16Array ||\n obj instanceof Uint32Array ||\n obj instanceof BigUint64Array ||\n obj instanceof Int8Array ||\n obj instanceof Int16Array ||\n obj instanceof Int32Array ||\n obj instanceof BigInt64Array ||\n obj instanceof Float32Array ||\n obj instanceof Float64Array\n );\n}\n"],"mappings":";AAkBA,SAAgB,aACd,KAYe;AACf,QACE,eAAe,cACf,eAAe,qBACf,eAAe,eACf,eAAe,eACf,eAAe,kBACf,eAAe,aACf,eAAe,cACf,eAAe,cACf,eAAe,iBACf,eAAe,gBACf,eAAe"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-undefined.mjs","names":[],"sources":["../../../../type-checks/src/is-undefined.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const isUndefined = (value: unknown): value is undefined => {\n return value === undefined;\n};\n"],"mappings":";AAkBA,MAAa,eAAe,UAAuC;AACjE,QAAO,UAAU"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const require_is_object = require('./is-object.cjs');
|
|
2
|
-
|
|
3
|
-
//#region ../type-checks/src/property-exists.ts
|
|
4
|
-
/**
|
|
5
|
-
* Check if the provided object has the provided property
|
|
6
|
-
*
|
|
7
|
-
* @param object - The object to check
|
|
8
|
-
* @param propertyKey - The property to check
|
|
9
|
-
* @returns An indicator specifying if the object has the provided property
|
|
10
|
-
*/
|
|
11
|
-
const propertyExists = (object, propertyKey) => {
|
|
12
|
-
try {
|
|
13
|
-
return require_is_object.isObject(object) && propertyKey in object;
|
|
14
|
-
} catch {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Check if the provided object has the provided property and if it's safe to merge
|
|
20
|
-
*
|
|
21
|
-
* @param object - The object to check
|
|
22
|
-
* @param propertyKey - The property to check
|
|
23
|
-
* @returns An indicator specifying if the object has the provided property and if it's safe to merge
|
|
24
|
-
*/
|
|
25
|
-
const propertyUnsafe = (object, propertyKey) => {
|
|
26
|
-
return propertyExists(object, propertyKey) && !(Object.hasOwnProperty.call(object, propertyKey) && Object.propertyIsEnumerable.call(object, propertyKey));
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
//#endregion
|
|
30
|
-
exports.propertyExists = propertyExists;
|
|
31
|
-
exports.propertyUnsafe = propertyUnsafe;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { isObject } from "./is-object.mjs";
|
|
2
|
-
|
|
3
|
-
//#region ../type-checks/src/property-exists.ts
|
|
4
|
-
/**
|
|
5
|
-
* Check if the provided object has the provided property
|
|
6
|
-
*
|
|
7
|
-
* @param object - The object to check
|
|
8
|
-
* @param propertyKey - The property to check
|
|
9
|
-
* @returns An indicator specifying if the object has the provided property
|
|
10
|
-
*/
|
|
11
|
-
const propertyExists = (object, propertyKey) => {
|
|
12
|
-
try {
|
|
13
|
-
return isObject(object) && propertyKey in object;
|
|
14
|
-
} catch {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Check if the provided object has the provided property and if it's safe to merge
|
|
20
|
-
*
|
|
21
|
-
* @param object - The object to check
|
|
22
|
-
* @param propertyKey - The property to check
|
|
23
|
-
* @returns An indicator specifying if the object has the provided property and if it's safe to merge
|
|
24
|
-
*/
|
|
25
|
-
const propertyUnsafe = (object, propertyKey) => {
|
|
26
|
-
return propertyExists(object, propertyKey) && !(Object.hasOwnProperty.call(object, propertyKey) && Object.propertyIsEnumerable.call(object, propertyKey));
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
//#endregion
|
|
30
|
-
export { propertyExists, propertyUnsafe };
|
|
31
|
-
//# sourceMappingURL=property-exists.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"property-exists.mjs","names":[],"sources":["../../../../type-checks/src/property-exists.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isObject } from \"./is-object\";\n\n/**\n * Check if the provided object has the provided property\n *\n * @param object - The object to check\n * @param propertyKey - The property to check\n * @returns An indicator specifying if the object has the provided property\n */\nexport const propertyExists = (object: any, propertyKey: PropertyKey) => {\n try {\n return isObject(object) && propertyKey in object;\n } catch {\n return false;\n }\n};\n\n/**\n * Check if the provided object has the provided property and if it's safe to merge\n *\n * @param object - The object to check\n * @param propertyKey - The property to check\n * @returns An indicator specifying if the object has the provided property and if it's safe to merge\n */\nexport const propertyUnsafe = (object: any, propertyKey: PropertyKey) => {\n return (\n propertyExists(object, propertyKey) && // Properties are safe to merge if they don't exist in the target yet,\n !(\n Object.hasOwnProperty.call(object, propertyKey) && // unsafe if they exist up the prototype chain,\n Object.propertyIsEnumerable.call(object, propertyKey)\n )\n ); // and also unsafe if they're non-enumerable.\n};\n"],"mappings":";;;;;;;;;;AA2BA,MAAa,kBAAkB,QAAa,gBAA6B;AACvE,KAAI;AACF,SAAO,SAAS,OAAO,IAAI,eAAe;SACpC;AACN,SAAO;;;;;;;;;;AAWX,MAAa,kBAAkB,QAAa,gBAA6B;AACvE,QACE,eAAe,QAAQ,YAAY,IACnC,EACE,OAAO,eAAe,KAAK,QAAQ,YAAY,IAC/C,OAAO,qBAAqB,KAAK,QAAQ,YAAY"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
require('./is-buffer.cjs');
|
|
2
|
-
|
|
3
|
-
//#region ../type-checks/src/type-detect.ts
|
|
4
|
-
const globalObject = ((obj) => {
|
|
5
|
-
if (typeof globalThis === "object") return globalThis;
|
|
6
|
-
Object.defineProperty(obj, "typeDetectGlobalObject", {
|
|
7
|
-
get() {
|
|
8
|
-
return this;
|
|
9
|
-
},
|
|
10
|
-
configurable: true
|
|
11
|
-
});
|
|
12
|
-
return globalThis;
|
|
13
|
-
})(Object.prototype);
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import "./is-buffer.mjs";
|
|
2
|
-
|
|
3
|
-
//#region ../type-checks/src/type-detect.ts
|
|
4
|
-
const globalObject = ((obj) => {
|
|
5
|
-
if (typeof globalThis === "object") return globalThis;
|
|
6
|
-
Object.defineProperty(obj, "typeDetectGlobalObject", {
|
|
7
|
-
get() {
|
|
8
|
-
return this;
|
|
9
|
-
},
|
|
10
|
-
configurable: true
|
|
11
|
-
});
|
|
12
|
-
return globalThis;
|
|
13
|
-
})(Object.prototype);
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
16
|
-
export { };
|
|
17
|
-
//# sourceMappingURL=type-detect.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"type-detect.mjs","names":[],"sources":["../../../../type-checks/src/type-detect.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isBuffer } from \"./is-buffer\";\n\nconst globalObject = (obj => {\n if (typeof globalThis === \"object\") {\n return globalThis;\n }\n Object.defineProperty(obj, \"typeDetectGlobalObject\", {\n get() {\n return this;\n },\n configurable: true\n });\n\n // // biome-ignore lint/correctness/noUndeclaredVariables: <explanation>\n // const global = typeDetectGlobalObject;\n\n // // biome-ignore lint/performance/noDelete: <explanation>\n // delete obj.typeDetectGlobalObject;\n return globalThis;\n})(Object.prototype);\n\nexport function typeDetect(obj: unknown): string {\n // NOTE: isBuffer must execute before type-detect,\n // because type-detect returns 'Uint8Array'.\n if (isBuffer(obj)) {\n return \"Buffer\";\n }\n\n const typeofObj = typeof obj;\n if (typeofObj !== \"object\") {\n return typeofObj;\n }\n\n if (obj === null) {\n return \"null\";\n }\n\n if (obj === globalObject) {\n return \"global\";\n }\n\n if (\n Array.isArray(obj) &&\n (Symbol.toStringTag === undefined || !(Symbol.toStringTag in obj))\n ) {\n return \"Array\";\n }\n\n // https://html.spec.whatwg.org/multipage/browsers.html#location\n if (typeof globalThis === \"object\" && globalThis !== null) {\n if (\n typeof (globalThis as any).location === \"object\" &&\n obj === (globalThis as any).location\n ) {\n return \"Location\";\n }\n\n // https://html.spec.whatwg.org/#document\n if (\n typeof (globalThis as any).document === \"object\" &&\n obj === (globalThis as any).document\n ) {\n return \"Document\";\n }\n\n // https://html.spec.whatwg.org/multipage/webappapis.html#mimetypearray\n if (typeof (globalThis as any).navigator === \"object\") {\n if (\n typeof (globalThis as any).navigator.mimeTypes === \"object\" &&\n obj === (globalThis as any).navigator.mimeTypes\n ) {\n return \"MimeTypeArray\";\n }\n\n // https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray\n if (\n typeof (globalThis as any).navigator.plugins === \"object\" &&\n obj === (globalThis as any).navigator.plugins\n ) {\n return \"PluginArray\";\n }\n }\n\n // https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray\n if (\n (typeof (globalThis as any).HTMLElement === \"function\" ||\n typeof (globalThis as any).HTMLElement === \"object\") &&\n obj instanceof (globalThis as any).HTMLElement\n ) {\n if ((obj as any).tagName === \"BLOCKQUOTE\") {\n return \"HTMLQuoteElement\";\n }\n\n // https://html.spec.whatwg.org/#htmltabledatacellelement\n if ((obj as any).tagName === \"TD\") {\n return \"HTMLTableDataCellElement\";\n }\n\n // https://html.spec.whatwg.org/#htmltableheadercellelement\n if ((obj as any).tagName === \"TH\") {\n return \"HTMLTableHeaderCellElement\";\n }\n }\n }\n\n const stringTag =\n Symbol.toStringTag !== undefined && (obj as any)[Symbol.toStringTag];\n if (typeof stringTag === \"string\") {\n return stringTag;\n }\n\n const objPrototype = Object.getPrototypeOf(obj);\n if (objPrototype === RegExp.prototype) {\n return \"RegExp\";\n }\n\n if (objPrototype === Date.prototype) {\n return \"Date\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-promise.prototype-@@tostringtag\n if (typeof Promise !== \"undefined\" && objPrototype === Promise.prototype) {\n return \"Promise\";\n }\n\n if (typeof Set !== \"undefined\" && objPrototype === Set.prototype) {\n return \"Set\";\n }\n\n if (typeof Map !== \"undefined\" && objPrototype === Map.prototype) {\n return \"Map\";\n }\n\n if (typeof WeakSet !== \"undefined\" && objPrototype === WeakSet.prototype) {\n return \"WeakSet\";\n }\n\n if (typeof WeakMap !== \"undefined\" && objPrototype === WeakMap.prototype) {\n return \"WeakMap\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-dataview.prototype-@@tostringtag\n if (typeof DataView !== \"undefined\" && objPrototype === DataView.prototype) {\n return \"DataView\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%mapiteratorprototype%-@@tostringtag\n if (\n typeof Map !== \"undefined\" &&\n objPrototype === Object.getPrototypeOf(new Map().entries())\n ) {\n return \"Map Iterator\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%setiteratorprototype%-@@tostringtag\n if (\n typeof Set !== \"undefined\" &&\n objPrototype === Object.getPrototypeOf(new Set().entries())\n ) {\n return \"Set Iterator\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%arrayiteratorprototype%-@@tostringtag\n if (\n typeof Array.prototype[Symbol.iterator] === \"function\" &&\n objPrototype === Object.getPrototypeOf([][Symbol.iterator]())\n ) {\n return \"Array Iterator\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%stringiteratorprototype%-@@tostringtag\n if (\n Symbol.iterator !== undefined &&\n typeof String.prototype[Symbol.iterator] === \"function\" &&\n Object.getPrototypeOf(\"\"[Symbol.iterator]()) &&\n objPrototype === Object.getPrototypeOf(\"\"[Symbol.iterator]())\n ) {\n return \"String Iterator\";\n }\n\n if (objPrototype === null) {\n return \"Object\";\n }\n\n return Object.prototype.toString.call(obj).slice(8, -1);\n}\n"],"mappings":";;;AAoBA,MAAM,iBAAgB,QAAO;AAC3B,KAAI,OAAO,eAAe,SACxB,QAAO;AAET,QAAO,eAAe,KAAK,0BAA0B;EACnD,MAAM;AACJ,UAAO;;EAET,cAAc;EACf,CAAC;AAOF,QAAO;GACN,OAAO,UAAU"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
//#region ../types/src/base.d.ts
|
|
2
|
-
|
|
3
|
-
type Nullish = undefined | null;
|
|
4
|
-
type ComputeRange<N extends number, Result extends unknown[] = []> = Result["length"] extends N ? Result : ComputeRange<N, [...Result, Result["length"]]>;
|
|
5
|
-
type Index40 = ComputeRange<40>[number];
|
|
6
|
-
//#endregion
|
|
7
|
-
export { Index40, Nullish };
|
|
8
|
-
//# sourceMappingURL=base.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.cts","names":[],"sources":["../../../../types/src/base.ts"],"sourcesContent":[],"mappings":";;KAuIY,OAAA;KA2OA,gEAGR,yBAAyB,IACzB,SACA,aAAa,OAAO,QAAQ;KAEpB,OAAA,GAAU"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
//#region ../types/src/base.d.ts
|
|
2
|
-
|
|
3
|
-
type Nullish = undefined | null;
|
|
4
|
-
type ComputeRange<N extends number, Result extends unknown[] = []> = Result["length"] extends N ? Result : ComputeRange<N, [...Result, Result["length"]]>;
|
|
5
|
-
type Index40 = ComputeRange<40>[number];
|
|
6
|
-
//#endregion
|
|
7
|
-
export { Index40, Nullish };
|
|
8
|
-
//# sourceMappingURL=base.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.mts","names":[],"sources":["../../../../types/src/base.ts"],"sourcesContent":[],"mappings":";;KAuIY,OAAA;KA2OA,gEAGR,yBAAyB,IACzB,SACA,aAAa,OAAO,QAAQ;KAEpB,OAAA,GAAU"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
//#region ../types/src/json.d.ts
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Get keys of the given type as strings.
|
|
5
|
-
*
|
|
6
|
-
* Number keys are converted to strings.
|
|
7
|
-
*
|
|
8
|
-
* Use-cases:
|
|
9
|
-
* - Get string keys from a type which may have number keys.
|
|
10
|
-
* - Makes it possible to index using strings retrieved from template types.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```
|
|
14
|
-
* import type {StringKeyOf} from 'type-fest';
|
|
15
|
-
*
|
|
16
|
-
* type Foo = {
|
|
17
|
-
* 1: number,
|
|
18
|
-
* stringKey: string,
|
|
19
|
-
* };
|
|
20
|
-
*
|
|
21
|
-
* type StringKeysOfFoo = StringKeyOf<Foo>;
|
|
22
|
-
* //=> '1' | 'stringKey'
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
type StringKeyOf<BaseType> = `${Extract<keyof BaseType, string | number>}`;
|
|
26
|
-
//#endregion
|
|
27
|
-
export { StringKeyOf };
|
|
28
|
-
//# sourceMappingURL=json.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.cts","names":[],"sources":["../../../../types/src/json.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;KA2FY,2BACP,cAAc"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
//#region ../types/src/json.d.ts
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Get keys of the given type as strings.
|
|
5
|
-
*
|
|
6
|
-
* Number keys are converted to strings.
|
|
7
|
-
*
|
|
8
|
-
* Use-cases:
|
|
9
|
-
* - Get string keys from a type which may have number keys.
|
|
10
|
-
* - Makes it possible to index using strings retrieved from template types.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```
|
|
14
|
-
* import type {StringKeyOf} from 'type-fest';
|
|
15
|
-
*
|
|
16
|
-
* type Foo = {
|
|
17
|
-
* 1: number,
|
|
18
|
-
* stringKey: string,
|
|
19
|
-
* };
|
|
20
|
-
*
|
|
21
|
-
* type StringKeysOfFoo = StringKeyOf<Foo>;
|
|
22
|
-
* //=> '1' | 'stringKey'
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
type StringKeyOf<BaseType> = `${Extract<keyof BaseType, string | number>}`;
|
|
26
|
-
//#endregion
|
|
27
|
-
export { StringKeyOf };
|
|
28
|
-
//# sourceMappingURL=json.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.mts","names":[],"sources":["../../../../types/src/json.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;KA2FY,2BACP,cAAc"}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { Index40, Nullish } from "./base.cjs";
|
|
2
|
-
import { StringKeyOf } from "./json.cjs";
|
|
3
|
-
import { StringDigit } from "./string.cjs";
|
|
4
|
-
|
|
5
|
-
//#region ../types/src/object.d.ts
|
|
6
|
-
|
|
7
|
-
interface GetOptions {
|
|
8
|
-
/**
|
|
9
|
-
* Include `undefined` in the return type when accessing properties.
|
|
10
|
-
*
|
|
11
|
-
* Setting this to `false` is not recommended.
|
|
12
|
-
*
|
|
13
|
-
* @defaultValue `true`
|
|
14
|
-
*/
|
|
15
|
-
strict?: boolean;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Like the `Get` type but receives an array of strings as a path parameter.
|
|
19
|
-
*/
|
|
20
|
-
type GetWithPath<BaseType, Keys extends readonly string[], Options extends GetOptions = {}> = Keys extends readonly [] ? BaseType : Keys extends readonly [infer Head, ...infer Tail] ? GetWithPath<PropertyOf<BaseType, Extract<Head, string>, Options>, Extract<Tail, string[]>, Options> : never;
|
|
21
|
-
/**
|
|
22
|
-
* Adds `undefined` to `Type` if `strict` is enabled.
|
|
23
|
-
*/
|
|
24
|
-
type Strictify<Type, Options extends GetOptions> = Options["strict"] extends false ? Type : Type | undefined;
|
|
25
|
-
/**
|
|
26
|
-
* If `Options['strict']` is `true`, includes `undefined` in the returned type when accessing properties on `Record<string, any>`.
|
|
27
|
-
*
|
|
28
|
-
* Known limitations:
|
|
29
|
-
* - Does not include `undefined` in the type on object types with an index signature (for example, `{a: string; [key: string]: string}`).
|
|
30
|
-
*/
|
|
31
|
-
type StrictPropertyOf<BaseType, Key$1 extends keyof BaseType, Options extends GetOptions> = Record<string, any> extends BaseType ? string extends keyof BaseType ? Strictify<BaseType[Key$1], Options> : BaseType[Key$1] : BaseType[Key$1];
|
|
32
|
-
/**
|
|
33
|
-
* Represents an array of strings split using a given character or character set.
|
|
34
|
-
*
|
|
35
|
-
* Use-case: Defining the return type of a method like `String.prototype.split`.
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```
|
|
39
|
-
* import type {Split} from 'type-fest';
|
|
40
|
-
*
|
|
41
|
-
* declare function split<S extends string, D extends string>(string: S, separator: D): Split<S, D>;
|
|
42
|
-
*
|
|
43
|
-
* type Item = 'foo' | 'bar' | 'baz' | 'waldo';
|
|
44
|
-
* const items = 'foo,bar,baz,waldo';
|
|
45
|
-
* let array: Item[];
|
|
46
|
-
*
|
|
47
|
-
* array = split(items, ',');
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
type Split<S extends string, Delimiter extends string> = S extends `${infer Head}${Delimiter}${infer Tail}` ? [Head, ...Split<Tail, Delimiter>] : S extends Delimiter ? [] : [S];
|
|
51
|
-
/**
|
|
52
|
-
* Splits a dot-prop style path into a tuple comprised of the properties in the path. Handles square-bracket notation.
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```
|
|
56
|
-
* ToPath<'foo.bar.baz'>
|
|
57
|
-
* //=> ['foo', 'bar', 'baz']
|
|
58
|
-
*
|
|
59
|
-
* ToPath<'foo[0].bar.baz'>
|
|
60
|
-
* //=> ['foo', '0', 'bar', 'baz']
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
type ToPath<S extends string> = Split<FixPathSquareBrackets<S>, ".">;
|
|
64
|
-
/**
|
|
65
|
-
* Replaces square-bracketed dot notation with dots, for example, `foo[0].bar` -\> `foo.0.bar`.
|
|
66
|
-
*/
|
|
67
|
-
type FixPathSquareBrackets<Path extends string> = Path extends `[${infer Head}]${infer Tail}` ? Tail extends `[${string}` ? `${Head}.${FixPathSquareBrackets<Tail>}` : `${Head}${FixPathSquareBrackets<Tail>}` : Path extends `${infer Head}[${infer Middle}]${infer Tail}` ? `${Head}.${FixPathSquareBrackets<`[${Middle}]${Tail}`>}` : Path;
|
|
68
|
-
/**
|
|
69
|
-
* Returns true if `LongString` is made up out of `Substring` repeated 0 or more times.
|
|
70
|
-
*
|
|
71
|
-
* @example
|
|
72
|
-
* ```ts
|
|
73
|
-
* ConsistsOnlyOf<'aaa', 'a'> //=> true
|
|
74
|
-
* ConsistsOnlyOf<'ababab', 'ab'> //=> true
|
|
75
|
-
* ConsistsOnlyOf<'aBa', 'a'> //=> false
|
|
76
|
-
* ConsistsOnlyOf<'', 'a'> //=> true
|
|
77
|
-
* ```
|
|
78
|
-
*
|
|
79
|
-
*/
|
|
80
|
-
type ConsistsOnlyOf<LongString extends string, Substring extends string> = LongString extends "" ? true : LongString extends `${Substring}${infer Tail}` ? ConsistsOnlyOf<Tail, Substring> : false;
|
|
81
|
-
/**
|
|
82
|
-
* Convert a type which may have number keys to one with string keys, making it possible to index using strings retrieved from template types.
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
*
|
|
86
|
-
* ```ts
|
|
87
|
-
* type WithNumbers = {foo: string; 0: boolean};
|
|
88
|
-
* type WithStrings = WithStringKeys<WithNumbers>;
|
|
89
|
-
*
|
|
90
|
-
* type WithNumbersKeys = keyof WithNumbers;
|
|
91
|
-
* //=> 'foo' | 0
|
|
92
|
-
* type WithStringsKeys = keyof WithStrings;
|
|
93
|
-
* //=> 'foo' | '0'
|
|
94
|
-
* ```
|
|
95
|
-
*
|
|
96
|
-
*/
|
|
97
|
-
type WithStringKeys<BaseType> = { [Key in StringKeyOf<BaseType>]: UncheckedIndex<BaseType, Key> };
|
|
98
|
-
/**
|
|
99
|
-
Perform a `T[U]` operation if `T` supports indexing.
|
|
100
|
-
*/
|
|
101
|
-
type UncheckedIndex<T, U$1 extends number | string> = [T] extends [Record<number | string, any>] ? T[U$1] : never;
|
|
102
|
-
/**
|
|
103
|
-
* Get a property of an object or array. Works when indexing arrays using number-literal-strings, for example, `PropertyOf<number[], '0'> = number`, and when indexing objects with number keys.
|
|
104
|
-
*
|
|
105
|
-
* Note:
|
|
106
|
-
* - Returns `unknown` if `Key` is not a property of `BaseType`, since TypeScript uses structural typing, and it cannot be guaranteed that extra properties unknown to the type system will exist at runtime.
|
|
107
|
-
* - Returns `undefined` from nullish values, to match the behavior of most deep-key libraries like `lodash`, `dot-prop`, etc.
|
|
108
|
-
*/
|
|
109
|
-
type PropertyOf<BaseType, Key$1 extends string, Options extends GetOptions = {}> = BaseType extends Nullish ? undefined : Key$1 extends keyof BaseType ? StrictPropertyOf<BaseType, Key$1, Options> : BaseType extends readonly [] | readonly [unknown, ...unknown[]] ? unknown : BaseType extends {
|
|
110
|
-
[n: number]: infer Item;
|
|
111
|
-
length: number;
|
|
112
|
-
} ? ConsistsOnlyOf<Key$1, StringDigit> extends true ? Strictify<Item, Options> : unknown : Key$1 extends keyof WithStringKeys<BaseType> ? StrictPropertyOf<WithStringKeys<BaseType>, Key$1, Options> : unknown;
|
|
113
|
-
type IsTuple<T> = T extends {
|
|
114
|
-
length: infer Length;
|
|
115
|
-
} & readonly any[] ? Length extends Index40 ? T : never : never;
|
|
116
|
-
type AllowedIndexes<Tuple extends readonly any[], Keys extends number = never> = Tuple extends readonly [] ? Keys : Tuple extends readonly [infer _First, ...infer Tail] ? AllowedIndexes<Tail, Keys | Tail["length"]> : Keys;
|
|
117
|
-
type PrefixArrayAccessor<T extends any[], TDepth extends any[]> = { [K in keyof T]: `[${number}]${DeepKey<T[K], TDepth>}` }[number];
|
|
118
|
-
type PrefixTupleAccessor<T extends any[], TIndex extends number, TDepth extends any[]> = { [K in TIndex]: `[${K}]${DeepKey<T[K], TDepth>}` | `[${K}]` }[TIndex];
|
|
119
|
-
type PrefixObjectAccessor<T extends object, TDepth extends any[]> = { [K in keyof T]-?: K extends number | string ? `${PrefixFromDepth<K, TDepth>}${DeepKey<T[K], [TDepth]>}` | PrefixFromDepth<K, TDepth> : never }[keyof T];
|
|
120
|
-
type PrefixFromDepth<T extends number | string, TDepth extends any[]> = TDepth["length"] extends 0 ? T : `.${T}`;
|
|
121
|
-
type DeepKey<T, TDepth extends any[] = []> = TDepth["length"] extends 5 ? never : unknown extends T ? PrefixFromDepth<string, TDepth> : T extends IsTuple<T> & any[] ? PrefixTupleAccessor<T, AllowedIndexes<T>, TDepth> : T extends any[] ? PrefixArrayAccessor<T, [...TDepth, any]> : T extends Date ? never : T extends object ? PrefixObjectAccessor<T, TDepth> : T extends bigint | boolean | number | string ? "" : never;
|
|
122
|
-
type DeepValue<TObject extends Record<string, unknown>, TPath extends DeepKey<TObject>> = GetWithPath<TObject, ToPath<TPath>>;
|
|
123
|
-
//#endregion
|
|
124
|
-
export { DeepKey, DeepValue };
|
|
125
|
-
//# sourceMappingURL=object.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"object.d.cts","names":[],"sources":["../../../../types/src/object.ts"],"sourcesContent":[],"mappings":"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"}
|