@stryke/helpers 0.10.18 → 0.10.20
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 +16 -0
- package/dist/_virtual/_rolldown/runtime.cjs +19 -0
- package/dist/_virtual/_rolldown/runtime.mjs +18 -0
- package/dist/arg-identity.cjs +9 -1
- package/dist/arg-identity.mjs +4 -1
- package/dist/arg-identity.mjs.map +1 -1
- package/dist/arg-identity.test.cjs +12 -0
- package/dist/arg-identity.test.d.cts +1 -0
- package/dist/arg-identity.test.d.mts +1 -0
- package/dist/arg-identity.test.mjs +14 -0
- package/dist/arg-identity.test.mjs.map +1 -0
- package/dist/deep-clone.cjs +9 -1
- package/dist/deep-clone.mjs +3 -1
- package/dist/deep-clone.mjs.map +1 -1
- package/dist/deep-clone.test.cjs +12 -0
- package/dist/deep-clone.test.d.cts +1 -0
- package/dist/deep-clone.test.d.mts +1 -0
- package/dist/deep-clone.test.mjs +14 -0
- package/dist/deep-clone.test.mjs.map +1 -0
- package/dist/deep-merge.cjs +9 -1
- package/dist/deep-merge.mjs +3 -1
- package/dist/deep-merge.mjs.map +1 -1
- package/dist/deep-merge.test.cjs +12 -0
- package/dist/deep-merge.test.d.cts +1 -0
- package/dist/deep-merge.test.d.mts +1 -0
- package/dist/deep-merge.test.mjs +14 -0
- package/dist/deep-merge.test.mjs.map +1 -0
- package/dist/filter-empty.cjs +9 -1
- package/dist/filter-empty.mjs +3 -1
- package/dist/filter-empty.mjs.map +1 -1
- package/dist/filter-empty.test.cjs +12 -0
- package/dist/filter-empty.test.d.cts +1 -0
- package/dist/filter-empty.test.d.mts +1 -0
- package/dist/filter-empty.test.mjs +14 -0
- package/dist/filter-empty.test.mjs.map +1 -0
- package/dist/flatten-object.cjs +9 -1
- package/dist/flatten-object.mjs +3 -1
- package/dist/flatten-object.mjs.map +1 -1
- package/dist/flatten-object.test.cjs +12 -0
- package/dist/flatten-object.test.d.cts +1 -0
- package/dist/flatten-object.test.d.mts +1 -0
- package/dist/flatten-object.test.mjs +14 -0
- package/dist/flatten-object.test.mjs.map +1 -0
- package/dist/get-field.cjs +9 -1
- package/dist/get-field.mjs +3 -1
- package/dist/get-field.mjs.map +1 -1
- package/dist/get-field.test.cjs +12 -0
- package/dist/get-field.test.d.cts +1 -0
- package/dist/get-field.test.d.mts +1 -0
- package/dist/get-field.test.mjs +14 -0
- package/dist/get-field.test.mjs.map +1 -0
- package/dist/get-ordered-by.cjs +9 -1
- package/dist/get-ordered-by.mjs +4 -1
- package/dist/get-ordered-by.mjs.map +1 -1
- package/dist/get-ordered-by.test.cjs +12 -0
- package/dist/get-ordered-by.test.d.cts +1 -0
- package/dist/get-ordered-by.test.d.mts +1 -0
- package/dist/get-ordered-by.test.mjs +14 -0
- package/dist/get-ordered-by.test.mjs.map +1 -0
- package/dist/get-unique.cjs +12 -1
- package/dist/get-unique.mjs +7 -1
- package/dist/get-unique.mjs.map +1 -1
- package/dist/get-unique.test.cjs +12 -0
- package/dist/get-unique.test.d.cts +1 -0
- package/dist/get-unique.test.d.mts +1 -0
- package/dist/get-unique.test.mjs +14 -0
- package/dist/get-unique.test.mjs.map +1 -0
- package/dist/identity.cjs +9 -1
- package/dist/identity.mjs +4 -1
- package/dist/identity.mjs.map +1 -1
- package/dist/identity.test.cjs +12 -0
- package/dist/identity.test.d.cts +1 -0
- package/dist/identity.test.d.mts +1 -0
- package/dist/identity.test.mjs +14 -0
- package/dist/identity.test.mjs.map +1 -0
- package/dist/index.cjs +41 -0
- package/dist/index.mjs +37 -1
- package/dist/index.mjs.map +1 -0
- package/dist/index.test.cjs +12 -0
- package/dist/index.test.d.cts +1 -0
- package/dist/index.test.d.mts +1 -0
- package/dist/index.test.mjs +14 -0
- package/dist/index.test.mjs.map +1 -0
- package/dist/is-equal.cjs +9 -1
- package/dist/is-equal.mjs +3 -1
- package/dist/is-equal.mjs.map +1 -1
- package/dist/is-equal.test.cjs +12 -0
- package/dist/is-equal.test.d.cts +1 -0
- package/dist/is-equal.test.d.mts +1 -0
- package/dist/is-equal.test.mjs +14 -0
- package/dist/is-equal.test.mjs.map +1 -0
- package/dist/lru-cache.cjs +9 -1
- package/dist/lru-cache.mjs +4 -1
- package/dist/lru-cache.mjs.map +1 -1
- package/dist/lru-cache.test.cjs +12 -0
- package/dist/lru-cache.test.d.cts +1 -0
- package/dist/lru-cache.test.d.mts +1 -0
- package/dist/lru-cache.test.mjs +14 -0
- package/dist/lru-cache.test.mjs.map +1 -0
- package/dist/match-sorter.cjs +12 -0
- package/dist/match-sorter.mjs +7 -1
- package/dist/match-sorter.mjs.map +1 -1
- package/dist/match-sorter.test.cjs +12 -0
- package/dist/match-sorter.test.d.cts +1 -0
- package/dist/match-sorter.test.d.mts +1 -0
- package/dist/match-sorter.test.mjs +14 -0
- package/dist/match-sorter.test.mjs.map +1 -0
- package/dist/memoize.cjs +9 -1
- package/dist/memoize.mjs +4 -1
- package/dist/memoize.mjs.map +1 -1
- package/dist/memoize.test.cjs +12 -0
- package/dist/memoize.test.d.cts +1 -0
- package/dist/memoize.test.d.mts +1 -0
- package/dist/memoize.test.mjs +14 -0
- package/dist/memoize.test.mjs.map +1 -0
- package/dist/noop.cjs +12 -1
- package/dist/noop.mjs +7 -1
- package/dist/noop.mjs.map +1 -1
- package/dist/noop.test.cjs +12 -0
- package/dist/noop.test.d.cts +1 -0
- package/dist/noop.test.d.mts +1 -0
- package/dist/noop.test.mjs +14 -0
- package/dist/noop.test.mjs.map +1 -0
- package/dist/omit.cjs +9 -1
- package/dist/omit.mjs +4 -1
- package/dist/omit.mjs.map +1 -1
- package/dist/omit.test.cjs +12 -0
- package/dist/omit.test.d.cts +1 -0
- package/dist/omit.test.d.mts +1 -0
- package/dist/omit.test.mjs +14 -0
- package/dist/omit.test.mjs.map +1 -0
- package/dist/pick.cjs +9 -1
- package/dist/pick.mjs +4 -1
- package/dist/pick.mjs.map +1 -1
- package/dist/pick.test.cjs +12 -0
- package/dist/pick.test.d.cts +1 -0
- package/dist/pick.test.d.mts +1 -0
- package/dist/pick.test.mjs +14 -0
- package/dist/pick.test.mjs.map +1 -0
- package/dist/remove-accents.cjs +12 -1
- package/dist/remove-accents.mjs +7 -1
- package/dist/remove-accents.mjs.map +1 -1
- package/dist/remove-accents.test.cjs +12 -0
- package/dist/remove-accents.test.d.cts +1 -0
- package/dist/remove-accents.test.d.mts +1 -0
- package/dist/remove-accents.test.mjs +14 -0
- package/dist/remove-accents.test.mjs.map +1 -0
- package/dist/remove-empty-items.cjs +9 -1
- package/dist/remove-empty-items.mjs +4 -1
- package/dist/remove-empty-items.mjs.map +1 -1
- package/dist/remove-empty-items.test.cjs +12 -0
- package/dist/remove-empty-items.test.d.cts +1 -0
- package/dist/remove-empty-items.test.d.mts +1 -0
- package/dist/remove-empty-items.test.mjs +14 -0
- package/dist/remove-empty-items.test.mjs.map +1 -0
- package/dist/set-field.cjs +9 -1
- package/dist/set-field.mjs +3 -1
- package/dist/set-field.mjs.map +1 -1
- package/dist/set-field.test.cjs +12 -0
- package/dist/set-field.test.d.cts +1 -0
- package/dist/set-field.test.d.mts +1 -0
- package/dist/set-field.test.mjs +14 -0
- package/dist/set-field.test.mjs.map +1 -0
- package/dist/to-deep-key.cjs +12 -1
- package/dist/to-deep-key.mjs +6 -1
- package/dist/to-deep-key.mjs.map +1 -1
- package/dist/to-deep-key.test.cjs +12 -0
- package/dist/to-deep-key.test.d.cts +1 -0
- package/dist/to-deep-key.test.d.mts +1 -0
- package/dist/to-deep-key.test.mjs +14 -0
- package/dist/to-deep-key.test.mjs.map +1 -0
- package/dist/to-path.cjs +9 -1
- package/dist/to-path.mjs +4 -1
- package/dist/to-path.mjs.map +1 -1
- package/dist/to-path.test.cjs +12 -0
- package/dist/to-path.test.d.cts +1 -0
- package/dist/to-path.test.d.mts +1 -0
- package/dist/to-path.test.mjs +14 -0
- package/dist/to-path.test.mjs.map +1 -0
- package/dist/unflatten-object.cjs +9 -1
- package/dist/unflatten-object.mjs +3 -1
- package/dist/unflatten-object.mjs.map +1 -1
- package/dist/unflatten-object.test.cjs +12 -0
- package/dist/unflatten-object.test.d.cts +1 -0
- package/dist/unflatten-object.test.d.mts +1 -0
- package/dist/unflatten-object.test.mjs +14 -0
- package/dist/unflatten-object.test.mjs.map +1 -0
- package/dist/union.cjs +9 -1
- package/dist/union.mjs +3 -1
- package/dist/union.mjs.map +1 -1
- package/dist/union.test.cjs +12 -0
- package/dist/union.test.d.cts +1 -0
- package/dist/union.test.d.mts +1 -0
- package/dist/union.test.mjs +14 -0
- package/dist/union.test.mjs.map +1 -0
- package/package.json +101 -5
package/dist/get-field.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-field.mjs","names":[],"sources":["../src/get-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 { toStringKey } from \"@stryke/convert\";\nimport { isDeepKey, isNumber } from \"@stryke/type-checks\";\nimport { toPath } from \"./to-path\";\n\n/**\n * See the definition of `@types/lodash`.\n */\ntype GetIndexedField<T, K> = K extends keyof T\n ? T[K]\n : K extends `${number}`\n ? \"length\" extends keyof T\n ? number extends T[\"length\"]\n ? number extends keyof T\n ? T[number]\n : undefined\n : undefined\n : undefined\n : undefined;\n\ntype FieldWithPossiblyUndefined<T, Key> =\n | GetField<Exclude<T, undefined>, Key>\n | Extract<T, undefined>;\n\ntype IndexedFieldWithPossiblyUndefined<T, Key> =\n | GetIndexedField<Exclude<T, undefined>, Key>\n | Extract<T, undefined>;\n\nexport type GetField<T, P> = P extends `${infer Left}.${infer Right}`\n ? Left extends keyof Exclude<T, undefined>\n ?\n | FieldWithPossiblyUndefined<Exclude<T, undefined>[Left], Right>\n | Extract<T, undefined>\n : Left extends `${infer FieldKey}[${infer IndexKey}]`\n ? FieldKey extends keyof T\n ? FieldWithPossiblyUndefined<\n IndexedFieldWithPossiblyUndefined<T[FieldKey], IndexKey>,\n Right\n >\n : undefined\n : undefined\n : P extends keyof T\n ? T[P]\n : P extends `${infer FieldKey}[${infer IndexKey}]`\n ? FieldKey extends keyof T\n ? IndexedFieldWithPossiblyUndefined<T[FieldKey], IndexKey>\n : undefined\n : IndexedFieldWithPossiblyUndefined<T, P>;\n\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K - The type of the key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value.\n */\nexport function getField<T extends object, K extends keyof T>(\n object: T,\n path: K | readonly [K]\n): T[K];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K - The type of the key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value or undefined.\n */\nexport function getField<T extends object, K extends keyof T>(\n object: T | null | undefined,\n path: K | readonly [K]\n): T[K] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K - The type of the key in the object.\n * @typeParam D - The type of the default value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value or default value.\n */\nexport function getField<T extends object, K extends keyof T, D>(\n object: T | null | undefined,\n path: K | readonly [K],\n defaultValue: D\n): Exclude<T[K], undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1]\n>(object: T, path: readonly [K1, K2]): T[K1][K2];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value or undefined.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1]\n>(object: T | null | undefined, path: readonly [K1, K2]): T[K1][K2] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n * @typeParam D - The type of the default value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value or default value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n D\n>(\n object: T | null | undefined,\n path: readonly [K1, K2],\n defaultValue: D\n): Exclude<T[K1][K2], undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n * @typeParam K3 - The type of the third key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2]\n>(object: T, path: readonly [K1, K2, K3]): T[K1][K2][K3];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n * @typeParam K3 - The type of the third key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value or undefined.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2]\n>(\n object: T | null | undefined,\n path: readonly [K1, K2, K3]\n): T[K1][K2][K3] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n * @typeParam K3 - The type of the third key in the object.\n * @typeParam D - The type of the default value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value or default value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2],\n D\n>(\n object: T | null | undefined,\n path: readonly [K1, K2, K3],\n defaultValue: D\n): Exclude<T[K1][K2][K3], undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n * @typeParam K3 - The type of the third key in the object.\n * @typeParam K4 - The type of the fourth key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2],\n K4 extends keyof T[K1][K2][K3]\n>(object: T, path: readonly [K1, K2, K3, K4]): T[K1][K2][K3][K4];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n * @typeParam K3 - The type of the third key in the object.\n * @typeParam K4 - The type of the fourth key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value or undefined.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2],\n K4 extends keyof T[K1][K2][K3]\n>(\n object: T | null | undefined,\n path: readonly [K1, K2, K3, K4]\n): T[K1][K2][K3][K4] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n * @typeParam K3 - The type of the third key in the object.\n * @typeParam K4 - The type of the fourth key in the object.\n * @typeParam D - The type of the default value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value or default value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2],\n K4 extends keyof T[K1][K2][K3],\n D\n>(\n object: T | null | undefined,\n path: readonly [K1, K2, K3, K4],\n defaultValue: D\n): Exclude<T[K1][K2][K3][K4], undefined> | D;\n/**\n * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value.\n */\nexport function getField<T>(object: Record<number, T>, path: number): T;\n/**\n * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value or undefined.\n */\nexport function getField<T>(\n object: Record<number, T> | null | undefined,\n path: number\n): T | undefined;\n/**\n * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the value.\n * @typeParam D - The type of the default value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value or default value.\n */\nexport function getField<T, D>(\n object: Record<number, T> | null | undefined,\n path: number,\n defaultValue: D\n): T | D;\n/**\n * Retrieves the value at a given path from a null or undefined object, returning the default value.\n *\n * @typeParam D - The type of the default value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The default value.\n */\nexport function getField<D>(\n object: null | undefined,\n path: PropertyKey,\n defaultValue: D\n): D;\n\n/**\n * Retrieves the value at a given path from a null or undefined object, returning undefined.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n */\nexport function getField(\n object: null | undefined,\n path: PropertyKey\n): undefined;\n\n/**\n * Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam P - The type of the path.\n *\n * @param data - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value, or any if path is a general string.\n */\nexport function getField<T, P extends string>(\n data: T,\n path: P\n): string extends P ? any : GetField<T, P>;\n/**\n * Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam P - The type of the path.\n * @typeParam D - The type of the default value.\n *\n * @param data - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value or default value.\n */\nexport function getField<T, P extends string, D = GetField<T, P>>(\n data: T,\n path: P,\n defaultValue: D\n): Exclude<GetField<T, P>, null | undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value.\n */\nexport function getField(\n object: unknown,\n path: PropertyKey | readonly PropertyKey[],\n defaultValue?: unknown\n): any;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value.\n */\nexport function getField(\n object: any,\n path: PropertyKey | readonly PropertyKey[],\n defaultValue?: any\n): any {\n if (object === null) {\n return defaultValue;\n }\n\n switch (typeof path) {\n case \"string\": {\n const result = object[path];\n\n if (result === undefined) {\n if (isDeepKey(path)) {\n return getField(object, toPath(path), defaultValue);\n }\n return defaultValue;\n }\n\n return result;\n }\n case \"number\":\n case \"symbol\": {\n if (isNumber(path)) {\n path = toStringKey(path);\n }\n\n const result = Array.isArray(path)\n ? undefined\n : object[path as PropertyKey];\n if (result === undefined) {\n return defaultValue;\n }\n\n return result;\n }\n case \"bigint\":\n case \"boolean\":\n case \"undefined\":\n case \"object\":\n case \"function\":\n default: {\n if (Array.isArray(path)) {\n return getWithPath(object, path, defaultValue);\n }\n\n path = Object.is(path?.valueOf(), -0) ? \"-0\" : String(path);\n\n const result = object[path];\n\n if (result === undefined) {\n return defaultValue;\n }\n\n return result;\n }\n }\n}\n\nfunction getWithPath(\n object: any,\n path: readonly PropertyKey[],\n defaultValue?: any\n): any {\n if (path.length === 0) {\n return defaultValue;\n }\n\n let current = object;\n\n for (const element of path) {\n if (current === null) {\n return defaultValue;\n }\n\n current = current[element];\n }\n\n if (current === undefined) {\n return defaultValue;\n }\n\n return current;\n}\n"],"mappings":";;;;;;;;;;;;;AAkaA,SAAgB,SACd,QACA,MACA,cACK;AACL,KAAI,WAAW,KACb,QAAO;AAGT,SAAQ,OAAO,MAAf;EACE,KAAK,UAAU;GACb,MAAM,SAAS,OAAO;AAEtB,OAAI,WAAW,QAAW;AACxB,QAAI,UAAU,KAAK,CACjB,QAAO,SAAS,QAAQ,OAAO,KAAK,EAAE,aAAa;AAErD,WAAO;;AAGT,UAAO;;EAET,KAAK;EACL,KAAK,UAAU;AACb,OAAI,SAAS,KAAK,CAChB,QAAO,YAAY,KAAK;GAG1B,MAAM,SAAS,MAAM,QAAQ,KAAK,GAC9B,SACA,OAAO;AACX,OAAI,WAAW,OACb,QAAO;AAGT,UAAO;;EAOT,SAAS;AACP,OAAI,MAAM,QAAQ,KAAK,CACrB,QAAO,YAAY,QAAQ,MAAM,aAAa;AAGhD,UAAO,OAAO,GAAG,MAAM,SAAS,EAAE,GAAG,GAAG,OAAO,OAAO,KAAK;GAE3D,MAAM,SAAS,OAAO;AAEtB,OAAI,WAAW,OACb,QAAO;AAGT,UAAO;;;;AAKb,SAAS,YACP,QACA,MACA,cACK;AACL,KAAI,KAAK,WAAW,EAClB,QAAO;CAGT,IAAI,UAAU;AAEd,MAAK,MAAM,WAAW,MAAM;AAC1B,MAAI,YAAY,KACd,QAAO;AAGT,YAAU,QAAQ;;AAGpB,KAAI,YAAY,OACd,QAAO;AAGT,QAAO"}
|
|
1
|
+
{"version":3,"file":"get-field.mjs","names":[],"sources":["../src/get-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 { toStringKey } from \"@stryke/convert\";\nimport { isDeepKey, isNumber } from \"@stryke/type-checks\";\nimport { toPath } from \"./to-path\";\n\n/**\n * See the definition of `@types/lodash`.\n */\ntype GetIndexedField<T, K> = K extends keyof T\n ? T[K]\n : K extends `${number}`\n ? \"length\" extends keyof T\n ? number extends T[\"length\"]\n ? number extends keyof T\n ? T[number]\n : undefined\n : undefined\n : undefined\n : undefined;\n\ntype FieldWithPossiblyUndefined<T, Key> =\n | GetField<Exclude<T, undefined>, Key>\n | Extract<T, undefined>;\n\ntype IndexedFieldWithPossiblyUndefined<T, Key> =\n | GetIndexedField<Exclude<T, undefined>, Key>\n | Extract<T, undefined>;\n\nexport type GetField<T, P> = P extends `${infer Left}.${infer Right}`\n ? Left extends keyof Exclude<T, undefined>\n ?\n | FieldWithPossiblyUndefined<Exclude<T, undefined>[Left], Right>\n | Extract<T, undefined>\n : Left extends `${infer FieldKey}[${infer IndexKey}]`\n ? FieldKey extends keyof T\n ? FieldWithPossiblyUndefined<\n IndexedFieldWithPossiblyUndefined<T[FieldKey], IndexKey>,\n Right\n >\n : undefined\n : undefined\n : P extends keyof T\n ? T[P]\n : P extends `${infer FieldKey}[${infer IndexKey}]`\n ? FieldKey extends keyof T\n ? IndexedFieldWithPossiblyUndefined<T[FieldKey], IndexKey>\n : undefined\n : IndexedFieldWithPossiblyUndefined<T, P>;\n\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K - The type of the key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value.\n */\nexport function getField<T extends object, K extends keyof T>(\n object: T,\n path: K | readonly [K]\n): T[K];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K - The type of the key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value or undefined.\n */\nexport function getField<T extends object, K extends keyof T>(\n object: T | null | undefined,\n path: K | readonly [K]\n): T[K] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K - The type of the key in the object.\n * @typeParam D - The type of the default value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value or default value.\n */\nexport function getField<T extends object, K extends keyof T, D>(\n object: T | null | undefined,\n path: K | readonly [K],\n defaultValue: D\n): Exclude<T[K], undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1]\n>(object: T, path: readonly [K1, K2]): T[K1][K2];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value or undefined.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1]\n>(object: T | null | undefined, path: readonly [K1, K2]): T[K1][K2] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n * @typeParam D - The type of the default value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value or default value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n D\n>(\n object: T | null | undefined,\n path: readonly [K1, K2],\n defaultValue: D\n): Exclude<T[K1][K2], undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n * @typeParam K3 - The type of the third key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2]\n>(object: T, path: readonly [K1, K2, K3]): T[K1][K2][K3];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n * @typeParam K3 - The type of the third key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value or undefined.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2]\n>(\n object: T | null | undefined,\n path: readonly [K1, K2, K3]\n): T[K1][K2][K3] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n * @typeParam K3 - The type of the third key in the object.\n * @typeParam D - The type of the default value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value or default value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2],\n D\n>(\n object: T | null | undefined,\n path: readonly [K1, K2, K3],\n defaultValue: D\n): Exclude<T[K1][K2][K3], undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n * @typeParam K3 - The type of the third key in the object.\n * @typeParam K4 - The type of the fourth key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2],\n K4 extends keyof T[K1][K2][K3]\n>(object: T, path: readonly [K1, K2, K3, K4]): T[K1][K2][K3][K4];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n * @typeParam K3 - The type of the third key in the object.\n * @typeParam K4 - The type of the fourth key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value or undefined.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2],\n K4 extends keyof T[K1][K2][K3]\n>(\n object: T | null | undefined,\n path: readonly [K1, K2, K3, K4]\n): T[K1][K2][K3][K4] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n * @typeParam K3 - The type of the third key in the object.\n * @typeParam K4 - The type of the fourth key in the object.\n * @typeParam D - The type of the default value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value or default value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2],\n K4 extends keyof T[K1][K2][K3],\n D\n>(\n object: T | null | undefined,\n path: readonly [K1, K2, K3, K4],\n defaultValue: D\n): Exclude<T[K1][K2][K3][K4], undefined> | D;\n/**\n * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value.\n */\nexport function getField<T>(object: Record<number, T>, path: number): T;\n/**\n * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value or undefined.\n */\nexport function getField<T>(\n object: Record<number, T> | null | undefined,\n path: number\n): T | undefined;\n/**\n * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the value.\n * @typeParam D - The type of the default value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value or default value.\n */\nexport function getField<T, D>(\n object: Record<number, T> | null | undefined,\n path: number,\n defaultValue: D\n): T | D;\n/**\n * Retrieves the value at a given path from a null or undefined object, returning the default value.\n *\n * @typeParam D - The type of the default value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The default value.\n */\nexport function getField<D>(\n object: null | undefined,\n path: PropertyKey,\n defaultValue: D\n): D;\n\n/**\n * Retrieves the value at a given path from a null or undefined object, returning undefined.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n */\nexport function getField(\n object: null | undefined,\n path: PropertyKey\n): undefined;\n\n/**\n * Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam P - The type of the path.\n *\n * @param data - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value, or any if path is a general string.\n */\nexport function getField<T, P extends string>(\n data: T,\n path: P\n): string extends P ? any : GetField<T, P>;\n/**\n * Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam P - The type of the path.\n * @typeParam D - The type of the default value.\n *\n * @param data - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value or default value.\n */\nexport function getField<T, P extends string, D = GetField<T, P>>(\n data: T,\n path: P,\n defaultValue: D\n): Exclude<GetField<T, P>, null | undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value.\n */\nexport function getField(\n object: unknown,\n path: PropertyKey | readonly PropertyKey[],\n defaultValue?: unknown\n): any;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value.\n */\nexport function getField(\n object: any,\n path: PropertyKey | readonly PropertyKey[],\n defaultValue?: any\n): any {\n if (object === null) {\n return defaultValue;\n }\n\n switch (typeof path) {\n case \"string\": {\n const result = object[path];\n\n if (result === undefined) {\n if (isDeepKey(path)) {\n return getField(object, toPath(path), defaultValue);\n }\n return defaultValue;\n }\n\n return result;\n }\n case \"number\":\n case \"symbol\": {\n if (isNumber(path)) {\n path = toStringKey(path);\n }\n\n const result = Array.isArray(path)\n ? undefined\n : object[path as PropertyKey];\n if (result === undefined) {\n return defaultValue;\n }\n\n return result;\n }\n case \"bigint\":\n case \"boolean\":\n case \"undefined\":\n case \"object\":\n case \"function\":\n default: {\n if (Array.isArray(path)) {\n return getWithPath(object, path, defaultValue);\n }\n\n path = Object.is(path?.valueOf(), -0) ? \"-0\" : String(path);\n\n const result = object[path];\n\n if (result === undefined) {\n return defaultValue;\n }\n\n return result;\n }\n }\n}\n\nfunction getWithPath(\n object: any,\n path: readonly PropertyKey[],\n defaultValue?: any\n): any {\n if (path.length === 0) {\n return defaultValue;\n }\n\n let current = object;\n\n for (const element of path) {\n if (current === null) {\n return defaultValue;\n }\n\n current = current[element];\n }\n\n if (current === undefined) {\n return defaultValue;\n }\n\n return current;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAkaA,SAAgB,SACd,QACA,MACA,cACK;AACL,KAAI,WAAW,KACb,QAAO;AAGT,SAAQ,OAAO,MAAf;EACE,KAAK,UAAU;GACb,MAAM,SAAS,OAAO;AAEtB,OAAI,WAAW,QAAW;AACxB,QAAI,UAAU,KAAK,CACjB,QAAO,SAAS,QAAQ,OAAO,KAAK,EAAE,aAAa;AAErD,WAAO;;AAGT,UAAO;;EAET,KAAK;EACL,KAAK,UAAU;AACb,OAAI,SAAS,KAAK,CAChB,QAAO,YAAY,KAAK;GAG1B,MAAM,SAAS,MAAM,QAAQ,KAAK,GAC9B,SACA,OAAO;AACX,OAAI,WAAW,OACb,QAAO;AAGT,UAAO;;EAOT,SAAS;AACP,OAAI,MAAM,QAAQ,KAAK,CACrB,QAAO,YAAY,QAAQ,MAAM,aAAa;AAGhD,UAAO,OAAO,GAAG,MAAM,SAAS,EAAE,GAAG,GAAG,OAAO,OAAO,KAAK;GAE3D,MAAM,SAAS,OAAO;AAEtB,OAAI,WAAW,OACb,QAAO;AAGT,UAAO;;;;AAKb,SAAS,YACP,QACA,MACA,cACK;AACL,KAAI,KAAK,WAAW,EAClB,QAAO;CAGT,IAAI,UAAU;AAEd,MAAK,MAAM,WAAW,MAAM;AAC1B,MAAI,YAAY,KACd,QAAO;AAGT,YAAU,QAAQ;;AAGpB,KAAI,YAAY,OACd,QAAO;AAGT,QAAO"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const require_get_field = require('./get-field.cjs');
|
|
2
|
+
let vitest = require("vitest");
|
|
3
|
+
|
|
4
|
+
//#region src/get-field.test.ts
|
|
5
|
+
(0, vitest.describe)("get-field.ts exports", () => {
|
|
6
|
+
(0, vitest.it)("loads module exports", () => {
|
|
7
|
+
(0, vitest.expect)(require_get_field.get_field_exports).toBeDefined();
|
|
8
|
+
(0, vitest.expect)(typeof require_get_field.get_field_exports).toBe("object");
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { get_field_exports } from "./get-field.mjs";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
|
|
4
|
+
//#region src/get-field.test.ts
|
|
5
|
+
describe("get-field.ts exports", () => {
|
|
6
|
+
it("loads module exports", () => {
|
|
7
|
+
expect(get_field_exports).toBeDefined();
|
|
8
|
+
expect(typeof get_field_exports).toBe("object");
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { };
|
|
14
|
+
//# sourceMappingURL=get-field.test.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-field.test.mjs","names":["moduleExports"],"sources":["../src/get-field.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport * as moduleExports from \"./get-field.ts\";\n\ndescribe(\"get-field.ts exports\", () => {\n it(\"loads module exports\", () => {\n expect(moduleExports).toBeDefined();\n expect(typeof moduleExports).toBe(\"object\");\n });\n});\n"],"mappings":";;;;AAGA,SAAS,8BAA8B;AACrC,IAAG,8BAA8B;AAC/B,SAAOA,kBAAc,CAAC,aAAa;AACnC,SAAO,OAAOA,kBAAc,CAAC,KAAK,SAAS;GAC3C;EACF"}
|
package/dist/get-ordered-by.cjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
3
|
|
|
3
4
|
//#region src/get-ordered-by.ts
|
|
5
|
+
var get_ordered_by_exports = /* @__PURE__ */ require_runtime.__exportAll({ getOrderedBy: () => getOrderedBy });
|
|
4
6
|
/**
|
|
5
7
|
* Sorts an array of objects based on multiple properties and their corresponding order directions.
|
|
6
8
|
*
|
|
@@ -52,4 +54,10 @@ function getOrderedBy(collection, keys, orders) {
|
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
//#endregion
|
|
55
|
-
exports.getOrderedBy = getOrderedBy;
|
|
57
|
+
exports.getOrderedBy = getOrderedBy;
|
|
58
|
+
Object.defineProperty(exports, 'get_ordered_by_exports', {
|
|
59
|
+
enumerable: true,
|
|
60
|
+
get: function () {
|
|
61
|
+
return get_ordered_by_exports;
|
|
62
|
+
}
|
|
63
|
+
});
|
package/dist/get-ordered-by.mjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
|
|
1
3
|
//#region src/get-ordered-by.ts
|
|
4
|
+
var get_ordered_by_exports = /* @__PURE__ */ __exportAll({ getOrderedBy: () => getOrderedBy });
|
|
2
5
|
/**
|
|
3
6
|
* Sorts an array of objects based on multiple properties and their corresponding order directions.
|
|
4
7
|
*
|
|
@@ -50,5 +53,5 @@ function getOrderedBy(collection, keys, orders) {
|
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
//#endregion
|
|
53
|
-
export { getOrderedBy };
|
|
56
|
+
export { getOrderedBy, get_ordered_by_exports };
|
|
54
57
|
//# sourceMappingURL=get-ordered-by.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-ordered-by.mjs","names":[],"sources":["../src/get-ordered-by.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\ntype Order = \"asc\" | \"desc\";\n\n/**\n * Sorts an array of objects based on multiple properties and their corresponding order directions.\n *\n * @remarks\n * This function takes an array of objects, an array of keys to sort by, and an array of order directions.\n * It returns the sorted array, ordering by each key according to its corresponding direction\n * ('asc' for ascending or 'desc' for descending). If values for a key are equal,\n * it moves to the next key to determine the order.\n *\n * @example\n * ```typescript\n * // Sort an array of objects by 'user' in ascending order and 'age' in descending order.\n * const users = [\n * { user: 'fred', age: 48 },\n * { user: 'barney', age: 34 },\n * { user: 'fred', age: 40 },\n * { user: 'barney', age: 36 },\n * ];\n * const result = orderBy(users, ['user', 'age'], ['asc', 'desc']);\n * // result will be:\n * // [\n * // { user: 'barney', age: 36 },\n * // { user: 'barney', age: 34 },\n * // { user: 'fred', age: 48 },\n * // { user: 'fred', age: 40 },\n * // ]\n * ```\n *\n * @param collection - The array of objects to be sorted.\n * @param keys - An array of keys (properties) by which to sort.\n * @param orders - An array of order directions ('asc' for ascending or 'desc' for descending).\n * @returns The sorted array.\n */\nexport function getOrderedBy<T>(\n collection: T[],\n keys: (keyof T)[],\n orders: Order[]\n): T[] {\n const compareValues = (a: T[keyof T], b: T[keyof T], order: Order) => {\n if (a < b) {\n return order === \"asc\" ? -1 : 1;\n }\n if (a > b) {\n return order === \"asc\" ? 1 : -1;\n }\n return 0;\n };\n\n const effectiveOrders = keys.map(\n (_, index) => orders[index] ?? orders.at(-1)\n );\n\n return [...collection].sort((a, b) => {\n for (const [i, key] of keys.entries()) {\n const order = effectiveOrders[i];\n const result = compareValues(a[key], b[key], order!);\n if (result !== 0) {\n return result;\n }\n }\n return 0;\n });\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-ordered-by.mjs","names":[],"sources":["../src/get-ordered-by.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\ntype Order = \"asc\" | \"desc\";\n\n/**\n * Sorts an array of objects based on multiple properties and their corresponding order directions.\n *\n * @remarks\n * This function takes an array of objects, an array of keys to sort by, and an array of order directions.\n * It returns the sorted array, ordering by each key according to its corresponding direction\n * ('asc' for ascending or 'desc' for descending). If values for a key are equal,\n * it moves to the next key to determine the order.\n *\n * @example\n * ```typescript\n * // Sort an array of objects by 'user' in ascending order and 'age' in descending order.\n * const users = [\n * { user: 'fred', age: 48 },\n * { user: 'barney', age: 34 },\n * { user: 'fred', age: 40 },\n * { user: 'barney', age: 36 },\n * ];\n * const result = orderBy(users, ['user', 'age'], ['asc', 'desc']);\n * // result will be:\n * // [\n * // { user: 'barney', age: 36 },\n * // { user: 'barney', age: 34 },\n * // { user: 'fred', age: 48 },\n * // { user: 'fred', age: 40 },\n * // ]\n * ```\n *\n * @param collection - The array of objects to be sorted.\n * @param keys - An array of keys (properties) by which to sort.\n * @param orders - An array of order directions ('asc' for ascending or 'desc' for descending).\n * @returns The sorted array.\n */\nexport function getOrderedBy<T>(\n collection: T[],\n keys: (keyof T)[],\n orders: Order[]\n): T[] {\n const compareValues = (a: T[keyof T], b: T[keyof T], order: Order) => {\n if (a < b) {\n return order === \"asc\" ? -1 : 1;\n }\n if (a > b) {\n return order === \"asc\" ? 1 : -1;\n }\n return 0;\n };\n\n const effectiveOrders = keys.map(\n (_, index) => orders[index] ?? orders.at(-1)\n );\n\n return [...collection].sort((a, b) => {\n for (const [i, key] of keys.entries()) {\n const order = effectiveOrders[i];\n const result = compareValues(a[key], b[key], order!);\n if (result !== 0) {\n return result;\n }\n }\n return 0;\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDA,SAAgB,aACd,YACA,MACA,QACK;CACL,MAAM,iBAAiB,GAAe,GAAe,UAAiB;AACpE,MAAI,IAAI,EACN,QAAO,UAAU,QAAQ,KAAK;AAEhC,MAAI,IAAI,EACN,QAAO,UAAU,QAAQ,IAAI;AAE/B,SAAO;;CAGT,MAAM,kBAAkB,KAAK,KAC1B,GAAG,UAAU,OAAO,UAAU,OAAO,GAAG,GAAG,CAC7C;AAED,QAAO,CAAC,GAAG,WAAW,CAAC,MAAM,GAAG,MAAM;AACpC,OAAK,MAAM,CAAC,GAAG,QAAQ,KAAK,SAAS,EAAE;GACrC,MAAM,QAAQ,gBAAgB;GAC9B,MAAM,SAAS,cAAc,EAAE,MAAM,EAAE,MAAM,MAAO;AACpD,OAAI,WAAW,EACb,QAAO;;AAGX,SAAO;GACP"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const require_get_ordered_by = require('./get-ordered-by.cjs');
|
|
2
|
+
let vitest = require("vitest");
|
|
3
|
+
|
|
4
|
+
//#region src/get-ordered-by.test.ts
|
|
5
|
+
(0, vitest.describe)("get-ordered-by.ts exports", () => {
|
|
6
|
+
(0, vitest.it)("loads module exports", () => {
|
|
7
|
+
(0, vitest.expect)(require_get_ordered_by.get_ordered_by_exports).toBeDefined();
|
|
8
|
+
(0, vitest.expect)(typeof require_get_ordered_by.get_ordered_by_exports).toBe("object");
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { get_ordered_by_exports } from "./get-ordered-by.mjs";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
|
|
4
|
+
//#region src/get-ordered-by.test.ts
|
|
5
|
+
describe("get-ordered-by.ts exports", () => {
|
|
6
|
+
it("loads module exports", () => {
|
|
7
|
+
expect(get_ordered_by_exports).toBeDefined();
|
|
8
|
+
expect(typeof get_ordered_by_exports).toBe("object");
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { };
|
|
14
|
+
//# sourceMappingURL=get-ordered-by.test.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-ordered-by.test.mjs","names":["moduleExports"],"sources":["../src/get-ordered-by.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport * as moduleExports from \"./get-ordered-by.ts\";\n\ndescribe(\"get-ordered-by.ts exports\", () => {\n it(\"loads module exports\", () => {\n expect(moduleExports).toBeDefined();\n expect(typeof moduleExports).toBe(\"object\");\n });\n});\n"],"mappings":";;;;AAGA,SAAS,mCAAmC;AAC1C,IAAG,8BAA8B;AAC/B,SAAOA,uBAAc,CAAC,aAAa;AACnC,SAAO,OAAOA,uBAAc,CAAC,KAAK,SAAS;GAC3C;EACF"}
|
package/dist/get-unique.cjs
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
3
|
|
|
3
4
|
//#region src/get-unique.ts
|
|
5
|
+
var get_unique_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
6
|
+
getUnique: () => getUnique,
|
|
7
|
+
getUniqueBy: () => getUniqueBy
|
|
8
|
+
});
|
|
4
9
|
/**
|
|
5
10
|
* Returns an array of unique values from the given array.
|
|
6
11
|
*
|
|
@@ -35,4 +40,10 @@ function getUniqueBy(arr, mapper = (item) => item) {
|
|
|
35
40
|
|
|
36
41
|
//#endregion
|
|
37
42
|
exports.getUnique = getUnique;
|
|
38
|
-
exports.getUniqueBy = getUniqueBy;
|
|
43
|
+
exports.getUniqueBy = getUniqueBy;
|
|
44
|
+
Object.defineProperty(exports, 'get_unique_exports', {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function () {
|
|
47
|
+
return get_unique_exports;
|
|
48
|
+
}
|
|
49
|
+
});
|
package/dist/get-unique.mjs
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
|
|
1
3
|
//#region src/get-unique.ts
|
|
4
|
+
var get_unique_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
getUnique: () => getUnique,
|
|
6
|
+
getUniqueBy: () => getUniqueBy
|
|
7
|
+
});
|
|
2
8
|
/**
|
|
3
9
|
* Returns an array of unique values from the given array.
|
|
4
10
|
*
|
|
@@ -32,5 +38,5 @@ function getUniqueBy(arr, mapper = (item) => item) {
|
|
|
32
38
|
}
|
|
33
39
|
|
|
34
40
|
//#endregion
|
|
35
|
-
export { getUnique, getUniqueBy };
|
|
41
|
+
export { getUnique, getUniqueBy, get_unique_exports };
|
|
36
42
|
//# sourceMappingURL=get-unique.mjs.map
|
package/dist/get-unique.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-unique.mjs","names":[],"sources":["../src/get-unique.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 * Returns an array of unique values from the given array.\n *\n * @param arr - The array to get unique values from.\n * @returns An array of unique values.\n */\nexport const getUnique = <T = any>(arr: T[]): T[] => {\n return [...new Set(arr)];\n};\n\n/**\n * Returns a new array containing only the unique elements from the original array,\n * based on the values returned by the mapper function.\n *\n * @example\n * ```ts\n * uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor);\n * // [1.2, 2.1, 3.2, 5.7, 7.19]\n * ```\n *\n * @param arr - The array to process.\n * @param mapper - The function used to convert the array elements.\n * @returns A new array containing only the unique elements from the original array, based on the values returned by the mapper function.\n */\nexport function getUniqueBy<T, U>(\n arr: readonly T[],\n mapper: (item: T) => U = item => item as unknown as U\n): T[] {\n const map = new Map<U, T>();\n\n for (const item of arr) {\n const key = mapper(item);\n\n if (!map.has(key)) {\n map.set(key, item);\n }\n }\n\n return [...map.values()];\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-unique.mjs","names":[],"sources":["../src/get-unique.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 * Returns an array of unique values from the given array.\n *\n * @param arr - The array to get unique values from.\n * @returns An array of unique values.\n */\nexport const getUnique = <T = any>(arr: T[]): T[] => {\n return [...new Set(arr)];\n};\n\n/**\n * Returns a new array containing only the unique elements from the original array,\n * based on the values returned by the mapper function.\n *\n * @example\n * ```ts\n * uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor);\n * // [1.2, 2.1, 3.2, 5.7, 7.19]\n * ```\n *\n * @param arr - The array to process.\n * @param mapper - The function used to convert the array elements.\n * @returns A new array containing only the unique elements from the original array, based on the values returned by the mapper function.\n */\nexport function getUniqueBy<T, U>(\n arr: readonly T[],\n mapper: (item: T) => U = item => item as unknown as U\n): T[] {\n const map = new Map<U, T>();\n\n for (const item of arr) {\n const key = mapper(item);\n\n if (!map.has(key)) {\n map.set(key, item);\n }\n }\n\n return [...map.values()];\n}\n"],"mappings":";;;;;;;;;;;;;AAwBA,MAAa,aAAsB,QAAkB;AACnD,QAAO,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC;;;;;;;;;;;;;;;;AAiB1B,SAAgB,YACd,KACA,UAAyB,SAAQ,MAC5B;CACL,MAAM,sBAAM,IAAI,KAAW;AAE3B,MAAK,MAAM,QAAQ,KAAK;EACtB,MAAM,MAAM,OAAO,KAAK;AAExB,MAAI,CAAC,IAAI,IAAI,IAAI,CACf,KAAI,IAAI,KAAK,KAAK;;AAItB,QAAO,CAAC,GAAG,IAAI,QAAQ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const require_get_unique = require('./get-unique.cjs');
|
|
2
|
+
let vitest = require("vitest");
|
|
3
|
+
|
|
4
|
+
//#region src/get-unique.test.ts
|
|
5
|
+
(0, vitest.describe)("get-unique.ts exports", () => {
|
|
6
|
+
(0, vitest.it)("loads module exports", () => {
|
|
7
|
+
(0, vitest.expect)(require_get_unique.get_unique_exports).toBeDefined();
|
|
8
|
+
(0, vitest.expect)(typeof require_get_unique.get_unique_exports).toBe("object");
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { get_unique_exports } from "./get-unique.mjs";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
|
|
4
|
+
//#region src/get-unique.test.ts
|
|
5
|
+
describe("get-unique.ts exports", () => {
|
|
6
|
+
it("loads module exports", () => {
|
|
7
|
+
expect(get_unique_exports).toBeDefined();
|
|
8
|
+
expect(typeof get_unique_exports).toBe("object");
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { };
|
|
14
|
+
//# sourceMappingURL=get-unique.test.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-unique.test.mjs","names":["moduleExports"],"sources":["../src/get-unique.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport * as moduleExports from \"./get-unique.ts\";\n\ndescribe(\"get-unique.ts exports\", () => {\n it(\"loads module exports\", () => {\n expect(moduleExports).toBeDefined();\n expect(typeof moduleExports).toBe(\"object\");\n });\n});\n"],"mappings":";;;;AAGA,SAAS,+BAA+B;AACtC,IAAG,8BAA8B;AAC/B,SAAOA,mBAAc,CAAC,aAAa;AACnC,SAAO,OAAOA,mBAAc,CAAC,KAAK,SAAS;GAC3C;EACF"}
|
package/dist/identity.cjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
3
|
|
|
3
4
|
//#region src/identity.ts
|
|
5
|
+
var identity_exports = /* @__PURE__ */ require_runtime.__exportAll({ identity: () => identity });
|
|
4
6
|
/**
|
|
5
7
|
* Returns the input value unchanged.
|
|
6
8
|
*
|
|
@@ -19,4 +21,10 @@ function identity(x) {
|
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
//#endregion
|
|
22
|
-
exports.identity = identity;
|
|
24
|
+
exports.identity = identity;
|
|
25
|
+
Object.defineProperty(exports, 'identity_exports', {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return identity_exports;
|
|
29
|
+
}
|
|
30
|
+
});
|
package/dist/identity.mjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
|
|
1
3
|
//#region src/identity.ts
|
|
4
|
+
var identity_exports = /* @__PURE__ */ __exportAll({ identity: () => identity });
|
|
2
5
|
/**
|
|
3
6
|
* Returns the input value unchanged.
|
|
4
7
|
*
|
|
@@ -17,5 +20,5 @@ function identity(x) {
|
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
//#endregion
|
|
20
|
-
export { identity };
|
|
23
|
+
export { identity, identity_exports };
|
|
21
24
|
//# sourceMappingURL=identity.mjs.map
|
package/dist/identity.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.mjs","names":[],"sources":["../src/identity.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 * Returns the input value unchanged.\n *\n * @example\n * ```ts\n * identity(5); // Returns 5\n * identity('hello'); // Returns 'hello'\n * identity({ key: 'value' }); // Returns { key: 'value' }\n * ```\n *\n * @param x - The value to be returned.\n * @returns The input value.\n */\nexport function identity<T>(x: T): T {\n return x;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"identity.mjs","names":[],"sources":["../src/identity.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 * Returns the input value unchanged.\n *\n * @example\n * ```ts\n * identity(5); // Returns 5\n * identity('hello'); // Returns 'hello'\n * identity({ key: 'value' }); // Returns { key: 'value' }\n * ```\n *\n * @param x - The value to be returned.\n * @returns The input value.\n */\nexport function identity<T>(x: T): T {\n return x;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA+BA,SAAgB,SAAY,GAAS;AACnC,QAAO"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const require_identity = require('./identity.cjs');
|
|
2
|
+
let vitest = require("vitest");
|
|
3
|
+
|
|
4
|
+
//#region src/identity.test.ts
|
|
5
|
+
(0, vitest.describe)("identity.ts exports", () => {
|
|
6
|
+
(0, vitest.it)("loads module exports", () => {
|
|
7
|
+
(0, vitest.expect)(require_identity.identity_exports).toBeDefined();
|
|
8
|
+
(0, vitest.expect)(typeof require_identity.identity_exports).toBe("object");
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { identity_exports } from "./identity.mjs";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
|
|
4
|
+
//#region src/identity.test.ts
|
|
5
|
+
describe("identity.ts exports", () => {
|
|
6
|
+
it("loads module exports", () => {
|
|
7
|
+
expect(identity_exports).toBeDefined();
|
|
8
|
+
expect(typeof identity_exports).toBe("object");
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { };
|
|
14
|
+
//# sourceMappingURL=identity.test.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.test.mjs","names":["moduleExports"],"sources":["../src/identity.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport * as moduleExports from \"./identity.ts\";\n\ndescribe(\"identity.ts exports\", () => {\n it(\"loads module exports\", () => {\n expect(moduleExports).toBeDefined();\n expect(typeof moduleExports).toBe(\"object\");\n });\n});\n"],"mappings":";;;;AAGA,SAAS,6BAA6B;AACpC,IAAG,8BAA8B;AAC/B,SAAOA,iBAAc,CAAC,aAAa;AACnC,SAAO,OAAOA,iBAAc,CAAC,KAAK,SAAS;GAC3C;EACF"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
3
|
const require_arg_identity = require('./arg-identity.cjs');
|
|
3
4
|
const require_deep_clone = require('./deep-clone.cjs');
|
|
4
5
|
const require_deep_merge = require('./deep-merge.cjs');
|
|
@@ -23,6 +24,40 @@ const require_to_deep_key = require('./to-deep-key.cjs');
|
|
|
23
24
|
const require_unflatten_object = require('./unflatten-object.cjs');
|
|
24
25
|
const require_union = require('./union.cjs');
|
|
25
26
|
|
|
27
|
+
//#region src/index.ts
|
|
28
|
+
var src_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
29
|
+
LRUCache: () => require_lru_cache.LRUCache,
|
|
30
|
+
addPathToDeepKey: () => require_to_deep_key.addPathToDeepKey,
|
|
31
|
+
argIdentity: () => require_arg_identity.argIdentity,
|
|
32
|
+
asyncNoop: () => require_noop.asyncNoop,
|
|
33
|
+
characterMap: () => require_remove_accents.characterMap,
|
|
34
|
+
deepClone: () => require_deep_clone.deepClone,
|
|
35
|
+
deepMerge: () => require_deep_merge.deepMerge,
|
|
36
|
+
defaultBaseSortFn: () => require_match_sorter.defaultBaseSortFn,
|
|
37
|
+
filterEmpty: () => require_filter_empty.filterEmpty,
|
|
38
|
+
flattenObject: () => require_flatten_object.flattenObject,
|
|
39
|
+
getField: () => require_get_field.getField,
|
|
40
|
+
getOrderedBy: () => require_get_ordered_by.getOrderedBy,
|
|
41
|
+
getUnique: () => require_get_unique.getUnique,
|
|
42
|
+
getUniqueBy: () => require_get_unique.getUniqueBy,
|
|
43
|
+
identity: () => require_identity.identity,
|
|
44
|
+
isEqual: () => require_is_equal.isEqual,
|
|
45
|
+
matchSorter: () => require_match_sorter.matchSorter,
|
|
46
|
+
memoizeOnId: () => require_memoize.memoizeOnId,
|
|
47
|
+
noop: () => require_noop.noop,
|
|
48
|
+
omit: () => require_omit.omit,
|
|
49
|
+
pick: () => require_pick.pick,
|
|
50
|
+
rankings: () => require_match_sorter.rankings,
|
|
51
|
+
removeAccents: () => require_remove_accents.removeAccents,
|
|
52
|
+
removeEmptyItems: () => require_remove_empty_items.removeEmptyItems,
|
|
53
|
+
setField: () => require_set_field.setField,
|
|
54
|
+
toDeepKey: () => require_to_deep_key.toDeepKey,
|
|
55
|
+
toPath: () => require_to_path.toPath,
|
|
56
|
+
unflattenObject: () => require_unflatten_object.unflattenObject,
|
|
57
|
+
union: () => require_union.union
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
26
61
|
exports.LRUCache = require_lru_cache.LRUCache;
|
|
27
62
|
exports.addPathToDeepKey = require_to_deep_key.addPathToDeepKey;
|
|
28
63
|
exports.argIdentity = require_arg_identity.argIdentity;
|
|
@@ -48,6 +83,12 @@ exports.rankings = require_match_sorter.rankings;
|
|
|
48
83
|
exports.removeAccents = require_remove_accents.removeAccents;
|
|
49
84
|
exports.removeEmptyItems = require_remove_empty_items.removeEmptyItems;
|
|
50
85
|
exports.setField = require_set_field.setField;
|
|
86
|
+
Object.defineProperty(exports, 'src_exports', {
|
|
87
|
+
enumerable: true,
|
|
88
|
+
get: function () {
|
|
89
|
+
return src_exports;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
51
92
|
exports.toDeepKey = require_to_deep_key.toDeepKey;
|
|
52
93
|
exports.toPath = require_to_path.toPath;
|
|
53
94
|
exports.unflattenObject = require_unflatten_object.unflattenObject;
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
|
|
1
2
|
import { argIdentity } from "./arg-identity.mjs";
|
|
2
3
|
import { deepClone } from "./deep-clone.mjs";
|
|
3
4
|
import { deepMerge } from "./deep-merge.mjs";
|
|
@@ -22,4 +23,39 @@ import { addPathToDeepKey, toDeepKey } from "./to-deep-key.mjs";
|
|
|
22
23
|
import { unflattenObject } from "./unflatten-object.mjs";
|
|
23
24
|
import { union } from "./union.mjs";
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
//#region src/index.ts
|
|
27
|
+
var src_exports = /* @__PURE__ */ __exportAll({
|
|
28
|
+
LRUCache: () => LRUCache,
|
|
29
|
+
addPathToDeepKey: () => addPathToDeepKey,
|
|
30
|
+
argIdentity: () => argIdentity,
|
|
31
|
+
asyncNoop: () => asyncNoop,
|
|
32
|
+
characterMap: () => characterMap,
|
|
33
|
+
deepClone: () => deepClone,
|
|
34
|
+
deepMerge: () => deepMerge,
|
|
35
|
+
defaultBaseSortFn: () => defaultBaseSortFn,
|
|
36
|
+
filterEmpty: () => filterEmpty,
|
|
37
|
+
flattenObject: () => flattenObject,
|
|
38
|
+
getField: () => getField,
|
|
39
|
+
getOrderedBy: () => getOrderedBy,
|
|
40
|
+
getUnique: () => getUnique,
|
|
41
|
+
getUniqueBy: () => getUniqueBy,
|
|
42
|
+
identity: () => identity,
|
|
43
|
+
isEqual: () => isEqual,
|
|
44
|
+
matchSorter: () => matchSorter,
|
|
45
|
+
memoizeOnId: () => memoizeOnId,
|
|
46
|
+
noop: () => noop,
|
|
47
|
+
omit: () => omit,
|
|
48
|
+
pick: () => pick,
|
|
49
|
+
rankings: () => rankings,
|
|
50
|
+
removeAccents: () => removeAccents,
|
|
51
|
+
removeEmptyItems: () => removeEmptyItems,
|
|
52
|
+
setField: () => setField,
|
|
53
|
+
toDeepKey: () => toDeepKey,
|
|
54
|
+
toPath: () => toPath,
|
|
55
|
+
unflattenObject: () => unflattenObject,
|
|
56
|
+
union: () => union
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
export { LRUCache, addPathToDeepKey, argIdentity, asyncNoop, characterMap, deepClone, deepMerge, defaultBaseSortFn, filterEmpty, flattenObject, getField, getOrderedBy, getUnique, getUniqueBy, identity, isEqual, matchSorter, memoizeOnId, noop, omit, pick, rankings, removeAccents, removeEmptyItems, setField, src_exports, toDeepKey, toPath, unflattenObject, union };
|
|
61
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/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\nexport * from \"./arg-identity\";\nexport * from \"./deep-clone\";\nexport * from \"./deep-merge\";\nexport * from \"./filter-empty\";\nexport * from \"./flatten-object\";\nexport * from \"./get-field\";\nexport * from \"./get-ordered-by\";\nexport * from \"./get-unique\";\nexport * from \"./identity\";\nexport * from \"./is-equal\";\nexport * from \"./lru-cache\";\nexport * from \"./match-sorter\";\nexport * from \"./memoize\";\nexport * from \"./noop\";\nexport * from \"./omit\";\nexport * from \"./pick\";\nexport * from \"./remove-accents\";\nexport * from \"./remove-empty-items\";\nexport * from \"./set-field\";\nexport * from \"./to-deep-key\";\nexport * from \"./to-path\";\nexport * from \"./unflatten-object\";\nexport * from \"./union\";\n"],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const require_index = require('./index.cjs');
|
|
2
|
+
let vitest = require("vitest");
|
|
3
|
+
|
|
4
|
+
//#region src/index.test.ts
|
|
5
|
+
(0, vitest.describe)("index.ts exports", () => {
|
|
6
|
+
(0, vitest.it)("loads module exports", () => {
|
|
7
|
+
(0, vitest.expect)(require_index.src_exports).toBeDefined();
|
|
8
|
+
(0, vitest.expect)(typeof require_index.src_exports).toBe("object");
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { src_exports } from "./index.mjs";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
|
|
4
|
+
//#region src/index.test.ts
|
|
5
|
+
describe("index.ts exports", () => {
|
|
6
|
+
it("loads module exports", () => {
|
|
7
|
+
expect(src_exports).toBeDefined();
|
|
8
|
+
expect(typeof src_exports).toBe("object");
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { };
|
|
14
|
+
//# sourceMappingURL=index.test.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.mjs","names":["moduleExports"],"sources":["../src/index.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport * as moduleExports from \"./index.ts\";\n\ndescribe(\"index.ts exports\", () => {\n it(\"loads module exports\", () => {\n expect(moduleExports).toBeDefined();\n expect(typeof moduleExports).toBe(\"object\");\n });\n});\n"],"mappings":";;;;AAGA,SAAS,0BAA0B;AACjC,IAAG,8BAA8B;AAC/B,SAAOA,YAAc,CAAC,aAAa;AACnC,SAAO,OAAOA,YAAc,CAAC,KAAK,SAAS;GAC3C;EACF"}
|
package/dist/is-equal.cjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
3
|
let _stryke_type_checks_is_set = require("@stryke/type-checks/is-set");
|
|
3
4
|
let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
4
5
|
|
|
5
6
|
//#region src/is-equal.ts
|
|
7
|
+
var is_equal_exports = /* @__PURE__ */ require_runtime.__exportAll({ isEqual: () => isEqual });
|
|
6
8
|
const hasMap = typeof Map === "function";
|
|
7
9
|
const hasSet = typeof Set === "function";
|
|
8
10
|
const hasArrayBuffer = typeof ArrayBuffer === "function" && ArrayBuffer.isView !== void 0;
|
|
@@ -85,4 +87,10 @@ function isEqual(a, b) {
|
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
//#endregion
|
|
88
|
-
exports.isEqual = isEqual;
|
|
90
|
+
exports.isEqual = isEqual;
|
|
91
|
+
Object.defineProperty(exports, 'is_equal_exports', {
|
|
92
|
+
enumerable: true,
|
|
93
|
+
get: function () {
|
|
94
|
+
return is_equal_exports;
|
|
95
|
+
}
|
|
96
|
+
});
|
package/dist/is-equal.mjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
|
|
1
2
|
import { isSet } from "@stryke/type-checks/is-set";
|
|
2
3
|
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
3
4
|
|
|
4
5
|
//#region src/is-equal.ts
|
|
6
|
+
var is_equal_exports = /* @__PURE__ */ __exportAll({ isEqual: () => isEqual });
|
|
5
7
|
const hasMap = typeof Map === "function";
|
|
6
8
|
const hasSet = typeof Set === "function";
|
|
7
9
|
const hasArrayBuffer = typeof ArrayBuffer === "function" && ArrayBuffer.isView !== void 0;
|
|
@@ -84,5 +86,5 @@ function isEqual(a, b) {
|
|
|
84
86
|
}
|
|
85
87
|
|
|
86
88
|
//#endregion
|
|
87
|
-
export { isEqual };
|
|
89
|
+
export { isEqual, is_equal_exports };
|
|
88
90
|
//# sourceMappingURL=is-equal.mjs.map
|