@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,34 +0,0 @@
|
|
|
1
|
-
//#region ../type-checks/src/is-deep-key.ts
|
|
2
|
-
/**
|
|
3
|
-
* Checks if a given key is a deep key.
|
|
4
|
-
*
|
|
5
|
-
* A deep key is a string that contains a dot (.) or square brackets with a property accessor.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* isDeepKey('a.b') // true
|
|
9
|
-
* isDeepKey('a[b]') // true
|
|
10
|
-
* isDeepKey('a') // false
|
|
11
|
-
* isDeepKey(123) // false
|
|
12
|
-
* isDeepKey('a.b.c') // true
|
|
13
|
-
* isDeepKey('a[b][c]') // true
|
|
14
|
-
*
|
|
15
|
-
* @param key - The key to check.
|
|
16
|
-
* @returns Returns true if the key is a deep key, otherwise false.
|
|
17
|
-
*/
|
|
18
|
-
function isDeepKey(key) {
|
|
19
|
-
switch (typeof key) {
|
|
20
|
-
case "number":
|
|
21
|
-
case "symbol": return false;
|
|
22
|
-
case "string": return key.includes(".") || key.includes("[") || key.includes("]");
|
|
23
|
-
case "bigint":
|
|
24
|
-
case "boolean":
|
|
25
|
-
case "function":
|
|
26
|
-
case "object":
|
|
27
|
-
case "undefined":
|
|
28
|
-
default: return false;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
//#endregion
|
|
33
|
-
export { isDeepKey };
|
|
34
|
-
//# sourceMappingURL=is-deep-key.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-deep-key.mjs","names":[],"sources":["../../../../type-checks/src/is-deep-key.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 type { DeepKey } from \"@stryke/types\";\n\n/**\n * Checks if a given key is a deep key.\n *\n * A deep key is a string that contains a dot (.) or square brackets with a property accessor.\n *\n * @example\n * isDeepKey('a.b') // true\n * isDeepKey('a[b]') // true\n * isDeepKey('a') // false\n * isDeepKey(123) // false\n * isDeepKey('a.b.c') // true\n * isDeepKey('a[b][c]') // true\n *\n * @param key - The key to check.\n * @returns Returns true if the key is a deep key, otherwise false.\n */\nexport function isDeepKey(key: PropertyKey): key is DeepKey<any> {\n switch (typeof key) {\n case \"number\":\n case \"symbol\": {\n return false;\n }\n case \"string\": {\n return key.includes(\".\") || key.includes(\"[\") || key.includes(\"]\");\n }\n case \"bigint\":\n case \"boolean\":\n case \"function\":\n case \"object\":\n case \"undefined\":\n default: {\n return false;\n }\n }\n}\n\n/**\n * Checks if a given key is a deep key or normal (shallow key).\n *\n * A deep key is a string that contains a dot (.) or square brackets with a property accessor.\n *\n * @example\n * isDeepKey('a.b') // true\n * isDeepKey('a[b]') // true\n * isDeepKey('a') // true\n * isDeepKey(123) // false\n * isDeepKey('a.b.c') // true\n * isDeepKey('a[b][c]') // true\n *\n * @param key - The key to check.\n * @returns Returns true if the key is a deep key, otherwise false.\n */\nexport function isKeyOrDeepKey(key: PropertyKey): key is DeepKey<any> {\n switch (typeof key) {\n case \"number\": {\n return true;\n }\n case \"symbol\": {\n return false;\n }\n case \"string\": {\n return true;\n }\n case \"bigint\":\n case \"boolean\":\n case \"function\":\n case \"object\":\n case \"undefined\":\n default: {\n return false;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoCA,SAAgB,UAAU,KAAuC;AAC/D,SAAQ,OAAO,KAAf;EACE,KAAK;EACL,KAAK,SACH,QAAO;EAET,KAAK,SACH,QAAO,IAAI,SAAS,IAAI,IAAI,IAAI,SAAS,IAAI,IAAI,IAAI,SAAS,IAAI;EAEpE,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,QACE,QAAO"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const require_is_null = require('./is-null.cjs');
|
|
2
|
-
const require_is_undefined = require('./is-undefined.cjs');
|
|
3
|
-
|
|
4
|
-
//#region ../type-checks/src/is-empty.ts
|
|
5
|
-
/**
|
|
6
|
-
* Check if the provided value's type is `null` or `undefined`
|
|
7
|
-
*
|
|
8
|
-
* @param value - The value to type check
|
|
9
|
-
* @returns An indicator specifying if the value provided is of type `null` or `undefined`
|
|
10
|
-
*/
|
|
11
|
-
const isEmpty = (value) => {
|
|
12
|
-
try {
|
|
13
|
-
return require_is_undefined.isUndefined(value) || require_is_null.isNull(value);
|
|
14
|
-
} catch {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
exports.isEmpty = isEmpty;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { isNull } from "./is-null.mjs";
|
|
2
|
-
import { isUndefined } from "./is-undefined.mjs";
|
|
3
|
-
|
|
4
|
-
//#region ../type-checks/src/is-empty.ts
|
|
5
|
-
/**
|
|
6
|
-
* Check if the provided value's type is `null` or `undefined`
|
|
7
|
-
*
|
|
8
|
-
* @param value - The value to type check
|
|
9
|
-
* @returns An indicator specifying if the value provided is of type `null` or `undefined`
|
|
10
|
-
*/
|
|
11
|
-
const isEmpty = (value) => {
|
|
12
|
-
try {
|
|
13
|
-
return isUndefined(value) || isNull(value);
|
|
14
|
-
} catch {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
export { isEmpty };
|
|
21
|
-
//# sourceMappingURL=is-empty.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-empty.mjs","names":[],"sources":["../../../../type-checks/src/is-empty.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 { isDate } from \"./is-date\";\nimport { isFunction } from \"./is-function\";\nimport { isNull } from \"./is-null\";\nimport { isNumber } from \"./is-number\";\nimport { isSymbol } from \"./is-symbol\";\nimport { isUndefined } from \"./is-undefined\";\n\n/**\n * Check if the provided value's type is `null` or `undefined`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `null` or `undefined`\n */\nexport const isEmpty = (value: unknown) => {\n try {\n return isUndefined(value) || isNull(value);\n } catch {\n return false;\n }\n};\n\nexport const isEmptyAnything = (value: any) => {\n if (value === true || value === false) return true;\n if (value === null || value === undefined) return true;\n if (isNumber(value)) return value === 0;\n if (isDate(value)) return Number.isNaN(value.getTime());\n if (isFunction(value)) return false;\n if (isSymbol(value)) return false;\n const { length } = value;\n if (isNumber(length)) return length === 0;\n const { size } = value;\n if (isNumber(size)) return size === 0;\n const keys = Object.keys(value).length;\n\n return keys === 0;\n};\n"],"mappings":";;;;;;;;;;AA+BA,MAAa,WAAW,UAAmB;AACzC,KAAI;AACF,SAAO,YAAY,MAAM,IAAI,OAAO,MAAM;SACpC;AACN,SAAO"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const require_get_object_tag = require('./get-object-tag.cjs');
|
|
2
|
-
|
|
3
|
-
//#region ../type-checks/src/is-function.ts
|
|
4
|
-
function isSyncFunction(value) {
|
|
5
|
-
return require_get_object_tag.getObjectTag(value) === "[object Function]";
|
|
6
|
-
}
|
|
7
|
-
function isAsyncFunction(value) {
|
|
8
|
-
return require_get_object_tag.getObjectTag(value) === "[object AsyncFunction]";
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Check if the provided value's type is `Function`
|
|
12
|
-
*
|
|
13
|
-
* @param value - The value to type check
|
|
14
|
-
* @returns An indicator specifying if the value provided is of type `Function`
|
|
15
|
-
*/
|
|
16
|
-
const isFunction = (value) => {
|
|
17
|
-
try {
|
|
18
|
-
return value instanceof Function || typeof value === "function" || Boolean(value?.constructor && value?.call && value?.apply) || isSyncFunction(value) || isAsyncFunction(value);
|
|
19
|
-
} catch {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
//#endregion
|
|
25
|
-
exports.isAsyncFunction = isAsyncFunction;
|
|
26
|
-
exports.isFunction = isFunction;
|
|
27
|
-
exports.isSyncFunction = isSyncFunction;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { getObjectTag } from "./get-object-tag.mjs";
|
|
2
|
-
|
|
3
|
-
//#region ../type-checks/src/is-function.ts
|
|
4
|
-
function isSyncFunction(value) {
|
|
5
|
-
return getObjectTag(value) === "[object Function]";
|
|
6
|
-
}
|
|
7
|
-
function isAsyncFunction(value) {
|
|
8
|
-
return getObjectTag(value) === "[object AsyncFunction]";
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Check if the provided value's type is `Function`
|
|
12
|
-
*
|
|
13
|
-
* @param value - The value to type check
|
|
14
|
-
* @returns An indicator specifying if the value provided is of type `Function`
|
|
15
|
-
*/
|
|
16
|
-
const isFunction = (value) => {
|
|
17
|
-
try {
|
|
18
|
-
return value instanceof Function || typeof value === "function" || Boolean(value?.constructor && value?.call && value?.apply) || isSyncFunction(value) || isAsyncFunction(value);
|
|
19
|
-
} catch {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
//#endregion
|
|
25
|
-
export { isAsyncFunction, isFunction, isSyncFunction };
|
|
26
|
-
//# sourceMappingURL=is-function.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-function.mjs","names":[],"sources":["../../../../type-checks/src/is-function.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 type { AnyFunction } from \"@stryke/types/base\";\nimport { getObjectTag } from \"./get-object-tag\";\n\nexport function isSyncFunction(value?: any): value is AnyFunction {\n return getObjectTag(value) === \"[object Function]\";\n}\n\nexport function isAsyncFunction(value?: any): value is AnyFunction {\n return getObjectTag(value) === \"[object AsyncFunction]\";\n}\n\n/**\n * Check if the provided value's type is `Function`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `Function`\n */\nexport const isFunction = (value: unknown): value is AnyFunction => {\n try {\n return (\n value instanceof Function ||\n typeof value === \"function\" ||\n Boolean(\n value?.constructor && (value as any)?.call && (value as any)?.apply\n ) ||\n isSyncFunction(value) ||\n isAsyncFunction(value)\n );\n } catch {\n return false;\n }\n};\n"],"mappings":";;;AAqBA,SAAgB,eAAe,OAAmC;AAChE,QAAO,aAAa,MAAM,KAAK;;AAGjC,SAAgB,gBAAgB,OAAmC;AACjE,QAAO,aAAa,MAAM,KAAK;;;;;;;;AASjC,MAAa,cAAc,UAAyC;AAClE,KAAI;AACF,SACE,iBAAiB,YACjB,OAAO,UAAU,cACjB,QACE,OAAO,eAAgB,OAAe,QAAS,OAAe,MAC/D,IACD,eAAe,MAAM,IACrB,gBAAgB,MAAM;SAElB;AACN,SAAO"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const require_is_non_null_object = require('./is-non-null-object.cjs');
|
|
2
|
-
const require_is_react_element = require('./is-react-element.cjs');
|
|
3
|
-
|
|
4
|
-
//#region ../type-checks/src/is-mergeable-object.ts
|
|
5
|
-
const isSpecialType = (value) => {
|
|
6
|
-
const stringValue = Object.prototype.toString.call(value);
|
|
7
|
-
return stringValue === "[object RegExp]" || stringValue === "[object Date]" || require_is_react_element.isReactElement(value);
|
|
8
|
-
};
|
|
9
|
-
const isMergeableObject = (value) => {
|
|
10
|
-
return require_is_non_null_object.isNonNullObject(value) && !isSpecialType(value);
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
//#endregion
|
|
14
|
-
exports.isMergeableObject = isMergeableObject;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { isNonNullObject } from "./is-non-null-object.mjs";
|
|
2
|
-
import { isReactElement } from "./is-react-element.mjs";
|
|
3
|
-
|
|
4
|
-
//#region ../type-checks/src/is-mergeable-object.ts
|
|
5
|
-
const isSpecialType = (value) => {
|
|
6
|
-
const stringValue = Object.prototype.toString.call(value);
|
|
7
|
-
return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value);
|
|
8
|
-
};
|
|
9
|
-
const isMergeableObject = (value) => {
|
|
10
|
-
return isNonNullObject(value) && !isSpecialType(value);
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
//#endregion
|
|
14
|
-
export { isMergeableObject };
|
|
15
|
-
//# sourceMappingURL=is-mergeable-object.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-mergeable-object.mjs","names":[],"sources":["../../../../type-checks/src/is-mergeable-object.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 { isNonNullObject } from \"./is-non-null-object\";\nimport { isReactElement } from \"./is-react-element\";\n\nconst isSpecialType = (value: any) => {\n const stringValue = Object.prototype.toString.call(value);\n\n return (\n stringValue === \"[object RegExp]\" ||\n stringValue === \"[object Date]\" ||\n isReactElement(value)\n );\n};\n\nexport const isMergeableObject = (value: any): boolean => {\n return isNonNullObject(value) && !isSpecialType(value);\n};\n"],"mappings":";;;;AAqBA,MAAM,iBAAiB,UAAe;CACpC,MAAM,cAAc,OAAO,UAAU,SAAS,KAAK,MAAM;AAEzD,QACE,gBAAgB,qBAChB,gBAAgB,mBAChB,eAAe,MAAM;;AAIzB,MAAa,qBAAqB,UAAwB;AACxD,QAAO,gBAAgB,MAAM,IAAI,CAAC,cAAc,MAAM"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const require_is_object = require('./is-object.cjs');
|
|
2
|
-
const require_is_set = require('./is-set.cjs');
|
|
3
|
-
|
|
4
|
-
//#region ../type-checks/src/is-non-null-object.ts
|
|
5
|
-
/**
|
|
6
|
-
* Check if the provided value's type is `Object` and is not `null` or `undefined`
|
|
7
|
-
*
|
|
8
|
-
* @param value - The value to type check
|
|
9
|
-
* @returns An indicator specifying if the value provided is of type `Object` and is not `null` or `undefined`
|
|
10
|
-
*/
|
|
11
|
-
const isNonNullObject = (value) => {
|
|
12
|
-
return require_is_set.isSet(value) && require_is_object.isObject(value);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
16
|
-
exports.isNonNullObject = isNonNullObject;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { isObject } from "./is-object.mjs";
|
|
2
|
-
import { isSet } from "./is-set.mjs";
|
|
3
|
-
|
|
4
|
-
//#region ../type-checks/src/is-non-null-object.ts
|
|
5
|
-
/**
|
|
6
|
-
* Check if the provided value's type is `Object` and is not `null` or `undefined`
|
|
7
|
-
*
|
|
8
|
-
* @param value - The value to type check
|
|
9
|
-
* @returns An indicator specifying if the value provided is of type `Object` and is not `null` or `undefined`
|
|
10
|
-
*/
|
|
11
|
-
const isNonNullObject = (value) => {
|
|
12
|
-
return isSet(value) && isObject(value);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
16
|
-
export { isNonNullObject };
|
|
17
|
-
//# sourceMappingURL=is-non-null-object.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-non-null-object.mjs","names":[],"sources":["../../../../type-checks/src/is-non-null-object.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\";\nimport { isSet } from \"./is-set\";\n\n/**\n * Check if the provided value's type is `Object` and is not `null` or `undefined`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `Object` and is not `null` or `undefined`\n */\nexport const isNonNullObject = (value: any): value is NonNullable<object> => {\n return isSet(value) && isObject(value);\n};\n"],"mappings":";;;;;;;;;;AA2BA,MAAa,mBAAmB,UAA6C;AAC3E,QAAO,MAAM,MAAM,IAAI,SAAS,MAAM"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-null.mjs","names":[],"sources":["../../../../type-checks/src/is-null.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 isNull = (value: unknown): value is null => {\n try {\n return value === null;\n } catch {\n return false;\n }\n};\n"],"mappings":";AAkBA,MAAa,UAAU,UAAkC;AACvD,KAAI;AACF,SAAO,UAAU;SACX;AACN,SAAO"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region ../type-checks/src/is-number.ts
|
|
3
|
-
/**
|
|
4
|
-
* Check if the provided value's type is `number`
|
|
5
|
-
*
|
|
6
|
-
* @param value - The value to type check
|
|
7
|
-
* @returns An indicator specifying if the value provided is of type `number`
|
|
8
|
-
*/
|
|
9
|
-
const isNumber = (value) => {
|
|
10
|
-
try {
|
|
11
|
-
return value instanceof Number || typeof value === "number" || Number(value) === value;
|
|
12
|
-
} catch {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
//#endregion
|
|
18
|
-
exports.isNumber = isNumber;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
//#region ../type-checks/src/is-number.ts
|
|
2
|
-
/**
|
|
3
|
-
* Check if the provided value's type is `number`
|
|
4
|
-
*
|
|
5
|
-
* @param value - The value to type check
|
|
6
|
-
* @returns An indicator specifying if the value provided is of type `number`
|
|
7
|
-
*/
|
|
8
|
-
const isNumber = (value) => {
|
|
9
|
-
try {
|
|
10
|
-
return value instanceof Number || typeof value === "number" || Number(value) === value;
|
|
11
|
-
} catch {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
//#endregion
|
|
17
|
-
export { isNumber };
|
|
18
|
-
//# sourceMappingURL=is-number.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-number.mjs","names":[],"sources":["../../../../type-checks/src/is-number.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 type { AnyNumber } from \"@stryke/types/base\";\nimport { getObjectTag } from \"./get-object-tag\";\n\n/**\n * Check if the provided value's type is `number`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `number`\n */\nexport const isNumber = (value: unknown): value is number => {\n try {\n return (\n value instanceof Number ||\n typeof value === \"number\" ||\n Number(value) === value\n );\n } catch {\n return false;\n }\n};\n\n/**\n * Check if the provided value's type is `AnyNumber`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `AnyNumber`\n */\nexport function isAnyNumber(value?: any): value is AnyNumber {\n return isNumber(value) || getObjectTag(value) === \"[object Number]\";\n}\n"],"mappings":";;;;;;;AA2BA,MAAa,YAAY,UAAoC;AAC3D,KAAI;AACF,SACE,iBAAiB,UACjB,OAAO,UAAU,YACjB,OAAO,MAAM,KAAK;SAEd;AACN,SAAO"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region ../type-checks/src/is-object-index.ts
|
|
3
|
-
const IS_UNSIGNED_INTEGER = /^(?:0|[1-9]\d*)$/;
|
|
4
|
-
/**
|
|
5
|
-
* Checks if the given value is an object index.
|
|
6
|
-
*
|
|
7
|
-
* @param value - The value to check.
|
|
8
|
-
* @returns Returns `true` if the value is an object index, otherwise `false`.
|
|
9
|
-
*/
|
|
10
|
-
function isObjectIndex(value) {
|
|
11
|
-
switch (typeof value) {
|
|
12
|
-
case "number": return Number.isInteger(value) && value >= 0 && value < Number.MAX_SAFE_INTEGER;
|
|
13
|
-
case "symbol": return false;
|
|
14
|
-
case "string": return IS_UNSIGNED_INTEGER.test(value);
|
|
15
|
-
case "bigint":
|
|
16
|
-
case "boolean":
|
|
17
|
-
case "function":
|
|
18
|
-
case "object":
|
|
19
|
-
case "undefined":
|
|
20
|
-
default: return false;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
//#endregion
|
|
25
|
-
exports.isObjectIndex = isObjectIndex;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
//#region ../type-checks/src/is-object-index.ts
|
|
2
|
-
const IS_UNSIGNED_INTEGER = /^(?:0|[1-9]\d*)$/;
|
|
3
|
-
/**
|
|
4
|
-
* Checks if the given value is an object index.
|
|
5
|
-
*
|
|
6
|
-
* @param value - The value to check.
|
|
7
|
-
* @returns Returns `true` if the value is an object index, otherwise `false`.
|
|
8
|
-
*/
|
|
9
|
-
function isObjectIndex(value) {
|
|
10
|
-
switch (typeof value) {
|
|
11
|
-
case "number": return Number.isInteger(value) && value >= 0 && value < Number.MAX_SAFE_INTEGER;
|
|
12
|
-
case "symbol": return false;
|
|
13
|
-
case "string": return IS_UNSIGNED_INTEGER.test(value);
|
|
14
|
-
case "bigint":
|
|
15
|
-
case "boolean":
|
|
16
|
-
case "function":
|
|
17
|
-
case "object":
|
|
18
|
-
case "undefined":
|
|
19
|
-
default: return false;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
export { isObjectIndex };
|
|
25
|
-
//# sourceMappingURL=is-object-index.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-object-index.mjs","names":[],"sources":["../../../../type-checks/src/is-object-index.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\nconst IS_UNSIGNED_INTEGER = /^(?:0|[1-9]\\d*)$/;\n\n/**\n * Checks if the given value is an object index.\n *\n * @param value - The value to check.\n * @returns Returns `true` if the value is an object index, otherwise `false`.\n */\nexport function isObjectIndex(\n value: PropertyKey\n): value is string | number | symbol {\n switch (typeof value) {\n case \"number\": {\n return (\n Number.isInteger(value) && value >= 0 && value < Number.MAX_SAFE_INTEGER\n );\n }\n case \"symbol\": {\n return false;\n }\n case \"string\": {\n return IS_UNSIGNED_INTEGER.test(value);\n }\n case \"bigint\":\n case \"boolean\":\n case \"function\":\n case \"object\":\n case \"undefined\":\n default: {\n return false;\n }\n }\n}\n"],"mappings":";AAkBA,MAAM,sBAAsB;;;;;;;AAQ5B,SAAgB,cACd,OACmC;AACnC,SAAQ,OAAO,OAAf;EACE,KAAK,SACH,QACE,OAAO,UAAU,MAAM,IAAI,SAAS,KAAK,QAAQ,OAAO;EAG5D,KAAK,SACH,QAAO;EAET,KAAK,SACH,QAAO,oBAAoB,KAAK,MAAM;EAExC,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,QACE,QAAO"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const require_is_plain_object = require('./is-plain-object.cjs');
|
|
2
|
-
|
|
3
|
-
//#region ../type-checks/src/is-object.ts
|
|
4
|
-
/**
|
|
5
|
-
* Check if the provided value's type is `Object`
|
|
6
|
-
*
|
|
7
|
-
* @param value - The value to type check
|
|
8
|
-
* @returns An indicator specifying if the value provided is of type `Object`
|
|
9
|
-
*/
|
|
10
|
-
const isObject = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
return typeof value === "object" || Boolean(value) && value?.constructor === Object || require_is_plain_object.isPlainObject(value);
|
|
13
|
-
} catch {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
exports.isObject = isObject;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { isPlainObject } from "./is-plain-object.mjs";
|
|
2
|
-
|
|
3
|
-
//#region ../type-checks/src/is-object.ts
|
|
4
|
-
/**
|
|
5
|
-
* Check if the provided value's type is `Object`
|
|
6
|
-
*
|
|
7
|
-
* @param value - The value to type check
|
|
8
|
-
* @returns An indicator specifying if the value provided is of type `Object`
|
|
9
|
-
*/
|
|
10
|
-
const isObject = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
return typeof value === "object" || Boolean(value) && value?.constructor === Object || isPlainObject(value);
|
|
13
|
-
} catch {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
export { isObject };
|
|
20
|
-
//# sourceMappingURL=is-object.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-object.mjs","names":[],"sources":["../../../../type-checks/src/is-object.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\n/* eslint-disable ts/no-unsafe-function-type */\n/* eslint-disable ts/no-unsafe-call */\n\nimport type { NativeClass } from \"@stryke/types/base\";\nimport { isPlainObject } from \"./is-plain-object\";\n\n// Prepare\nconst isClassRegex = /^class\\s|^function\\s+[A-Z]/;\nconst isConventionalClassRegex = /^function\\s+[A-Z]/;\nconst isNativeClassRegex = /^class\\s/;\n\n/** Is ES6+ class */\nexport function isNativeClass(value?: any): value is NativeClass {\n // NOTE TO DEVELOPER: If any of this changes, isClass must also be updated\n return (\n typeof value === \"function\" && isNativeClassRegex.test(value.toString())\n );\n}\n\n/**\n * Check if the provided value's type is a conventional class\n *\n * @remarks\n * Is Conventional Class\n * Looks for function with capital first letter MyClass\n * First letter is the 9th character\n * If changed, isClass must also be updated\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is a conventional class\n */\nexport function isConventionalClass(value?: any): value is Function {\n return (\n typeof value === \"function\" &&\n isConventionalClassRegex.test(value.toString())\n );\n}\n\n/**\n * Check if the provided value's type is `Object`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `Object`\n */\nexport function isClass(value?: any): value is Function | NativeClass; // only guarantee of truth type, not of validity\nexport function isClass(value?: any): boolean {\n return typeof value === \"function\" && isClassRegex.test(value.toString());\n}\n\n/**\n * Check if the provided value's type is `Object`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `Object`\n */\nexport const isObject = (value: unknown): value is object => {\n try {\n return (\n typeof value === \"object\" ||\n (Boolean(value) && value?.constructor === Object) ||\n isPlainObject(value)\n );\n } catch {\n return false;\n }\n};\n"],"mappings":";;;;;;;;;AAyEA,MAAa,YAAY,UAAoC;AAC3D,KAAI;AACF,SACE,OAAO,UAAU,YAChB,QAAQ,MAAM,IAAI,OAAO,gBAAgB,UAC1C,cAAc,MAAM;SAEhB;AACN,SAAO"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
const require_get_object_tag = require('./get-object-tag.cjs');
|
|
2
|
-
|
|
3
|
-
//#region ../type-checks/src/is-plain-object.ts
|
|
4
|
-
/**
|
|
5
|
-
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
6
|
-
* and has a `typeof` result of "object".
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* isObjectLike({})
|
|
11
|
-
* // => true
|
|
12
|
-
*
|
|
13
|
-
* isObjectLike([1, 2, 3])
|
|
14
|
-
* // => true
|
|
15
|
-
*
|
|
16
|
-
* isObjectLike(Function)
|
|
17
|
-
* // => false
|
|
18
|
-
*
|
|
19
|
-
* isObjectLike(null)
|
|
20
|
-
* // => false
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @param value - The value to check.
|
|
24
|
-
* @returns Returns `true` if `value` is object-like, else `false`.
|
|
25
|
-
*/
|
|
26
|
-
const isObjectLike = (value) => {
|
|
27
|
-
return typeof value === "object" && value !== null;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Checks if `obj` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`.
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* ```typescript
|
|
34
|
-
* function Foo() {
|
|
35
|
-
* this.a = 1
|
|
36
|
-
* }
|
|
37
|
-
*
|
|
38
|
-
* isPlainObject(new Foo)
|
|
39
|
-
* // => false
|
|
40
|
-
*
|
|
41
|
-
* isPlainObject([1, 2, 3])
|
|
42
|
-
* // => false
|
|
43
|
-
*
|
|
44
|
-
* isPlainObject({ 'x': 0, 'y': 0 })
|
|
45
|
-
* // => true
|
|
46
|
-
*
|
|
47
|
-
* isPlainObject(Object.create(null))
|
|
48
|
-
* // => true
|
|
49
|
-
* ```
|
|
50
|
-
*
|
|
51
|
-
* @param obj - The value to check.
|
|
52
|
-
* @returns Returns `true` if `obj` is a plain object, else `false`.
|
|
53
|
-
*/
|
|
54
|
-
const isPlainObject = (obj) => {
|
|
55
|
-
if (!isObjectLike(obj) || require_get_object_tag.getObjectTag(obj) !== "[object Object]") return false;
|
|
56
|
-
if (Object.getPrototypeOf(obj) === null) return true;
|
|
57
|
-
let proto = obj;
|
|
58
|
-
while (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto);
|
|
59
|
-
return Object.getPrototypeOf(obj) === proto;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
//#endregion
|
|
63
|
-
exports.isObjectLike = isObjectLike;
|
|
64
|
-
exports.isPlainObject = isPlainObject;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { getObjectTag } from "./get-object-tag.mjs";
|
|
2
|
-
|
|
3
|
-
//#region ../type-checks/src/is-plain-object.ts
|
|
4
|
-
/**
|
|
5
|
-
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
6
|
-
* and has a `typeof` result of "object".
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* isObjectLike({})
|
|
11
|
-
* // => true
|
|
12
|
-
*
|
|
13
|
-
* isObjectLike([1, 2, 3])
|
|
14
|
-
* // => true
|
|
15
|
-
*
|
|
16
|
-
* isObjectLike(Function)
|
|
17
|
-
* // => false
|
|
18
|
-
*
|
|
19
|
-
* isObjectLike(null)
|
|
20
|
-
* // => false
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @param value - The value to check.
|
|
24
|
-
* @returns Returns `true` if `value` is object-like, else `false`.
|
|
25
|
-
*/
|
|
26
|
-
const isObjectLike = (value) => {
|
|
27
|
-
return typeof value === "object" && value !== null;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Checks if `obj` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`.
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* ```typescript
|
|
34
|
-
* function Foo() {
|
|
35
|
-
* this.a = 1
|
|
36
|
-
* }
|
|
37
|
-
*
|
|
38
|
-
* isPlainObject(new Foo)
|
|
39
|
-
* // => false
|
|
40
|
-
*
|
|
41
|
-
* isPlainObject([1, 2, 3])
|
|
42
|
-
* // => false
|
|
43
|
-
*
|
|
44
|
-
* isPlainObject({ 'x': 0, 'y': 0 })
|
|
45
|
-
* // => true
|
|
46
|
-
*
|
|
47
|
-
* isPlainObject(Object.create(null))
|
|
48
|
-
* // => true
|
|
49
|
-
* ```
|
|
50
|
-
*
|
|
51
|
-
* @param obj - The value to check.
|
|
52
|
-
* @returns Returns `true` if `obj` is a plain object, else `false`.
|
|
53
|
-
*/
|
|
54
|
-
const isPlainObject = (obj) => {
|
|
55
|
-
if (!isObjectLike(obj) || getObjectTag(obj) !== "[object Object]") return false;
|
|
56
|
-
if (Object.getPrototypeOf(obj) === null) return true;
|
|
57
|
-
let proto = obj;
|
|
58
|
-
while (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto);
|
|
59
|
-
return Object.getPrototypeOf(obj) === proto;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
//#endregion
|
|
63
|
-
export { isObjectLike, isPlainObject };
|
|
64
|
-
//# sourceMappingURL=is-plain-object.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-plain-object.mjs","names":[],"sources":["../../../../type-checks/src/is-plain-object.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 type { PlainObject } from \"@stryke/types/base\";\nimport { getObjectTag } from \"./get-object-tag\";\n\n/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @example\n * ```typescript\n * isObjectLike({})\n * // => true\n *\n * isObjectLike([1, 2, 3])\n * // => true\n *\n * isObjectLike(Function)\n * // => false\n *\n * isObjectLike(null)\n * // => false\n * ```\n *\n * @param value - The value to check.\n * @returns Returns `true` if `value` is object-like, else `false`.\n */\nexport const isObjectLike = (value: unknown) => {\n return typeof value === \"object\" && value !== null;\n};\n\n/**\n * Checks if `obj` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`.\n *\n * @example\n * ```typescript\n * function Foo() {\n * this.a = 1\n * }\n *\n * isPlainObject(new Foo)\n * // => false\n *\n * isPlainObject([1, 2, 3])\n * // => false\n *\n * isPlainObject({ 'x': 0, 'y': 0 })\n * // => true\n *\n * isPlainObject(Object.create(null))\n * // => true\n * ```\n *\n * @param obj - The value to check.\n * @returns Returns `true` if `obj` is a plain object, else `false`.\n */\nexport const isPlainObject = (obj: unknown): obj is PlainObject => {\n if (!isObjectLike(obj) || getObjectTag(obj) !== \"[object Object]\") {\n return false;\n }\n if (Object.getPrototypeOf(obj) === null) {\n return true;\n }\n let proto = obj;\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n return Object.getPrototypeOf(obj) === proto;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAa,gBAAgB,UAAmB;AAC9C,QAAO,OAAO,UAAU,YAAY,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BhD,MAAa,iBAAiB,QAAqC;AACjE,KAAI,CAAC,aAAa,IAAI,IAAI,aAAa,IAAI,KAAK,kBAC9C,QAAO;AAET,KAAI,OAAO,eAAe,IAAI,KAAK,KACjC,QAAO;CAET,IAAI,QAAQ;AACZ,QAAO,OAAO,eAAe,MAAM,KAAK,KACtC,SAAQ,OAAO,eAAe,MAAM;AAEtC,QAAO,OAAO,eAAe,IAAI,KAAK"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region ../type-checks/src/is-primitive.ts
|
|
3
|
-
const isPrimitive = (value) => {
|
|
4
|
-
try {
|
|
5
|
-
return value === void 0 || value === null || typeof value !== "object" && typeof value !== "function";
|
|
6
|
-
} catch {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
//#endregion
|
|
12
|
-
exports.isPrimitive = isPrimitive;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
//#region ../type-checks/src/is-primitive.ts
|
|
2
|
-
const isPrimitive = (value) => {
|
|
3
|
-
try {
|
|
4
|
-
return value === void 0 || value === null || typeof value !== "object" && typeof value !== "function";
|
|
5
|
-
} catch {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
//#endregion
|
|
11
|
-
export { isPrimitive };
|
|
12
|
-
//# sourceMappingURL=is-primitive.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-primitive.mjs","names":[],"sources":["../../../../type-checks/src/is-primitive.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 isPrimitive = (value: unknown): boolean => {\n try {\n return (\n value === undefined ||\n value === null ||\n (typeof value !== \"object\" && typeof value !== \"function\")\n );\n } catch {\n return false;\n }\n};\n"],"mappings":";AAkBA,MAAa,eAAe,UAA4B;AACtD,KAAI;AACF,SACE,UAAU,UACV,UAAU,QACT,OAAO,UAAU,YAAY,OAAO,UAAU;SAE3C;AACN,SAAO"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
//#region ../type-checks/src/is-react-element.ts
|
|
2
|
-
const isReactElement = (value) => {
|
|
3
|
-
return value.$$typeof === (typeof Symbol === "function" && Symbol.for ? Symbol.for("react.element") : 60103);
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
//#endregion
|
|
7
|
-
export { isReactElement };
|
|
8
|
-
//# sourceMappingURL=is-react-element.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-react-element.mjs","names":[],"sources":["../../../../type-checks/src/is-react-element.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 isReactElement = (value: any) => {\n return (\n value.$$typeof ===\n (typeof Symbol === \"function\" && Symbol.for\n ? Symbol.for(\"react.element\")\n : 0xea_c7)\n );\n};\n"],"mappings":";AAkBA,MAAa,kBAAkB,UAAe;AAC5C,QACE,MAAM,cACL,OAAO,WAAW,cAAc,OAAO,MACpC,OAAO,IAAI,gBAAgB,GAC3B"}
|