Add settings page for managing forecasting API key and URL via UI
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
cae411eae7
commit
1c411e402e
19809 changed files with 1962608 additions and 97 deletions
32
frontend/node_modules/es-toolkit/dist/object/clone.d.mts
generated
vendored
Normal file
32
frontend/node_modules/es-toolkit/dist/object/clone.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
//#region src/object/clone.d.ts
|
||||
/**
|
||||
* Creates a shallow clone of the given object.
|
||||
*
|
||||
* @template T - The type of the object.
|
||||
* @param obj - The object to clone.
|
||||
* @returns A shallow clone of the given object.
|
||||
*
|
||||
* @example
|
||||
* // Clone a primitive value
|
||||
* const num = 29;
|
||||
* const clonedNum = clone(num);
|
||||
* console.log(clonedNum); // 29
|
||||
* console.log(clonedNum === num); // true
|
||||
*
|
||||
* @example
|
||||
* // Clone an array
|
||||
* const arr = [1, 2, 3];
|
||||
* const clonedArr = clone(arr);
|
||||
* console.log(clonedArr); // [1, 2, 3]
|
||||
* console.log(clonedArr === arr); // false
|
||||
*
|
||||
* @example
|
||||
* // Clone an object
|
||||
* const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };
|
||||
* const clonedObj = clone(obj);
|
||||
* console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }
|
||||
* console.log(clonedObj === obj); // false
|
||||
*/
|
||||
declare function clone<T>(obj: T): T;
|
||||
//#endregion
|
||||
export { clone };
|
||||
32
frontend/node_modules/es-toolkit/dist/object/clone.d.ts
generated
vendored
Normal file
32
frontend/node_modules/es-toolkit/dist/object/clone.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
//#region src/object/clone.d.ts
|
||||
/**
|
||||
* Creates a shallow clone of the given object.
|
||||
*
|
||||
* @template T - The type of the object.
|
||||
* @param obj - The object to clone.
|
||||
* @returns A shallow clone of the given object.
|
||||
*
|
||||
* @example
|
||||
* // Clone a primitive value
|
||||
* const num = 29;
|
||||
* const clonedNum = clone(num);
|
||||
* console.log(clonedNum); // 29
|
||||
* console.log(clonedNum === num); // true
|
||||
*
|
||||
* @example
|
||||
* // Clone an array
|
||||
* const arr = [1, 2, 3];
|
||||
* const clonedArr = clone(arr);
|
||||
* console.log(clonedArr); // [1, 2, 3]
|
||||
* console.log(clonedArr === arr); // false
|
||||
*
|
||||
* @example
|
||||
* // Clone an object
|
||||
* const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };
|
||||
* const clonedObj = clone(obj);
|
||||
* console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }
|
||||
* console.log(clonedObj === obj); // false
|
||||
*/
|
||||
declare function clone<T>(obj: T): T;
|
||||
//#endregion
|
||||
export { clone };
|
||||
61
frontend/node_modules/es-toolkit/dist/object/clone.js
generated
vendored
Normal file
61
frontend/node_modules/es-toolkit/dist/object/clone.js
generated
vendored
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
const require_isPrimitive = require("../predicate/isPrimitive.js");
|
||||
const require_isTypedArray = require("../predicate/isTypedArray.js");
|
||||
//#region src/object/clone.ts
|
||||
/**
|
||||
* Creates a shallow clone of the given object.
|
||||
*
|
||||
* @template T - The type of the object.
|
||||
* @param obj - The object to clone.
|
||||
* @returns A shallow clone of the given object.
|
||||
*
|
||||
* @example
|
||||
* // Clone a primitive value
|
||||
* const num = 29;
|
||||
* const clonedNum = clone(num);
|
||||
* console.log(clonedNum); // 29
|
||||
* console.log(clonedNum === num); // true
|
||||
*
|
||||
* @example
|
||||
* // Clone an array
|
||||
* const arr = [1, 2, 3];
|
||||
* const clonedArr = clone(arr);
|
||||
* console.log(clonedArr); // [1, 2, 3]
|
||||
* console.log(clonedArr === arr); // false
|
||||
*
|
||||
* @example
|
||||
* // Clone an object
|
||||
* const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };
|
||||
* const clonedObj = clone(obj);
|
||||
* console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }
|
||||
* console.log(clonedObj === obj); // false
|
||||
*/
|
||||
function clone(obj) {
|
||||
if (require_isPrimitive.isPrimitive(obj)) return obj;
|
||||
if (Array.isArray(obj) || require_isTypedArray.isTypedArray(obj) || obj instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && obj instanceof SharedArrayBuffer) return obj.slice(0);
|
||||
const prototype = Object.getPrototypeOf(obj);
|
||||
if (prototype == null) return Object.assign(Object.create(prototype), obj);
|
||||
const Constructor = prototype.constructor;
|
||||
if (obj instanceof Date || obj instanceof Map || obj instanceof Set) return new Constructor(obj);
|
||||
if (obj instanceof RegExp) {
|
||||
const newRegExp = new Constructor(obj);
|
||||
newRegExp.lastIndex = obj.lastIndex;
|
||||
return newRegExp;
|
||||
}
|
||||
if (obj instanceof DataView) return new Constructor(obj.buffer.slice(0));
|
||||
if (obj instanceof Error) {
|
||||
let newError;
|
||||
if (obj instanceof AggregateError) newError = new Constructor(obj.errors, obj.message, { cause: obj.cause });
|
||||
else newError = new Constructor(obj.message, { cause: obj.cause });
|
||||
newError.stack = obj.stack;
|
||||
Object.assign(newError, obj);
|
||||
return newError;
|
||||
}
|
||||
if (typeof File !== "undefined" && obj instanceof File) return new Constructor([obj], obj.name, {
|
||||
type: obj.type,
|
||||
lastModified: obj.lastModified
|
||||
});
|
||||
if (typeof obj === "object") return Object.assign(Object.create(prototype), obj);
|
||||
return obj;
|
||||
}
|
||||
//#endregion
|
||||
exports.clone = clone;
|
||||
61
frontend/node_modules/es-toolkit/dist/object/clone.mjs
generated
vendored
Normal file
61
frontend/node_modules/es-toolkit/dist/object/clone.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
import { isPrimitive } from "../predicate/isPrimitive.mjs";
|
||||
import { isTypedArray } from "../predicate/isTypedArray.mjs";
|
||||
//#region src/object/clone.ts
|
||||
/**
|
||||
* Creates a shallow clone of the given object.
|
||||
*
|
||||
* @template T - The type of the object.
|
||||
* @param obj - The object to clone.
|
||||
* @returns A shallow clone of the given object.
|
||||
*
|
||||
* @example
|
||||
* // Clone a primitive value
|
||||
* const num = 29;
|
||||
* const clonedNum = clone(num);
|
||||
* console.log(clonedNum); // 29
|
||||
* console.log(clonedNum === num); // true
|
||||
*
|
||||
* @example
|
||||
* // Clone an array
|
||||
* const arr = [1, 2, 3];
|
||||
* const clonedArr = clone(arr);
|
||||
* console.log(clonedArr); // [1, 2, 3]
|
||||
* console.log(clonedArr === arr); // false
|
||||
*
|
||||
* @example
|
||||
* // Clone an object
|
||||
* const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };
|
||||
* const clonedObj = clone(obj);
|
||||
* console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }
|
||||
* console.log(clonedObj === obj); // false
|
||||
*/
|
||||
function clone(obj) {
|
||||
if (isPrimitive(obj)) return obj;
|
||||
if (Array.isArray(obj) || isTypedArray(obj) || obj instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && obj instanceof SharedArrayBuffer) return obj.slice(0);
|
||||
const prototype = Object.getPrototypeOf(obj);
|
||||
if (prototype == null) return Object.assign(Object.create(prototype), obj);
|
||||
const Constructor = prototype.constructor;
|
||||
if (obj instanceof Date || obj instanceof Map || obj instanceof Set) return new Constructor(obj);
|
||||
if (obj instanceof RegExp) {
|
||||
const newRegExp = new Constructor(obj);
|
||||
newRegExp.lastIndex = obj.lastIndex;
|
||||
return newRegExp;
|
||||
}
|
||||
if (obj instanceof DataView) return new Constructor(obj.buffer.slice(0));
|
||||
if (obj instanceof Error) {
|
||||
let newError;
|
||||
if (obj instanceof AggregateError) newError = new Constructor(obj.errors, obj.message, { cause: obj.cause });
|
||||
else newError = new Constructor(obj.message, { cause: obj.cause });
|
||||
newError.stack = obj.stack;
|
||||
Object.assign(newError, obj);
|
||||
return newError;
|
||||
}
|
||||
if (typeof File !== "undefined" && obj instanceof File) return new Constructor([obj], obj.name, {
|
||||
type: obj.type,
|
||||
lastModified: obj.lastModified
|
||||
});
|
||||
if (typeof obj === "object") return Object.assign(Object.create(prototype), obj);
|
||||
return obj;
|
||||
}
|
||||
//#endregion
|
||||
export { clone };
|
||||
50
frontend/node_modules/es-toolkit/dist/object/cloneDeep.d.mts
generated
vendored
Normal file
50
frontend/node_modules/es-toolkit/dist/object/cloneDeep.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
//#region src/object/cloneDeep.d.ts
|
||||
/**
|
||||
* Creates a deep clone of the given object.
|
||||
*
|
||||
* @template T - The type of the object.
|
||||
* @param obj - The object to clone.
|
||||
* @returns A deep clone of the given object.
|
||||
*
|
||||
* @example
|
||||
* // Clone a primitive value
|
||||
* const num = 29;
|
||||
* const clonedNum = cloneDeep(num);
|
||||
* console.log(clonedNum); // 29
|
||||
* console.log(clonedNum === num); // true
|
||||
*
|
||||
* @example
|
||||
* // Clone an array
|
||||
* const arr = [1, 2, 3];
|
||||
* const clonedArr = cloneDeep(arr);
|
||||
* console.log(clonedArr); // [1, 2, 3]
|
||||
* console.log(clonedArr === arr); // false
|
||||
*
|
||||
* @example
|
||||
* // Clone an array with nested objects
|
||||
* const arr = [1, { a: 1 }, [1, 2, 3]];
|
||||
* const clonedArr = cloneDeep(arr);
|
||||
* arr[1].a = 2;
|
||||
* console.log(arr); // [1, { a: 2 }, [1, 2, 3]]
|
||||
* console.log(clonedArr); // [1, { a: 1 }, [1, 2, 3]]
|
||||
* console.log(clonedArr === arr); // false
|
||||
*
|
||||
* @example
|
||||
* // Clone an object
|
||||
* const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };
|
||||
* const clonedObj = cloneDeep(obj);
|
||||
* console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }
|
||||
* console.log(clonedObj === obj); // false
|
||||
*
|
||||
* @example
|
||||
* // Clone an object with nested objects
|
||||
* const obj = { a: 1, b: { c: 1 } };
|
||||
* const clonedObj = cloneDeep(obj);
|
||||
* obj.b.c = 2;
|
||||
* console.log(obj); // { a: 1, b: { c: 2 } }
|
||||
* console.log(clonedObj); // { a: 1, b: { c: 1 } }
|
||||
* console.log(clonedObj === obj); // false
|
||||
*/
|
||||
declare function cloneDeep<T>(obj: T): T;
|
||||
//#endregion
|
||||
export { cloneDeep };
|
||||
50
frontend/node_modules/es-toolkit/dist/object/cloneDeep.d.ts
generated
vendored
Normal file
50
frontend/node_modules/es-toolkit/dist/object/cloneDeep.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
//#region src/object/cloneDeep.d.ts
|
||||
/**
|
||||
* Creates a deep clone of the given object.
|
||||
*
|
||||
* @template T - The type of the object.
|
||||
* @param obj - The object to clone.
|
||||
* @returns A deep clone of the given object.
|
||||
*
|
||||
* @example
|
||||
* // Clone a primitive value
|
||||
* const num = 29;
|
||||
* const clonedNum = cloneDeep(num);
|
||||
* console.log(clonedNum); // 29
|
||||
* console.log(clonedNum === num); // true
|
||||
*
|
||||
* @example
|
||||
* // Clone an array
|
||||
* const arr = [1, 2, 3];
|
||||
* const clonedArr = cloneDeep(arr);
|
||||
* console.log(clonedArr); // [1, 2, 3]
|
||||
* console.log(clonedArr === arr); // false
|
||||
*
|
||||
* @example
|
||||
* // Clone an array with nested objects
|
||||
* const arr = [1, { a: 1 }, [1, 2, 3]];
|
||||
* const clonedArr = cloneDeep(arr);
|
||||
* arr[1].a = 2;
|
||||
* console.log(arr); // [1, { a: 2 }, [1, 2, 3]]
|
||||
* console.log(clonedArr); // [1, { a: 1 }, [1, 2, 3]]
|
||||
* console.log(clonedArr === arr); // false
|
||||
*
|
||||
* @example
|
||||
* // Clone an object
|
||||
* const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };
|
||||
* const clonedObj = cloneDeep(obj);
|
||||
* console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }
|
||||
* console.log(clonedObj === obj); // false
|
||||
*
|
||||
* @example
|
||||
* // Clone an object with nested objects
|
||||
* const obj = { a: 1, b: { c: 1 } };
|
||||
* const clonedObj = cloneDeep(obj);
|
||||
* obj.b.c = 2;
|
||||
* console.log(obj); // { a: 1, b: { c: 2 } }
|
||||
* console.log(clonedObj); // { a: 1, b: { c: 1 } }
|
||||
* console.log(clonedObj === obj); // false
|
||||
*/
|
||||
declare function cloneDeep<T>(obj: T): T;
|
||||
//#endregion
|
||||
export { cloneDeep };
|
||||
53
frontend/node_modules/es-toolkit/dist/object/cloneDeep.js
generated
vendored
Normal file
53
frontend/node_modules/es-toolkit/dist/object/cloneDeep.js
generated
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
const require_cloneDeepWith = require("./cloneDeepWith.js");
|
||||
//#region src/object/cloneDeep.ts
|
||||
/**
|
||||
* Creates a deep clone of the given object.
|
||||
*
|
||||
* @template T - The type of the object.
|
||||
* @param obj - The object to clone.
|
||||
* @returns A deep clone of the given object.
|
||||
*
|
||||
* @example
|
||||
* // Clone a primitive value
|
||||
* const num = 29;
|
||||
* const clonedNum = cloneDeep(num);
|
||||
* console.log(clonedNum); // 29
|
||||
* console.log(clonedNum === num); // true
|
||||
*
|
||||
* @example
|
||||
* // Clone an array
|
||||
* const arr = [1, 2, 3];
|
||||
* const clonedArr = cloneDeep(arr);
|
||||
* console.log(clonedArr); // [1, 2, 3]
|
||||
* console.log(clonedArr === arr); // false
|
||||
*
|
||||
* @example
|
||||
* // Clone an array with nested objects
|
||||
* const arr = [1, { a: 1 }, [1, 2, 3]];
|
||||
* const clonedArr = cloneDeep(arr);
|
||||
* arr[1].a = 2;
|
||||
* console.log(arr); // [1, { a: 2 }, [1, 2, 3]]
|
||||
* console.log(clonedArr); // [1, { a: 1 }, [1, 2, 3]]
|
||||
* console.log(clonedArr === arr); // false
|
||||
*
|
||||
* @example
|
||||
* // Clone an object
|
||||
* const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };
|
||||
* const clonedObj = cloneDeep(obj);
|
||||
* console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }
|
||||
* console.log(clonedObj === obj); // false
|
||||
*
|
||||
* @example
|
||||
* // Clone an object with nested objects
|
||||
* const obj = { a: 1, b: { c: 1 } };
|
||||
* const clonedObj = cloneDeep(obj);
|
||||
* obj.b.c = 2;
|
||||
* console.log(obj); // { a: 1, b: { c: 2 } }
|
||||
* console.log(clonedObj); // { a: 1, b: { c: 1 } }
|
||||
* console.log(clonedObj === obj); // false
|
||||
*/
|
||||
function cloneDeep(obj) {
|
||||
return require_cloneDeepWith.cloneDeepWithImpl(obj, void 0, obj, /* @__PURE__ */ new Map(), void 0);
|
||||
}
|
||||
//#endregion
|
||||
exports.cloneDeep = cloneDeep;
|
||||
53
frontend/node_modules/es-toolkit/dist/object/cloneDeep.mjs
generated
vendored
Normal file
53
frontend/node_modules/es-toolkit/dist/object/cloneDeep.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
import { cloneDeepWithImpl } from "./cloneDeepWith.mjs";
|
||||
//#region src/object/cloneDeep.ts
|
||||
/**
|
||||
* Creates a deep clone of the given object.
|
||||
*
|
||||
* @template T - The type of the object.
|
||||
* @param obj - The object to clone.
|
||||
* @returns A deep clone of the given object.
|
||||
*
|
||||
* @example
|
||||
* // Clone a primitive value
|
||||
* const num = 29;
|
||||
* const clonedNum = cloneDeep(num);
|
||||
* console.log(clonedNum); // 29
|
||||
* console.log(clonedNum === num); // true
|
||||
*
|
||||
* @example
|
||||
* // Clone an array
|
||||
* const arr = [1, 2, 3];
|
||||
* const clonedArr = cloneDeep(arr);
|
||||
* console.log(clonedArr); // [1, 2, 3]
|
||||
* console.log(clonedArr === arr); // false
|
||||
*
|
||||
* @example
|
||||
* // Clone an array with nested objects
|
||||
* const arr = [1, { a: 1 }, [1, 2, 3]];
|
||||
* const clonedArr = cloneDeep(arr);
|
||||
* arr[1].a = 2;
|
||||
* console.log(arr); // [1, { a: 2 }, [1, 2, 3]]
|
||||
* console.log(clonedArr); // [1, { a: 1 }, [1, 2, 3]]
|
||||
* console.log(clonedArr === arr); // false
|
||||
*
|
||||
* @example
|
||||
* // Clone an object
|
||||
* const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };
|
||||
* const clonedObj = cloneDeep(obj);
|
||||
* console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }
|
||||
* console.log(clonedObj === obj); // false
|
||||
*
|
||||
* @example
|
||||
* // Clone an object with nested objects
|
||||
* const obj = { a: 1, b: { c: 1 } };
|
||||
* const clonedObj = cloneDeep(obj);
|
||||
* obj.b.c = 2;
|
||||
* console.log(obj); // { a: 1, b: { c: 2 } }
|
||||
* console.log(clonedObj); // { a: 1, b: { c: 1 } }
|
||||
* console.log(clonedObj === obj); // false
|
||||
*/
|
||||
function cloneDeep(obj) {
|
||||
return cloneDeepWithImpl(obj, void 0, obj, /* @__PURE__ */ new Map(), void 0);
|
||||
}
|
||||
//#endregion
|
||||
export { cloneDeep };
|
||||
46
frontend/node_modules/es-toolkit/dist/object/cloneDeepWith.d.mts
generated
vendored
Normal file
46
frontend/node_modules/es-toolkit/dist/object/cloneDeepWith.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
//#region src/object/cloneDeepWith.d.ts
|
||||
/**
|
||||
* Deeply clones the given object.
|
||||
*
|
||||
* You can customize the deep cloning process using the `cloneValue` function.
|
||||
* The function takes the current value `value`, the property name `key`, and the entire object `obj` as arguments.
|
||||
* If the function returns a value, that value is used;
|
||||
* if it returns `undefined`, the default cloning method is used.
|
||||
*
|
||||
* @template T - The type of the object.
|
||||
* @param obj - The object to clone.
|
||||
* @param [cloneValue] - A function to customize the cloning process.
|
||||
* @returns A deep clone of the given object.
|
||||
*
|
||||
* @example
|
||||
* // Clone a primitive value
|
||||
* const num = 29;
|
||||
* const clonedNum = cloneDeepWith(num);
|
||||
* console.log(clonedNum); // 29
|
||||
* console.log(clonedNum === num); // true
|
||||
*
|
||||
* @example
|
||||
* // Clone an object with a customizer
|
||||
* const obj = { a: 1, b: 2 };
|
||||
* const clonedObj = cloneDeepWith(obj, (value) => {
|
||||
* if (typeof value === 'number') {
|
||||
* return value * 2; // Double the number
|
||||
* }
|
||||
* });
|
||||
* console.log(clonedObj); // { a: 2, b: 4 }
|
||||
* console.log(clonedObj === obj); // false
|
||||
*
|
||||
* @example
|
||||
* // Clone an array with a customizer
|
||||
* const arr = [1, 2, 3];
|
||||
* const clonedArr = cloneDeepWith(arr, (value) => {
|
||||
* return value + 1; // Increment each value
|
||||
* });
|
||||
* console.log(clonedArr); // [2, 3, 4]
|
||||
* console.log(clonedArr === arr); // false
|
||||
*/
|
||||
declare function cloneDeepWith<T>(obj: T, cloneValue: (value: any, key: PropertyKey | undefined, obj: T, stack: Map<any, any>) => any): T;
|
||||
declare function cloneDeepWithImpl<T>(valueToClone: any, keyToClone: PropertyKey | undefined, objectToClone: T, stack?: Map<any, any>, cloneValue?: ((value: any, key: PropertyKey | undefined, obj: T, stack: Map<any, any>) => any) | undefined): T;
|
||||
declare function copyProperties<T>(target: any, source: any, objectToClone?: T, stack?: Map<any, any> | undefined, cloneValue?: ((value: any, key: PropertyKey | undefined, obj: T, stack: Map<any, any>) => any) | undefined): void;
|
||||
//#endregion
|
||||
export { cloneDeepWith };
|
||||
46
frontend/node_modules/es-toolkit/dist/object/cloneDeepWith.d.ts
generated
vendored
Normal file
46
frontend/node_modules/es-toolkit/dist/object/cloneDeepWith.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
//#region src/object/cloneDeepWith.d.ts
|
||||
/**
|
||||
* Deeply clones the given object.
|
||||
*
|
||||
* You can customize the deep cloning process using the `cloneValue` function.
|
||||
* The function takes the current value `value`, the property name `key`, and the entire object `obj` as arguments.
|
||||
* If the function returns a value, that value is used;
|
||||
* if it returns `undefined`, the default cloning method is used.
|
||||
*
|
||||
* @template T - The type of the object.
|
||||
* @param obj - The object to clone.
|
||||
* @param [cloneValue] - A function to customize the cloning process.
|
||||
* @returns A deep clone of the given object.
|
||||
*
|
||||
* @example
|
||||
* // Clone a primitive value
|
||||
* const num = 29;
|
||||
* const clonedNum = cloneDeepWith(num);
|
||||
* console.log(clonedNum); // 29
|
||||
* console.log(clonedNum === num); // true
|
||||
*
|
||||
* @example
|
||||
* // Clone an object with a customizer
|
||||
* const obj = { a: 1, b: 2 };
|
||||
* const clonedObj = cloneDeepWith(obj, (value) => {
|
||||
* if (typeof value === 'number') {
|
||||
* return value * 2; // Double the number
|
||||
* }
|
||||
* });
|
||||
* console.log(clonedObj); // { a: 2, b: 4 }
|
||||
* console.log(clonedObj === obj); // false
|
||||
*
|
||||
* @example
|
||||
* // Clone an array with a customizer
|
||||
* const arr = [1, 2, 3];
|
||||
* const clonedArr = cloneDeepWith(arr, (value) => {
|
||||
* return value + 1; // Increment each value
|
||||
* });
|
||||
* console.log(clonedArr); // [2, 3, 4]
|
||||
* console.log(clonedArr === arr); // false
|
||||
*/
|
||||
declare function cloneDeepWith<T>(obj: T, cloneValue: (value: any, key: PropertyKey | undefined, obj: T, stack: Map<any, any>) => any): T;
|
||||
declare function cloneDeepWithImpl<T>(valueToClone: any, keyToClone: PropertyKey | undefined, objectToClone: T, stack?: Map<any, any>, cloneValue?: ((value: any, key: PropertyKey | undefined, obj: T, stack: Map<any, any>) => any) | undefined): T;
|
||||
declare function copyProperties<T>(target: any, source: any, objectToClone?: T, stack?: Map<any, any> | undefined, cloneValue?: ((value: any, key: PropertyKey | undefined, obj: T, stack: Map<any, any>) => any) | undefined): void;
|
||||
//#endregion
|
||||
export { cloneDeepWith };
|
||||
183
frontend/node_modules/es-toolkit/dist/object/cloneDeepWith.js
generated
vendored
Normal file
183
frontend/node_modules/es-toolkit/dist/object/cloneDeepWith.js
generated
vendored
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
const require_isPrimitive = require("../predicate/isPrimitive.js");
|
||||
const require_isTypedArray = require("../predicate/isTypedArray.js");
|
||||
const require_getSymbols = require("../compat/_internal/getSymbols.js");
|
||||
const require_getTag = require("../compat/_internal/getTag.js");
|
||||
const require_tags = require("../compat/_internal/tags.js");
|
||||
const require_isBuffer = require("../predicate/isBuffer.js");
|
||||
//#region src/object/cloneDeepWith.ts
|
||||
/**
|
||||
* Deeply clones the given object.
|
||||
*
|
||||
* You can customize the deep cloning process using the `cloneValue` function.
|
||||
* The function takes the current value `value`, the property name `key`, and the entire object `obj` as arguments.
|
||||
* If the function returns a value, that value is used;
|
||||
* if it returns `undefined`, the default cloning method is used.
|
||||
*
|
||||
* @template T - The type of the object.
|
||||
* @param obj - The object to clone.
|
||||
* @param [cloneValue] - A function to customize the cloning process.
|
||||
* @returns A deep clone of the given object.
|
||||
*
|
||||
* @example
|
||||
* // Clone a primitive value
|
||||
* const num = 29;
|
||||
* const clonedNum = cloneDeepWith(num);
|
||||
* console.log(clonedNum); // 29
|
||||
* console.log(clonedNum === num); // true
|
||||
*
|
||||
* @example
|
||||
* // Clone an object with a customizer
|
||||
* const obj = { a: 1, b: 2 };
|
||||
* const clonedObj = cloneDeepWith(obj, (value) => {
|
||||
* if (typeof value === 'number') {
|
||||
* return value * 2; // Double the number
|
||||
* }
|
||||
* });
|
||||
* console.log(clonedObj); // { a: 2, b: 4 }
|
||||
* console.log(clonedObj === obj); // false
|
||||
*
|
||||
* @example
|
||||
* // Clone an array with a customizer
|
||||
* const arr = [1, 2, 3];
|
||||
* const clonedArr = cloneDeepWith(arr, (value) => {
|
||||
* return value + 1; // Increment each value
|
||||
* });
|
||||
* console.log(clonedArr); // [2, 3, 4]
|
||||
* console.log(clonedArr === arr); // false
|
||||
*/
|
||||
function cloneDeepWith(obj, cloneValue) {
|
||||
return cloneDeepWithImpl(obj, void 0, obj, /* @__PURE__ */ new Map(), cloneValue);
|
||||
}
|
||||
function cloneDeepWithImpl(valueToClone, keyToClone, objectToClone, stack = /* @__PURE__ */ new Map(), cloneValue = void 0) {
|
||||
const cloned = cloneValue?.(valueToClone, keyToClone, objectToClone, stack);
|
||||
if (cloned !== void 0) return cloned;
|
||||
if (require_isPrimitive.isPrimitive(valueToClone)) return valueToClone;
|
||||
if (stack.has(valueToClone)) return stack.get(valueToClone);
|
||||
if (Array.isArray(valueToClone)) {
|
||||
const result = new Array(valueToClone.length);
|
||||
stack.set(valueToClone, result);
|
||||
for (let i = 0; i < valueToClone.length; i++) result[i] = cloneDeepWithImpl(valueToClone[i], i, objectToClone, stack, cloneValue);
|
||||
if (Object.hasOwn(valueToClone, "index")) result.index = valueToClone.index;
|
||||
if (Object.hasOwn(valueToClone, "input")) result.input = valueToClone.input;
|
||||
return result;
|
||||
}
|
||||
if (valueToClone instanceof Date) return new Date(valueToClone.getTime());
|
||||
if (valueToClone instanceof RegExp) {
|
||||
const result = new RegExp(valueToClone.source, valueToClone.flags);
|
||||
result.lastIndex = valueToClone.lastIndex;
|
||||
return result;
|
||||
}
|
||||
if (valueToClone instanceof Map) {
|
||||
const result = /* @__PURE__ */ new Map();
|
||||
stack.set(valueToClone, result);
|
||||
for (const [key, value] of valueToClone) result.set(key, cloneDeepWithImpl(value, key, objectToClone, stack, cloneValue));
|
||||
return result;
|
||||
}
|
||||
if (valueToClone instanceof Set) {
|
||||
const result = /* @__PURE__ */ new Set();
|
||||
stack.set(valueToClone, result);
|
||||
for (const value of valueToClone) result.add(cloneDeepWithImpl(value, void 0, objectToClone, stack, cloneValue));
|
||||
return result;
|
||||
}
|
||||
if (require_isBuffer.isBuffer(valueToClone)) return valueToClone.subarray();
|
||||
if (require_isTypedArray.isTypedArray(valueToClone)) {
|
||||
const result = new (Object.getPrototypeOf(valueToClone)).constructor(valueToClone.length);
|
||||
stack.set(valueToClone, result);
|
||||
for (let i = 0; i < valueToClone.length; i++) result[i] = cloneDeepWithImpl(valueToClone[i], i, objectToClone, stack, cloneValue);
|
||||
return result;
|
||||
}
|
||||
if (valueToClone instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && valueToClone instanceof SharedArrayBuffer) return valueToClone.slice(0);
|
||||
if (valueToClone instanceof DataView) {
|
||||
const result = new DataView(valueToClone.buffer.slice(0), valueToClone.byteOffset, valueToClone.byteLength);
|
||||
stack.set(valueToClone, result);
|
||||
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
||||
return result;
|
||||
}
|
||||
if (typeof File !== "undefined" && valueToClone instanceof File) {
|
||||
const result = new File([valueToClone], valueToClone.name, { type: valueToClone.type });
|
||||
stack.set(valueToClone, result);
|
||||
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
||||
return result;
|
||||
}
|
||||
if (typeof Blob !== "undefined" && valueToClone instanceof Blob) {
|
||||
const result = new Blob([valueToClone], { type: valueToClone.type });
|
||||
stack.set(valueToClone, result);
|
||||
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
||||
return result;
|
||||
}
|
||||
if (valueToClone instanceof Error) {
|
||||
const result = structuredClone(valueToClone);
|
||||
stack.set(valueToClone, result);
|
||||
result.message = valueToClone.message;
|
||||
result.name = valueToClone.name;
|
||||
result.stack = valueToClone.stack;
|
||||
result.cause = valueToClone.cause;
|
||||
result.constructor = valueToClone.constructor;
|
||||
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
||||
return result;
|
||||
}
|
||||
if (valueToClone instanceof Boolean) {
|
||||
const result = new Boolean(valueToClone.valueOf());
|
||||
stack.set(valueToClone, result);
|
||||
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
||||
return result;
|
||||
}
|
||||
if (valueToClone instanceof Number) {
|
||||
const result = new Number(valueToClone.valueOf());
|
||||
stack.set(valueToClone, result);
|
||||
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
||||
return result;
|
||||
}
|
||||
if (valueToClone instanceof String) {
|
||||
const result = new String(valueToClone.valueOf());
|
||||
stack.set(valueToClone, result);
|
||||
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
||||
return result;
|
||||
}
|
||||
if (typeof valueToClone === "object" && isCloneableObject(valueToClone)) {
|
||||
const result = Object.create(Object.getPrototypeOf(valueToClone));
|
||||
stack.set(valueToClone, result);
|
||||
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
||||
return result;
|
||||
}
|
||||
return valueToClone;
|
||||
}
|
||||
function copyProperties(target, source, objectToClone = target, stack, cloneValue) {
|
||||
const keys = [...Object.keys(source), ...require_getSymbols.getSymbols(source)];
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
const descriptor = Object.getOwnPropertyDescriptor(target, key);
|
||||
if (descriptor == null || descriptor.writable) target[key] = cloneDeepWithImpl(source[key], key, objectToClone, stack, cloneValue);
|
||||
}
|
||||
}
|
||||
function isCloneableObject(object) {
|
||||
switch (require_getTag.getTag(object)) {
|
||||
case require_tags.argumentsTag:
|
||||
case require_tags.arrayTag:
|
||||
case require_tags.arrayBufferTag:
|
||||
case require_tags.dataViewTag:
|
||||
case require_tags.booleanTag:
|
||||
case require_tags.dateTag:
|
||||
case require_tags.float32ArrayTag:
|
||||
case require_tags.float64ArrayTag:
|
||||
case require_tags.int8ArrayTag:
|
||||
case require_tags.int16ArrayTag:
|
||||
case require_tags.int32ArrayTag:
|
||||
case require_tags.mapTag:
|
||||
case require_tags.numberTag:
|
||||
case require_tags.objectTag:
|
||||
case require_tags.regexpTag:
|
||||
case require_tags.setTag:
|
||||
case require_tags.stringTag:
|
||||
case require_tags.symbolTag:
|
||||
case require_tags.uint8ArrayTag:
|
||||
case require_tags.uint8ClampedArrayTag:
|
||||
case require_tags.uint16ArrayTag:
|
||||
case require_tags.uint32ArrayTag: return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
//#endregion
|
||||
exports.cloneDeepWith = cloneDeepWith;
|
||||
exports.cloneDeepWithImpl = cloneDeepWithImpl;
|
||||
exports.copyProperties = copyProperties;
|
||||
181
frontend/node_modules/es-toolkit/dist/object/cloneDeepWith.mjs
generated
vendored
Normal file
181
frontend/node_modules/es-toolkit/dist/object/cloneDeepWith.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,181 @@
|
|||
import { isPrimitive } from "../predicate/isPrimitive.mjs";
|
||||
import { isTypedArray } from "../predicate/isTypedArray.mjs";
|
||||
import { getSymbols } from "../compat/_internal/getSymbols.mjs";
|
||||
import { getTag } from "../compat/_internal/getTag.mjs";
|
||||
import { argumentsTag, arrayBufferTag, arrayTag, booleanTag, dataViewTag, dateTag, float32ArrayTag, float64ArrayTag, int16ArrayTag, int32ArrayTag, int8ArrayTag, mapTag, numberTag, objectTag, regexpTag, setTag, stringTag, symbolTag, uint16ArrayTag, uint32ArrayTag, uint8ArrayTag, uint8ClampedArrayTag } from "../compat/_internal/tags.mjs";
|
||||
import { isBuffer } from "../predicate/isBuffer.mjs";
|
||||
//#region src/object/cloneDeepWith.ts
|
||||
/**
|
||||
* Deeply clones the given object.
|
||||
*
|
||||
* You can customize the deep cloning process using the `cloneValue` function.
|
||||
* The function takes the current value `value`, the property name `key`, and the entire object `obj` as arguments.
|
||||
* If the function returns a value, that value is used;
|
||||
* if it returns `undefined`, the default cloning method is used.
|
||||
*
|
||||
* @template T - The type of the object.
|
||||
* @param obj - The object to clone.
|
||||
* @param [cloneValue] - A function to customize the cloning process.
|
||||
* @returns A deep clone of the given object.
|
||||
*
|
||||
* @example
|
||||
* // Clone a primitive value
|
||||
* const num = 29;
|
||||
* const clonedNum = cloneDeepWith(num);
|
||||
* console.log(clonedNum); // 29
|
||||
* console.log(clonedNum === num); // true
|
||||
*
|
||||
* @example
|
||||
* // Clone an object with a customizer
|
||||
* const obj = { a: 1, b: 2 };
|
||||
* const clonedObj = cloneDeepWith(obj, (value) => {
|
||||
* if (typeof value === 'number') {
|
||||
* return value * 2; // Double the number
|
||||
* }
|
||||
* });
|
||||
* console.log(clonedObj); // { a: 2, b: 4 }
|
||||
* console.log(clonedObj === obj); // false
|
||||
*
|
||||
* @example
|
||||
* // Clone an array with a customizer
|
||||
* const arr = [1, 2, 3];
|
||||
* const clonedArr = cloneDeepWith(arr, (value) => {
|
||||
* return value + 1; // Increment each value
|
||||
* });
|
||||
* console.log(clonedArr); // [2, 3, 4]
|
||||
* console.log(clonedArr === arr); // false
|
||||
*/
|
||||
function cloneDeepWith(obj, cloneValue) {
|
||||
return cloneDeepWithImpl(obj, void 0, obj, /* @__PURE__ */ new Map(), cloneValue);
|
||||
}
|
||||
function cloneDeepWithImpl(valueToClone, keyToClone, objectToClone, stack = /* @__PURE__ */ new Map(), cloneValue = void 0) {
|
||||
const cloned = cloneValue?.(valueToClone, keyToClone, objectToClone, stack);
|
||||
if (cloned !== void 0) return cloned;
|
||||
if (isPrimitive(valueToClone)) return valueToClone;
|
||||
if (stack.has(valueToClone)) return stack.get(valueToClone);
|
||||
if (Array.isArray(valueToClone)) {
|
||||
const result = new Array(valueToClone.length);
|
||||
stack.set(valueToClone, result);
|
||||
for (let i = 0; i < valueToClone.length; i++) result[i] = cloneDeepWithImpl(valueToClone[i], i, objectToClone, stack, cloneValue);
|
||||
if (Object.hasOwn(valueToClone, "index")) result.index = valueToClone.index;
|
||||
if (Object.hasOwn(valueToClone, "input")) result.input = valueToClone.input;
|
||||
return result;
|
||||
}
|
||||
if (valueToClone instanceof Date) return new Date(valueToClone.getTime());
|
||||
if (valueToClone instanceof RegExp) {
|
||||
const result = new RegExp(valueToClone.source, valueToClone.flags);
|
||||
result.lastIndex = valueToClone.lastIndex;
|
||||
return result;
|
||||
}
|
||||
if (valueToClone instanceof Map) {
|
||||
const result = /* @__PURE__ */ new Map();
|
||||
stack.set(valueToClone, result);
|
||||
for (const [key, value] of valueToClone) result.set(key, cloneDeepWithImpl(value, key, objectToClone, stack, cloneValue));
|
||||
return result;
|
||||
}
|
||||
if (valueToClone instanceof Set) {
|
||||
const result = /* @__PURE__ */ new Set();
|
||||
stack.set(valueToClone, result);
|
||||
for (const value of valueToClone) result.add(cloneDeepWithImpl(value, void 0, objectToClone, stack, cloneValue));
|
||||
return result;
|
||||
}
|
||||
if (isBuffer(valueToClone)) return valueToClone.subarray();
|
||||
if (isTypedArray(valueToClone)) {
|
||||
const result = new (Object.getPrototypeOf(valueToClone)).constructor(valueToClone.length);
|
||||
stack.set(valueToClone, result);
|
||||
for (let i = 0; i < valueToClone.length; i++) result[i] = cloneDeepWithImpl(valueToClone[i], i, objectToClone, stack, cloneValue);
|
||||
return result;
|
||||
}
|
||||
if (valueToClone instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && valueToClone instanceof SharedArrayBuffer) return valueToClone.slice(0);
|
||||
if (valueToClone instanceof DataView) {
|
||||
const result = new DataView(valueToClone.buffer.slice(0), valueToClone.byteOffset, valueToClone.byteLength);
|
||||
stack.set(valueToClone, result);
|
||||
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
||||
return result;
|
||||
}
|
||||
if (typeof File !== "undefined" && valueToClone instanceof File) {
|
||||
const result = new File([valueToClone], valueToClone.name, { type: valueToClone.type });
|
||||
stack.set(valueToClone, result);
|
||||
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
||||
return result;
|
||||
}
|
||||
if (typeof Blob !== "undefined" && valueToClone instanceof Blob) {
|
||||
const result = new Blob([valueToClone], { type: valueToClone.type });
|
||||
stack.set(valueToClone, result);
|
||||
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
||||
return result;
|
||||
}
|
||||
if (valueToClone instanceof Error) {
|
||||
const result = structuredClone(valueToClone);
|
||||
stack.set(valueToClone, result);
|
||||
result.message = valueToClone.message;
|
||||
result.name = valueToClone.name;
|
||||
result.stack = valueToClone.stack;
|
||||
result.cause = valueToClone.cause;
|
||||
result.constructor = valueToClone.constructor;
|
||||
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
||||
return result;
|
||||
}
|
||||
if (valueToClone instanceof Boolean) {
|
||||
const result = new Boolean(valueToClone.valueOf());
|
||||
stack.set(valueToClone, result);
|
||||
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
||||
return result;
|
||||
}
|
||||
if (valueToClone instanceof Number) {
|
||||
const result = new Number(valueToClone.valueOf());
|
||||
stack.set(valueToClone, result);
|
||||
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
||||
return result;
|
||||
}
|
||||
if (valueToClone instanceof String) {
|
||||
const result = new String(valueToClone.valueOf());
|
||||
stack.set(valueToClone, result);
|
||||
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
||||
return result;
|
||||
}
|
||||
if (typeof valueToClone === "object" && isCloneableObject(valueToClone)) {
|
||||
const result = Object.create(Object.getPrototypeOf(valueToClone));
|
||||
stack.set(valueToClone, result);
|
||||
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
||||
return result;
|
||||
}
|
||||
return valueToClone;
|
||||
}
|
||||
function copyProperties(target, source, objectToClone = target, stack, cloneValue) {
|
||||
const keys = [...Object.keys(source), ...getSymbols(source)];
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
const descriptor = Object.getOwnPropertyDescriptor(target, key);
|
||||
if (descriptor == null || descriptor.writable) target[key] = cloneDeepWithImpl(source[key], key, objectToClone, stack, cloneValue);
|
||||
}
|
||||
}
|
||||
function isCloneableObject(object) {
|
||||
switch (getTag(object)) {
|
||||
case argumentsTag:
|
||||
case arrayTag:
|
||||
case arrayBufferTag:
|
||||
case dataViewTag:
|
||||
case booleanTag:
|
||||
case dateTag:
|
||||
case float32ArrayTag:
|
||||
case float64ArrayTag:
|
||||
case int8ArrayTag:
|
||||
case int16ArrayTag:
|
||||
case int32ArrayTag:
|
||||
case mapTag:
|
||||
case numberTag:
|
||||
case objectTag:
|
||||
case regexpTag:
|
||||
case setTag:
|
||||
case stringTag:
|
||||
case symbolTag:
|
||||
case uint8ArrayTag:
|
||||
case uint8ClampedArrayTag:
|
||||
case uint16ArrayTag:
|
||||
case uint32ArrayTag: return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
//#endregion
|
||||
export { cloneDeepWith, cloneDeepWithImpl, copyProperties };
|
||||
22
frontend/node_modules/es-toolkit/dist/object/findKey.d.mts
generated
vendored
Normal file
22
frontend/node_modules/es-toolkit/dist/object/findKey.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
//#region src/object/findKey.d.ts
|
||||
/**
|
||||
* Finds the key of the first element in the object that satisfies the provided testing function.
|
||||
*
|
||||
* @param obj - The object to search.
|
||||
* @param predicate - The function to execute on each value in the object. It takes three arguments:
|
||||
* - value: The current value being processed in the object.
|
||||
* - key: The key of the current value being processed in the object.
|
||||
* - obj: The object that findKey was called upon.
|
||||
* @returns The key of the first element in the object that passes the test, or undefined if no element passes.
|
||||
*
|
||||
* @example
|
||||
* const users = {
|
||||
* 'barney': { 'age': 36, 'active': true },
|
||||
* 'fred': { 'age': 40, 'active': false },
|
||||
* 'pebbles': { 'age': 1, 'active': true }
|
||||
* };
|
||||
* findKey(users, function(o) { return o.age < 40; }); => 'barney'
|
||||
*/
|
||||
declare function findKey<T extends Record<any, any>>(obj: T, predicate: (value: T[keyof T], key: keyof T, obj: T) => boolean): keyof T | undefined;
|
||||
//#endregion
|
||||
export { findKey };
|
||||
22
frontend/node_modules/es-toolkit/dist/object/findKey.d.ts
generated
vendored
Normal file
22
frontend/node_modules/es-toolkit/dist/object/findKey.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
//#region src/object/findKey.d.ts
|
||||
/**
|
||||
* Finds the key of the first element in the object that satisfies the provided testing function.
|
||||
*
|
||||
* @param obj - The object to search.
|
||||
* @param predicate - The function to execute on each value in the object. It takes three arguments:
|
||||
* - value: The current value being processed in the object.
|
||||
* - key: The key of the current value being processed in the object.
|
||||
* - obj: The object that findKey was called upon.
|
||||
* @returns The key of the first element in the object that passes the test, or undefined if no element passes.
|
||||
*
|
||||
* @example
|
||||
* const users = {
|
||||
* 'barney': { 'age': 36, 'active': true },
|
||||
* 'fred': { 'age': 40, 'active': false },
|
||||
* 'pebbles': { 'age': 1, 'active': true }
|
||||
* };
|
||||
* findKey(users, function(o) { return o.age < 40; }); => 'barney'
|
||||
*/
|
||||
declare function findKey<T extends Record<any, any>>(obj: T, predicate: (value: T[keyof T], key: keyof T, obj: T) => boolean): keyof T | undefined;
|
||||
//#endregion
|
||||
export { findKey };
|
||||
24
frontend/node_modules/es-toolkit/dist/object/findKey.js
generated
vendored
Normal file
24
frontend/node_modules/es-toolkit/dist/object/findKey.js
generated
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
//#region src/object/findKey.ts
|
||||
/**
|
||||
* Finds the key of the first element in the object that satisfies the provided testing function.
|
||||
*
|
||||
* @param obj - The object to search.
|
||||
* @param predicate - The function to execute on each value in the object. It takes three arguments:
|
||||
* - value: The current value being processed in the object.
|
||||
* - key: The key of the current value being processed in the object.
|
||||
* - obj: The object that findKey was called upon.
|
||||
* @returns The key of the first element in the object that passes the test, or undefined if no element passes.
|
||||
*
|
||||
* @example
|
||||
* const users = {
|
||||
* 'barney': { 'age': 36, 'active': true },
|
||||
* 'fred': { 'age': 40, 'active': false },
|
||||
* 'pebbles': { 'age': 1, 'active': true }
|
||||
* };
|
||||
* findKey(users, function(o) { return o.age < 40; }); => 'barney'
|
||||
*/
|
||||
function findKey(obj, predicate) {
|
||||
return Object.keys(obj).find((key) => predicate(obj[key], key, obj));
|
||||
}
|
||||
//#endregion
|
||||
exports.findKey = findKey;
|
||||
24
frontend/node_modules/es-toolkit/dist/object/findKey.mjs
generated
vendored
Normal file
24
frontend/node_modules/es-toolkit/dist/object/findKey.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
//#region src/object/findKey.ts
|
||||
/**
|
||||
* Finds the key of the first element in the object that satisfies the provided testing function.
|
||||
*
|
||||
* @param obj - The object to search.
|
||||
* @param predicate - The function to execute on each value in the object. It takes three arguments:
|
||||
* - value: The current value being processed in the object.
|
||||
* - key: The key of the current value being processed in the object.
|
||||
* - obj: The object that findKey was called upon.
|
||||
* @returns The key of the first element in the object that passes the test, or undefined if no element passes.
|
||||
*
|
||||
* @example
|
||||
* const users = {
|
||||
* 'barney': { 'age': 36, 'active': true },
|
||||
* 'fred': { 'age': 40, 'active': false },
|
||||
* 'pebbles': { 'age': 1, 'active': true }
|
||||
* };
|
||||
* findKey(users, function(o) { return o.age < 40; }); => 'barney'
|
||||
*/
|
||||
function findKey(obj, predicate) {
|
||||
return Object.keys(obj).find((key) => predicate(obj[key], key, obj));
|
||||
}
|
||||
//#endregion
|
||||
export { findKey };
|
||||
39
frontend/node_modules/es-toolkit/dist/object/flattenObject.d.mts
generated
vendored
Normal file
39
frontend/node_modules/es-toolkit/dist/object/flattenObject.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
//#region src/object/flattenObject.d.ts
|
||||
interface FlattenObjectOptions {
|
||||
/**
|
||||
* The delimiter to use between nested keys.
|
||||
* @default '.'
|
||||
*/
|
||||
delimiter?: string;
|
||||
}
|
||||
/**
|
||||
* Flattens a nested object into a single level object with delimiter-separated keys.
|
||||
*
|
||||
* @param object - The object to flatten.
|
||||
* @param [options.delimiter='.'] - The delimiter to use between nested keys.
|
||||
* @returns The flattened object.
|
||||
*
|
||||
* @example
|
||||
* const nestedObject = {
|
||||
* a: {
|
||||
* b: {
|
||||
* c: 1
|
||||
* }
|
||||
* },
|
||||
* d: [2, 3]
|
||||
* };
|
||||
*
|
||||
* const flattened = flattenObject(nestedObject);
|
||||
* console.log(flattened);
|
||||
* // Output:
|
||||
* // {
|
||||
* // 'a.b.c': 1,
|
||||
* // 'd.0': 2,
|
||||
* // 'd.1': 3
|
||||
* // }
|
||||
*/
|
||||
declare function flattenObject(object: object, {
|
||||
delimiter
|
||||
}?: FlattenObjectOptions): Record<string, any>;
|
||||
//#endregion
|
||||
export { flattenObject };
|
||||
39
frontend/node_modules/es-toolkit/dist/object/flattenObject.d.ts
generated
vendored
Normal file
39
frontend/node_modules/es-toolkit/dist/object/flattenObject.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
//#region src/object/flattenObject.d.ts
|
||||
interface FlattenObjectOptions {
|
||||
/**
|
||||
* The delimiter to use between nested keys.
|
||||
* @default '.'
|
||||
*/
|
||||
delimiter?: string;
|
||||
}
|
||||
/**
|
||||
* Flattens a nested object into a single level object with delimiter-separated keys.
|
||||
*
|
||||
* @param object - The object to flatten.
|
||||
* @param [options.delimiter='.'] - The delimiter to use between nested keys.
|
||||
* @returns The flattened object.
|
||||
*
|
||||
* @example
|
||||
* const nestedObject = {
|
||||
* a: {
|
||||
* b: {
|
||||
* c: 1
|
||||
* }
|
||||
* },
|
||||
* d: [2, 3]
|
||||
* };
|
||||
*
|
||||
* const flattened = flattenObject(nestedObject);
|
||||
* console.log(flattened);
|
||||
* // Output:
|
||||
* // {
|
||||
* // 'a.b.c': 1,
|
||||
* // 'd.0': 2,
|
||||
* // 'd.1': 3
|
||||
* // }
|
||||
*/
|
||||
declare function flattenObject(object: object, {
|
||||
delimiter
|
||||
}?: FlattenObjectOptions): Record<string, any>;
|
||||
//#endregion
|
||||
export { flattenObject };
|
||||
52
frontend/node_modules/es-toolkit/dist/object/flattenObject.js
generated
vendored
Normal file
52
frontend/node_modules/es-toolkit/dist/object/flattenObject.js
generated
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
const require_isPlainObject = require("../predicate/isPlainObject.js");
|
||||
//#region src/object/flattenObject.ts
|
||||
/**
|
||||
* Flattens a nested object into a single level object with delimiter-separated keys.
|
||||
*
|
||||
* @param object - The object to flatten.
|
||||
* @param [options.delimiter='.'] - The delimiter to use between nested keys.
|
||||
* @returns The flattened object.
|
||||
*
|
||||
* @example
|
||||
* const nestedObject = {
|
||||
* a: {
|
||||
* b: {
|
||||
* c: 1
|
||||
* }
|
||||
* },
|
||||
* d: [2, 3]
|
||||
* };
|
||||
*
|
||||
* const flattened = flattenObject(nestedObject);
|
||||
* console.log(flattened);
|
||||
* // Output:
|
||||
* // {
|
||||
* // 'a.b.c': 1,
|
||||
* // 'd.0': 2,
|
||||
* // 'd.1': 3
|
||||
* // }
|
||||
*/
|
||||
function flattenObject(object, { delimiter = "." } = {}) {
|
||||
return flattenObjectImpl(object, "", delimiter);
|
||||
}
|
||||
function flattenObjectImpl(object, prefix, delimiter) {
|
||||
const result = {};
|
||||
const keys = Object.keys(object);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
const value = object[key];
|
||||
const prefixedKey = prefix ? `${prefix}${delimiter}${key}` : key;
|
||||
if (require_isPlainObject.isPlainObject(value) && Object.keys(value).length > 0) {
|
||||
Object.assign(result, flattenObjectImpl(value, prefixedKey, delimiter));
|
||||
continue;
|
||||
}
|
||||
if (Array.isArray(value) && value.length > 0) {
|
||||
Object.assign(result, flattenObjectImpl(value, prefixedKey, delimiter));
|
||||
continue;
|
||||
}
|
||||
result[prefixedKey] = value;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//#endregion
|
||||
exports.flattenObject = flattenObject;
|
||||
52
frontend/node_modules/es-toolkit/dist/object/flattenObject.mjs
generated
vendored
Normal file
52
frontend/node_modules/es-toolkit/dist/object/flattenObject.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
import { isPlainObject } from "../predicate/isPlainObject.mjs";
|
||||
//#region src/object/flattenObject.ts
|
||||
/**
|
||||
* Flattens a nested object into a single level object with delimiter-separated keys.
|
||||
*
|
||||
* @param object - The object to flatten.
|
||||
* @param [options.delimiter='.'] - The delimiter to use between nested keys.
|
||||
* @returns The flattened object.
|
||||
*
|
||||
* @example
|
||||
* const nestedObject = {
|
||||
* a: {
|
||||
* b: {
|
||||
* c: 1
|
||||
* }
|
||||
* },
|
||||
* d: [2, 3]
|
||||
* };
|
||||
*
|
||||
* const flattened = flattenObject(nestedObject);
|
||||
* console.log(flattened);
|
||||
* // Output:
|
||||
* // {
|
||||
* // 'a.b.c': 1,
|
||||
* // 'd.0': 2,
|
||||
* // 'd.1': 3
|
||||
* // }
|
||||
*/
|
||||
function flattenObject(object, { delimiter = "." } = {}) {
|
||||
return flattenObjectImpl(object, "", delimiter);
|
||||
}
|
||||
function flattenObjectImpl(object, prefix, delimiter) {
|
||||
const result = {};
|
||||
const keys = Object.keys(object);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
const value = object[key];
|
||||
const prefixedKey = prefix ? `${prefix}${delimiter}${key}` : key;
|
||||
if (isPlainObject(value) && Object.keys(value).length > 0) {
|
||||
Object.assign(result, flattenObjectImpl(value, prefixedKey, delimiter));
|
||||
continue;
|
||||
}
|
||||
if (Array.isArray(value) && value.length > 0) {
|
||||
Object.assign(result, flattenObjectImpl(value, prefixedKey, delimiter));
|
||||
continue;
|
||||
}
|
||||
result[prefixedKey] = value;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//#endregion
|
||||
export { flattenObject };
|
||||
19
frontend/node_modules/es-toolkit/dist/object/index.d.mts
generated
vendored
Normal file
19
frontend/node_modules/es-toolkit/dist/object/index.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import { clone } from "./clone.mjs";
|
||||
import { cloneDeep } from "./cloneDeep.mjs";
|
||||
import { cloneDeepWith } from "./cloneDeepWith.mjs";
|
||||
import { findKey } from "./findKey.mjs";
|
||||
import { flattenObject } from "./flattenObject.mjs";
|
||||
import { invert } from "./invert.mjs";
|
||||
import { mapKeys } from "./mapKeys.mjs";
|
||||
import { mapValues } from "./mapValues.mjs";
|
||||
import { merge } from "./merge.mjs";
|
||||
import { mergeWith } from "./mergeWith.mjs";
|
||||
import { omit } from "./omit.mjs";
|
||||
import { omitBy } from "./omitBy.mjs";
|
||||
import { pick } from "./pick.mjs";
|
||||
import { pickBy } from "./pickBy.mjs";
|
||||
import { sortKeys } from "./sortKeys.mjs";
|
||||
import { toCamelCaseKeys } from "./toCamelCaseKeys.mjs";
|
||||
import { toMerged } from "./toMerged.mjs";
|
||||
import { toSnakeCaseKeys } from "./toSnakeCaseKeys.mjs";
|
||||
export { clone, cloneDeep, cloneDeepWith, findKey, flattenObject, invert, mapKeys, mapValues, merge, mergeWith, omit, omitBy, pick, pickBy, sortKeys, toCamelCaseKeys, toMerged, toSnakeCaseKeys };
|
||||
19
frontend/node_modules/es-toolkit/dist/object/index.d.ts
generated
vendored
Normal file
19
frontend/node_modules/es-toolkit/dist/object/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import { clone } from "./clone.js";
|
||||
import { cloneDeep } from "./cloneDeep.js";
|
||||
import { cloneDeepWith } from "./cloneDeepWith.js";
|
||||
import { findKey } from "./findKey.js";
|
||||
import { flattenObject } from "./flattenObject.js";
|
||||
import { invert } from "./invert.js";
|
||||
import { mapKeys } from "./mapKeys.js";
|
||||
import { mapValues } from "./mapValues.js";
|
||||
import { merge } from "./merge.js";
|
||||
import { mergeWith } from "./mergeWith.js";
|
||||
import { omit } from "./omit.js";
|
||||
import { omitBy } from "./omitBy.js";
|
||||
import { pick } from "./pick.js";
|
||||
import { pickBy } from "./pickBy.js";
|
||||
import { sortKeys } from "./sortKeys.js";
|
||||
import { toCamelCaseKeys } from "./toCamelCaseKeys.js";
|
||||
import { toMerged } from "./toMerged.js";
|
||||
import { toSnakeCaseKeys } from "./toSnakeCaseKeys.js";
|
||||
export { clone, cloneDeep, cloneDeepWith, findKey, flattenObject, invert, mapKeys, mapValues, merge, mergeWith, omit, omitBy, pick, pickBy, sortKeys, toCamelCaseKeys, toMerged, toSnakeCaseKeys };
|
||||
37
frontend/node_modules/es-toolkit/dist/object/index.js
generated
vendored
Normal file
37
frontend/node_modules/es-toolkit/dist/object/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
const require_clone = require("./clone.js");
|
||||
const require_cloneDeepWith = require("./cloneDeepWith.js");
|
||||
const require_cloneDeep = require("./cloneDeep.js");
|
||||
const require_findKey = require("./findKey.js");
|
||||
const require_flattenObject = require("./flattenObject.js");
|
||||
const require_invert = require("./invert.js");
|
||||
const require_mapKeys = require("./mapKeys.js");
|
||||
const require_mapValues = require("./mapValues.js");
|
||||
const require_merge = require("./merge.js");
|
||||
const require_mergeWith = require("./mergeWith.js");
|
||||
const require_omit = require("./omit.js");
|
||||
const require_omitBy = require("./omitBy.js");
|
||||
const require_pick = require("./pick.js");
|
||||
const require_pickBy = require("./pickBy.js");
|
||||
const require_sortKeys = require("./sortKeys.js");
|
||||
const require_toCamelCaseKeys = require("./toCamelCaseKeys.js");
|
||||
const require_toMerged = require("./toMerged.js");
|
||||
const require_toSnakeCaseKeys = require("./toSnakeCaseKeys.js");
|
||||
exports.clone = require_clone.clone;
|
||||
exports.cloneDeep = require_cloneDeep.cloneDeep;
|
||||
exports.cloneDeepWith = require_cloneDeepWith.cloneDeepWith;
|
||||
exports.findKey = require_findKey.findKey;
|
||||
exports.flattenObject = require_flattenObject.flattenObject;
|
||||
exports.invert = require_invert.invert;
|
||||
exports.mapKeys = require_mapKeys.mapKeys;
|
||||
exports.mapValues = require_mapValues.mapValues;
|
||||
exports.merge = require_merge.merge;
|
||||
exports.mergeWith = require_mergeWith.mergeWith;
|
||||
exports.omit = require_omit.omit;
|
||||
exports.omitBy = require_omitBy.omitBy;
|
||||
exports.pick = require_pick.pick;
|
||||
exports.pickBy = require_pickBy.pickBy;
|
||||
exports.sortKeys = require_sortKeys.sortKeys;
|
||||
exports.toCamelCaseKeys = require_toCamelCaseKeys.toCamelCaseKeys;
|
||||
exports.toMerged = require_toMerged.toMerged;
|
||||
exports.toSnakeCaseKeys = require_toSnakeCaseKeys.toSnakeCaseKeys;
|
||||
19
frontend/node_modules/es-toolkit/dist/object/index.mjs
generated
vendored
Normal file
19
frontend/node_modules/es-toolkit/dist/object/index.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import { clone } from "./clone.mjs";
|
||||
import { cloneDeepWith } from "./cloneDeepWith.mjs";
|
||||
import { cloneDeep } from "./cloneDeep.mjs";
|
||||
import { findKey } from "./findKey.mjs";
|
||||
import { flattenObject } from "./flattenObject.mjs";
|
||||
import { invert } from "./invert.mjs";
|
||||
import { mapKeys } from "./mapKeys.mjs";
|
||||
import { mapValues } from "./mapValues.mjs";
|
||||
import { merge } from "./merge.mjs";
|
||||
import { mergeWith } from "./mergeWith.mjs";
|
||||
import { omit } from "./omit.mjs";
|
||||
import { omitBy } from "./omitBy.mjs";
|
||||
import { pick } from "./pick.mjs";
|
||||
import { pickBy } from "./pickBy.mjs";
|
||||
import { sortKeys } from "./sortKeys.mjs";
|
||||
import { toCamelCaseKeys } from "./toCamelCaseKeys.mjs";
|
||||
import { toMerged } from "./toMerged.mjs";
|
||||
import { toSnakeCaseKeys } from "./toSnakeCaseKeys.mjs";
|
||||
export { clone, cloneDeep, cloneDeepWith, findKey, flattenObject, invert, mapKeys, mapValues, merge, mergeWith, omit, omitBy, pick, pickBy, sortKeys, toCamelCaseKeys, toMerged, toSnakeCaseKeys };
|
||||
22
frontend/node_modules/es-toolkit/dist/object/invert.d.mts
generated
vendored
Normal file
22
frontend/node_modules/es-toolkit/dist/object/invert.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
//#region src/object/invert.d.ts
|
||||
/**
|
||||
* Inverts the keys and values of an object. The keys of the input object become the values of the output object and vice versa.
|
||||
*
|
||||
* This function takes an object and creates a new object by inverting its keys and values. If the input object has duplicate values,
|
||||
* the key of the last occurrence will be used as the value for the new key in the output object. It effectively creates a reverse mapping
|
||||
* of the input object's key-value pairs.
|
||||
*
|
||||
* @template K - Type of the keys in the input object (string, number, symbol)
|
||||
* @template V - Type of the values in the input object (string, number, symbol)
|
||||
* @param obj - The input object whose keys and values are to be inverted
|
||||
* @returns A new object with keys and values inverted
|
||||
*
|
||||
* @example
|
||||
* invert({ a: 1, b: 2, c: 3 }); // { 1: 'a', 2: 'b', 3: 'c' }
|
||||
* invert({ 1: 'a', 2: 'b', 3: 'c' }); // { a: '1', b: '2', c: '3' }
|
||||
* invert({ a: 1, 2: 'b', c: 3, 4: 'd' }); // { 1: 'a', b: '2', 3: 'c', d: '4' }
|
||||
* invert({ a: Symbol('sym1'), b: Symbol('sym2') }); // { [Symbol('sym1')]: 'a', [Symbol('sym2')]: 'b' }
|
||||
*/
|
||||
declare function invert<K extends PropertyKey, V extends PropertyKey>(obj: Record<K, V>): Record<V, K>;
|
||||
//#endregion
|
||||
export { invert };
|
||||
22
frontend/node_modules/es-toolkit/dist/object/invert.d.ts
generated
vendored
Normal file
22
frontend/node_modules/es-toolkit/dist/object/invert.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
//#region src/object/invert.d.ts
|
||||
/**
|
||||
* Inverts the keys and values of an object. The keys of the input object become the values of the output object and vice versa.
|
||||
*
|
||||
* This function takes an object and creates a new object by inverting its keys and values. If the input object has duplicate values,
|
||||
* the key of the last occurrence will be used as the value for the new key in the output object. It effectively creates a reverse mapping
|
||||
* of the input object's key-value pairs.
|
||||
*
|
||||
* @template K - Type of the keys in the input object (string, number, symbol)
|
||||
* @template V - Type of the values in the input object (string, number, symbol)
|
||||
* @param obj - The input object whose keys and values are to be inverted
|
||||
* @returns A new object with keys and values inverted
|
||||
*
|
||||
* @example
|
||||
* invert({ a: 1, b: 2, c: 3 }); // { 1: 'a', 2: 'b', 3: 'c' }
|
||||
* invert({ 1: 'a', 2: 'b', 3: 'c' }); // { a: '1', b: '2', c: '3' }
|
||||
* invert({ a: 1, 2: 'b', c: 3, 4: 'd' }); // { 1: 'a', b: '2', 3: 'c', d: '4' }
|
||||
* invert({ a: Symbol('sym1'), b: Symbol('sym2') }); // { [Symbol('sym1')]: 'a', [Symbol('sym2')]: 'b' }
|
||||
*/
|
||||
declare function invert<K extends PropertyKey, V extends PropertyKey>(obj: Record<K, V>): Record<V, K>;
|
||||
//#endregion
|
||||
export { invert };
|
||||
31
frontend/node_modules/es-toolkit/dist/object/invert.js
generated
vendored
Normal file
31
frontend/node_modules/es-toolkit/dist/object/invert.js
generated
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
//#region src/object/invert.ts
|
||||
/**
|
||||
* Inverts the keys and values of an object. The keys of the input object become the values of the output object and vice versa.
|
||||
*
|
||||
* This function takes an object and creates a new object by inverting its keys and values. If the input object has duplicate values,
|
||||
* the key of the last occurrence will be used as the value for the new key in the output object. It effectively creates a reverse mapping
|
||||
* of the input object's key-value pairs.
|
||||
*
|
||||
* @template K - Type of the keys in the input object (string, number, symbol)
|
||||
* @template V - Type of the values in the input object (string, number, symbol)
|
||||
* @param obj - The input object whose keys and values are to be inverted
|
||||
* @returns A new object with keys and values inverted
|
||||
*
|
||||
* @example
|
||||
* invert({ a: 1, b: 2, c: 3 }); // { 1: 'a', 2: 'b', 3: 'c' }
|
||||
* invert({ 1: 'a', 2: 'b', 3: 'c' }); // { a: '1', b: '2', c: '3' }
|
||||
* invert({ a: 1, 2: 'b', c: 3, 4: 'd' }); // { 1: 'a', b: '2', 3: 'c', d: '4' }
|
||||
* invert({ a: Symbol('sym1'), b: Symbol('sym2') }); // { [Symbol('sym1')]: 'a', [Symbol('sym2')]: 'b' }
|
||||
*/
|
||||
function invert(obj) {
|
||||
const result = {};
|
||||
const keys = Object.keys(obj);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
const value = obj[key];
|
||||
result[value] = key;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//#endregion
|
||||
exports.invert = invert;
|
||||
31
frontend/node_modules/es-toolkit/dist/object/invert.mjs
generated
vendored
Normal file
31
frontend/node_modules/es-toolkit/dist/object/invert.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
//#region src/object/invert.ts
|
||||
/**
|
||||
* Inverts the keys and values of an object. The keys of the input object become the values of the output object and vice versa.
|
||||
*
|
||||
* This function takes an object and creates a new object by inverting its keys and values. If the input object has duplicate values,
|
||||
* the key of the last occurrence will be used as the value for the new key in the output object. It effectively creates a reverse mapping
|
||||
* of the input object's key-value pairs.
|
||||
*
|
||||
* @template K - Type of the keys in the input object (string, number, symbol)
|
||||
* @template V - Type of the values in the input object (string, number, symbol)
|
||||
* @param obj - The input object whose keys and values are to be inverted
|
||||
* @returns A new object with keys and values inverted
|
||||
*
|
||||
* @example
|
||||
* invert({ a: 1, b: 2, c: 3 }); // { 1: 'a', 2: 'b', 3: 'c' }
|
||||
* invert({ 1: 'a', 2: 'b', 3: 'c' }); // { a: '1', b: '2', c: '3' }
|
||||
* invert({ a: 1, 2: 'b', c: 3, 4: 'd' }); // { 1: 'a', b: '2', 3: 'c', d: '4' }
|
||||
* invert({ a: Symbol('sym1'), b: Symbol('sym2') }); // { [Symbol('sym1')]: 'a', [Symbol('sym2')]: 'b' }
|
||||
*/
|
||||
function invert(obj) {
|
||||
const result = {};
|
||||
const keys = Object.keys(obj);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
const value = obj[key];
|
||||
result[value] = key;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//#endregion
|
||||
export { invert };
|
||||
21
frontend/node_modules/es-toolkit/dist/object/mapKeys.d.mts
generated
vendored
Normal file
21
frontend/node_modules/es-toolkit/dist/object/mapKeys.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
//#region src/object/mapKeys.d.ts
|
||||
/**
|
||||
* Creates a new object with the same values as the given object, but with keys generated
|
||||
* by running each own enumerable property of the object through the iteratee function.
|
||||
*
|
||||
* @template T - The type of the object.
|
||||
* @template K - The type of the new keys generated by the iteratee function.
|
||||
*
|
||||
* @param object - The object to iterate over.
|
||||
* @param getNewKey - The function invoked per own enumerable property.
|
||||
* @returns Returns the new mapped object.
|
||||
*
|
||||
* @example
|
||||
* // Example usage:
|
||||
* const obj = { a: 1, b: 2 };
|
||||
* const result = mapKeys(obj, (value, key) => key + value);
|
||||
* console.log(result); // { a1: 1, b2: 2 }
|
||||
*/
|
||||
declare function mapKeys<T extends Record<PropertyKey, any>, K extends PropertyKey>(object: T, getNewKey: (value: T[keyof T], key: keyof T, object: T) => K): Record<K, T[keyof T]>;
|
||||
//#endregion
|
||||
export { mapKeys };
|
||||
21
frontend/node_modules/es-toolkit/dist/object/mapKeys.d.ts
generated
vendored
Normal file
21
frontend/node_modules/es-toolkit/dist/object/mapKeys.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
//#region src/object/mapKeys.d.ts
|
||||
/**
|
||||
* Creates a new object with the same values as the given object, but with keys generated
|
||||
* by running each own enumerable property of the object through the iteratee function.
|
||||
*
|
||||
* @template T - The type of the object.
|
||||
* @template K - The type of the new keys generated by the iteratee function.
|
||||
*
|
||||
* @param object - The object to iterate over.
|
||||
* @param getNewKey - The function invoked per own enumerable property.
|
||||
* @returns Returns the new mapped object.
|
||||
*
|
||||
* @example
|
||||
* // Example usage:
|
||||
* const obj = { a: 1, b: 2 };
|
||||
* const result = mapKeys(obj, (value, key) => key + value);
|
||||
* console.log(result); // { a1: 1, b2: 2 }
|
||||
*/
|
||||
declare function mapKeys<T extends Record<PropertyKey, any>, K extends PropertyKey>(object: T, getNewKey: (value: T[keyof T], key: keyof T, object: T) => K): Record<K, T[keyof T]>;
|
||||
//#endregion
|
||||
export { mapKeys };
|
||||
30
frontend/node_modules/es-toolkit/dist/object/mapKeys.js
generated
vendored
Normal file
30
frontend/node_modules/es-toolkit/dist/object/mapKeys.js
generated
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
//#region src/object/mapKeys.ts
|
||||
/**
|
||||
* Creates a new object with the same values as the given object, but with keys generated
|
||||
* by running each own enumerable property of the object through the iteratee function.
|
||||
*
|
||||
* @template T - The type of the object.
|
||||
* @template K - The type of the new keys generated by the iteratee function.
|
||||
*
|
||||
* @param object - The object to iterate over.
|
||||
* @param getNewKey - The function invoked per own enumerable property.
|
||||
* @returns Returns the new mapped object.
|
||||
*
|
||||
* @example
|
||||
* // Example usage:
|
||||
* const obj = { a: 1, b: 2 };
|
||||
* const result = mapKeys(obj, (value, key) => key + value);
|
||||
* console.log(result); // { a1: 1, b2: 2 }
|
||||
*/
|
||||
function mapKeys(object, getNewKey) {
|
||||
const result = {};
|
||||
const keys = Object.keys(object);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
const value = object[key];
|
||||
result[getNewKey(value, key, object)] = value;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//#endregion
|
||||
exports.mapKeys = mapKeys;
|
||||
30
frontend/node_modules/es-toolkit/dist/object/mapKeys.mjs
generated
vendored
Normal file
30
frontend/node_modules/es-toolkit/dist/object/mapKeys.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
//#region src/object/mapKeys.ts
|
||||
/**
|
||||
* Creates a new object with the same values as the given object, but with keys generated
|
||||
* by running each own enumerable property of the object through the iteratee function.
|
||||
*
|
||||
* @template T - The type of the object.
|
||||
* @template K - The type of the new keys generated by the iteratee function.
|
||||
*
|
||||
* @param object - The object to iterate over.
|
||||
* @param getNewKey - The function invoked per own enumerable property.
|
||||
* @returns Returns the new mapped object.
|
||||
*
|
||||
* @example
|
||||
* // Example usage:
|
||||
* const obj = { a: 1, b: 2 };
|
||||
* const result = mapKeys(obj, (value, key) => key + value);
|
||||
* console.log(result); // { a1: 1, b2: 2 }
|
||||
*/
|
||||
function mapKeys(object, getNewKey) {
|
||||
const result = {};
|
||||
const keys = Object.keys(object);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
const value = object[key];
|
||||
result[getNewKey(value, key, object)] = value;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//#endregion
|
||||
export { mapKeys };
|
||||
22
frontend/node_modules/es-toolkit/dist/object/mapValues.d.mts
generated
vendored
Normal file
22
frontend/node_modules/es-toolkit/dist/object/mapValues.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
//#region src/object/mapValues.d.ts
|
||||
/**
|
||||
* Creates a new object with the same keys as the given object, but with values generated
|
||||
* by running each own enumerable property of the object through the iteratee function.
|
||||
*
|
||||
* @template T - The type of the object.
|
||||
* @template K - The type of the keys in the object.
|
||||
* @template V - The type of the new values generated by the iteratee function.
|
||||
*
|
||||
* @param object - The object to iterate over.
|
||||
* @param getNewValue - The function invoked per own enumerable property.
|
||||
* @returns Returns the new mapped object.
|
||||
*
|
||||
* @example
|
||||
* // Example usage:
|
||||
* const obj = { a: 1, b: 2 };
|
||||
* const result = mapValues(obj, (value) => value * 2);
|
||||
* console.log(result); // { a: 2, b: 4 }
|
||||
*/
|
||||
declare function mapValues<T extends object, K extends keyof T, V>(object: T, getNewValue: (value: T[K], key: K, object: T) => V): Record<K, V>;
|
||||
//#endregion
|
||||
export { mapValues };
|
||||
22
frontend/node_modules/es-toolkit/dist/object/mapValues.d.ts
generated
vendored
Normal file
22
frontend/node_modules/es-toolkit/dist/object/mapValues.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
//#region src/object/mapValues.d.ts
|
||||
/**
|
||||
* Creates a new object with the same keys as the given object, but with values generated
|
||||
* by running each own enumerable property of the object through the iteratee function.
|
||||
*
|
||||
* @template T - The type of the object.
|
||||
* @template K - The type of the keys in the object.
|
||||
* @template V - The type of the new values generated by the iteratee function.
|
||||
*
|
||||
* @param object - The object to iterate over.
|
||||
* @param getNewValue - The function invoked per own enumerable property.
|
||||
* @returns Returns the new mapped object.
|
||||
*
|
||||
* @example
|
||||
* // Example usage:
|
||||
* const obj = { a: 1, b: 2 };
|
||||
* const result = mapValues(obj, (value) => value * 2);
|
||||
* console.log(result); // { a: 2, b: 4 }
|
||||
*/
|
||||
declare function mapValues<T extends object, K extends keyof T, V>(object: T, getNewValue: (value: T[K], key: K, object: T) => V): Record<K, V>;
|
||||
//#endregion
|
||||
export { mapValues };
|
||||
31
frontend/node_modules/es-toolkit/dist/object/mapValues.js
generated
vendored
Normal file
31
frontend/node_modules/es-toolkit/dist/object/mapValues.js
generated
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
//#region src/object/mapValues.ts
|
||||
/**
|
||||
* Creates a new object with the same keys as the given object, but with values generated
|
||||
* by running each own enumerable property of the object through the iteratee function.
|
||||
*
|
||||
* @template T - The type of the object.
|
||||
* @template K - The type of the keys in the object.
|
||||
* @template V - The type of the new values generated by the iteratee function.
|
||||
*
|
||||
* @param object - The object to iterate over.
|
||||
* @param getNewValue - The function invoked per own enumerable property.
|
||||
* @returns Returns the new mapped object.
|
||||
*
|
||||
* @example
|
||||
* // Example usage:
|
||||
* const obj = { a: 1, b: 2 };
|
||||
* const result = mapValues(obj, (value) => value * 2);
|
||||
* console.log(result); // { a: 2, b: 4 }
|
||||
*/
|
||||
function mapValues(object, getNewValue) {
|
||||
const result = {};
|
||||
const keys = Object.keys(object);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
const value = object[key];
|
||||
result[key] = getNewValue(value, key, object);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//#endregion
|
||||
exports.mapValues = mapValues;
|
||||
31
frontend/node_modules/es-toolkit/dist/object/mapValues.mjs
generated
vendored
Normal file
31
frontend/node_modules/es-toolkit/dist/object/mapValues.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
//#region src/object/mapValues.ts
|
||||
/**
|
||||
* Creates a new object with the same keys as the given object, but with values generated
|
||||
* by running each own enumerable property of the object through the iteratee function.
|
||||
*
|
||||
* @template T - The type of the object.
|
||||
* @template K - The type of the keys in the object.
|
||||
* @template V - The type of the new values generated by the iteratee function.
|
||||
*
|
||||
* @param object - The object to iterate over.
|
||||
* @param getNewValue - The function invoked per own enumerable property.
|
||||
* @returns Returns the new mapped object.
|
||||
*
|
||||
* @example
|
||||
* // Example usage:
|
||||
* const obj = { a: 1, b: 2 };
|
||||
* const result = mapValues(obj, (value) => value * 2);
|
||||
* console.log(result); // { a: 2, b: 4 }
|
||||
*/
|
||||
function mapValues(object, getNewValue) {
|
||||
const result = {};
|
||||
const keys = Object.keys(object);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
const value = object[key];
|
||||
result[key] = getNewValue(value, key, object);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//#endregion
|
||||
export { mapValues };
|
||||
44
frontend/node_modules/es-toolkit/dist/object/merge.d.mts
generated
vendored
Normal file
44
frontend/node_modules/es-toolkit/dist/object/merge.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
//#region src/object/merge.d.ts
|
||||
/**
|
||||
* Merges the properties of the source object into the target object.
|
||||
*
|
||||
* This function performs a deep merge, meaning nested objects and arrays are merged recursively.
|
||||
* If a property in the source object is an array or an object and the corresponding property in the target object is also an array or object, they will be merged.
|
||||
* If a property in the source object is undefined, it will not overwrite a defined property in the target object.
|
||||
*
|
||||
* Note that this function mutates the target object.
|
||||
*
|
||||
* @param target - The target object into which the source object properties will be merged. This object is modified in place.
|
||||
* @param source - The source object whose properties will be merged into the target object.
|
||||
* @returns The updated target object with properties from the source object merged in.
|
||||
*
|
||||
* @template T - Type of the target object.
|
||||
* @template S - Type of the source object.
|
||||
*
|
||||
* @example
|
||||
* const target = { a: 1, b: { x: 1, y: 2 } };
|
||||
* const source = { b: { y: 3, z: 4 }, c: 5 };
|
||||
*
|
||||
* const result = merge(target, source);
|
||||
* console.log(result);
|
||||
* // Output: { a: 1, b: { x: 1, y: 3, z: 4 }, c: 5 }
|
||||
*
|
||||
* @example
|
||||
* const target = { a: [1, 2], b: { x: 1 } };
|
||||
* const source = { a: [3], b: { y: 2 } };
|
||||
*
|
||||
* const result = merge(target, source);
|
||||
* console.log(result);
|
||||
* // Output: { a: [3, 2], b: { x: 1, y: 2 } }
|
||||
*
|
||||
* @example
|
||||
* const target = { a: null };
|
||||
* const source = { a: [1, 2, 3] };
|
||||
*
|
||||
* const result = merge(target, source);
|
||||
* console.log(result);
|
||||
* // Output: { a: [1, 2, 3] }
|
||||
*/
|
||||
declare function merge<T extends Record<PropertyKey, any>, S extends Record<PropertyKey, any>>(target: T, source: S): T & S;
|
||||
//#endregion
|
||||
export { merge };
|
||||
44
frontend/node_modules/es-toolkit/dist/object/merge.d.ts
generated
vendored
Normal file
44
frontend/node_modules/es-toolkit/dist/object/merge.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
//#region src/object/merge.d.ts
|
||||
/**
|
||||
* Merges the properties of the source object into the target object.
|
||||
*
|
||||
* This function performs a deep merge, meaning nested objects and arrays are merged recursively.
|
||||
* If a property in the source object is an array or an object and the corresponding property in the target object is also an array or object, they will be merged.
|
||||
* If a property in the source object is undefined, it will not overwrite a defined property in the target object.
|
||||
*
|
||||
* Note that this function mutates the target object.
|
||||
*
|
||||
* @param target - The target object into which the source object properties will be merged. This object is modified in place.
|
||||
* @param source - The source object whose properties will be merged into the target object.
|
||||
* @returns The updated target object with properties from the source object merged in.
|
||||
*
|
||||
* @template T - Type of the target object.
|
||||
* @template S - Type of the source object.
|
||||
*
|
||||
* @example
|
||||
* const target = { a: 1, b: { x: 1, y: 2 } };
|
||||
* const source = { b: { y: 3, z: 4 }, c: 5 };
|
||||
*
|
||||
* const result = merge(target, source);
|
||||
* console.log(result);
|
||||
* // Output: { a: 1, b: { x: 1, y: 3, z: 4 }, c: 5 }
|
||||
*
|
||||
* @example
|
||||
* const target = { a: [1, 2], b: { x: 1 } };
|
||||
* const source = { a: [3], b: { y: 2 } };
|
||||
*
|
||||
* const result = merge(target, source);
|
||||
* console.log(result);
|
||||
* // Output: { a: [3, 2], b: { x: 1, y: 2 } }
|
||||
*
|
||||
* @example
|
||||
* const target = { a: null };
|
||||
* const source = { a: [1, 2, 3] };
|
||||
*
|
||||
* const result = merge(target, source);
|
||||
* console.log(result);
|
||||
* // Output: { a: [1, 2, 3] }
|
||||
*/
|
||||
declare function merge<T extends Record<PropertyKey, any>, S extends Record<PropertyKey, any>>(target: T, source: S): T & S;
|
||||
//#endregion
|
||||
export { merge };
|
||||
62
frontend/node_modules/es-toolkit/dist/object/merge.js
generated
vendored
Normal file
62
frontend/node_modules/es-toolkit/dist/object/merge.js
generated
vendored
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
const require_isPlainObject = require("../predicate/isPlainObject.js");
|
||||
const require_isUnsafeProperty = require("../_internal/isUnsafeProperty.js");
|
||||
//#region src/object/merge.ts
|
||||
/**
|
||||
* Merges the properties of the source object into the target object.
|
||||
*
|
||||
* This function performs a deep merge, meaning nested objects and arrays are merged recursively.
|
||||
* If a property in the source object is an array or an object and the corresponding property in the target object is also an array or object, they will be merged.
|
||||
* If a property in the source object is undefined, it will not overwrite a defined property in the target object.
|
||||
*
|
||||
* Note that this function mutates the target object.
|
||||
*
|
||||
* @param target - The target object into which the source object properties will be merged. This object is modified in place.
|
||||
* @param source - The source object whose properties will be merged into the target object.
|
||||
* @returns The updated target object with properties from the source object merged in.
|
||||
*
|
||||
* @template T - Type of the target object.
|
||||
* @template S - Type of the source object.
|
||||
*
|
||||
* @example
|
||||
* const target = { a: 1, b: { x: 1, y: 2 } };
|
||||
* const source = { b: { y: 3, z: 4 }, c: 5 };
|
||||
*
|
||||
* const result = merge(target, source);
|
||||
* console.log(result);
|
||||
* // Output: { a: 1, b: { x: 1, y: 3, z: 4 }, c: 5 }
|
||||
*
|
||||
* @example
|
||||
* const target = { a: [1, 2], b: { x: 1 } };
|
||||
* const source = { a: [3], b: { y: 2 } };
|
||||
*
|
||||
* const result = merge(target, source);
|
||||
* console.log(result);
|
||||
* // Output: { a: [3, 2], b: { x: 1, y: 2 } }
|
||||
*
|
||||
* @example
|
||||
* const target = { a: null };
|
||||
* const source = { a: [1, 2, 3] };
|
||||
*
|
||||
* const result = merge(target, source);
|
||||
* console.log(result);
|
||||
* // Output: { a: [1, 2, 3] }
|
||||
*/
|
||||
function merge(target, source) {
|
||||
const sourceKeys = Object.keys(source);
|
||||
for (let i = 0; i < sourceKeys.length; i++) {
|
||||
const key = sourceKeys[i];
|
||||
if (require_isUnsafeProperty.isUnsafeProperty(key)) continue;
|
||||
const sourceValue = source[key];
|
||||
const targetValue = target[key];
|
||||
if (isMergeableValue(sourceValue) && isMergeableValue(targetValue)) target[key] = merge(targetValue, sourceValue);
|
||||
else if (Array.isArray(sourceValue)) target[key] = merge([], sourceValue);
|
||||
else if (require_isPlainObject.isPlainObject(sourceValue)) target[key] = merge({}, sourceValue);
|
||||
else if (targetValue === void 0 || sourceValue !== void 0) target[key] = sourceValue;
|
||||
}
|
||||
return target;
|
||||
}
|
||||
function isMergeableValue(value) {
|
||||
return require_isPlainObject.isPlainObject(value) || Array.isArray(value);
|
||||
}
|
||||
//#endregion
|
||||
exports.merge = merge;
|
||||
62
frontend/node_modules/es-toolkit/dist/object/merge.mjs
generated
vendored
Normal file
62
frontend/node_modules/es-toolkit/dist/object/merge.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
import { isPlainObject } from "../predicate/isPlainObject.mjs";
|
||||
import { isUnsafeProperty } from "../_internal/isUnsafeProperty.mjs";
|
||||
//#region src/object/merge.ts
|
||||
/**
|
||||
* Merges the properties of the source object into the target object.
|
||||
*
|
||||
* This function performs a deep merge, meaning nested objects and arrays are merged recursively.
|
||||
* If a property in the source object is an array or an object and the corresponding property in the target object is also an array or object, they will be merged.
|
||||
* If a property in the source object is undefined, it will not overwrite a defined property in the target object.
|
||||
*
|
||||
* Note that this function mutates the target object.
|
||||
*
|
||||
* @param target - The target object into which the source object properties will be merged. This object is modified in place.
|
||||
* @param source - The source object whose properties will be merged into the target object.
|
||||
* @returns The updated target object with properties from the source object merged in.
|
||||
*
|
||||
* @template T - Type of the target object.
|
||||
* @template S - Type of the source object.
|
||||
*
|
||||
* @example
|
||||
* const target = { a: 1, b: { x: 1, y: 2 } };
|
||||
* const source = { b: { y: 3, z: 4 }, c: 5 };
|
||||
*
|
||||
* const result = merge(target, source);
|
||||
* console.log(result);
|
||||
* // Output: { a: 1, b: { x: 1, y: 3, z: 4 }, c: 5 }
|
||||
*
|
||||
* @example
|
||||
* const target = { a: [1, 2], b: { x: 1 } };
|
||||
* const source = { a: [3], b: { y: 2 } };
|
||||
*
|
||||
* const result = merge(target, source);
|
||||
* console.log(result);
|
||||
* // Output: { a: [3, 2], b: { x: 1, y: 2 } }
|
||||
*
|
||||
* @example
|
||||
* const target = { a: null };
|
||||
* const source = { a: [1, 2, 3] };
|
||||
*
|
||||
* const result = merge(target, source);
|
||||
* console.log(result);
|
||||
* // Output: { a: [1, 2, 3] }
|
||||
*/
|
||||
function merge(target, source) {
|
||||
const sourceKeys = Object.keys(source);
|
||||
for (let i = 0; i < sourceKeys.length; i++) {
|
||||
const key = sourceKeys[i];
|
||||
if (isUnsafeProperty(key)) continue;
|
||||
const sourceValue = source[key];
|
||||
const targetValue = target[key];
|
||||
if (isMergeableValue(sourceValue) && isMergeableValue(targetValue)) target[key] = merge(targetValue, sourceValue);
|
||||
else if (Array.isArray(sourceValue)) target[key] = merge([], sourceValue);
|
||||
else if (isPlainObject(sourceValue)) target[key] = merge({}, sourceValue);
|
||||
else if (targetValue === void 0 || sourceValue !== void 0) target[key] = sourceValue;
|
||||
}
|
||||
return target;
|
||||
}
|
||||
function isMergeableValue(value) {
|
||||
return isPlainObject(value) || Array.isArray(value);
|
||||
}
|
||||
//#endregion
|
||||
export { merge };
|
||||
52
frontend/node_modules/es-toolkit/dist/object/mergeWith.d.mts
generated
vendored
Normal file
52
frontend/node_modules/es-toolkit/dist/object/mergeWith.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
//#region src/object/mergeWith.d.ts
|
||||
/**
|
||||
* Merges the properties of the source object into the target object.
|
||||
*
|
||||
* You can provide a custom `merge` function to control how properties are merged. It should return the value to be set in the target object.
|
||||
*
|
||||
* If it returns `undefined`, a default deep merge will be applied for arrays and objects:
|
||||
*
|
||||
* - If a property in the source object is an array or an object and the corresponding property in the target object is also an array or object, they will be merged.
|
||||
* - If a property in the source object is undefined, it will not overwrite a defined property in the target object.
|
||||
*
|
||||
* Note that this function mutates the target object.
|
||||
*
|
||||
* @param target - The target object into which the source object properties will be merged. This object is modified in place.
|
||||
* @param source - The source object whose properties will be merged into the target object.
|
||||
* @param merge - A custom merge function that defines how properties should be combined. It receives the following arguments:
|
||||
* - `targetValue`: The current value of the property in the target object.
|
||||
* - `sourceValue`: The value of the property in the source object.
|
||||
* - `key`: The key of the property being merged.
|
||||
* - `target`: The target object.
|
||||
* - `source`: The source object.
|
||||
*
|
||||
* @returns The updated target object with properties from the source object merged in.
|
||||
*
|
||||
* @template T - Type of the target object.
|
||||
* @template S - Type of the source object.
|
||||
*
|
||||
* @example
|
||||
* const target = { a: 1, b: 2 };
|
||||
* const source = { b: 3, c: 4 };
|
||||
*
|
||||
* mergeWith(target, source, (targetValue, sourceValue) => {
|
||||
* if (typeof targetValue === 'number' && typeof sourceValue === 'number') {
|
||||
* return targetValue + sourceValue;
|
||||
* }
|
||||
* });
|
||||
* // Returns { a: 1, b: 5, c: 4 }
|
||||
* @example
|
||||
* const target = { a: [1], b: [2] };
|
||||
* const source = { a: [3], b: [4] };
|
||||
*
|
||||
* const result = mergeWith(target, source, (objValue, srcValue) => {
|
||||
* if (Array.isArray(objValue)) {
|
||||
* return objValue.concat(srcValue);
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* expect(result).toEqual({ a: [1, 3], b: [2, 4] });
|
||||
*/
|
||||
declare function mergeWith<T extends Record<PropertyKey, any>, S extends Record<PropertyKey, any>>(target: T, source: S, merge: (targetValue: any, sourceValue: any, key: string, target: T, source: S) => any): T & S;
|
||||
//#endregion
|
||||
export { mergeWith };
|
||||
52
frontend/node_modules/es-toolkit/dist/object/mergeWith.d.ts
generated
vendored
Normal file
52
frontend/node_modules/es-toolkit/dist/object/mergeWith.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
//#region src/object/mergeWith.d.ts
|
||||
/**
|
||||
* Merges the properties of the source object into the target object.
|
||||
*
|
||||
* You can provide a custom `merge` function to control how properties are merged. It should return the value to be set in the target object.
|
||||
*
|
||||
* If it returns `undefined`, a default deep merge will be applied for arrays and objects:
|
||||
*
|
||||
* - If a property in the source object is an array or an object and the corresponding property in the target object is also an array or object, they will be merged.
|
||||
* - If a property in the source object is undefined, it will not overwrite a defined property in the target object.
|
||||
*
|
||||
* Note that this function mutates the target object.
|
||||
*
|
||||
* @param target - The target object into which the source object properties will be merged. This object is modified in place.
|
||||
* @param source - The source object whose properties will be merged into the target object.
|
||||
* @param merge - A custom merge function that defines how properties should be combined. It receives the following arguments:
|
||||
* - `targetValue`: The current value of the property in the target object.
|
||||
* - `sourceValue`: The value of the property in the source object.
|
||||
* - `key`: The key of the property being merged.
|
||||
* - `target`: The target object.
|
||||
* - `source`: The source object.
|
||||
*
|
||||
* @returns The updated target object with properties from the source object merged in.
|
||||
*
|
||||
* @template T - Type of the target object.
|
||||
* @template S - Type of the source object.
|
||||
*
|
||||
* @example
|
||||
* const target = { a: 1, b: 2 };
|
||||
* const source = { b: 3, c: 4 };
|
||||
*
|
||||
* mergeWith(target, source, (targetValue, sourceValue) => {
|
||||
* if (typeof targetValue === 'number' && typeof sourceValue === 'number') {
|
||||
* return targetValue + sourceValue;
|
||||
* }
|
||||
* });
|
||||
* // Returns { a: 1, b: 5, c: 4 }
|
||||
* @example
|
||||
* const target = { a: [1], b: [2] };
|
||||
* const source = { a: [3], b: [4] };
|
||||
*
|
||||
* const result = mergeWith(target, source, (objValue, srcValue) => {
|
||||
* if (Array.isArray(objValue)) {
|
||||
* return objValue.concat(srcValue);
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* expect(result).toEqual({ a: [1, 3], b: [2, 4] });
|
||||
*/
|
||||
declare function mergeWith<T extends Record<PropertyKey, any>, S extends Record<PropertyKey, any>>(target: T, source: S, merge: (targetValue: any, sourceValue: any, key: string, target: T, source: S) => any): T & S;
|
||||
//#endregion
|
||||
export { mergeWith };
|
||||
70
frontend/node_modules/es-toolkit/dist/object/mergeWith.js
generated
vendored
Normal file
70
frontend/node_modules/es-toolkit/dist/object/mergeWith.js
generated
vendored
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
const require_isPlainObject = require("../predicate/isPlainObject.js");
|
||||
const require_isUnsafeProperty = require("../_internal/isUnsafeProperty.js");
|
||||
//#region src/object/mergeWith.ts
|
||||
/**
|
||||
* Merges the properties of the source object into the target object.
|
||||
*
|
||||
* You can provide a custom `merge` function to control how properties are merged. It should return the value to be set in the target object.
|
||||
*
|
||||
* If it returns `undefined`, a default deep merge will be applied for arrays and objects:
|
||||
*
|
||||
* - If a property in the source object is an array or an object and the corresponding property in the target object is also an array or object, they will be merged.
|
||||
* - If a property in the source object is undefined, it will not overwrite a defined property in the target object.
|
||||
*
|
||||
* Note that this function mutates the target object.
|
||||
*
|
||||
* @param target - The target object into which the source object properties will be merged. This object is modified in place.
|
||||
* @param source - The source object whose properties will be merged into the target object.
|
||||
* @param merge - A custom merge function that defines how properties should be combined. It receives the following arguments:
|
||||
* - `targetValue`: The current value of the property in the target object.
|
||||
* - `sourceValue`: The value of the property in the source object.
|
||||
* - `key`: The key of the property being merged.
|
||||
* - `target`: The target object.
|
||||
* - `source`: The source object.
|
||||
*
|
||||
* @returns The updated target object with properties from the source object merged in.
|
||||
*
|
||||
* @template T - Type of the target object.
|
||||
* @template S - Type of the source object.
|
||||
*
|
||||
* @example
|
||||
* const target = { a: 1, b: 2 };
|
||||
* const source = { b: 3, c: 4 };
|
||||
*
|
||||
* mergeWith(target, source, (targetValue, sourceValue) => {
|
||||
* if (typeof targetValue === 'number' && typeof sourceValue === 'number') {
|
||||
* return targetValue + sourceValue;
|
||||
* }
|
||||
* });
|
||||
* // Returns { a: 1, b: 5, c: 4 }
|
||||
* @example
|
||||
* const target = { a: [1], b: [2] };
|
||||
* const source = { a: [3], b: [4] };
|
||||
*
|
||||
* const result = mergeWith(target, source, (objValue, srcValue) => {
|
||||
* if (Array.isArray(objValue)) {
|
||||
* return objValue.concat(srcValue);
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* expect(result).toEqual({ a: [1, 3], b: [2, 4] });
|
||||
*/
|
||||
function mergeWith(target, source, merge) {
|
||||
const sourceKeys = Object.keys(source);
|
||||
for (let i = 0; i < sourceKeys.length; i++) {
|
||||
const key = sourceKeys[i];
|
||||
if (require_isUnsafeProperty.isUnsafeProperty(key)) continue;
|
||||
const sourceValue = source[key];
|
||||
const targetValue = target[key];
|
||||
const merged = merge(targetValue, sourceValue, key, target, source);
|
||||
if (merged !== void 0) target[key] = merged;
|
||||
else if (Array.isArray(sourceValue)) if (Array.isArray(targetValue)) target[key] = mergeWith(targetValue, sourceValue, merge);
|
||||
else target[key] = mergeWith([], sourceValue, merge);
|
||||
else if (require_isPlainObject.isPlainObject(sourceValue)) if (require_isPlainObject.isPlainObject(targetValue)) target[key] = mergeWith(targetValue, sourceValue, merge);
|
||||
else target[key] = mergeWith({}, sourceValue, merge);
|
||||
else if (targetValue === void 0 || sourceValue !== void 0) target[key] = sourceValue;
|
||||
}
|
||||
return target;
|
||||
}
|
||||
//#endregion
|
||||
exports.mergeWith = mergeWith;
|
||||
70
frontend/node_modules/es-toolkit/dist/object/mergeWith.mjs
generated
vendored
Normal file
70
frontend/node_modules/es-toolkit/dist/object/mergeWith.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
import { isPlainObject } from "../predicate/isPlainObject.mjs";
|
||||
import { isUnsafeProperty } from "../_internal/isUnsafeProperty.mjs";
|
||||
//#region src/object/mergeWith.ts
|
||||
/**
|
||||
* Merges the properties of the source object into the target object.
|
||||
*
|
||||
* You can provide a custom `merge` function to control how properties are merged. It should return the value to be set in the target object.
|
||||
*
|
||||
* If it returns `undefined`, a default deep merge will be applied for arrays and objects:
|
||||
*
|
||||
* - If a property in the source object is an array or an object and the corresponding property in the target object is also an array or object, they will be merged.
|
||||
* - If a property in the source object is undefined, it will not overwrite a defined property in the target object.
|
||||
*
|
||||
* Note that this function mutates the target object.
|
||||
*
|
||||
* @param target - The target object into which the source object properties will be merged. This object is modified in place.
|
||||
* @param source - The source object whose properties will be merged into the target object.
|
||||
* @param merge - A custom merge function that defines how properties should be combined. It receives the following arguments:
|
||||
* - `targetValue`: The current value of the property in the target object.
|
||||
* - `sourceValue`: The value of the property in the source object.
|
||||
* - `key`: The key of the property being merged.
|
||||
* - `target`: The target object.
|
||||
* - `source`: The source object.
|
||||
*
|
||||
* @returns The updated target object with properties from the source object merged in.
|
||||
*
|
||||
* @template T - Type of the target object.
|
||||
* @template S - Type of the source object.
|
||||
*
|
||||
* @example
|
||||
* const target = { a: 1, b: 2 };
|
||||
* const source = { b: 3, c: 4 };
|
||||
*
|
||||
* mergeWith(target, source, (targetValue, sourceValue) => {
|
||||
* if (typeof targetValue === 'number' && typeof sourceValue === 'number') {
|
||||
* return targetValue + sourceValue;
|
||||
* }
|
||||
* });
|
||||
* // Returns { a: 1, b: 5, c: 4 }
|
||||
* @example
|
||||
* const target = { a: [1], b: [2] };
|
||||
* const source = { a: [3], b: [4] };
|
||||
*
|
||||
* const result = mergeWith(target, source, (objValue, srcValue) => {
|
||||
* if (Array.isArray(objValue)) {
|
||||
* return objValue.concat(srcValue);
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* expect(result).toEqual({ a: [1, 3], b: [2, 4] });
|
||||
*/
|
||||
function mergeWith(target, source, merge) {
|
||||
const sourceKeys = Object.keys(source);
|
||||
for (let i = 0; i < sourceKeys.length; i++) {
|
||||
const key = sourceKeys[i];
|
||||
if (isUnsafeProperty(key)) continue;
|
||||
const sourceValue = source[key];
|
||||
const targetValue = target[key];
|
||||
const merged = merge(targetValue, sourceValue, key, target, source);
|
||||
if (merged !== void 0) target[key] = merged;
|
||||
else if (Array.isArray(sourceValue)) if (Array.isArray(targetValue)) target[key] = mergeWith(targetValue, sourceValue, merge);
|
||||
else target[key] = mergeWith([], sourceValue, merge);
|
||||
else if (isPlainObject(sourceValue)) if (isPlainObject(targetValue)) target[key] = mergeWith(targetValue, sourceValue, merge);
|
||||
else target[key] = mergeWith({}, sourceValue, merge);
|
||||
else if (targetValue === void 0 || sourceValue !== void 0) target[key] = sourceValue;
|
||||
}
|
||||
return target;
|
||||
}
|
||||
//#endregion
|
||||
export { mergeWith };
|
||||
21
frontend/node_modules/es-toolkit/dist/object/omit.d.mts
generated
vendored
Normal file
21
frontend/node_modules/es-toolkit/dist/object/omit.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
//#region src/object/omit.d.ts
|
||||
/**
|
||||
* Creates a new object with specified keys omitted.
|
||||
*
|
||||
* This function takes an object and an array of keys, and returns a new object that
|
||||
* excludes the properties corresponding to the specified keys.
|
||||
*
|
||||
* @template T - The type of object.
|
||||
* @template K - The type of keys in object.
|
||||
* @param obj - The object to omit keys from.
|
||||
* @param keys - An array of keys to be omitted from the object.
|
||||
* @returns A new object with the specified keys omitted.
|
||||
*
|
||||
* @example
|
||||
* const obj = { a: 1, b: 2, c: 3 };
|
||||
* const result = omit(obj, ['b', 'c']);
|
||||
* // result will be { a: 1 }
|
||||
*/
|
||||
declare function omit<T extends Record<string, any>, K extends keyof T>(obj: T, keys: readonly K[]): Omit<T, K>;
|
||||
//#endregion
|
||||
export { omit };
|
||||
21
frontend/node_modules/es-toolkit/dist/object/omit.d.ts
generated
vendored
Normal file
21
frontend/node_modules/es-toolkit/dist/object/omit.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
//#region src/object/omit.d.ts
|
||||
/**
|
||||
* Creates a new object with specified keys omitted.
|
||||
*
|
||||
* This function takes an object and an array of keys, and returns a new object that
|
||||
* excludes the properties corresponding to the specified keys.
|
||||
*
|
||||
* @template T - The type of object.
|
||||
* @template K - The type of keys in object.
|
||||
* @param obj - The object to omit keys from.
|
||||
* @param keys - An array of keys to be omitted from the object.
|
||||
* @returns A new object with the specified keys omitted.
|
||||
*
|
||||
* @example
|
||||
* const obj = { a: 1, b: 2, c: 3 };
|
||||
* const result = omit(obj, ['b', 'c']);
|
||||
* // result will be { a: 1 }
|
||||
*/
|
||||
declare function omit<T extends Record<string, any>, K extends keyof T>(obj: T, keys: readonly K[]): Omit<T, K>;
|
||||
//#endregion
|
||||
export { omit };
|
||||
28
frontend/node_modules/es-toolkit/dist/object/omit.js
generated
vendored
Normal file
28
frontend/node_modules/es-toolkit/dist/object/omit.js
generated
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
//#region src/object/omit.ts
|
||||
/**
|
||||
* Creates a new object with specified keys omitted.
|
||||
*
|
||||
* This function takes an object and an array of keys, and returns a new object that
|
||||
* excludes the properties corresponding to the specified keys.
|
||||
*
|
||||
* @template T - The type of object.
|
||||
* @template K - The type of keys in object.
|
||||
* @param obj - The object to omit keys from.
|
||||
* @param keys - An array of keys to be omitted from the object.
|
||||
* @returns A new object with the specified keys omitted.
|
||||
*
|
||||
* @example
|
||||
* const obj = { a: 1, b: 2, c: 3 };
|
||||
* const result = omit(obj, ['b', 'c']);
|
||||
* // result will be { a: 1 }
|
||||
*/
|
||||
function omit(obj, keys) {
|
||||
const result = { ...obj };
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
delete result[key];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//#endregion
|
||||
exports.omit = omit;
|
||||
28
frontend/node_modules/es-toolkit/dist/object/omit.mjs
generated
vendored
Normal file
28
frontend/node_modules/es-toolkit/dist/object/omit.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
//#region src/object/omit.ts
|
||||
/**
|
||||
* Creates a new object with specified keys omitted.
|
||||
*
|
||||
* This function takes an object and an array of keys, and returns a new object that
|
||||
* excludes the properties corresponding to the specified keys.
|
||||
*
|
||||
* @template T - The type of object.
|
||||
* @template K - The type of keys in object.
|
||||
* @param obj - The object to omit keys from.
|
||||
* @param keys - An array of keys to be omitted from the object.
|
||||
* @returns A new object with the specified keys omitted.
|
||||
*
|
||||
* @example
|
||||
* const obj = { a: 1, b: 2, c: 3 };
|
||||
* const result = omit(obj, ['b', 'c']);
|
||||
* // result will be { a: 1 }
|
||||
*/
|
||||
function omit(obj, keys) {
|
||||
const result = { ...obj };
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
delete result[key];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//#endregion
|
||||
export { omit };
|
||||
23
frontend/node_modules/es-toolkit/dist/object/omitBy.d.mts
generated
vendored
Normal file
23
frontend/node_modules/es-toolkit/dist/object/omitBy.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
//#region src/object/omitBy.d.ts
|
||||
/**
|
||||
* Creates a new object composed of the properties that do not satisfy the predicate function.
|
||||
*
|
||||
* This function takes an object and a predicate function, and returns a new object that
|
||||
* includes only the properties for which the predicate function returns false.
|
||||
*
|
||||
* @template T - The type of object.
|
||||
* @param obj - The object to omit properties from.
|
||||
* @param shouldOmit - A predicate function that determines
|
||||
* whether a property should be omitted. It takes the property's key and value as arguments and returns `true`
|
||||
* if the property should be omitted, and `false` otherwise.
|
||||
* @returns A new object with the properties that do not satisfy the predicate function.
|
||||
*
|
||||
* @example
|
||||
* const obj = { a: 1, b: 'omit', c: 3 };
|
||||
* const shouldOmit = (value) => typeof value === 'string';
|
||||
* const result = omitBy(obj, shouldOmit);
|
||||
* // result will be { a: 1, c: 3 }
|
||||
*/
|
||||
declare function omitBy<T extends Record<string, any>>(obj: T, shouldOmit: (value: T[keyof T], key: keyof T) => boolean): Partial<T>;
|
||||
//#endregion
|
||||
export { omitBy };
|
||||
23
frontend/node_modules/es-toolkit/dist/object/omitBy.d.ts
generated
vendored
Normal file
23
frontend/node_modules/es-toolkit/dist/object/omitBy.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
//#region src/object/omitBy.d.ts
|
||||
/**
|
||||
* Creates a new object composed of the properties that do not satisfy the predicate function.
|
||||
*
|
||||
* This function takes an object and a predicate function, and returns a new object that
|
||||
* includes only the properties for which the predicate function returns false.
|
||||
*
|
||||
* @template T - The type of object.
|
||||
* @param obj - The object to omit properties from.
|
||||
* @param shouldOmit - A predicate function that determines
|
||||
* whether a property should be omitted. It takes the property's key and value as arguments and returns `true`
|
||||
* if the property should be omitted, and `false` otherwise.
|
||||
* @returns A new object with the properties that do not satisfy the predicate function.
|
||||
*
|
||||
* @example
|
||||
* const obj = { a: 1, b: 'omit', c: 3 };
|
||||
* const shouldOmit = (value) => typeof value === 'string';
|
||||
* const result = omitBy(obj, shouldOmit);
|
||||
* // result will be { a: 1, c: 3 }
|
||||
*/
|
||||
declare function omitBy<T extends Record<string, any>>(obj: T, shouldOmit: (value: T[keyof T], key: keyof T) => boolean): Partial<T>;
|
||||
//#endregion
|
||||
export { omitBy };
|
||||
32
frontend/node_modules/es-toolkit/dist/object/omitBy.js
generated
vendored
Normal file
32
frontend/node_modules/es-toolkit/dist/object/omitBy.js
generated
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
//#region src/object/omitBy.ts
|
||||
/**
|
||||
* Creates a new object composed of the properties that do not satisfy the predicate function.
|
||||
*
|
||||
* This function takes an object and a predicate function, and returns a new object that
|
||||
* includes only the properties for which the predicate function returns false.
|
||||
*
|
||||
* @template T - The type of object.
|
||||
* @param obj - The object to omit properties from.
|
||||
* @param shouldOmit - A predicate function that determines
|
||||
* whether a property should be omitted. It takes the property's key and value as arguments and returns `true`
|
||||
* if the property should be omitted, and `false` otherwise.
|
||||
* @returns A new object with the properties that do not satisfy the predicate function.
|
||||
*
|
||||
* @example
|
||||
* const obj = { a: 1, b: 'omit', c: 3 };
|
||||
* const shouldOmit = (value) => typeof value === 'string';
|
||||
* const result = omitBy(obj, shouldOmit);
|
||||
* // result will be { a: 1, c: 3 }
|
||||
*/
|
||||
function omitBy(obj, shouldOmit) {
|
||||
const result = {};
|
||||
const keys = Object.keys(obj);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
const value = obj[key];
|
||||
if (!shouldOmit(value, key)) result[key] = value;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//#endregion
|
||||
exports.omitBy = omitBy;
|
||||
32
frontend/node_modules/es-toolkit/dist/object/omitBy.mjs
generated
vendored
Normal file
32
frontend/node_modules/es-toolkit/dist/object/omitBy.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
//#region src/object/omitBy.ts
|
||||
/**
|
||||
* Creates a new object composed of the properties that do not satisfy the predicate function.
|
||||
*
|
||||
* This function takes an object and a predicate function, and returns a new object that
|
||||
* includes only the properties for which the predicate function returns false.
|
||||
*
|
||||
* @template T - The type of object.
|
||||
* @param obj - The object to omit properties from.
|
||||
* @param shouldOmit - A predicate function that determines
|
||||
* whether a property should be omitted. It takes the property's key and value as arguments and returns `true`
|
||||
* if the property should be omitted, and `false` otherwise.
|
||||
* @returns A new object with the properties that do not satisfy the predicate function.
|
||||
*
|
||||
* @example
|
||||
* const obj = { a: 1, b: 'omit', c: 3 };
|
||||
* const shouldOmit = (value) => typeof value === 'string';
|
||||
* const result = omitBy(obj, shouldOmit);
|
||||
* // result will be { a: 1, c: 3 }
|
||||
*/
|
||||
function omitBy(obj, shouldOmit) {
|
||||
const result = {};
|
||||
const keys = Object.keys(obj);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
const value = obj[key];
|
||||
if (!shouldOmit(value, key)) result[key] = value;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//#endregion
|
||||
export { omitBy };
|
||||
21
frontend/node_modules/es-toolkit/dist/object/pick.d.mts
generated
vendored
Normal file
21
frontend/node_modules/es-toolkit/dist/object/pick.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
//#region src/object/pick.d.ts
|
||||
/**
|
||||
* Creates a new object composed of the picked object properties.
|
||||
*
|
||||
* This function takes an object and an array of keys, and returns a new object that
|
||||
* includes only the properties corresponding to the specified keys.
|
||||
*
|
||||
* @template T - The type of object.
|
||||
* @template K - The type of keys in object.
|
||||
* @param obj - The object to pick keys from.
|
||||
* @param keys - An array of keys to be picked from the object.
|
||||
* @returns A new object with the specified keys picked.
|
||||
*
|
||||
* @example
|
||||
* const obj = { a: 1, b: 2, c: 3 };
|
||||
* const result = pick(obj, ['a', 'c']);
|
||||
* // result will be { a: 1, c: 3 }
|
||||
*/
|
||||
declare function pick<T extends Record<string, any>, K extends keyof T>(obj: T, keys: readonly K[]): Pick<T, K>;
|
||||
//#endregion
|
||||
export { pick };
|
||||
21
frontend/node_modules/es-toolkit/dist/object/pick.d.ts
generated
vendored
Normal file
21
frontend/node_modules/es-toolkit/dist/object/pick.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
//#region src/object/pick.d.ts
|
||||
/**
|
||||
* Creates a new object composed of the picked object properties.
|
||||
*
|
||||
* This function takes an object and an array of keys, and returns a new object that
|
||||
* includes only the properties corresponding to the specified keys.
|
||||
*
|
||||
* @template T - The type of object.
|
||||
* @template K - The type of keys in object.
|
||||
* @param obj - The object to pick keys from.
|
||||
* @param keys - An array of keys to be picked from the object.
|
||||
* @returns A new object with the specified keys picked.
|
||||
*
|
||||
* @example
|
||||
* const obj = { a: 1, b: 2, c: 3 };
|
||||
* const result = pick(obj, ['a', 'c']);
|
||||
* // result will be { a: 1, c: 3 }
|
||||
*/
|
||||
declare function pick<T extends Record<string, any>, K extends keyof T>(obj: T, keys: readonly K[]): Pick<T, K>;
|
||||
//#endregion
|
||||
export { pick };
|
||||
28
frontend/node_modules/es-toolkit/dist/object/pick.js
generated
vendored
Normal file
28
frontend/node_modules/es-toolkit/dist/object/pick.js
generated
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
//#region src/object/pick.ts
|
||||
/**
|
||||
* Creates a new object composed of the picked object properties.
|
||||
*
|
||||
* This function takes an object and an array of keys, and returns a new object that
|
||||
* includes only the properties corresponding to the specified keys.
|
||||
*
|
||||
* @template T - The type of object.
|
||||
* @template K - The type of keys in object.
|
||||
* @param obj - The object to pick keys from.
|
||||
* @param keys - An array of keys to be picked from the object.
|
||||
* @returns A new object with the specified keys picked.
|
||||
*
|
||||
* @example
|
||||
* const obj = { a: 1, b: 2, c: 3 };
|
||||
* const result = pick(obj, ['a', 'c']);
|
||||
* // result will be { a: 1, c: 3 }
|
||||
*/
|
||||
function pick(obj, keys) {
|
||||
const result = {};
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
if (Object.hasOwn(obj, key)) result[key] = obj[key];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//#endregion
|
||||
exports.pick = pick;
|
||||
28
frontend/node_modules/es-toolkit/dist/object/pick.mjs
generated
vendored
Normal file
28
frontend/node_modules/es-toolkit/dist/object/pick.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
//#region src/object/pick.ts
|
||||
/**
|
||||
* Creates a new object composed of the picked object properties.
|
||||
*
|
||||
* This function takes an object and an array of keys, and returns a new object that
|
||||
* includes only the properties corresponding to the specified keys.
|
||||
*
|
||||
* @template T - The type of object.
|
||||
* @template K - The type of keys in object.
|
||||
* @param obj - The object to pick keys from.
|
||||
* @param keys - An array of keys to be picked from the object.
|
||||
* @returns A new object with the specified keys picked.
|
||||
*
|
||||
* @example
|
||||
* const obj = { a: 1, b: 2, c: 3 };
|
||||
* const result = pick(obj, ['a', 'c']);
|
||||
* // result will be { a: 1, c: 3 }
|
||||
*/
|
||||
function pick(obj, keys) {
|
||||
const result = {};
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
if (Object.hasOwn(obj, key)) result[key] = obj[key];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//#endregion
|
||||
export { pick };
|
||||
23
frontend/node_modules/es-toolkit/dist/object/pickBy.d.mts
generated
vendored
Normal file
23
frontend/node_modules/es-toolkit/dist/object/pickBy.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
//#region src/object/pickBy.d.ts
|
||||
/**
|
||||
* Creates a new object composed of the properties that satisfy the predicate function.
|
||||
*
|
||||
* This function takes an object and a predicate function, and returns a new object that
|
||||
* includes only the properties for which the predicate function returns true.
|
||||
*
|
||||
* @template T - The type of object.
|
||||
* @param obj - The object to pick properties from.
|
||||
* @param shouldPick - A predicate function that determines
|
||||
* whether a property should be picked. It takes the property's key and value as arguments and returns `true`
|
||||
* if the property should be picked, and `false` otherwise.
|
||||
* @returns A new object with the properties that satisfy the predicate function.
|
||||
*
|
||||
* @example
|
||||
* const obj = { a: 1, b: 'pick', c: 3 };
|
||||
* const shouldPick = (value) => typeof value === 'string';
|
||||
* const result = pickBy(obj, shouldPick);
|
||||
* // result will be { b: 'pick' }
|
||||
*/
|
||||
declare function pickBy<T extends Record<string, any>>(obj: T, shouldPick: (value: T[keyof T], key: keyof T) => boolean): Partial<T>;
|
||||
//#endregion
|
||||
export { pickBy };
|
||||
23
frontend/node_modules/es-toolkit/dist/object/pickBy.d.ts
generated
vendored
Normal file
23
frontend/node_modules/es-toolkit/dist/object/pickBy.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
//#region src/object/pickBy.d.ts
|
||||
/**
|
||||
* Creates a new object composed of the properties that satisfy the predicate function.
|
||||
*
|
||||
* This function takes an object and a predicate function, and returns a new object that
|
||||
* includes only the properties for which the predicate function returns true.
|
||||
*
|
||||
* @template T - The type of object.
|
||||
* @param obj - The object to pick properties from.
|
||||
* @param shouldPick - A predicate function that determines
|
||||
* whether a property should be picked. It takes the property's key and value as arguments and returns `true`
|
||||
* if the property should be picked, and `false` otherwise.
|
||||
* @returns A new object with the properties that satisfy the predicate function.
|
||||
*
|
||||
* @example
|
||||
* const obj = { a: 1, b: 'pick', c: 3 };
|
||||
* const shouldPick = (value) => typeof value === 'string';
|
||||
* const result = pickBy(obj, shouldPick);
|
||||
* // result will be { b: 'pick' }
|
||||
*/
|
||||
declare function pickBy<T extends Record<string, any>>(obj: T, shouldPick: (value: T[keyof T], key: keyof T) => boolean): Partial<T>;
|
||||
//#endregion
|
||||
export { pickBy };
|
||||
32
frontend/node_modules/es-toolkit/dist/object/pickBy.js
generated
vendored
Normal file
32
frontend/node_modules/es-toolkit/dist/object/pickBy.js
generated
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
//#region src/object/pickBy.ts
|
||||
/**
|
||||
* Creates a new object composed of the properties that satisfy the predicate function.
|
||||
*
|
||||
* This function takes an object and a predicate function, and returns a new object that
|
||||
* includes only the properties for which the predicate function returns true.
|
||||
*
|
||||
* @template T - The type of object.
|
||||
* @param obj - The object to pick properties from.
|
||||
* @param shouldPick - A predicate function that determines
|
||||
* whether a property should be picked. It takes the property's key and value as arguments and returns `true`
|
||||
* if the property should be picked, and `false` otherwise.
|
||||
* @returns A new object with the properties that satisfy the predicate function.
|
||||
*
|
||||
* @example
|
||||
* const obj = { a: 1, b: 'pick', c: 3 };
|
||||
* const shouldPick = (value) => typeof value === 'string';
|
||||
* const result = pickBy(obj, shouldPick);
|
||||
* // result will be { b: 'pick' }
|
||||
*/
|
||||
function pickBy(obj, shouldPick) {
|
||||
const result = {};
|
||||
const keys = Object.keys(obj);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
const value = obj[key];
|
||||
if (shouldPick(value, key)) result[key] = value;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//#endregion
|
||||
exports.pickBy = pickBy;
|
||||
32
frontend/node_modules/es-toolkit/dist/object/pickBy.mjs
generated
vendored
Normal file
32
frontend/node_modules/es-toolkit/dist/object/pickBy.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
//#region src/object/pickBy.ts
|
||||
/**
|
||||
* Creates a new object composed of the properties that satisfy the predicate function.
|
||||
*
|
||||
* This function takes an object and a predicate function, and returns a new object that
|
||||
* includes only the properties for which the predicate function returns true.
|
||||
*
|
||||
* @template T - The type of object.
|
||||
* @param obj - The object to pick properties from.
|
||||
* @param shouldPick - A predicate function that determines
|
||||
* whether a property should be picked. It takes the property's key and value as arguments and returns `true`
|
||||
* if the property should be picked, and `false` otherwise.
|
||||
* @returns A new object with the properties that satisfy the predicate function.
|
||||
*
|
||||
* @example
|
||||
* const obj = { a: 1, b: 'pick', c: 3 };
|
||||
* const shouldPick = (value) => typeof value === 'string';
|
||||
* const result = pickBy(obj, shouldPick);
|
||||
* // result will be { b: 'pick' }
|
||||
*/
|
||||
function pickBy(obj, shouldPick) {
|
||||
const result = {};
|
||||
const keys = Object.keys(obj);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
const value = obj[key];
|
||||
if (shouldPick(value, key)) result[key] = value;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//#endregion
|
||||
export { pickBy };
|
||||
22
frontend/node_modules/es-toolkit/dist/object/sortKeys.d.mts
generated
vendored
Normal file
22
frontend/node_modules/es-toolkit/dist/object/sortKeys.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
//#region src/object/sortKeys.d.ts
|
||||
/**
|
||||
* Creates a new object with the keys sorted.
|
||||
*
|
||||
* The keys are sorted alphabetically by default, but a custom compare function can be provided.
|
||||
*
|
||||
* @template T - The type of the object.
|
||||
* @param object - The object to sort keys from.
|
||||
* @param [compareKeys] - A custom compare function for sorting keys.
|
||||
* @returns A new object with the keys sorted.
|
||||
*
|
||||
* @example
|
||||
* sortKeys({ b: 2, a: 1, c: 3 });
|
||||
* // => { a: 1, b: 2, c: 3 }
|
||||
*
|
||||
* @example
|
||||
* sortKeys({ b: 2, a: 1, c: 3 }, (a, b) => b.localeCompare(a));
|
||||
* // => { c: 3, b: 2, a: 1 }
|
||||
*/
|
||||
declare function sortKeys<T extends Record<string, any>>(object: T, compareKeys?: (a: string, b: string) => number): T;
|
||||
//#endregion
|
||||
export { sortKeys };
|
||||
22
frontend/node_modules/es-toolkit/dist/object/sortKeys.d.ts
generated
vendored
Normal file
22
frontend/node_modules/es-toolkit/dist/object/sortKeys.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
//#region src/object/sortKeys.d.ts
|
||||
/**
|
||||
* Creates a new object with the keys sorted.
|
||||
*
|
||||
* The keys are sorted alphabetically by default, but a custom compare function can be provided.
|
||||
*
|
||||
* @template T - The type of the object.
|
||||
* @param object - The object to sort keys from.
|
||||
* @param [compareKeys] - A custom compare function for sorting keys.
|
||||
* @returns A new object with the keys sorted.
|
||||
*
|
||||
* @example
|
||||
* sortKeys({ b: 2, a: 1, c: 3 });
|
||||
* // => { a: 1, b: 2, c: 3 }
|
||||
*
|
||||
* @example
|
||||
* sortKeys({ b: 2, a: 1, c: 3 }, (a, b) => b.localeCompare(a));
|
||||
* // => { c: 3, b: 2, a: 1 }
|
||||
*/
|
||||
declare function sortKeys<T extends Record<string, any>>(object: T, compareKeys?: (a: string, b: string) => number): T;
|
||||
//#endregion
|
||||
export { sortKeys };
|
||||
30
frontend/node_modules/es-toolkit/dist/object/sortKeys.js
generated
vendored
Normal file
30
frontend/node_modules/es-toolkit/dist/object/sortKeys.js
generated
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
//#region src/object/sortKeys.ts
|
||||
/**
|
||||
* Creates a new object with the keys sorted.
|
||||
*
|
||||
* The keys are sorted alphabetically by default, but a custom compare function can be provided.
|
||||
*
|
||||
* @template T - The type of the object.
|
||||
* @param object - The object to sort keys from.
|
||||
* @param [compareKeys] - A custom compare function for sorting keys.
|
||||
* @returns A new object with the keys sorted.
|
||||
*
|
||||
* @example
|
||||
* sortKeys({ b: 2, a: 1, c: 3 });
|
||||
* // => { a: 1, b: 2, c: 3 }
|
||||
*
|
||||
* @example
|
||||
* sortKeys({ b: 2, a: 1, c: 3 }, (a, b) => b.localeCompare(a));
|
||||
* // => { c: 3, b: 2, a: 1 }
|
||||
*/
|
||||
function sortKeys(object, compareKeys) {
|
||||
const sortedKeys = Object.keys(object).sort(compareKeys);
|
||||
const result = {};
|
||||
for (let i = 0; i < sortedKeys.length; i++) {
|
||||
const key = sortedKeys[i];
|
||||
result[key] = object[key];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//#endregion
|
||||
exports.sortKeys = sortKeys;
|
||||
30
frontend/node_modules/es-toolkit/dist/object/sortKeys.mjs
generated
vendored
Normal file
30
frontend/node_modules/es-toolkit/dist/object/sortKeys.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
//#region src/object/sortKeys.ts
|
||||
/**
|
||||
* Creates a new object with the keys sorted.
|
||||
*
|
||||
* The keys are sorted alphabetically by default, but a custom compare function can be provided.
|
||||
*
|
||||
* @template T - The type of the object.
|
||||
* @param object - The object to sort keys from.
|
||||
* @param [compareKeys] - A custom compare function for sorting keys.
|
||||
* @returns A new object with the keys sorted.
|
||||
*
|
||||
* @example
|
||||
* sortKeys({ b: 2, a: 1, c: 3 });
|
||||
* // => { a: 1, b: 2, c: 3 }
|
||||
*
|
||||
* @example
|
||||
* sortKeys({ b: 2, a: 1, c: 3 }, (a, b) => b.localeCompare(a));
|
||||
* // => { c: 3, b: 2, a: 1 }
|
||||
*/
|
||||
function sortKeys(object, compareKeys) {
|
||||
const sortedKeys = Object.keys(object).sort(compareKeys);
|
||||
const result = {};
|
||||
for (let i = 0; i < sortedKeys.length; i++) {
|
||||
const key = sortedKeys[i];
|
||||
result[key] = object[key];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//#endregion
|
||||
export { sortKeys };
|
||||
56
frontend/node_modules/es-toolkit/dist/object/toCamelCaseKeys.d.mts
generated
vendored
Normal file
56
frontend/node_modules/es-toolkit/dist/object/toCamelCaseKeys.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
//#region src/object/toCamelCaseKeys.d.ts
|
||||
type SnakeToCamel<S extends string> = S extends `${infer H}_${infer T}` ? `${Lowercase<H>}${Capitalize<SnakeToCamel<T>>}` : Lowercase<S>;
|
||||
type PascalToCamel<S extends string> = S extends `${infer F}${infer R}` ? `${Lowercase<F>}${R}` : S;
|
||||
/** If it's snake_case, apply the snake_case rule; for uppercase keys, lowercase the entire string; otherwise, just lowercase the first letter (including PascalCase → camelCase). */
|
||||
type AnyToCamel<S extends string> = S extends `${string}_${string}` ? SnakeToCamel<S> : S extends Uppercase<S> ? Lowercase<S> : PascalToCamel<S>;
|
||||
type NonPlainObject = Date | RegExp | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | Promise<any> | Error | ArrayBuffer | DataView | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array | ((...args: any[]) => any) | typeof globalThis;
|
||||
type ToCamelCaseKeys<T> = T extends NonPlainObject ? T : T extends any[] ? Array<ToCamelCaseKeys<T[number]>> : T extends Record<string, any> ? { [K in keyof T as AnyToCamel<Extract<K, string>>]: ToCamelCaseKeys<T[K]> } : T;
|
||||
/**
|
||||
* Creates a new object composed of the properties with keys converted to camelCase.
|
||||
*
|
||||
* This function takes an object and returns a new object that includes the same properties,
|
||||
* but with all keys converted to camelCase format.
|
||||
*
|
||||
* @template T - The type of object.
|
||||
* @param obj - The object to convert keys from.
|
||||
* @returns A new object with all keys converted to camelCase.
|
||||
*
|
||||
* @example
|
||||
* // Example with objects
|
||||
* const obj = { user_id: 1, first_name: 'John' };
|
||||
* const result = toCamelCaseKeys(obj);
|
||||
* // result will be { userId: 1, firstName: 'John' }
|
||||
*
|
||||
* // Example with arrays of objects
|
||||
* const arr = [
|
||||
* { user_id: 1, first_name: 'John' },
|
||||
* { user_id: 2, first_name: 'Jane' }
|
||||
* ];
|
||||
* const arrResult = toCamelCaseKeys(arr);
|
||||
* // arrResult will be [{ userId: 1, firstName: 'John' }, { userId: 2, firstName: 'Jane' }]
|
||||
*
|
||||
* // Example with nested objects
|
||||
* const nested = {
|
||||
* user_data: {
|
||||
* user_id: 1,
|
||||
* user_address: {
|
||||
* street_name: 'Main St',
|
||||
* zip_code: '12345'
|
||||
* }
|
||||
* }
|
||||
* };
|
||||
* const nestedResult = toCamelCaseKeys(nested);
|
||||
* // nestedResult will be:
|
||||
* // {
|
||||
* // userData: {
|
||||
* // userId: 1,
|
||||
* // userAddress: {
|
||||
* // streetName: 'Main St',
|
||||
* // zipCode: '12345'
|
||||
* // }
|
||||
* // }
|
||||
* // }
|
||||
*/
|
||||
declare function toCamelCaseKeys<T>(obj: T): ToCamelCaseKeys<T>;
|
||||
//#endregion
|
||||
export { toCamelCaseKeys };
|
||||
56
frontend/node_modules/es-toolkit/dist/object/toCamelCaseKeys.d.ts
generated
vendored
Normal file
56
frontend/node_modules/es-toolkit/dist/object/toCamelCaseKeys.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
//#region src/object/toCamelCaseKeys.d.ts
|
||||
type SnakeToCamel<S extends string> = S extends `${infer H}_${infer T}` ? `${Lowercase<H>}${Capitalize<SnakeToCamel<T>>}` : Lowercase<S>;
|
||||
type PascalToCamel<S extends string> = S extends `${infer F}${infer R}` ? `${Lowercase<F>}${R}` : S;
|
||||
/** If it's snake_case, apply the snake_case rule; for uppercase keys, lowercase the entire string; otherwise, just lowercase the first letter (including PascalCase → camelCase). */
|
||||
type AnyToCamel<S extends string> = S extends `${string}_${string}` ? SnakeToCamel<S> : S extends Uppercase<S> ? Lowercase<S> : PascalToCamel<S>;
|
||||
type NonPlainObject = Date | RegExp | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | Promise<any> | Error | ArrayBuffer | DataView | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array | ((...args: any[]) => any) | typeof globalThis;
|
||||
type ToCamelCaseKeys<T> = T extends NonPlainObject ? T : T extends any[] ? Array<ToCamelCaseKeys<T[number]>> : T extends Record<string, any> ? { [K in keyof T as AnyToCamel<Extract<K, string>>]: ToCamelCaseKeys<T[K]> } : T;
|
||||
/**
|
||||
* Creates a new object composed of the properties with keys converted to camelCase.
|
||||
*
|
||||
* This function takes an object and returns a new object that includes the same properties,
|
||||
* but with all keys converted to camelCase format.
|
||||
*
|
||||
* @template T - The type of object.
|
||||
* @param obj - The object to convert keys from.
|
||||
* @returns A new object with all keys converted to camelCase.
|
||||
*
|
||||
* @example
|
||||
* // Example with objects
|
||||
* const obj = { user_id: 1, first_name: 'John' };
|
||||
* const result = toCamelCaseKeys(obj);
|
||||
* // result will be { userId: 1, firstName: 'John' }
|
||||
*
|
||||
* // Example with arrays of objects
|
||||
* const arr = [
|
||||
* { user_id: 1, first_name: 'John' },
|
||||
* { user_id: 2, first_name: 'Jane' }
|
||||
* ];
|
||||
* const arrResult = toCamelCaseKeys(arr);
|
||||
* // arrResult will be [{ userId: 1, firstName: 'John' }, { userId: 2, firstName: 'Jane' }]
|
||||
*
|
||||
* // Example with nested objects
|
||||
* const nested = {
|
||||
* user_data: {
|
||||
* user_id: 1,
|
||||
* user_address: {
|
||||
* street_name: 'Main St',
|
||||
* zip_code: '12345'
|
||||
* }
|
||||
* }
|
||||
* };
|
||||
* const nestedResult = toCamelCaseKeys(nested);
|
||||
* // nestedResult will be:
|
||||
* // {
|
||||
* // userData: {
|
||||
* // userId: 1,
|
||||
* // userAddress: {
|
||||
* // streetName: 'Main St',
|
||||
* // zipCode: '12345'
|
||||
* // }
|
||||
* // }
|
||||
* // }
|
||||
*/
|
||||
declare function toCamelCaseKeys<T>(obj: T): ToCamelCaseKeys<T>;
|
||||
//#endregion
|
||||
export { toCamelCaseKeys };
|
||||
66
frontend/node_modules/es-toolkit/dist/object/toCamelCaseKeys.js
generated
vendored
Normal file
66
frontend/node_modules/es-toolkit/dist/object/toCamelCaseKeys.js
generated
vendored
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
const require_isPlainObject = require("../predicate/isPlainObject.js");
|
||||
const require_isArray = require("../compat/predicate/isArray.js");
|
||||
const require_camelCase = require("../string/camelCase.js");
|
||||
//#region src/object/toCamelCaseKeys.ts
|
||||
/**
|
||||
* Creates a new object composed of the properties with keys converted to camelCase.
|
||||
*
|
||||
* This function takes an object and returns a new object that includes the same properties,
|
||||
* but with all keys converted to camelCase format.
|
||||
*
|
||||
* @template T - The type of object.
|
||||
* @param obj - The object to convert keys from.
|
||||
* @returns A new object with all keys converted to camelCase.
|
||||
*
|
||||
* @example
|
||||
* // Example with objects
|
||||
* const obj = { user_id: 1, first_name: 'John' };
|
||||
* const result = toCamelCaseKeys(obj);
|
||||
* // result will be { userId: 1, firstName: 'John' }
|
||||
*
|
||||
* // Example with arrays of objects
|
||||
* const arr = [
|
||||
* { user_id: 1, first_name: 'John' },
|
||||
* { user_id: 2, first_name: 'Jane' }
|
||||
* ];
|
||||
* const arrResult = toCamelCaseKeys(arr);
|
||||
* // arrResult will be [{ userId: 1, firstName: 'John' }, { userId: 2, firstName: 'Jane' }]
|
||||
*
|
||||
* // Example with nested objects
|
||||
* const nested = {
|
||||
* user_data: {
|
||||
* user_id: 1,
|
||||
* user_address: {
|
||||
* street_name: 'Main St',
|
||||
* zip_code: '12345'
|
||||
* }
|
||||
* }
|
||||
* };
|
||||
* const nestedResult = toCamelCaseKeys(nested);
|
||||
* // nestedResult will be:
|
||||
* // {
|
||||
* // userData: {
|
||||
* // userId: 1,
|
||||
* // userAddress: {
|
||||
* // streetName: 'Main St',
|
||||
* // zipCode: '12345'
|
||||
* // }
|
||||
* // }
|
||||
* // }
|
||||
*/
|
||||
function toCamelCaseKeys(obj) {
|
||||
if (require_isArray.isArray(obj)) return obj.map((item) => toCamelCaseKeys(item));
|
||||
if (require_isPlainObject.isPlainObject(obj)) {
|
||||
const result = {};
|
||||
const keys = Object.keys(obj);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
const camelKey = require_camelCase.camelCase(key);
|
||||
result[camelKey] = toCamelCaseKeys(obj[key]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
//#endregion
|
||||
exports.toCamelCaseKeys = toCamelCaseKeys;
|
||||
66
frontend/node_modules/es-toolkit/dist/object/toCamelCaseKeys.mjs
generated
vendored
Normal file
66
frontend/node_modules/es-toolkit/dist/object/toCamelCaseKeys.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
import { isPlainObject } from "../predicate/isPlainObject.mjs";
|
||||
import { isArray } from "../compat/predicate/isArray.mjs";
|
||||
import { camelCase } from "../string/camelCase.mjs";
|
||||
//#region src/object/toCamelCaseKeys.ts
|
||||
/**
|
||||
* Creates a new object composed of the properties with keys converted to camelCase.
|
||||
*
|
||||
* This function takes an object and returns a new object that includes the same properties,
|
||||
* but with all keys converted to camelCase format.
|
||||
*
|
||||
* @template T - The type of object.
|
||||
* @param obj - The object to convert keys from.
|
||||
* @returns A new object with all keys converted to camelCase.
|
||||
*
|
||||
* @example
|
||||
* // Example with objects
|
||||
* const obj = { user_id: 1, first_name: 'John' };
|
||||
* const result = toCamelCaseKeys(obj);
|
||||
* // result will be { userId: 1, firstName: 'John' }
|
||||
*
|
||||
* // Example with arrays of objects
|
||||
* const arr = [
|
||||
* { user_id: 1, first_name: 'John' },
|
||||
* { user_id: 2, first_name: 'Jane' }
|
||||
* ];
|
||||
* const arrResult = toCamelCaseKeys(arr);
|
||||
* // arrResult will be [{ userId: 1, firstName: 'John' }, { userId: 2, firstName: 'Jane' }]
|
||||
*
|
||||
* // Example with nested objects
|
||||
* const nested = {
|
||||
* user_data: {
|
||||
* user_id: 1,
|
||||
* user_address: {
|
||||
* street_name: 'Main St',
|
||||
* zip_code: '12345'
|
||||
* }
|
||||
* }
|
||||
* };
|
||||
* const nestedResult = toCamelCaseKeys(nested);
|
||||
* // nestedResult will be:
|
||||
* // {
|
||||
* // userData: {
|
||||
* // userId: 1,
|
||||
* // userAddress: {
|
||||
* // streetName: 'Main St',
|
||||
* // zipCode: '12345'
|
||||
* // }
|
||||
* // }
|
||||
* // }
|
||||
*/
|
||||
function toCamelCaseKeys(obj) {
|
||||
if (isArray(obj)) return obj.map((item) => toCamelCaseKeys(item));
|
||||
if (isPlainObject(obj)) {
|
||||
const result = {};
|
||||
const keys = Object.keys(obj);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
const camelKey = camelCase(key);
|
||||
result[camelKey] = toCamelCaseKeys(obj[key]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
//#endregion
|
||||
export { toCamelCaseKeys };
|
||||
46
frontend/node_modules/es-toolkit/dist/object/toMerged.d.mts
generated
vendored
Normal file
46
frontend/node_modules/es-toolkit/dist/object/toMerged.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
//#region src/object/toMerged.d.ts
|
||||
/**
|
||||
* Merges the properties of the source object into a deep clone of the target object.
|
||||
* Unlike `merge`, This function does not modify the original target object.
|
||||
*
|
||||
* This function performs a deep merge, meaning nested objects and arrays are merged recursively.
|
||||
*
|
||||
* - If a property in the source object is an array or object and the corresponding property in the target object is also an array or object, they will be merged.
|
||||
* - If a property in the source object is undefined, it will not overwrite a defined property in the target object.
|
||||
*
|
||||
* Note that this function does not mutate the target object.
|
||||
*
|
||||
* @param target - The target object to be cloned and merged into. This object is not modified directly.
|
||||
* @param source - The source object whose properties will be merged into the cloned target object.
|
||||
* @returns A new object with properties from the source object merged into a deep clone of the target object.
|
||||
*
|
||||
* @template T - Type of the target object.
|
||||
* @template S - Type of the source object.
|
||||
*
|
||||
* @example
|
||||
* const target = { a: 1, b: { x: 1, y: 2 } };
|
||||
* const source = { b: { y: 3, z: 4 }, c: 5 };
|
||||
*
|
||||
* const result = toMerged(target, source);
|
||||
* console.log(result);
|
||||
* // Output: { a: 1, b: { x: 1, y: 3, z: 4 }, c: 5 }
|
||||
*
|
||||
* @example
|
||||
* const target = { a: [1, 2], b: { x: 1 } };
|
||||
* const source = { a: [3], b: { y: 2 } };
|
||||
*
|
||||
* const result = toMerged(target, source);
|
||||
* console.log(result);
|
||||
* // Output: { a: [3, 2], b: { x: 1, y: 2 } }
|
||||
*
|
||||
* @example
|
||||
* const target = { a: null };
|
||||
* const source = { a: [1, 2, 3] };
|
||||
*
|
||||
* const result = toMerged(target, source);
|
||||
* console.log(result);
|
||||
* // Output: { a: [1, 2, 3] }
|
||||
*/
|
||||
declare function toMerged<T extends Record<PropertyKey, any>, S extends Record<PropertyKey, any>>(target: T, source: S): T & S;
|
||||
//#endregion
|
||||
export { toMerged };
|
||||
46
frontend/node_modules/es-toolkit/dist/object/toMerged.d.ts
generated
vendored
Normal file
46
frontend/node_modules/es-toolkit/dist/object/toMerged.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
//#region src/object/toMerged.d.ts
|
||||
/**
|
||||
* Merges the properties of the source object into a deep clone of the target object.
|
||||
* Unlike `merge`, This function does not modify the original target object.
|
||||
*
|
||||
* This function performs a deep merge, meaning nested objects and arrays are merged recursively.
|
||||
*
|
||||
* - If a property in the source object is an array or object and the corresponding property in the target object is also an array or object, they will be merged.
|
||||
* - If a property in the source object is undefined, it will not overwrite a defined property in the target object.
|
||||
*
|
||||
* Note that this function does not mutate the target object.
|
||||
*
|
||||
* @param target - The target object to be cloned and merged into. This object is not modified directly.
|
||||
* @param source - The source object whose properties will be merged into the cloned target object.
|
||||
* @returns A new object with properties from the source object merged into a deep clone of the target object.
|
||||
*
|
||||
* @template T - Type of the target object.
|
||||
* @template S - Type of the source object.
|
||||
*
|
||||
* @example
|
||||
* const target = { a: 1, b: { x: 1, y: 2 } };
|
||||
* const source = { b: { y: 3, z: 4 }, c: 5 };
|
||||
*
|
||||
* const result = toMerged(target, source);
|
||||
* console.log(result);
|
||||
* // Output: { a: 1, b: { x: 1, y: 3, z: 4 }, c: 5 }
|
||||
*
|
||||
* @example
|
||||
* const target = { a: [1, 2], b: { x: 1 } };
|
||||
* const source = { a: [3], b: { y: 2 } };
|
||||
*
|
||||
* const result = toMerged(target, source);
|
||||
* console.log(result);
|
||||
* // Output: { a: [3, 2], b: { x: 1, y: 2 } }
|
||||
*
|
||||
* @example
|
||||
* const target = { a: null };
|
||||
* const source = { a: [1, 2, 3] };
|
||||
*
|
||||
* const result = toMerged(target, source);
|
||||
* console.log(result);
|
||||
* // Output: { a: [1, 2, 3] }
|
||||
*/
|
||||
declare function toMerged<T extends Record<PropertyKey, any>, S extends Record<PropertyKey, any>>(target: T, source: S): T & S;
|
||||
//#endregion
|
||||
export { toMerged };
|
||||
57
frontend/node_modules/es-toolkit/dist/object/toMerged.js
generated
vendored
Normal file
57
frontend/node_modules/es-toolkit/dist/object/toMerged.js
generated
vendored
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
const require_clone = require("./clone.js");
|
||||
const require_cloneDeep = require("./cloneDeep.js");
|
||||
const require_isPlainObject = require("../predicate/isPlainObject.js");
|
||||
const require_mergeWith = require("./mergeWith.js");
|
||||
//#region src/object/toMerged.ts
|
||||
/**
|
||||
* Merges the properties of the source object into a deep clone of the target object.
|
||||
* Unlike `merge`, This function does not modify the original target object.
|
||||
*
|
||||
* This function performs a deep merge, meaning nested objects and arrays are merged recursively.
|
||||
*
|
||||
* - If a property in the source object is an array or object and the corresponding property in the target object is also an array or object, they will be merged.
|
||||
* - If a property in the source object is undefined, it will not overwrite a defined property in the target object.
|
||||
*
|
||||
* Note that this function does not mutate the target object.
|
||||
*
|
||||
* @param target - The target object to be cloned and merged into. This object is not modified directly.
|
||||
* @param source - The source object whose properties will be merged into the cloned target object.
|
||||
* @returns A new object with properties from the source object merged into a deep clone of the target object.
|
||||
*
|
||||
* @template T - Type of the target object.
|
||||
* @template S - Type of the source object.
|
||||
*
|
||||
* @example
|
||||
* const target = { a: 1, b: { x: 1, y: 2 } };
|
||||
* const source = { b: { y: 3, z: 4 }, c: 5 };
|
||||
*
|
||||
* const result = toMerged(target, source);
|
||||
* console.log(result);
|
||||
* // Output: { a: 1, b: { x: 1, y: 3, z: 4 }, c: 5 }
|
||||
*
|
||||
* @example
|
||||
* const target = { a: [1, 2], b: { x: 1 } };
|
||||
* const source = { a: [3], b: { y: 2 } };
|
||||
*
|
||||
* const result = toMerged(target, source);
|
||||
* console.log(result);
|
||||
* // Output: { a: [3, 2], b: { x: 1, y: 2 } }
|
||||
*
|
||||
* @example
|
||||
* const target = { a: null };
|
||||
* const source = { a: [1, 2, 3] };
|
||||
*
|
||||
* const result = toMerged(target, source);
|
||||
* console.log(result);
|
||||
* // Output: { a: [1, 2, 3] }
|
||||
*/
|
||||
function toMerged(target, source) {
|
||||
return require_mergeWith.mergeWith(require_cloneDeep.cloneDeep(target), source, function mergeRecursively(targetValue, sourceValue) {
|
||||
if (Array.isArray(sourceValue)) if (Array.isArray(targetValue)) return require_mergeWith.mergeWith(require_clone.clone(targetValue), sourceValue, mergeRecursively);
|
||||
else return require_mergeWith.mergeWith([], sourceValue, mergeRecursively);
|
||||
else if (require_isPlainObject.isPlainObject(sourceValue)) if (require_isPlainObject.isPlainObject(targetValue)) return require_mergeWith.mergeWith(require_clone.clone(targetValue), sourceValue, mergeRecursively);
|
||||
else return require_mergeWith.mergeWith({}, sourceValue, mergeRecursively);
|
||||
});
|
||||
}
|
||||
//#endregion
|
||||
exports.toMerged = toMerged;
|
||||
57
frontend/node_modules/es-toolkit/dist/object/toMerged.mjs
generated
vendored
Normal file
57
frontend/node_modules/es-toolkit/dist/object/toMerged.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
import { clone } from "./clone.mjs";
|
||||
import { cloneDeep } from "./cloneDeep.mjs";
|
||||
import { isPlainObject } from "../predicate/isPlainObject.mjs";
|
||||
import { mergeWith } from "./mergeWith.mjs";
|
||||
//#region src/object/toMerged.ts
|
||||
/**
|
||||
* Merges the properties of the source object into a deep clone of the target object.
|
||||
* Unlike `merge`, This function does not modify the original target object.
|
||||
*
|
||||
* This function performs a deep merge, meaning nested objects and arrays are merged recursively.
|
||||
*
|
||||
* - If a property in the source object is an array or object and the corresponding property in the target object is also an array or object, they will be merged.
|
||||
* - If a property in the source object is undefined, it will not overwrite a defined property in the target object.
|
||||
*
|
||||
* Note that this function does not mutate the target object.
|
||||
*
|
||||
* @param target - The target object to be cloned and merged into. This object is not modified directly.
|
||||
* @param source - The source object whose properties will be merged into the cloned target object.
|
||||
* @returns A new object with properties from the source object merged into a deep clone of the target object.
|
||||
*
|
||||
* @template T - Type of the target object.
|
||||
* @template S - Type of the source object.
|
||||
*
|
||||
* @example
|
||||
* const target = { a: 1, b: { x: 1, y: 2 } };
|
||||
* const source = { b: { y: 3, z: 4 }, c: 5 };
|
||||
*
|
||||
* const result = toMerged(target, source);
|
||||
* console.log(result);
|
||||
* // Output: { a: 1, b: { x: 1, y: 3, z: 4 }, c: 5 }
|
||||
*
|
||||
* @example
|
||||
* const target = { a: [1, 2], b: { x: 1 } };
|
||||
* const source = { a: [3], b: { y: 2 } };
|
||||
*
|
||||
* const result = toMerged(target, source);
|
||||
* console.log(result);
|
||||
* // Output: { a: [3, 2], b: { x: 1, y: 2 } }
|
||||
*
|
||||
* @example
|
||||
* const target = { a: null };
|
||||
* const source = { a: [1, 2, 3] };
|
||||
*
|
||||
* const result = toMerged(target, source);
|
||||
* console.log(result);
|
||||
* // Output: { a: [1, 2, 3] }
|
||||
*/
|
||||
function toMerged(target, source) {
|
||||
return mergeWith(cloneDeep(target), source, function mergeRecursively(targetValue, sourceValue) {
|
||||
if (Array.isArray(sourceValue)) if (Array.isArray(targetValue)) return mergeWith(clone(targetValue), sourceValue, mergeRecursively);
|
||||
else return mergeWith([], sourceValue, mergeRecursively);
|
||||
else if (isPlainObject(sourceValue)) if (isPlainObject(targetValue)) return mergeWith(clone(targetValue), sourceValue, mergeRecursively);
|
||||
else return mergeWith({}, sourceValue, mergeRecursively);
|
||||
});
|
||||
}
|
||||
//#endregion
|
||||
export { toMerged };
|
||||
53
frontend/node_modules/es-toolkit/dist/object/toSnakeCaseKeys.d.mts
generated
vendored
Normal file
53
frontend/node_modules/es-toolkit/dist/object/toSnakeCaseKeys.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
//#region src/object/toSnakeCaseKeys.d.ts
|
||||
type SnakeCase<S extends string> = S extends Uppercase<S> ? Lowercase<S> : S extends `${infer P1}${infer P2}` ? P2 extends Uncapitalize<P2> ? `${Lowercase<P1>}${SnakeCase<P2>}` : `${Lowercase<P1>}_${SnakeCase<Uncapitalize<P2>>}` : Lowercase<S>;
|
||||
type NonPlainObject = Date | RegExp | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | Promise<any> | Error | ArrayBuffer | DataView | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array | ((...args: any[]) => any) | typeof globalThis;
|
||||
type ToSnakeCaseKeys<T> = T extends NonPlainObject ? T : T extends any[] ? Array<ToSnakeCaseKeys<T[number]>> : T extends Record<string, any> ? { [K in keyof T as SnakeCase<string & K>]: ToSnakeCaseKeys<T[K]> } : T;
|
||||
/**
|
||||
* Creates a new object composed of the properties with keys converted to snake_case.
|
||||
*
|
||||
* This function takes an object and returns a new object that includes the same properties,
|
||||
* but with all keys converted to snake_case format.
|
||||
*
|
||||
* @template T - The type of object.
|
||||
* @param obj - The object to convert keys from.
|
||||
* @returns A new object with all keys converted to snake_case.
|
||||
*
|
||||
* @example
|
||||
* // Example with objects
|
||||
* const obj = { userId: 1, firstName: 'John' };
|
||||
* const result = toSnakeCaseKeys(obj);
|
||||
* // result will be { user_id: 1, first_name: 'John' }
|
||||
*
|
||||
* // Example with arrays of objects
|
||||
* const arr = [
|
||||
* { userId: 1, firstName: 'John' },
|
||||
* { userId: 2, firstName: 'Jane' }
|
||||
* ];
|
||||
* const arrResult = toSnakeCaseKeys(arr);
|
||||
* // arrResult will be [{ user_id: 1, first_name: 'John' }, { user_id: 2, first_name: 'Jane' }]
|
||||
*
|
||||
* // Example with nested objects
|
||||
* const nested = {
|
||||
* userData: {
|
||||
* userId: 1,
|
||||
* userAddress: {
|
||||
* streetName: 'Main St',
|
||||
* zipCode: '12345'
|
||||
* }
|
||||
* }
|
||||
* };
|
||||
* const nestedResult = toSnakeCaseKeys(nested);
|
||||
* // nestedResult will be:
|
||||
* // {
|
||||
* // user_data: {
|
||||
* // user_id: 1,
|
||||
* // user_address: {
|
||||
* // street_name: 'Main St',
|
||||
* // zip_code: '12345'
|
||||
* // }
|
||||
* // }
|
||||
* // }
|
||||
*/
|
||||
declare function toSnakeCaseKeys<T>(obj: T): ToSnakeCaseKeys<T>;
|
||||
//#endregion
|
||||
export { toSnakeCaseKeys };
|
||||
53
frontend/node_modules/es-toolkit/dist/object/toSnakeCaseKeys.d.ts
generated
vendored
Normal file
53
frontend/node_modules/es-toolkit/dist/object/toSnakeCaseKeys.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
//#region src/object/toSnakeCaseKeys.d.ts
|
||||
type SnakeCase<S extends string> = S extends Uppercase<S> ? Lowercase<S> : S extends `${infer P1}${infer P2}` ? P2 extends Uncapitalize<P2> ? `${Lowercase<P1>}${SnakeCase<P2>}` : `${Lowercase<P1>}_${SnakeCase<Uncapitalize<P2>>}` : Lowercase<S>;
|
||||
type NonPlainObject = Date | RegExp | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | Promise<any> | Error | ArrayBuffer | DataView | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array | ((...args: any[]) => any) | typeof globalThis;
|
||||
type ToSnakeCaseKeys<T> = T extends NonPlainObject ? T : T extends any[] ? Array<ToSnakeCaseKeys<T[number]>> : T extends Record<string, any> ? { [K in keyof T as SnakeCase<string & K>]: ToSnakeCaseKeys<T[K]> } : T;
|
||||
/**
|
||||
* Creates a new object composed of the properties with keys converted to snake_case.
|
||||
*
|
||||
* This function takes an object and returns a new object that includes the same properties,
|
||||
* but with all keys converted to snake_case format.
|
||||
*
|
||||
* @template T - The type of object.
|
||||
* @param obj - The object to convert keys from.
|
||||
* @returns A new object with all keys converted to snake_case.
|
||||
*
|
||||
* @example
|
||||
* // Example with objects
|
||||
* const obj = { userId: 1, firstName: 'John' };
|
||||
* const result = toSnakeCaseKeys(obj);
|
||||
* // result will be { user_id: 1, first_name: 'John' }
|
||||
*
|
||||
* // Example with arrays of objects
|
||||
* const arr = [
|
||||
* { userId: 1, firstName: 'John' },
|
||||
* { userId: 2, firstName: 'Jane' }
|
||||
* ];
|
||||
* const arrResult = toSnakeCaseKeys(arr);
|
||||
* // arrResult will be [{ user_id: 1, first_name: 'John' }, { user_id: 2, first_name: 'Jane' }]
|
||||
*
|
||||
* // Example with nested objects
|
||||
* const nested = {
|
||||
* userData: {
|
||||
* userId: 1,
|
||||
* userAddress: {
|
||||
* streetName: 'Main St',
|
||||
* zipCode: '12345'
|
||||
* }
|
||||
* }
|
||||
* };
|
||||
* const nestedResult = toSnakeCaseKeys(nested);
|
||||
* // nestedResult will be:
|
||||
* // {
|
||||
* // user_data: {
|
||||
* // user_id: 1,
|
||||
* // user_address: {
|
||||
* // street_name: 'Main St',
|
||||
* // zip_code: '12345'
|
||||
* // }
|
||||
* // }
|
||||
* // }
|
||||
*/
|
||||
declare function toSnakeCaseKeys<T>(obj: T): ToSnakeCaseKeys<T>;
|
||||
//#endregion
|
||||
export { toSnakeCaseKeys };
|
||||
66
frontend/node_modules/es-toolkit/dist/object/toSnakeCaseKeys.js
generated
vendored
Normal file
66
frontend/node_modules/es-toolkit/dist/object/toSnakeCaseKeys.js
generated
vendored
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
const require_isArray = require("../compat/predicate/isArray.js");
|
||||
const require_isPlainObject = require("../compat/predicate/isPlainObject.js");
|
||||
const require_snakeCase = require("../string/snakeCase.js");
|
||||
//#region src/object/toSnakeCaseKeys.ts
|
||||
/**
|
||||
* Creates a new object composed of the properties with keys converted to snake_case.
|
||||
*
|
||||
* This function takes an object and returns a new object that includes the same properties,
|
||||
* but with all keys converted to snake_case format.
|
||||
*
|
||||
* @template T - The type of object.
|
||||
* @param obj - The object to convert keys from.
|
||||
* @returns A new object with all keys converted to snake_case.
|
||||
*
|
||||
* @example
|
||||
* // Example with objects
|
||||
* const obj = { userId: 1, firstName: 'John' };
|
||||
* const result = toSnakeCaseKeys(obj);
|
||||
* // result will be { user_id: 1, first_name: 'John' }
|
||||
*
|
||||
* // Example with arrays of objects
|
||||
* const arr = [
|
||||
* { userId: 1, firstName: 'John' },
|
||||
* { userId: 2, firstName: 'Jane' }
|
||||
* ];
|
||||
* const arrResult = toSnakeCaseKeys(arr);
|
||||
* // arrResult will be [{ user_id: 1, first_name: 'John' }, { user_id: 2, first_name: 'Jane' }]
|
||||
*
|
||||
* // Example with nested objects
|
||||
* const nested = {
|
||||
* userData: {
|
||||
* userId: 1,
|
||||
* userAddress: {
|
||||
* streetName: 'Main St',
|
||||
* zipCode: '12345'
|
||||
* }
|
||||
* }
|
||||
* };
|
||||
* const nestedResult = toSnakeCaseKeys(nested);
|
||||
* // nestedResult will be:
|
||||
* // {
|
||||
* // user_data: {
|
||||
* // user_id: 1,
|
||||
* // user_address: {
|
||||
* // street_name: 'Main St',
|
||||
* // zip_code: '12345'
|
||||
* // }
|
||||
* // }
|
||||
* // }
|
||||
*/
|
||||
function toSnakeCaseKeys(obj) {
|
||||
if (require_isArray.isArray(obj)) return obj.map((item) => toSnakeCaseKeys(item));
|
||||
if (require_isPlainObject.isPlainObject(obj)) {
|
||||
const result = {};
|
||||
const keys = Object.keys(obj);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
const snakeKey = require_snakeCase.snakeCase(key);
|
||||
result[snakeKey] = toSnakeCaseKeys(obj[key]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
//#endregion
|
||||
exports.toSnakeCaseKeys = toSnakeCaseKeys;
|
||||
66
frontend/node_modules/es-toolkit/dist/object/toSnakeCaseKeys.mjs
generated
vendored
Normal file
66
frontend/node_modules/es-toolkit/dist/object/toSnakeCaseKeys.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
import { isArray } from "../compat/predicate/isArray.mjs";
|
||||
import { isPlainObject } from "../compat/predicate/isPlainObject.mjs";
|
||||
import { snakeCase } from "../string/snakeCase.mjs";
|
||||
//#region src/object/toSnakeCaseKeys.ts
|
||||
/**
|
||||
* Creates a new object composed of the properties with keys converted to snake_case.
|
||||
*
|
||||
* This function takes an object and returns a new object that includes the same properties,
|
||||
* but with all keys converted to snake_case format.
|
||||
*
|
||||
* @template T - The type of object.
|
||||
* @param obj - The object to convert keys from.
|
||||
* @returns A new object with all keys converted to snake_case.
|
||||
*
|
||||
* @example
|
||||
* // Example with objects
|
||||
* const obj = { userId: 1, firstName: 'John' };
|
||||
* const result = toSnakeCaseKeys(obj);
|
||||
* // result will be { user_id: 1, first_name: 'John' }
|
||||
*
|
||||
* // Example with arrays of objects
|
||||
* const arr = [
|
||||
* { userId: 1, firstName: 'John' },
|
||||
* { userId: 2, firstName: 'Jane' }
|
||||
* ];
|
||||
* const arrResult = toSnakeCaseKeys(arr);
|
||||
* // arrResult will be [{ user_id: 1, first_name: 'John' }, { user_id: 2, first_name: 'Jane' }]
|
||||
*
|
||||
* // Example with nested objects
|
||||
* const nested = {
|
||||
* userData: {
|
||||
* userId: 1,
|
||||
* userAddress: {
|
||||
* streetName: 'Main St',
|
||||
* zipCode: '12345'
|
||||
* }
|
||||
* }
|
||||
* };
|
||||
* const nestedResult = toSnakeCaseKeys(nested);
|
||||
* // nestedResult will be:
|
||||
* // {
|
||||
* // user_data: {
|
||||
* // user_id: 1,
|
||||
* // user_address: {
|
||||
* // street_name: 'Main St',
|
||||
* // zip_code: '12345'
|
||||
* // }
|
||||
* // }
|
||||
* // }
|
||||
*/
|
||||
function toSnakeCaseKeys(obj) {
|
||||
if (isArray(obj)) return obj.map((item) => toSnakeCaseKeys(item));
|
||||
if (isPlainObject(obj)) {
|
||||
const result = {};
|
||||
const keys = Object.keys(obj);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
const snakeKey = snakeCase(key);
|
||||
result[snakeKey] = toSnakeCaseKeys(obj[key]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
//#endregion
|
||||
export { toSnakeCaseKeys };
|
||||
Loading…
Add table
Add a link
Reference in a new issue