@pixpilot/object 1.1.9 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/delete-object-property-by-path.cjs +1 -0
- package/dist/delete-object-property-by-path.d.cts +2 -0
- package/dist/delete-object-property-by-path.d.ts +2 -0
- package/dist/delete-object-property-by-path.js +1 -0
- package/dist/get-object-value-by-path.cjs +1 -0
- package/dist/get-object-value-by-path.d.cts +2 -0
- package/dist/get-object-value-by-path.d.ts +2 -0
- package/dist/get-object-value-by-path.js +1 -0
- package/dist/has-object-value-by-path.cjs +1 -0
- package/dist/has-object-value-by-path.d.cts +2 -0
- package/dist/has-object-value-by-path.d.ts +2 -0
- package/dist/has-object-value-by-path.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +1 -1
- package/dist/manipulation.cjs +1 -1
- package/dist/manipulation.d.cts +10 -61
- package/dist/manipulation.d.ts +10 -61
- package/dist/manipulation.js +1 -1
- package/dist/set-object-value-by-path.cjs +1 -0
- package/dist/set-object-value-by-path.d.cts +22 -0
- package/dist/set-object-value-by-path.d.ts +22 -0
- package/dist/set-object-value-by-path.js +1 -0
- package/package.json +6 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./_virtual/rolldown_runtime.cjs`);let t=require(`dot-prop`);t=e.__toESM(t),exports.deleteObjectPropertyByPath=t.deleteProperty;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{deleteProperty as e}from"dot-prop";export{e as deleteObjectPropertyByPath};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./_virtual/rolldown_runtime.cjs`);let t=require(`dot-prop`);t=e.__toESM(t),exports.getObjectValueByPath=t.getProperty;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getProperty as e}from"dot-prop";export{e as getObjectValueByPath};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./_virtual/rolldown_runtime.cjs`);let t=require(`dot-prop`);t=e.__toESM(t),exports.hasObjectValueByPath=t.hasProperty;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{hasProperty as e}from"dot-prop";export{e as hasObjectValueByPath};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`./deep-merge.cjs`),
|
|
1
|
+
const e=require(`./_virtual/rolldown_runtime.cjs`),t=require(`./deep-merge.cjs`);require(`./delete-object-property-by-path.cjs`),require(`./get-object-value-by-path.cjs`),require(`./has-object-value-by-path.cjs`);const n=require(`./keys-to-camel-case.cjs`),r=require(`./keys-to-snake-case.cjs`),i=require(`./set-object-value-by-path.cjs`),a=require(`./manipulation.cjs`),o=require(`./type-guards.cjs`);let s=require(`dot-prop`);s=e.__toESM(s),exports.deepClone=a.deepClone,exports.deepEqual=a.deepEqual,exports.deepMerge=t.deepMerge,exports.deepMergeMany=t.deepMergeMany,exports.del=a.del,exports.deleteObjectPropertyByPath=s.deleteProperty,exports.escapePath=s.escapePath,exports.flatKeys=a.flatKeys,exports.get=a.get,exports.getObjectValueByPath=s.getProperty,exports.has=a.has,exports.hasObjectValueByPath=s.hasProperty,exports.isEmptyObject=o.isEmptyObject,exports.isObject=o.isObject,exports.isPlainObject=o.isPlainObject,exports.keysToCamelCase=n.keysToCamelCase,exports.keysToSnakeCase=r.keysToSnakeCase,exports.mapKeys=a.mapKeys,exports.mapValues=a.mapValues,exports.omit=a.omit,exports.parsePath=s.parsePath,exports.pick=a.pick,exports.set=a.set,exports.setObjectValueByPath=i.setObjectValueByPath,exports.setProperty=s.setProperty,exports.stringifyPath=s.stringifyPath,exports.unflatten=s.unflatten;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { deepMerge, deepMergeMany } from "./deep-merge.cjs";
|
|
2
|
+
import { deleteObjectPropertyByPath as deleteProperty } from "./delete-object-property-by-path.cjs";
|
|
3
|
+
import { getObjectValueByPath as getProperty } from "./get-object-value-by-path.cjs";
|
|
4
|
+
import { hasObjectValueByPath as hasProperty } from "./has-object-value-by-path.cjs";
|
|
2
5
|
import { KeysToCamelCase, ToCamelCase, keysToCamelCase } from "./keys-to-camel-case.cjs";
|
|
3
6
|
import { KeysToSnakeCase, ToSnakeCase, keysToSnakeCase } from "./keys-to-snake-case.cjs";
|
|
4
|
-
import {
|
|
7
|
+
import { setObjectValueByPath } from "./set-object-value-by-path.cjs";
|
|
8
|
+
import { deepClone, deepEqual, del, escapePath, flatKeys, get, has, mapKeys, mapValues, omit, parsePath, pick, set, setProperty, stringifyPath, unflatten } from "./manipulation.cjs";
|
|
5
9
|
import { isEmptyObject, isObject, isPlainObject } from "./type-guards.cjs";
|
|
6
|
-
export { KeysToCamelCase, KeysToSnakeCase, ToCamelCase, ToSnakeCase, deepClone, deepEqual, deepMerge, deepMergeMany, flatKeys, get, has, isEmptyObject, isObject, isPlainObject, keysToCamelCase, keysToSnakeCase, mapKeys, mapValues, omit, pick, set };
|
|
10
|
+
export { KeysToCamelCase, KeysToSnakeCase, ToCamelCase, ToSnakeCase, deepClone, deepEqual, deepMerge, deepMergeMany, del, deleteProperty as deleteObjectPropertyByPath, escapePath, flatKeys, get, getProperty as getObjectValueByPath, has, hasProperty as hasObjectValueByPath, isEmptyObject, isObject, isPlainObject, keysToCamelCase, keysToSnakeCase, mapKeys, mapValues, omit, parsePath, pick, set, setObjectValueByPath, setProperty, stringifyPath, unflatten };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { deepMerge, deepMergeMany } from "./deep-merge.js";
|
|
2
|
+
import { deleteObjectPropertyByPath as deleteProperty } from "./delete-object-property-by-path.js";
|
|
3
|
+
import { getObjectValueByPath as getProperty } from "./get-object-value-by-path.js";
|
|
4
|
+
import { hasObjectValueByPath as hasProperty } from "./has-object-value-by-path.js";
|
|
2
5
|
import { KeysToCamelCase, ToCamelCase, keysToCamelCase } from "./keys-to-camel-case.js";
|
|
3
6
|
import { KeysToSnakeCase, ToSnakeCase, keysToSnakeCase } from "./keys-to-snake-case.js";
|
|
4
|
-
import {
|
|
7
|
+
import { setObjectValueByPath } from "./set-object-value-by-path.js";
|
|
8
|
+
import { deepClone, deepEqual, del, escapePath, flatKeys, get, has, mapKeys, mapValues, omit, parsePath, pick, set, setProperty, stringifyPath, unflatten } from "./manipulation.js";
|
|
5
9
|
import { isEmptyObject, isObject, isPlainObject } from "./type-guards.js";
|
|
6
|
-
export { KeysToCamelCase, KeysToSnakeCase, ToCamelCase, ToSnakeCase, deepClone, deepEqual, deepMerge, deepMergeMany, flatKeys, get, has, isEmptyObject, isObject, isPlainObject, keysToCamelCase, keysToSnakeCase, mapKeys, mapValues, omit, pick, set };
|
|
10
|
+
export { KeysToCamelCase, KeysToSnakeCase, ToCamelCase, ToSnakeCase, deepClone, deepEqual, deepMerge, deepMergeMany, del, deleteProperty as deleteObjectPropertyByPath, escapePath, flatKeys, get, getProperty as getObjectValueByPath, has, hasProperty as hasObjectValueByPath, isEmptyObject, isObject, isPlainObject, keysToCamelCase, keysToSnakeCase, mapKeys, mapValues, omit, parsePath, pick, set, setObjectValueByPath, setProperty, stringifyPath, unflatten };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{deepMerge as e,deepMergeMany as t}from"./deep-merge.js";import{
|
|
1
|
+
import{deepMerge as e,deepMergeMany as t}from"./deep-merge.js";import{deleteObjectPropertyByPath as n}from"./delete-object-property-by-path.js";import{getObjectValueByPath as r}from"./get-object-value-by-path.js";import{hasObjectValueByPath as i}from"./has-object-value-by-path.js";import{keysToCamelCase as a}from"./keys-to-camel-case.js";import{keysToSnakeCase as o}from"./keys-to-snake-case.js";import{setObjectValueByPath as s}from"./set-object-value-by-path.js";import{deepClone as c,deepEqual as l,del as u,escapePath as d,flatKeys as f,get as p,has as m,mapKeys as h,mapValues as g,omit as _,parsePath as v,pick as y,set as b,setProperty as x,stringifyPath as S,unflatten as C}from"./manipulation.js";import{isEmptyObject as w,isObject as T,isPlainObject as E}from"./type-guards.js";export{c as deepClone,l as deepEqual,e as deepMerge,t as deepMergeMany,u as del,n as deleteObjectPropertyByPath,d as escapePath,f as flatKeys,p as get,r as getObjectValueByPath,m as has,i as hasObjectValueByPath,w as isEmptyObject,T as isObject,E as isPlainObject,a as keysToCamelCase,o as keysToSnakeCase,h as mapKeys,g as mapValues,_ as omit,v as parsePath,y as pick,b as set,s as setObjectValueByPath,x as setProperty,S as stringifyPath,C as unflatten};
|
package/dist/manipulation.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`./
|
|
1
|
+
const e=require(`./_virtual/rolldown_runtime.cjs`),t=require(`./set-object-value-by-path.cjs`);let n=require(`dot-prop`);n=e.__toESM(n);function r(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function i(e,t){let n={...e};for(let e of t)delete n[e];return n}function a(e){if(typeof e!=`object`||!e)return e;if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(Array.isArray(e))return e.map(e=>a(e));let t={};for(let[n,r]of Object.entries(e))t[n]=a(r);return t}function o(e,t){if(e===t)return!0;if(typeof e!=typeof t||e===null||t===null)return!1;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length?e.every((e,n)=>o(e,t[n])):!1;if(typeof e==`object`&&typeof t==`object`){let n=Object.keys(e),r=Object.keys(t);return n.length===r.length?n.every(n=>o(e[n],t[n])):!1}return!1}function s(e,t){let n={};for(let[r,i]of Object.entries(e))n[r]=t(i,r);return n}function c(e,t){let n={};for(let[r,i]of Object.entries(e)){let e=t(r);n[e]=i}return n}const l=n.getProperty,u=t.setObjectValueByPath,d=n.hasProperty,f=n.deleteProperty,p=n.deepKeys;exports.deepClone=a,exports.deepEqual=o,exports.del=f,exports.escapePath=n.escapePath,exports.flatKeys=p,exports.get=l,exports.has=d,exports.mapKeys=c,exports.mapValues=s,exports.omit=i,exports.parsePath=n.parsePath,exports.pick=r,exports.set=u,exports.setProperty=n.setProperty,exports.stringifyPath=n.stringifyPath,exports.unflatten=n.unflatten;
|
package/dist/manipulation.d.cts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import { setObjectValueByPath } from "./set-object-value-by-path.cjs";
|
|
2
|
+
import { deepKeys, deleteProperty, escapePath, getProperty, hasProperty, parsePath, setProperty, stringifyPath, unflatten } from "dot-prop";
|
|
3
|
+
|
|
1
4
|
//#region src/manipulation.d.ts
|
|
5
|
+
|
|
2
6
|
/**
|
|
3
7
|
* Pick specific keys from an object.
|
|
4
8
|
*
|
|
@@ -27,66 +31,6 @@ declare function pick<T extends Record<string, unknown>, K extends keyof T>(obj:
|
|
|
27
31
|
* ```
|
|
28
32
|
*/
|
|
29
33
|
declare function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: readonly K[]): Omit<T, K>;
|
|
30
|
-
/**
|
|
31
|
-
* Get a nested value from an object using a path string.
|
|
32
|
-
*
|
|
33
|
-
* @param obj - The source object
|
|
34
|
-
* @param path - The path to the value (e.g., 'a.b.c')
|
|
35
|
-
* @param defaultValue - The default value to return if the path doesn't exist
|
|
36
|
-
* @returns The value at the path or the default value
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```typescript
|
|
40
|
-
* const obj = { a: { b: { c: 42 } } };
|
|
41
|
-
* get(obj, 'a.b.c'); // 42
|
|
42
|
-
* get(obj, 'a.b.x', 'default'); // 'default'
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
declare function get<T = unknown>(obj: Record<string, unknown>, path: string, defaultValue?: T): T | undefined;
|
|
46
|
-
/**
|
|
47
|
-
* Set a nested value in an object using a path string.
|
|
48
|
-
*
|
|
49
|
-
* @param obj - The target object
|
|
50
|
-
* @param path - The path to set the value at (e.g., 'a.b.c')
|
|
51
|
-
* @param value - The value to set
|
|
52
|
-
* @returns The modified object
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```typescript
|
|
56
|
-
* const obj = { a: { b: {} } };
|
|
57
|
-
* set(obj, 'a.b.c', 42); // { a: { b: { c: 42 } } }
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
declare function set<T extends Record<string, unknown>>(obj: T, path: string, value: unknown): T;
|
|
61
|
-
/**
|
|
62
|
-
* Check if an object has a nested property using a path string.
|
|
63
|
-
*
|
|
64
|
-
* @param obj - The source object
|
|
65
|
-
* @param path - The path to check (e.g., 'a.b.c')
|
|
66
|
-
* @returns True if the path exists, false otherwise
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* ```typescript
|
|
70
|
-
* const obj = { a: { b: { c: 42 } } };
|
|
71
|
-
* has(obj, 'a.b.c'); // true
|
|
72
|
-
* has(obj, 'a.b.x'); // false
|
|
73
|
-
* ```
|
|
74
|
-
*/
|
|
75
|
-
declare function has(obj: Record<string, unknown>, path: string): boolean;
|
|
76
|
-
/**
|
|
77
|
-
* Get all keys of an object including nested keys.
|
|
78
|
-
*
|
|
79
|
-
* @param obj - The source object
|
|
80
|
-
* @param prefix - The prefix to prepend to keys (used internally for recursion)
|
|
81
|
-
* @returns An array of all keys including nested paths
|
|
82
|
-
*
|
|
83
|
-
* @example
|
|
84
|
-
* ```typescript
|
|
85
|
-
* const obj = { a: 1, b: { c: 2, d: { e: 3 } } };
|
|
86
|
-
* flatKeys(obj); // ['a', 'b.c', 'b.d.e']
|
|
87
|
-
* ```
|
|
88
|
-
*/
|
|
89
|
-
declare function flatKeys(obj: Record<string, unknown>, prefix?: string): string[];
|
|
90
34
|
/**
|
|
91
35
|
* Deep clone an object.
|
|
92
36
|
*
|
|
@@ -144,5 +88,10 @@ declare function mapValues<T extends Record<string, unknown>, U>(obj: T, fn: (va
|
|
|
144
88
|
* ```
|
|
145
89
|
*/
|
|
146
90
|
declare function mapKeys<T extends Record<string, unknown>>(obj: T, fn: (key: keyof T) => string): Record<string, T[keyof T]>;
|
|
91
|
+
declare const get: typeof getProperty;
|
|
92
|
+
declare const set: typeof setObjectValueByPath;
|
|
93
|
+
declare const has: typeof hasProperty;
|
|
94
|
+
declare const del: typeof deleteProperty;
|
|
95
|
+
declare const flatKeys: typeof deepKeys;
|
|
147
96
|
//#endregion
|
|
148
|
-
export { deepClone, deepEqual, flatKeys, get, has, mapKeys, mapValues, omit, pick, set };
|
|
97
|
+
export { deepClone, deepEqual, del, escapePath, flatKeys, get, has, mapKeys, mapValues, omit, parsePath, pick, set, setProperty, stringifyPath, unflatten };
|
package/dist/manipulation.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import { setObjectValueByPath } from "./set-object-value-by-path.js";
|
|
2
|
+
import { deepKeys, deleteProperty, escapePath, getProperty, hasProperty, parsePath, setProperty, stringifyPath, unflatten } from "dot-prop";
|
|
3
|
+
|
|
1
4
|
//#region src/manipulation.d.ts
|
|
5
|
+
|
|
2
6
|
/**
|
|
3
7
|
* Pick specific keys from an object.
|
|
4
8
|
*
|
|
@@ -27,66 +31,6 @@ declare function pick<T extends Record<string, unknown>, K extends keyof T>(obj:
|
|
|
27
31
|
* ```
|
|
28
32
|
*/
|
|
29
33
|
declare function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: readonly K[]): Omit<T, K>;
|
|
30
|
-
/**
|
|
31
|
-
* Get a nested value from an object using a path string.
|
|
32
|
-
*
|
|
33
|
-
* @param obj - The source object
|
|
34
|
-
* @param path - The path to the value (e.g., 'a.b.c')
|
|
35
|
-
* @param defaultValue - The default value to return if the path doesn't exist
|
|
36
|
-
* @returns The value at the path or the default value
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```typescript
|
|
40
|
-
* const obj = { a: { b: { c: 42 } } };
|
|
41
|
-
* get(obj, 'a.b.c'); // 42
|
|
42
|
-
* get(obj, 'a.b.x', 'default'); // 'default'
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
declare function get<T = unknown>(obj: Record<string, unknown>, path: string, defaultValue?: T): T | undefined;
|
|
46
|
-
/**
|
|
47
|
-
* Set a nested value in an object using a path string.
|
|
48
|
-
*
|
|
49
|
-
* @param obj - The target object
|
|
50
|
-
* @param path - The path to set the value at (e.g., 'a.b.c')
|
|
51
|
-
* @param value - The value to set
|
|
52
|
-
* @returns The modified object
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```typescript
|
|
56
|
-
* const obj = { a: { b: {} } };
|
|
57
|
-
* set(obj, 'a.b.c', 42); // { a: { b: { c: 42 } } }
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
declare function set<T extends Record<string, unknown>>(obj: T, path: string, value: unknown): T;
|
|
61
|
-
/**
|
|
62
|
-
* Check if an object has a nested property using a path string.
|
|
63
|
-
*
|
|
64
|
-
* @param obj - The source object
|
|
65
|
-
* @param path - The path to check (e.g., 'a.b.c')
|
|
66
|
-
* @returns True if the path exists, false otherwise
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* ```typescript
|
|
70
|
-
* const obj = { a: { b: { c: 42 } } };
|
|
71
|
-
* has(obj, 'a.b.c'); // true
|
|
72
|
-
* has(obj, 'a.b.x'); // false
|
|
73
|
-
* ```
|
|
74
|
-
*/
|
|
75
|
-
declare function has(obj: Record<string, unknown>, path: string): boolean;
|
|
76
|
-
/**
|
|
77
|
-
* Get all keys of an object including nested keys.
|
|
78
|
-
*
|
|
79
|
-
* @param obj - The source object
|
|
80
|
-
* @param prefix - The prefix to prepend to keys (used internally for recursion)
|
|
81
|
-
* @returns An array of all keys including nested paths
|
|
82
|
-
*
|
|
83
|
-
* @example
|
|
84
|
-
* ```typescript
|
|
85
|
-
* const obj = { a: 1, b: { c: 2, d: { e: 3 } } };
|
|
86
|
-
* flatKeys(obj); // ['a', 'b.c', 'b.d.e']
|
|
87
|
-
* ```
|
|
88
|
-
*/
|
|
89
|
-
declare function flatKeys(obj: Record<string, unknown>, prefix?: string): string[];
|
|
90
34
|
/**
|
|
91
35
|
* Deep clone an object.
|
|
92
36
|
*
|
|
@@ -144,5 +88,10 @@ declare function mapValues<T extends Record<string, unknown>, U>(obj: T, fn: (va
|
|
|
144
88
|
* ```
|
|
145
89
|
*/
|
|
146
90
|
declare function mapKeys<T extends Record<string, unknown>>(obj: T, fn: (key: keyof T) => string): Record<string, T[keyof T]>;
|
|
91
|
+
declare const get: typeof getProperty;
|
|
92
|
+
declare const set: typeof setObjectValueByPath;
|
|
93
|
+
declare const has: typeof hasProperty;
|
|
94
|
+
declare const del: typeof deleteProperty;
|
|
95
|
+
declare const flatKeys: typeof deepKeys;
|
|
147
96
|
//#endregion
|
|
148
|
-
export { deepClone, deepEqual, flatKeys, get, has, mapKeys, mapValues, omit, pick, set };
|
|
97
|
+
export { deepClone, deepEqual, del, escapePath, flatKeys, get, has, mapKeys, mapValues, omit, parsePath, pick, set, setProperty, stringifyPath, unflatten };
|
package/dist/manipulation.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{setObjectValueByPath as e}from"./set-object-value-by-path.js";import{deepKeys as t,deleteProperty as n,escapePath as r,getProperty as i,hasProperty as a,parsePath as o,setProperty as s,stringifyPath as c,unflatten as l}from"dot-prop";function u(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function d(e,t){let n={...e};for(let e of t)delete n[e];return n}function f(e){if(typeof e!=`object`||!e)return e;if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(Array.isArray(e))return e.map(e=>f(e));let t={};for(let[n,r]of Object.entries(e))t[n]=f(r);return t}function p(e,t){if(e===t)return!0;if(typeof e!=typeof t||e===null||t===null)return!1;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length?e.every((e,n)=>p(e,t[n])):!1;if(typeof e==`object`&&typeof t==`object`){let n=Object.keys(e),r=Object.keys(t);return n.length===r.length?n.every(n=>p(e[n],t[n])):!1}return!1}function m(e,t){let n={};for(let[r,i]of Object.entries(e))n[r]=t(i,r);return n}function h(e,t){let n={};for(let[r,i]of Object.entries(e)){let e=t(r);n[e]=i}return n}const g=i,_=e,v=a,y=n,b=t;export{f as deepClone,p as deepEqual,y as del,r as escapePath,b as flatKeys,g as get,v as has,h as mapKeys,m as mapValues,d as omit,o as parsePath,u as pick,_ as set,s as setProperty,c as stringifyPath,l as unflatten};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./_virtual/rolldown_runtime.cjs`);let t=require(`dot-prop`);t=e.__toESM(t);function n(e,n,r,i={}){i.deleteUndefine&&r===void 0?(0,t.deleteProperty)(e,n):(0,t.setProperty)(e,n,r)}exports.setObjectValueByPath=n;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/set-object-value-by-path.d.ts
|
|
2
|
+
type Path = (number | string)[] | string;
|
|
3
|
+
/**
|
|
4
|
+
* Set a nested value in an object using a path string.
|
|
5
|
+
*
|
|
6
|
+
* @param object - The target object
|
|
7
|
+
* @param path - The path to set the value at (e.g., 'a.b.c')
|
|
8
|
+
* @param value - The value to set
|
|
9
|
+
* @param options - Options for setting the value
|
|
10
|
+
* @param options.deleteUndefine - If true, delete the property when value is undefined
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const obj = { a: { b: {} } };
|
|
15
|
+
* setObjectValueByPath(obj, 'a.b.c', 42); // { a: { b: { c: 42 } } }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
declare function setObjectValueByPath<TResult = any>(object: object, path: Path, value: TResult, options?: {
|
|
19
|
+
deleteUndefine?: boolean;
|
|
20
|
+
}): void;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { setObjectValueByPath };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/set-object-value-by-path.d.ts
|
|
2
|
+
type Path = (number | string)[] | string;
|
|
3
|
+
/**
|
|
4
|
+
* Set a nested value in an object using a path string.
|
|
5
|
+
*
|
|
6
|
+
* @param object - The target object
|
|
7
|
+
* @param path - The path to set the value at (e.g., 'a.b.c')
|
|
8
|
+
* @param value - The value to set
|
|
9
|
+
* @param options - Options for setting the value
|
|
10
|
+
* @param options.deleteUndefine - If true, delete the property when value is undefined
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const obj = { a: { b: {} } };
|
|
15
|
+
* setObjectValueByPath(obj, 'a.b.c', 42); // { a: { b: { c: 42 } } }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
declare function setObjectValueByPath<TResult = any>(object: object, path: Path, value: TResult, options?: {
|
|
19
|
+
deleteUndefine?: boolean;
|
|
20
|
+
}): void;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { setObjectValueByPath };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{deleteProperty as e,setProperty as t}from"dot-prop";function n(n,r,i,a={}){a.deleteUndefine&&i===void 0?e(n,r):t(n,r,i)}export{n as setObjectValueByPath};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixpilot/object",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.2.0",
|
|
5
5
|
"description": "A collection of utility functions for object manipulation and transformation.",
|
|
6
6
|
"author": "Pixpilot <m.doaie@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@fastify/deepmerge": "^3.1.0",
|
|
29
|
-
"
|
|
29
|
+
"dot-prop": "^10.1.0",
|
|
30
|
+
"@pixpilot/string": "2.3.0"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
33
|
"@manypkg/get-packages": "^3.1.0",
|
|
@@ -34,11 +35,11 @@
|
|
|
34
35
|
"eslint": "^9.37.0",
|
|
35
36
|
"tsdown": "^0.15.8",
|
|
36
37
|
"typescript": "^5.9.3",
|
|
38
|
+
"@internal/eslint-config": "0.3.0",
|
|
37
39
|
"@internal/prettier-config": "0.0.1",
|
|
38
40
|
"@internal/tsconfig": "0.1.0",
|
|
39
|
-
"@internal/
|
|
40
|
-
"@internal/tsdown-config": "0.1.0"
|
|
41
|
-
"@internal/vitest-config": "0.1.0"
|
|
41
|
+
"@internal/vitest-config": "0.1.0",
|
|
42
|
+
"@internal/tsdown-config": "0.1.0"
|
|
42
43
|
},
|
|
43
44
|
"prettier": "@internal/prettier-config",
|
|
44
45
|
"scripts": {
|