@stryke/helpers 0.10.6 → 0.10.7
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 +12 -0
- package/dist/arg-identity.d.cts.map +1 -1
- package/dist/arg-identity.d.mts.map +1 -1
- package/dist/arg-identity.mjs.map +1 -1
- package/dist/convert/src/index.cjs +4 -0
- package/dist/convert/src/index.mjs +6 -0
- package/dist/convert/src/parse-type-definition.cjs +1 -0
- package/dist/convert/src/parse-type-definition.mjs +3 -0
- package/dist/convert/src/string-to-utf8-array.cjs +5 -0
- package/dist/convert/src/string-to-utf8-array.mjs +6 -0
- package/dist/convert/src/string-to-utf8-array.mjs.map +1 -0
- package/dist/convert/src/utf8-array-to-string.cjs +5 -0
- package/dist/convert/src/utf8-array-to-string.mjs +6 -0
- package/dist/convert/src/utf8-array-to-string.mjs.map +1 -0
- package/dist/debounce.cjs +5 -4
- package/dist/debounce.d.cts +4 -6
- package/dist/debounce.d.cts.map +1 -1
- package/dist/debounce.d.mts +4 -6
- package/dist/debounce.d.mts.map +1 -1
- package/dist/debounce.mjs +5 -4
- package/dist/debounce.mjs.map +1 -1
- package/dist/deep-clone.cjs +2 -1
- package/dist/deep-clone.d.cts.map +1 -1
- package/dist/deep-clone.d.mts.map +1 -1
- package/dist/deep-clone.mjs +2 -1
- package/dist/deep-clone.mjs.map +1 -1
- package/dist/delay.cjs +2 -1
- package/dist/delay.d.cts +1 -3
- package/dist/delay.d.cts.map +1 -1
- package/dist/delay.d.mts +1 -3
- package/dist/delay.d.mts.map +1 -1
- package/dist/delay.mjs +2 -1
- package/dist/delay.mjs.map +1 -1
- package/dist/filter-empty.d.cts.map +1 -1
- package/dist/filter-empty.d.mts.map +1 -1
- package/dist/filter-empty.mjs.map +1 -1
- package/dist/flatten-object.cjs +2 -1
- package/dist/flatten-object.d.cts.map +1 -1
- package/dist/flatten-object.d.mts.map +1 -1
- package/dist/flatten-object.mjs +2 -1
- package/dist/flatten-object.mjs.map +1 -1
- package/dist/get-field.cjs +14 -7
- package/dist/get-field.d.cts +123 -125
- package/dist/get-field.d.cts.map +1 -1
- package/dist/get-field.d.mts +123 -125
- package/dist/get-field.d.mts.map +1 -1
- package/dist/get-field.mjs +14 -7
- package/dist/get-field.mjs.map +1 -1
- package/dist/get-ordered-by.d.cts.map +1 -1
- package/dist/get-ordered-by.d.mts.map +1 -1
- package/dist/get-ordered-by.mjs.map +1 -1
- package/dist/identity.d.cts.map +1 -1
- package/dist/identity.d.mts.map +1 -1
- package/dist/identity.mjs.map +1 -1
- package/dist/is-equal.d.cts.map +1 -1
- package/dist/is-equal.d.mts.map +1 -1
- package/dist/is-equal.mjs.map +1 -1
- package/dist/match-sorter.cjs +2 -2
- package/dist/match-sorter.mjs +2 -2
- package/dist/match-sorter.mjs.map +1 -1
- package/dist/noop.d.cts.map +1 -1
- package/dist/noop.d.mts.map +1 -1
- package/dist/noop.mjs.map +1 -1
- package/dist/omit.mjs.map +1 -1
- package/dist/pick.mjs.map +1 -1
- package/dist/remove-accents.cjs +1 -3
- package/dist/remove-accents.d.cts.map +1 -1
- package/dist/remove-accents.d.mts.map +1 -1
- package/dist/remove-accents.mjs +1 -3
- package/dist/remove-accents.mjs.map +1 -1
- package/dist/remove-empty-items.d.cts.map +1 -1
- package/dist/remove-empty-items.d.mts.map +1 -1
- package/dist/remove-empty-items.mjs.map +1 -1
- package/dist/semaphore.cjs +10 -10
- package/dist/semaphore.d.cts +10 -10
- package/dist/semaphore.d.cts.map +1 -1
- package/dist/semaphore.d.mts +10 -10
- package/dist/semaphore.d.mts.map +1 -1
- package/dist/semaphore.mjs +10 -10
- package/dist/semaphore.mjs.map +1 -1
- package/dist/set-field.cjs +1 -1
- package/dist/set-field.d.cts.map +1 -1
- package/dist/set-field.d.mts.map +1 -1
- package/dist/set-field.mjs +1 -1
- package/dist/set-field.mjs.map +1 -1
- package/dist/throttle.d.cts.map +1 -1
- package/dist/throttle.d.mts.map +1 -1
- package/dist/throttle.mjs.map +1 -1
- package/dist/timeout.d.cts.map +1 -1
- package/dist/timeout.d.mts.map +1 -1
- package/dist/timeout.mjs.map +1 -1
- 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.map +1 -1
- package/dist/type-checks/src/index.cjs +21 -0
- package/dist/type-checks/src/index.mjs +23 -0
- package/dist/type-checks/src/is-buffer.cjs +13 -0
- package/dist/type-checks/src/is-buffer.mjs +14 -0
- package/dist/type-checks/src/is-buffer.mjs.map +1 -0
- package/dist/type-checks/src/is-collection.cjs +1 -0
- package/dist/type-checks/src/is-collection.mjs +3 -0
- package/dist/type-checks/src/is-deep-key.cjs +6 -0
- package/dist/type-checks/src/is-deep-key.mjs +6 -0
- package/dist/type-checks/src/is-deep-key.mjs.map +1 -1
- package/dist/type-checks/src/is-function.cjs +3 -1
- package/dist/type-checks/src/is-function.mjs +1 -1
- package/dist/type-checks/src/is-object-index.cjs +6 -0
- package/dist/type-checks/src/is-object-index.mjs +6 -0
- package/dist/type-checks/src/is-object-index.mjs.map +1 -1
- package/dist/type-checks/src/is-plain-object.cjs +3 -2
- package/dist/type-checks/src/is-plain-object.mjs +3 -3
- package/dist/type-checks/src/is-plain-object.mjs.map +1 -1
- package/dist/type-checks/src/is-set-string.cjs +1 -1
- package/dist/type-checks/src/is-set-string.mjs +1 -1
- package/dist/type-checks/src/property-exists.cjs +1 -0
- package/dist/type-checks/src/property-exists.mjs +1 -1
- package/dist/type-checks/src/type-detect.cjs +15 -0
- package/dist/type-checks/src/type-detect.mjs +17 -0
- package/dist/type-checks/src/type-detect.mjs.map +1 -0
- package/dist/types/src/object.d.cts +1 -1
- package/dist/types/src/object.d.mts +1 -1
- package/dist/unflatten-object.cjs +1 -1
- package/dist/unflatten-object.d.cts +1 -1
- package/dist/unflatten-object.d.cts.map +1 -1
- package/dist/unflatten-object.d.mts +1 -1
- package/dist/unflatten-object.d.mts.map +1 -1
- package/dist/unflatten-object.mjs +1 -1
- package/dist/unflatten-object.mjs.map +1 -1
- package/dist/union.d.cts.map +1 -1
- package/dist/union.d.mts.map +1 -1
- package/dist/union.mjs.map +1 -1
- package/dist/with-timeout.d.cts.map +1 -1
- package/dist/with-timeout.d.mts.map +1 -1
- package/dist/with-timeout.mjs.map +1 -1
- package/package.json +2 -2
package/dist/set-field.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-field.mjs","names":["current: any"],"sources":["../src/set-field.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
|
|
1
|
+
{"version":3,"file":"set-field.mjs","names":["current: any"],"sources":["../src/set-field.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 { isObjectIndex } from \"@stryke/type-checks/is-object-index\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport type { DeepKey } from \"@stryke/types/object\";\nimport { toPath } from \"./to-path\";\n\n/**\n * Sets a value at a given deep path in an object.\n *\n * @param object - The object to set the value in.\n * @param path - The deep path to set the value at.\n * @param value - The value to set.\n * @returns The object with the value set at the given deep path.\n */\nexport function setField<\n TObject extends Record<string, any> = Record<string, any>\n>(object: TObject, path: DeepKey<TObject>, value: unknown): TObject {\n const resolvedPath = Array.isArray(path)\n ? path\n : isString(path)\n ? toPath(path)\n : [path];\n\n // Validate resolvedPath to prevent prototype pollution\n for (const key of resolvedPath) {\n if (key === \"__proto__\" || key === \"constructor\" || key === \"prototype\") {\n throw new Error(`Invalid key in path: ${key}`);\n }\n }\n\n let current: any = object;\n for (let i = 0; i < resolvedPath.length - 1; i++) {\n const key = resolvedPath[i];\n const nextKey = resolvedPath[i + 1];\n\n if (current[key] === null) {\n current[key] = isObjectIndex(nextKey) ? [] : {};\n }\n\n current = current[key];\n }\n\n const lastKey = resolvedPath.at(-1);\n if (lastKey) {\n current[lastKey] = value;\n }\n\n return object;\n}\n"],"mappings":";;;;;;;;;;;;;AA+BA,SAAgB,SAEd,QAAiB,MAAwB,OAAyB;CAClE,MAAM,eAAe,MAAM,QAAQ,KAAK,GACpC,OACA,SAAS,KAAK,GACZ,OAAO,KAAK,GACZ,CAAC,KAAK;AAGZ,MAAK,MAAM,OAAO,aAChB,KAAI,QAAQ,eAAe,QAAQ,iBAAiB,QAAQ,YAC1D,OAAM,IAAI,MAAM,wBAAwB,MAAM;CAIlD,IAAIA,UAAe;AACnB,MAAK,IAAI,IAAI,GAAG,IAAI,aAAa,SAAS,GAAG,KAAK;EAChD,MAAM,MAAM,aAAa;EACzB,MAAM,UAAU,aAAa,IAAI;AAEjC,MAAI,QAAQ,SAAS,KACnB,SAAQ,OAAO,cAAc,QAAQ,GAAG,EAAE,GAAG,EAAE;AAGjD,YAAU,QAAQ;;CAGpB,MAAM,UAAU,aAAa,GAAG,GAAG;AACnC,KAAI,QACF,SAAQ,WAAW;AAGrB,QAAO"}
|
package/dist/throttle.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"throttle.d.cts","names":[],"sources":["../src/throttle.ts"],"sourcesContent":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"throttle.d.cts","names":[],"sources":["../src/throttle.ts"],"sourcesContent":[],"mappings":";;AA6CA;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,mDACR,wBAEL"}
|
package/dist/throttle.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"throttle.d.mts","names":[],"sources":["../src/throttle.ts"],"sourcesContent":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"throttle.d.mts","names":[],"sources":["../src/throttle.ts"],"sourcesContent":[],"mappings":";;AA6CA;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,mDACR,wBAEL"}
|
package/dist/throttle.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"throttle.mjs","names":["lastCallTime: number | null"],"sources":["../src/throttle.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
|
|
1
|
+
{"version":3,"file":"throttle.mjs","names":["lastCallTime: number | null"],"sources":["../src/throttle.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/**\n * Creates a throttled function that only invokes the provided function at most once\n * per every `throttleMs` milliseconds. Subsequent calls to the throttled function\n * within the wait time will not trigger the execution of the original function.\n *\n * @example\n * ```typescript\n * const throttledFunction = throttle(() => {\n * console.log('Function executed');\n * }, 1000);\n *\n * // Will log 'Function executed' immediately\n * throttledFunction();\n *\n * // Will not log anything as it is within the throttle time\n * throttledFunction();\n *\n * // After 1 second\n * setTimeout(() => {\n * throttledFunction(); // Will log 'Function executed'\n * }, 1000);\n * ```\n *\n * @param func - The function to throttle.\n * @param throttleMs - The number of milliseconds to throttle executions to.\n * @returns A new throttled function that accepts the same parameters as the original function.\n */\nexport function throttle<F extends (...args: any[]) => void>(\n func: F,\n throttleMs: number\n): F {\n let lastCallTime: number | null;\n\n const throttledFunction = ((...args: Parameters<F>) => {\n const now = Date.now();\n\n if (lastCallTime == null || now - lastCallTime >= throttleMs) {\n lastCallTime = now;\n func(...args);\n }\n }) as F;\n\n return throttledFunction;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,SAAgB,SACd,MACA,YACG;CACH,IAAIA;CAEJ,MAAM,sBAAsB,GAAG,SAAwB;EACrD,MAAM,MAAM,KAAK,KAAK;AAEtB,MAAI,gBAAgB,QAAQ,MAAM,gBAAgB,YAAY;AAC5D,kBAAe;AACf,QAAK,GAAG,KAAK;;;AAIjB,QAAO"}
|
package/dist/timeout.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeout.d.cts","names":[],"sources":["../src/timeout.ts"],"sourcesContent":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"timeout.d.cts","names":[],"sources":["../src/timeout.ts"],"sourcesContent":[],"mappings":";;AA4BA;;;;;;iBAAsB,OAAA,cAAqB"}
|
package/dist/timeout.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeout.d.mts","names":[],"sources":["../src/timeout.ts"],"sourcesContent":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"timeout.d.mts","names":[],"sources":["../src/timeout.ts"],"sourcesContent":[],"mappings":";;AA4BA;;;;;;iBAAsB,OAAA,cAAqB"}
|
package/dist/timeout.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeout.mjs","names":[],"sources":["../src/timeout.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
|
|
1
|
+
{"version":3,"file":"timeout.mjs","names":[],"sources":["../src/timeout.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 { delay } from \"./delay\";\nimport { TimeoutError } from \"./errors\";\n\n/**\n * Returns a promise that rejects with a `TimeoutError` after a specified delay.\n *\n * @param ms - The delay duration in milliseconds.\n * @returns A promise that rejects with a `TimeoutError` after the specified delay.\n * @throws Throws a `TimeoutError` after the specified delay.\n */\nexport async function timeout(ms: number): Promise<never> {\n await delay(ms);\n throw new TimeoutError();\n}\n"],"mappings":";;;;;;;;;;;AA4BA,eAAsB,QAAQ,IAA4B;AACxD,OAAM,MAAM,GAAG;AACf,OAAM,IAAI,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-deep-key.d.cts","names":[],"sources":["../src/to-deep-key.ts"],"sourcesContent":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"to-deep-key.d.cts","names":[],"sources":["../src/to-deep-key.ts"],"sourcesContent":[],"mappings":";;AAqCA;AA0BA;;;;;;;;;;;;;;iBA1BgB,SAAA;;;;;;;;;;;;;;;;;;;;;iBA0BA,gBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-deep-key.d.mts","names":[],"sources":["../src/to-deep-key.ts"],"sourcesContent":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"to-deep-key.d.mts","names":[],"sources":["../src/to-deep-key.ts"],"sourcesContent":[],"mappings":";;AAqCA;AA0BA;;;;;;;;;;;;;;iBA1BgB,SAAA;;;;;;;;;;;;;;;;;;;;;iBA0BA,gBAAA"}
|
package/dist/to-deep-key.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-deep-key.mjs","names":[],"sources":["../src/to-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
|
|
1
|
+
{"version":3,"file":"to-deep-key.mjs","names":[],"sources":["../src/to-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 { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\n\n/**\n * Converts an array of path segments into a deep key string.\n *\n * This function takes an array of strings and numbers representing path segments and combines them into a deep key string.\n *\n * @example\n * toDeepKey(['a', 'b', 'c']) // Returns 'a.b.c'\n * toDeepKey(['a', 0, 'c']) // Returns 'a[0].c'\n * toDeepKey(['', 'a', 'b', 'c']) // Returns '.a.b.c'\n * toDeepKey(['a', 'b.c', 'd']) // Returns 'a.b.c.d'\n * toDeepKey([]) // Returns ''\n * toDeepKey(['', 'a', 'b', 'c', 'd', 'e', 'f.g', 'h']) // Returns '.a.b.c.d.e.f.g.h'\n *\n * @param path - An array of strings and numbers representing path segments.\n * @returns A deep key string.\n */\nexport function toDeepKey(path: string[]): string {\n return path.reduce((ret, segment) => {\n return addPathToDeepKey(ret, segment);\n });\n}\n\n/**\n * Adds a path segment to a deep key string.\n *\n * @remarks\n * This function takes a deep key string and a path segment and combines them into a new deep key string.\n *\n * @example\n * ```ts\n * addPathToDeepKey('a.b', 'c') // Returns 'a.b.c'\n * addPathToDeepKey('a[0]', 'c') // Returns 'a[0].c'\n * addPathToDeepKey('.a.b', 'c') // Returns '.a.b.c'\n * addPathToDeepKey('a.b', 'b.c') // Returns 'a.b.b.c'\n * addPathToDeepKey('', 'a') // Returns 'a'\n * addPathToDeepKey('.a.b', 'c.d') // Returns '.a.b.c.d'\n * ```\n *\n * @param deepKey - The deep key string to add the path segment to.\n * @param path - The path segment to add to the deep key string.\n * @returns A new deep key string.\n */\nexport function addPathToDeepKey(\n deepKey: string,\n path: string | number\n): string {\n if (isNumber(path) || Number.isInteger(path)) {\n return `${deepKey}[${path}]`;\n }\n if (isSetString(path)) {\n return `${deepKey}.${path}`;\n }\n\n return deepKey;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqCA,SAAgB,UAAU,MAAwB;AAChD,QAAO,KAAK,QAAQ,KAAK,YAAY;AACnC,SAAO,iBAAiB,KAAK,QAAQ;GACrC;;;;;;;;;;;;;;;;;;;;;;AAuBJ,SAAgB,iBACd,SACA,MACQ;AACR,KAAI,SAAS,KAAK,IAAI,OAAO,UAAU,KAAK,CAC1C,QAAO,GAAG,QAAQ,GAAG,KAAK;AAE5B,KAAI,YAAY,KAAK,CACnB,QAAO,GAAG,QAAQ,GAAG;AAGvB,QAAO"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const require_get_object_tag = require('./get-object-tag.cjs');
|
|
2
|
+
const require_is_plain_object = require('./is-plain-object.cjs');
|
|
3
|
+
const require_is_function = require('./is-function.cjs');
|
|
4
|
+
const require_is_null = require('./is-null.cjs');
|
|
5
|
+
const require_is_number = require('./is-number.cjs');
|
|
6
|
+
const require_is_undefined = require('./is-undefined.cjs');
|
|
7
|
+
const require_is_empty = require('./is-empty.cjs');
|
|
8
|
+
const require_is_object = require('./is-object.cjs');
|
|
9
|
+
const require_is_buffer = require('./is-buffer.cjs');
|
|
10
|
+
require('./type-detect.cjs');
|
|
11
|
+
require('./is-collection.cjs');
|
|
12
|
+
const require_is_deep_key = require('./is-deep-key.cjs');
|
|
13
|
+
const require_is_string = require('./is-string.cjs');
|
|
14
|
+
const require_is_set = require('./is-set.cjs');
|
|
15
|
+
const require_is_set_string = require('./is-set-string.cjs');
|
|
16
|
+
const require_is_react_element = require('./is-react-element.cjs');
|
|
17
|
+
const require_is_mergeable_object = require('./is-mergeable-object.cjs');
|
|
18
|
+
const require_is_object_index = require('./is-object-index.cjs');
|
|
19
|
+
const require_is_primitive = require('./is-primitive.cjs');
|
|
20
|
+
const require_is_typed_array = require('./is-typed-array.cjs');
|
|
21
|
+
const require_property_exists = require('./property-exists.cjs');
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { getObjectTag } from "./get-object-tag.mjs";
|
|
2
|
+
import { isObjectLike, isPlainObject } from "./is-plain-object.mjs";
|
|
3
|
+
import { isAsyncFunction, isFunction, isSyncFunction } from "./is-function.mjs";
|
|
4
|
+
import { isNull } from "./is-null.mjs";
|
|
5
|
+
import { isNumber } from "./is-number.mjs";
|
|
6
|
+
import { isUndefined } from "./is-undefined.mjs";
|
|
7
|
+
import { isEmpty } from "./is-empty.mjs";
|
|
8
|
+
import { isObject } from "./is-object.mjs";
|
|
9
|
+
import { isBufferExists } from "./is-buffer.mjs";
|
|
10
|
+
import "./type-detect.mjs";
|
|
11
|
+
import "./is-collection.mjs";
|
|
12
|
+
import { isDeepKey } from "./is-deep-key.mjs";
|
|
13
|
+
import { isString } from "./is-string.mjs";
|
|
14
|
+
import { isSet } from "./is-set.mjs";
|
|
15
|
+
import { isSetString } from "./is-set-string.mjs";
|
|
16
|
+
import { isReactElement } from "./is-react-element.mjs";
|
|
17
|
+
import { isMergeableObject } from "./is-mergeable-object.mjs";
|
|
18
|
+
import { isObjectIndex } from "./is-object-index.mjs";
|
|
19
|
+
import { isPrimitive } from "./is-primitive.mjs";
|
|
20
|
+
import { isTypedArray } from "./is-typed-array.mjs";
|
|
21
|
+
import { propertyExists, propertyUnsafe } from "./property-exists.mjs";
|
|
22
|
+
|
|
23
|
+
export { };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
let node_buffer = require("node:buffer");
|
|
2
|
+
|
|
3
|
+
//#region ../type-checks/src/is-buffer.ts
|
|
4
|
+
const isBufferExists = typeof node_buffer.Buffer !== "undefined";
|
|
5
|
+
/**
|
|
6
|
+
* Check if the provided value's type is `Buffer`
|
|
7
|
+
*/
|
|
8
|
+
const isBuffer = isBufferExists ? node_buffer.Buffer.isBuffer.bind(node_buffer.Buffer) : function isBuffer$1(value) {
|
|
9
|
+
return false;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
exports.isBufferExists = isBufferExists;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
|
|
3
|
+
//#region ../type-checks/src/is-buffer.ts
|
|
4
|
+
const isBufferExists = typeof Buffer !== "undefined";
|
|
5
|
+
/**
|
|
6
|
+
* Check if the provided value's type is `Buffer`
|
|
7
|
+
*/
|
|
8
|
+
const isBuffer = isBufferExists ? Buffer.isBuffer.bind(Buffer) : function isBuffer$1(value) {
|
|
9
|
+
return false;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { isBufferExists };
|
|
14
|
+
//# sourceMappingURL=is-buffer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-buffer.mjs","names":["isBuffer: typeof Buffer.isBuffer","isBuffer"],"sources":["../../../../type-checks/src/is-buffer.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 { Buffer } from \"node:buffer\";\n\nexport const isBufferExists = typeof Buffer !== \"undefined\";\n\n/**\n * Check if the provided value's type is `Buffer`\n */\nexport const isBuffer: typeof Buffer.isBuffer = isBufferExists\n ? Buffer.isBuffer.bind(Buffer)\n : /**\n * Check if the provided value's type is `Buffer`\n\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `Buffer`\n */\n function isBuffer(\n value: Parameters<typeof Buffer.isBuffer>[0]\n ): value is Buffer {\n return false;\n };\n"],"mappings":";;;AAoBA,MAAa,iBAAiB,OAAO,WAAW;;;;AAKhD,MAAaA,WAAmC,iBAC5C,OAAO,SAAS,KAAK,OAAO,GAO5B,SAASC,WACP,OACiB;AACjB,QAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require('./type-detect.cjs');
|
|
@@ -21,6 +21,12 @@ function isDeepKey(key) {
|
|
|
21
21
|
case "number":
|
|
22
22
|
case "symbol": return false;
|
|
23
23
|
case "string": return key.includes(".") || key.includes("[") || key.includes("]");
|
|
24
|
+
case "bigint":
|
|
25
|
+
case "boolean":
|
|
26
|
+
case "function":
|
|
27
|
+
case "object":
|
|
28
|
+
case "undefined":
|
|
29
|
+
default: return false;
|
|
24
30
|
}
|
|
25
31
|
}
|
|
26
32
|
|
|
@@ -20,6 +20,12 @@ function isDeepKey(key) {
|
|
|
20
20
|
case "number":
|
|
21
21
|
case "symbol": return false;
|
|
22
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;
|
|
23
29
|
}
|
|
24
30
|
}
|
|
25
31
|
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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"}
|
|
@@ -12,6 +12,12 @@ function isObjectIndex(value) {
|
|
|
12
12
|
case "number": return Number.isInteger(value) && value >= 0 && value < Number.MAX_SAFE_INTEGER;
|
|
13
13
|
case "symbol": return false;
|
|
14
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;
|
|
15
21
|
}
|
|
16
22
|
}
|
|
17
23
|
|
|
@@ -11,6 +11,12 @@ function isObjectIndex(value) {
|
|
|
11
11
|
case "number": return Number.isInteger(value) && value >= 0 && value < Number.MAX_SAFE_INTEGER;
|
|
12
12
|
case "symbol": return false;
|
|
13
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;
|
|
14
20
|
}
|
|
15
21
|
}
|
|
16
22
|
|
|
@@ -1 +1 @@
|
|
|
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 }\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"}
|
|
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"}
|
|
@@ -23,8 +23,8 @@ const require_get_object_tag = require('./get-object-tag.cjs');
|
|
|
23
23
|
* @param value - The value to check.
|
|
24
24
|
* @returns Returns `true` if `value` is object-like, else `false`.
|
|
25
25
|
*/
|
|
26
|
-
const isObjectLike = (
|
|
27
|
-
return typeof
|
|
26
|
+
const isObjectLike = (value) => {
|
|
27
|
+
return typeof value === "object" && value !== null;
|
|
28
28
|
};
|
|
29
29
|
/**
|
|
30
30
|
* Checks if `obj` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`.
|
|
@@ -60,4 +60,5 @@ const isPlainObject = (obj) => {
|
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
//#endregion
|
|
63
|
+
exports.isObjectLike = isObjectLike;
|
|
63
64
|
exports.isPlainObject = isPlainObject;
|
|
@@ -23,8 +23,8 @@ import { getObjectTag } from "./get-object-tag.mjs";
|
|
|
23
23
|
* @param value - The value to check.
|
|
24
24
|
* @returns Returns `true` if `value` is object-like, else `false`.
|
|
25
25
|
*/
|
|
26
|
-
const isObjectLike = (
|
|
27
|
-
return typeof
|
|
26
|
+
const isObjectLike = (value) => {
|
|
27
|
+
return typeof value === "object" && value !== null;
|
|
28
28
|
};
|
|
29
29
|
/**
|
|
30
30
|
* Checks if `obj` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`.
|
|
@@ -60,5 +60,5 @@ const isPlainObject = (obj) => {
|
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
//#endregion
|
|
63
|
-
export { isPlainObject };
|
|
63
|
+
export { isObjectLike, isPlainObject };
|
|
64
64
|
//# sourceMappingURL=is-plain-object.mjs.map
|
|
@@ -1 +1 @@
|
|
|
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 = (
|
|
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"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -25,7 +25,7 @@ const require_set_field = require('./set-field.cjs');
|
|
|
25
25
|
* // }
|
|
26
26
|
* ```
|
|
27
27
|
*
|
|
28
|
-
* @param
|
|
28
|
+
* @param deepKeyObject - The object to flatten.
|
|
29
29
|
* @returns - The flattened object.
|
|
30
30
|
*/
|
|
31
31
|
function unflattenObject(deepKeyObject) {
|
|
@@ -26,7 +26,7 @@ import { DeepKey, DeepValue } from "./types/src/object.cjs";
|
|
|
26
26
|
* // }
|
|
27
27
|
* ```
|
|
28
28
|
*
|
|
29
|
-
* @param
|
|
29
|
+
* @param deepKeyObject - The object to flatten.
|
|
30
30
|
* @returns - The flattened object.
|
|
31
31
|
*/
|
|
32
32
|
declare function unflattenObject<TObject extends Record<string, any> = Record<string, any>, TDeepKeyObject extends { [TKey in DeepKey<TObject>]: DeepValue<TObject, TKey> } = { [TKey in DeepKey<TObject>]: DeepValue<TObject, TKey> }>(deepKeyObject: TDeepKeyObject): TObject;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unflatten-object.d.cts","names":[],"sources":["../src/unflatten-object.ts"],"sourcesContent":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"unflatten-object.d.cts","names":[],"sources":["../src/unflatten-object.ts"],"sourcesContent":[],"mappings":";;;;;;AAgDA;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,gCACE,sBAAsB,uDAE3B,QAAQ,WAAW,UAAU,SAAS,qBAClC,QAAQ,WAAW,UAAU,SAAS,wBACtC,iBAAiB"}
|
|
@@ -26,7 +26,7 @@ import { DeepKey, DeepValue } from "./types/src/object.mjs";
|
|
|
26
26
|
* // }
|
|
27
27
|
* ```
|
|
28
28
|
*
|
|
29
|
-
* @param
|
|
29
|
+
* @param deepKeyObject - The object to flatten.
|
|
30
30
|
* @returns - The flattened object.
|
|
31
31
|
*/
|
|
32
32
|
declare function unflattenObject<TObject extends Record<string, any> = Record<string, any>, TDeepKeyObject extends { [TKey in DeepKey<TObject>]: DeepValue<TObject, TKey> } = { [TKey in DeepKey<TObject>]: DeepValue<TObject, TKey> }>(deepKeyObject: TDeepKeyObject): TObject;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unflatten-object.d.mts","names":[],"sources":["../src/unflatten-object.ts"],"sourcesContent":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"unflatten-object.d.mts","names":[],"sources":["../src/unflatten-object.ts"],"sourcesContent":[],"mappings":";;;;;;AAgDA;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,gCACE,sBAAsB,uDAE3B,QAAQ,WAAW,UAAU,SAAS,qBAClC,QAAQ,WAAW,UAAU,SAAS,wBACtC,iBAAiB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unflatten-object.mjs","names":[],"sources":["../src/unflatten-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
|
|
1
|
+
{"version":3,"file":"unflatten-object.mjs","names":[],"sources":["../src/unflatten-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 { DeepKey, DeepValue } from \"@stryke/types\";\nimport { setField } from \"./set-field\";\n\n/**\n * Flattens a nested object into a single level object with dot-separated keys.\n *\n * @example\n * ```typescript\n * const nestedObject = {\n * a: {\n * b: {\n * c: 1\n * }\n * },\n * d: [2, 3]\n * };\n *\n * const flattened = flattenObject(nestedObject);\n * console.log(flattened);\n * // Output:\n * // {\n * // 'a.b.c': 1,\n * // 'd.0': 2,\n * // 'd.1': 3\n * // }\n * ```\n *\n * @param deepKeyObject - The object to flatten.\n * @returns - The flattened object.\n */\nexport function unflattenObject<\n TObject extends Record<string, any> = Record<string, any>,\n TDeepKeyObject extends {\n [TKey in DeepKey<TObject>]: DeepValue<TObject, TKey>;\n } = { [TKey in DeepKey<TObject>]: DeepValue<TObject, TKey> }\n>(deepKeyObject: TDeepKeyObject): TObject {\n return Object.entries(deepKeyObject).reduce(\n (ret: TObject, [key, value]: [string, any]) => {\n return setField<TObject>(ret, key as DeepKey<TObject>, value);\n },\n {} as TObject\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,SAAgB,gBAKd,eAAwC;AACxC,QAAO,OAAO,QAAQ,cAAc,CAAC,QAClC,KAAc,CAAC,KAAK,WAA0B;AAC7C,SAAO,SAAkB,KAAK,KAAyB,MAAM;IAE/D,EAAE,CACH"}
|
package/dist/union.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"union.d.cts","names":[],"sources":["../src/union.ts"],"sourcesContent":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"union.d.cts","names":[],"sources":["../src/union.ts"],"sourcesContent":[],"mappings":";;AAuCA;;;;;;;;;;;;;;;;;;iBAAgB,wBAAwB,oBAAoB,MAAM"}
|
package/dist/union.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"union.d.mts","names":[],"sources":["../src/union.ts"],"sourcesContent":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"union.d.mts","names":[],"sources":["../src/union.ts"],"sourcesContent":[],"mappings":";;AAuCA;;;;;;;;;;;;;;;;;;iBAAgB,wBAAwB,oBAAoB,MAAM"}
|
package/dist/union.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"union.mjs","names":[],"sources":["../src/union.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
|
|
1
|
+
{"version":3,"file":"union.mjs","names":[],"sources":["../src/union.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 { getUnique } from \"./get-unique\";\n\n/**\n * Creates an array of unique values from all given arrays.\n *\n * @remarks\n * This function takes two arrays, merges them into a single array, and returns a new array\n * containing only the unique values from the merged array.\n *\n * @example\n * ```ts\n * const array1 = [1, 2, 3];\n * const array2 = [3, 4, 5];\n * const result = union(array1, array2);\n * // result will be [1, 2, 3, 4, 5]\n * ```\n *\n * @param arr1 - The first array to merge and filter for unique values.\n * @param arr2 - The second array to merge and filter for unique values.\n * @returns A new array of unique values.\n */\nexport function union<T>(arr1: readonly T[], arr2: readonly T[]): T[] {\n return getUnique([...arr1, ...arr2]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,MAAS,MAAoB,MAAyB;AACpE,QAAO,UAAU,CAAC,GAAG,MAAM,GAAG,KAAK,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-timeout.d.cts","names":[],"sources":["../src/with-timeout.ts"],"sourcesContent":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"with-timeout.d.cts","names":[],"sources":["../src/with-timeout.ts"],"sourcesContent":[],"mappings":";;AAuCA;;;;;;;;;;;;;;;;;;iBAAsB,0BACT,QAAQ,iBAElB,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-timeout.d.mts","names":[],"sources":["../src/with-timeout.ts"],"sourcesContent":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"with-timeout.d.mts","names":[],"sources":["../src/with-timeout.ts"],"sourcesContent":[],"mappings":";;AAuCA;;;;;;;;;;;;;;;;;;iBAAsB,0BACT,QAAQ,iBAElB,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-timeout.mjs","names":[],"sources":["../src/with-timeout.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
|
|
1
|
+
{"version":3,"file":"with-timeout.mjs","names":[],"sources":["../src/with-timeout.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 { timeout } from \"./timeout\";\n\n/**\n * Executes an async function and enforces a timeout.\n *\n * If the promise does not resolve within the specified time,\n * the timeout will trigger and the returned promise will be rejected.\n *\n * @example\n * ```typescript\n * try {\n * await withTimeout(() => {}, 1000); // Timeout exception after 1 second\n * } catch (error) {\n * console.error(error); // Will log 'TimeoutError'\n * }\n * ```\n *\n * @param run - A function that returns a promise to be executed.\n * @param ms - The timeout duration in milliseconds.\n * @returns A promise that resolves with the result of the `run` function or rejects if the timeout is reached.\n */\nexport async function withTimeout<T>(\n run: () => Promise<T>,\n ms: number\n): Promise<T> {\n return Promise.race([run(), timeout(ms) as T]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuCA,eAAsB,YACpB,KACA,IACY;AACZ,QAAO,QAAQ,KAAK,CAAC,KAAK,EAAE,QAAQ,GAAG,CAAM,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/helpers",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A package containing miscellaneous helper functions that are used across many different Storm Software projects.",
|
|
6
6
|
"repository": {
|
|
@@ -129,5 +129,5 @@
|
|
|
129
129
|
"types": "./dist/index.d.cts",
|
|
130
130
|
"devDependencies": { "tsdown": "^0.17.2" },
|
|
131
131
|
"publishConfig": { "access": "public" },
|
|
132
|
-
"gitHead": "
|
|
132
|
+
"gitHead": "ad0acb8f9d34c16300a0901dd4db448756480415"
|
|
133
133
|
}
|