@pixpilot/object 2.1.0 → 2.1.1

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.
@@ -1 +1,25 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports.__toESM=s;
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+
23
+ //#endregion
24
+
25
+ exports.__toESM = __toESM;
@@ -0,0 +1,60 @@
1
+ const require_type_guards = require('./type-guards.cjs');
2
+
3
+ //#region src/clean-object.ts
4
+ function resolveOptions(options) {
5
+ return {
6
+ cleanKeys: options?.cleanKeys ?? [],
7
+ cleanValues: options?.cleanValues ?? [],
8
+ emptyArrays: options?.emptyArrays ?? true,
9
+ emptyObjects: options?.emptyObjects ?? true,
10
+ emptyStrings: options?.emptyStrings ?? true,
11
+ NaNValues: options?.NaNValues ?? false,
12
+ nullValues: options?.nullValues ?? true,
13
+ undefinedValues: options?.undefinedValues ?? true,
14
+ shouldRemove: options?.shouldRemove,
15
+ transform: options?.transform
16
+ };
17
+ }
18
+ function isCleanable(value) {
19
+ return (Array.isArray(value) || require_type_guards.isPlainObject(value)) && !(value instanceof Date);
20
+ }
21
+ function shouldSkipValue(value, options) {
22
+ if (options.cleanValues.includes(value)) return true;
23
+ if (options.emptyObjects && require_type_guards.isPlainObject(value) && require_type_guards.isEmptyObject(value)) return true;
24
+ if (options.emptyArrays && Array.isArray(value) && value.length === 0) return true;
25
+ if (options.emptyStrings && value === "") return true;
26
+ if (options.NaNValues && typeof value === "number" && Number.isNaN(value)) return true;
27
+ if (options.nullValues && value === null) return true;
28
+ if (options.undefinedValues && value === void 0) return true;
29
+ return false;
30
+ }
31
+ function cleanDeep(value, options) {
32
+ if (Array.isArray(value)) {
33
+ const result$1 = [];
34
+ for (let index = 0; index < value.length; index += 1) {
35
+ const key = String(index);
36
+ if (!options.cleanKeys.includes(key)) {
37
+ const transformed = options.transform ? options.transform(key, value[index], value) : value[index];
38
+ const cleaned = isCleanable(transformed) ? cleanDeep(transformed, options) : transformed;
39
+ if (!((options.shouldRemove ? options.shouldRemove(key, cleaned, value) : false) || shouldSkipValue(cleaned, options))) result$1.push(cleaned);
40
+ }
41
+ }
42
+ return result$1;
43
+ }
44
+ const prototype = Object.getPrototypeOf(value);
45
+ const result = Object.create(prototype);
46
+ for (const [key, originalValue] of Object.entries(value)) if (!options.cleanKeys.includes(key)) {
47
+ const transformed = options.transform ? options.transform(key, originalValue, value) : originalValue;
48
+ const cleaned = isCleanable(transformed) ? cleanDeep(transformed, options) : transformed;
49
+ if (!((options.shouldRemove ? options.shouldRemove(key, cleaned, value) : false) || shouldSkipValue(cleaned, options))) result[key] = cleaned;
50
+ }
51
+ return result;
52
+ }
53
+ function cleanObject(value, options) {
54
+ const resolvedOptions = resolveOptions(options);
55
+ if (!isCleanable(value)) return value;
56
+ return cleanDeep(value, resolvedOptions);
57
+ }
58
+
59
+ //#endregion
60
+ exports.cleanObject = cleanObject;
@@ -0,0 +1,19 @@
1
+ //#region src/clean-object.d.ts
2
+ /**
3
+ * Inspired by https://github.com/nunofgs/clean-deep
4
+ */
5
+ interface CleanOptions {
6
+ cleanKeys?: readonly string[];
7
+ cleanValues?: readonly unknown[];
8
+ emptyArrays?: boolean;
9
+ emptyObjects?: boolean;
10
+ emptyStrings?: boolean;
11
+ NaNValues?: boolean;
12
+ nullValues?: boolean;
13
+ undefinedValues?: boolean;
14
+ shouldRemove?: (key: string, value: unknown, base?: unknown) => boolean;
15
+ transform?: (key: string, value: unknown, base?: unknown) => unknown;
16
+ }
17
+ declare function cleanObject<T>(value: T, options?: CleanOptions): T;
18
+ //#endregion
19
+ export { CleanOptions, cleanObject };
@@ -0,0 +1,19 @@
1
+ //#region src/clean-object.d.ts
2
+ /**
3
+ * Inspired by https://github.com/nunofgs/clean-deep
4
+ */
5
+ interface CleanOptions {
6
+ cleanKeys?: readonly string[];
7
+ cleanValues?: readonly unknown[];
8
+ emptyArrays?: boolean;
9
+ emptyObjects?: boolean;
10
+ emptyStrings?: boolean;
11
+ NaNValues?: boolean;
12
+ nullValues?: boolean;
13
+ undefinedValues?: boolean;
14
+ shouldRemove?: (key: string, value: unknown, base?: unknown) => boolean;
15
+ transform?: (key: string, value: unknown, base?: unknown) => unknown;
16
+ }
17
+ declare function cleanObject<T>(value: T, options?: CleanOptions): T;
18
+ //#endregion
19
+ export { CleanOptions, cleanObject };
@@ -0,0 +1,60 @@
1
+ import { isEmptyObject, isPlainObject } from "./type-guards.js";
2
+
3
+ //#region src/clean-object.ts
4
+ function resolveOptions(options) {
5
+ return {
6
+ cleanKeys: options?.cleanKeys ?? [],
7
+ cleanValues: options?.cleanValues ?? [],
8
+ emptyArrays: options?.emptyArrays ?? true,
9
+ emptyObjects: options?.emptyObjects ?? true,
10
+ emptyStrings: options?.emptyStrings ?? true,
11
+ NaNValues: options?.NaNValues ?? false,
12
+ nullValues: options?.nullValues ?? true,
13
+ undefinedValues: options?.undefinedValues ?? true,
14
+ shouldRemove: options?.shouldRemove,
15
+ transform: options?.transform
16
+ };
17
+ }
18
+ function isCleanable(value) {
19
+ return (Array.isArray(value) || isPlainObject(value)) && !(value instanceof Date);
20
+ }
21
+ function shouldSkipValue(value, options) {
22
+ if (options.cleanValues.includes(value)) return true;
23
+ if (options.emptyObjects && isPlainObject(value) && isEmptyObject(value)) return true;
24
+ if (options.emptyArrays && Array.isArray(value) && value.length === 0) return true;
25
+ if (options.emptyStrings && value === "") return true;
26
+ if (options.NaNValues && typeof value === "number" && Number.isNaN(value)) return true;
27
+ if (options.nullValues && value === null) return true;
28
+ if (options.undefinedValues && value === void 0) return true;
29
+ return false;
30
+ }
31
+ function cleanDeep(value, options) {
32
+ if (Array.isArray(value)) {
33
+ const result$1 = [];
34
+ for (let index = 0; index < value.length; index += 1) {
35
+ const key = String(index);
36
+ if (!options.cleanKeys.includes(key)) {
37
+ const transformed = options.transform ? options.transform(key, value[index], value) : value[index];
38
+ const cleaned = isCleanable(transformed) ? cleanDeep(transformed, options) : transformed;
39
+ if (!((options.shouldRemove ? options.shouldRemove(key, cleaned, value) : false) || shouldSkipValue(cleaned, options))) result$1.push(cleaned);
40
+ }
41
+ }
42
+ return result$1;
43
+ }
44
+ const prototype = Object.getPrototypeOf(value);
45
+ const result = Object.create(prototype);
46
+ for (const [key, originalValue] of Object.entries(value)) if (!options.cleanKeys.includes(key)) {
47
+ const transformed = options.transform ? options.transform(key, originalValue, value) : originalValue;
48
+ const cleaned = isCleanable(transformed) ? cleanDeep(transformed, options) : transformed;
49
+ if (!((options.shouldRemove ? options.shouldRemove(key, cleaned, value) : false) || shouldSkipValue(cleaned, options))) result[key] = cleaned;
50
+ }
51
+ return result;
52
+ }
53
+ function cleanObject(value, options) {
54
+ const resolvedOptions = resolveOptions(options);
55
+ if (!isCleanable(value)) return value;
56
+ return cleanDeep(value, resolvedOptions);
57
+ }
58
+
59
+ //#endregion
60
+ export { cleanObject };
@@ -1 +1,54 @@
1
- const e=require(`./_virtual/rolldown_runtime.cjs`);let t=require(`@fastify/deepmerge`);t=e.__toESM(t);let n=null;function r(){return n||=(0,t.default)(),n}function i(...e){if(e.length===0)return{};if(e.length===1)return e[0]??{};let t={};for(let n of e)t=r()(t,n);return t}function a(e,t){return r()(e,t)}exports.deepMerge=a,exports.deepMergeMany=i;
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ let __fastify_deepmerge = require("@fastify/deepmerge");
3
+ __fastify_deepmerge = require_rolldown_runtime.__toESM(__fastify_deepmerge);
4
+
5
+ //#region src/deep-merge.ts
6
+ let deepMergeInstance = null;
7
+ function getDeepMerge() {
8
+ if (!deepMergeInstance) deepMergeInstance = (0, __fastify_deepmerge.default)();
9
+ return deepMergeInstance;
10
+ }
11
+ /**
12
+ * Deep merge multiple objects.
13
+ *
14
+ * Uses @fastify/deepmerge to merge any number of objects into a single result.
15
+ * Objects are merged from left to right, with later objects overriding earlier ones.
16
+ *
17
+ * @param objects - The objects to merge
18
+ * @returns A new merged object
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const obj1 = { a: 1, b: { c: 2 } };
23
+ * const obj2 = { b: { d: 3 }, e: 4 };
24
+ * const obj3 = { e: 5, f: 6 };
25
+ * deepMergeMany(obj1, obj2, obj3); // { a: 1, b: { c: 2, d: 3 }, e: 5, f: 6 }
26
+ * ```
27
+ */
28
+ function deepMergeMany(...objects) {
29
+ if (objects.length === 0) return {};
30
+ if (objects.length === 1) return objects[0] ?? {};
31
+ let result = {};
32
+ for (const obj of objects) result = getDeepMerge()(result, obj);
33
+ return result;
34
+ }
35
+ /**
36
+ * Re-export the configured deepmerge instance from @fastify/deepmerge.
37
+ *
38
+ * This provides direct access to the deepmerge function for advanced use cases,
39
+ * allowing merging of multiple objects and custom options.
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * import { deepmerge } from '@pixpilot/object';
44
+ * const result = deepmerge({ a: 1 }, { b: 2 }, { c: 3 });
45
+ * // { a: 1, b: 2, c: 3 }
46
+ * ```
47
+ */
48
+ function deepMerge(target, source) {
49
+ return getDeepMerge()(target, source);
50
+ }
51
+
52
+ //#endregion
53
+ exports.deepMerge = deepMerge;
54
+ exports.deepMergeMany = deepMergeMany;
@@ -1 +1,51 @@
1
- import e from"@fastify/deepmerge";let t=null;function n(){return t||=e(),t}function r(...e){if(e.length===0)return{};if(e.length===1)return e[0]??{};let t={};for(let r of e)t=n()(t,r);return t}function i(e,t){return n()(e,t)}export{i as deepMerge,r as deepMergeMany};
1
+ import deepmerge from "@fastify/deepmerge";
2
+
3
+ //#region src/deep-merge.ts
4
+ let deepMergeInstance = null;
5
+ function getDeepMerge() {
6
+ if (!deepMergeInstance) deepMergeInstance = deepmerge();
7
+ return deepMergeInstance;
8
+ }
9
+ /**
10
+ * Deep merge multiple objects.
11
+ *
12
+ * Uses @fastify/deepmerge to merge any number of objects into a single result.
13
+ * Objects are merged from left to right, with later objects overriding earlier ones.
14
+ *
15
+ * @param objects - The objects to merge
16
+ * @returns A new merged object
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const obj1 = { a: 1, b: { c: 2 } };
21
+ * const obj2 = { b: { d: 3 }, e: 4 };
22
+ * const obj3 = { e: 5, f: 6 };
23
+ * deepMergeMany(obj1, obj2, obj3); // { a: 1, b: { c: 2, d: 3 }, e: 5, f: 6 }
24
+ * ```
25
+ */
26
+ function deepMergeMany(...objects) {
27
+ if (objects.length === 0) return {};
28
+ if (objects.length === 1) return objects[0] ?? {};
29
+ let result = {};
30
+ for (const obj of objects) result = getDeepMerge()(result, obj);
31
+ return result;
32
+ }
33
+ /**
34
+ * Re-export the configured deepmerge instance from @fastify/deepmerge.
35
+ *
36
+ * This provides direct access to the deepmerge function for advanced use cases,
37
+ * allowing merging of multiple objects and custom options.
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * import { deepmerge } from '@pixpilot/object';
42
+ * const result = deepmerge({ a: 1 }, { b: 2 }, { c: 3 });
43
+ * // { a: 1, b: 2, c: 3 }
44
+ * ```
45
+ */
46
+ function deepMerge(target, source) {
47
+ return getDeepMerge()(target, source);
48
+ }
49
+
50
+ //#endregion
51
+ export { deepMerge, deepMergeMany };
@@ -1 +1,5 @@
1
- const e=require(`./_virtual/rolldown_runtime.cjs`);let t=require(`dot-prop`);t=e.__toESM(t),exports.deleteObjectPropertyByPath=t.deleteProperty;
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ let dot_prop = require("dot-prop");
3
+ dot_prop = require_rolldown_runtime.__toESM(dot_prop);
4
+
5
+ exports.deleteObjectPropertyByPath = dot_prop.deleteProperty;
@@ -1 +1,3 @@
1
- import{deleteProperty as e}from"dot-prop";export{e as deleteObjectPropertyByPath};
1
+ import { deleteProperty } from "dot-prop";
2
+
3
+ export { deleteProperty as deleteObjectPropertyByPath };
@@ -1 +1,5 @@
1
- const e=require(`./_virtual/rolldown_runtime.cjs`);let t=require(`dot-prop`);t=e.__toESM(t),exports.getObjectValueByPath=t.getProperty;
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ let dot_prop = require("dot-prop");
3
+ dot_prop = require_rolldown_runtime.__toESM(dot_prop);
4
+
5
+ exports.getObjectValueByPath = dot_prop.getProperty;
@@ -1 +1,3 @@
1
- import{getProperty as e}from"dot-prop";export{e as getObjectValueByPath};
1
+ import { getProperty } from "dot-prop";
2
+
3
+ export { getProperty as getObjectValueByPath };
@@ -1 +1,5 @@
1
- const e=require(`./_virtual/rolldown_runtime.cjs`);let t=require(`dot-prop`);t=e.__toESM(t),exports.hasObjectValueByPath=t.hasProperty;
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ let dot_prop = require("dot-prop");
3
+ dot_prop = require_rolldown_runtime.__toESM(dot_prop);
4
+
5
+ exports.hasObjectValueByPath = dot_prop.hasProperty;
@@ -1 +1,3 @@
1
- import{hasProperty as e}from"dot-prop";export{e as hasObjectValueByPath};
1
+ import { hasProperty } from "dot-prop";
2
+
3
+ export { hasProperty as hasObjectValueByPath };
package/dist/index.cjs CHANGED
@@ -1 +1,41 @@
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(`./manipulation.cjs`),a=require(`./set-object-value-by-path.cjs`),o=require(`./type-guards.cjs`);let s=require(`dot-prop`);s=e.__toESM(s),exports.deepClone=i.deepClone,exports.deepEqual=i.deepEqual,exports.deepMerge=t.deepMerge,exports.deepMergeMany=t.deepMergeMany,exports.deleteObjectPropertyByPath=s.deleteProperty,exports.deleteProperty=s.deleteProperty,exports.escapePath=s.escapePath,exports.flatKeys=i.flatKeys,exports.getObjectValueByPath=s.getProperty,exports.getProperty=s.getProperty,exports.hasObjectValueByPath=s.hasProperty,exports.hasProperty=s.hasProperty,exports.isEmptyObject=o.isEmptyObject,exports.isObject=o.isObject,exports.isPlainObject=o.isPlainObject,exports.keysToCamelCase=n.keysToCamelCase,exports.keysToSnakeCase=r.keysToSnakeCase,exports.mapKeys=i.mapKeys,exports.mapValues=i.mapValues,exports.omit=i.omit,exports.parsePath=s.parsePath,exports.pick=i.pick,exports.setObjectValueByPath=a.setObjectValueByPath,exports.setProperty=s.setProperty,exports.stringifyPath=s.stringifyPath,exports.unflatten=s.unflatten;
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ const require_type_guards = require('./type-guards.cjs');
3
+ const require_clean_object = require('./clean-object.cjs');
4
+ const require_deep_merge = require('./deep-merge.cjs');
5
+ require('./delete-object-property-by-path.cjs');
6
+ require('./get-object-value-by-path.cjs');
7
+ require('./has-object-value-by-path.cjs');
8
+ const require_keys_to_camel_case = require('./keys-to-camel-case.cjs');
9
+ const require_keys_to_snake_case = require('./keys-to-snake-case.cjs');
10
+ const require_manipulation = require('./manipulation.cjs');
11
+ const require_set_object_value_by_path = require('./set-object-value-by-path.cjs');
12
+ let dot_prop = require("dot-prop");
13
+ dot_prop = require_rolldown_runtime.__toESM(dot_prop);
14
+
15
+ exports.cleanObject = require_clean_object.cleanObject;
16
+ exports.deepClone = require_manipulation.deepClone;
17
+ exports.deepEqual = require_manipulation.deepEqual;
18
+ exports.deepMerge = require_deep_merge.deepMerge;
19
+ exports.deepMergeMany = require_deep_merge.deepMergeMany;
20
+ exports.deleteObjectPropertyByPath = dot_prop.deleteProperty;
21
+ exports.deleteProperty = dot_prop.deleteProperty;
22
+ exports.escapePath = dot_prop.escapePath;
23
+ exports.flatKeys = require_manipulation.flatKeys;
24
+ exports.getObjectValueByPath = dot_prop.getProperty;
25
+ exports.getProperty = dot_prop.getProperty;
26
+ exports.hasObjectValueByPath = dot_prop.hasProperty;
27
+ exports.hasProperty = dot_prop.hasProperty;
28
+ exports.isEmptyObject = require_type_guards.isEmptyObject;
29
+ exports.isObject = require_type_guards.isObject;
30
+ exports.isPlainObject = require_type_guards.isPlainObject;
31
+ exports.keysToCamelCase = require_keys_to_camel_case.keysToCamelCase;
32
+ exports.keysToSnakeCase = require_keys_to_snake_case.keysToSnakeCase;
33
+ exports.mapKeys = require_manipulation.mapKeys;
34
+ exports.mapValues = require_manipulation.mapValues;
35
+ exports.omit = require_manipulation.omit;
36
+ exports.parsePath = dot_prop.parsePath;
37
+ exports.pick = require_manipulation.pick;
38
+ exports.setObjectValueByPath = require_set_object_value_by_path.setObjectValueByPath;
39
+ exports.setProperty = dot_prop.setProperty;
40
+ exports.stringifyPath = dot_prop.stringifyPath;
41
+ exports.unflatten = dot_prop.unflatten;
package/dist/index.d.cts CHANGED
@@ -1,3 +1,4 @@
1
+ import { CleanOptions, cleanObject } from "./clean-object.cjs";
1
2
  import { deepMerge, deepMergeMany } from "./deep-merge.cjs";
2
3
  import { deleteObjectPropertyByPath as deleteProperty } from "./delete-object-property-by-path.cjs";
3
4
  import { getObjectValueByPath as getProperty } from "./get-object-value-by-path.cjs";
@@ -7,4 +8,4 @@ import { KeysToSnakeCase, ToSnakeCase, keysToSnakeCase } from "./keys-to-snake-c
7
8
  import { deepClone, deepEqual, deleteProperty as deleteProperty$1, escapePath, flatKeys, getProperty as getProperty$1, hasProperty as hasProperty$1, mapKeys, mapValues, omit, parsePath, pick, setProperty, stringifyPath, unflatten } from "./manipulation.cjs";
8
9
  import { setObjectValueByPath } from "./set-object-value-by-path.cjs";
9
10
  import { isEmptyObject, isObject, isPlainObject } from "./type-guards.cjs";
10
- export { KeysToCamelCase, KeysToSnakeCase, ToCamelCase, ToSnakeCase, deepClone, deepEqual, deepMerge, deepMergeMany, deleteProperty as deleteObjectPropertyByPath, deleteProperty$1 as deleteProperty, escapePath, flatKeys, getProperty as getObjectValueByPath, getProperty$1 as getProperty, hasProperty as hasObjectValueByPath, hasProperty$1 as hasProperty, isEmptyObject, isObject, isPlainObject, keysToCamelCase, keysToSnakeCase, mapKeys, mapValues, omit, parsePath, pick, setObjectValueByPath, setProperty, stringifyPath, unflatten };
11
+ export { CleanOptions, KeysToCamelCase, KeysToSnakeCase, ToCamelCase, ToSnakeCase, cleanObject, deepClone, deepEqual, deepMerge, deepMergeMany, deleteProperty as deleteObjectPropertyByPath, deleteProperty$1 as deleteProperty, escapePath, flatKeys, getProperty as getObjectValueByPath, getProperty$1 as getProperty, hasProperty as hasObjectValueByPath, hasProperty$1 as hasProperty, isEmptyObject, isObject, isPlainObject, keysToCamelCase, keysToSnakeCase, mapKeys, mapValues, omit, parsePath, pick, setObjectValueByPath, setProperty, stringifyPath, unflatten };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { CleanOptions, cleanObject } from "./clean-object.js";
1
2
  import { deepMerge, deepMergeMany } from "./deep-merge.js";
2
3
  import { deleteObjectPropertyByPath as deleteProperty } from "./delete-object-property-by-path.js";
3
4
  import { getObjectValueByPath as getProperty } from "./get-object-value-by-path.js";
@@ -7,4 +8,4 @@ import { KeysToSnakeCase, ToSnakeCase, keysToSnakeCase } from "./keys-to-snake-c
7
8
  import { deepClone, deepEqual, deleteProperty as deleteProperty$1, escapePath, flatKeys, getProperty as getProperty$1, hasProperty as hasProperty$1, mapKeys, mapValues, omit, parsePath, pick, setProperty, stringifyPath, unflatten } from "./manipulation.js";
8
9
  import { setObjectValueByPath } from "./set-object-value-by-path.js";
9
10
  import { isEmptyObject, isObject, isPlainObject } from "./type-guards.js";
10
- export { KeysToCamelCase, KeysToSnakeCase, ToCamelCase, ToSnakeCase, deepClone, deepEqual, deepMerge, deepMergeMany, deleteProperty as deleteObjectPropertyByPath, deleteProperty$1 as deleteProperty, escapePath, flatKeys, getProperty as getObjectValueByPath, getProperty$1 as getProperty, hasProperty as hasObjectValueByPath, hasProperty$1 as hasProperty, isEmptyObject, isObject, isPlainObject, keysToCamelCase, keysToSnakeCase, mapKeys, mapValues, omit, parsePath, pick, setObjectValueByPath, setProperty, stringifyPath, unflatten };
11
+ export { CleanOptions, KeysToCamelCase, KeysToSnakeCase, ToCamelCase, ToSnakeCase, cleanObject, deepClone, deepEqual, deepMerge, deepMergeMany, deleteProperty as deleteObjectPropertyByPath, deleteProperty$1 as deleteProperty, escapePath, flatKeys, getProperty as getObjectValueByPath, getProperty$1 as getProperty, hasProperty as hasObjectValueByPath, hasProperty$1 as hasProperty, isEmptyObject, isObject, isPlainObject, keysToCamelCase, keysToSnakeCase, mapKeys, mapValues, omit, parsePath, pick, setObjectValueByPath, setProperty, stringifyPath, unflatten };
package/dist/index.js CHANGED
@@ -1 +1,12 @@
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{deepClone as s,deepEqual as c,deleteProperty as l,escapePath as u,flatKeys as d,getProperty as f,hasProperty as p,mapKeys as m,mapValues as h,omit as g,parsePath as _,pick as v,setProperty as y,stringifyPath as b,unflatten as x}from"./manipulation.js";import{setObjectValueByPath as S}from"./set-object-value-by-path.js";import{isEmptyObject as C,isObject as w,isPlainObject as T}from"./type-guards.js";export{s as deepClone,c as deepEqual,e as deepMerge,t as deepMergeMany,n as deleteObjectPropertyByPath,l as deleteProperty,u as escapePath,d as flatKeys,r as getObjectValueByPath,f as getProperty,i as hasObjectValueByPath,p as hasProperty,C as isEmptyObject,w as isObject,T as isPlainObject,a as keysToCamelCase,o as keysToSnakeCase,m as mapKeys,h as mapValues,g as omit,_ as parsePath,v as pick,S as setObjectValueByPath,y as setProperty,b as stringifyPath,x as unflatten};
1
+ import { isEmptyObject, isObject, isPlainObject } from "./type-guards.js";
2
+ import { cleanObject } from "./clean-object.js";
3
+ import { deepMerge, deepMergeMany } from "./deep-merge.js";
4
+ import { deleteObjectPropertyByPath as deleteProperty } from "./delete-object-property-by-path.js";
5
+ import { getObjectValueByPath as getProperty } from "./get-object-value-by-path.js";
6
+ import { hasObjectValueByPath as hasProperty } from "./has-object-value-by-path.js";
7
+ import { keysToCamelCase } from "./keys-to-camel-case.js";
8
+ import { keysToSnakeCase } from "./keys-to-snake-case.js";
9
+ import { deepClone, deepEqual, deleteProperty as deleteProperty$1, escapePath, flatKeys, getProperty as getProperty$1, hasProperty as hasProperty$1, mapKeys, mapValues, omit, parsePath, pick, setProperty, stringifyPath, unflatten } from "./manipulation.js";
10
+ import { setObjectValueByPath } from "./set-object-value-by-path.js";
11
+
12
+ export { cleanObject, deepClone, deepEqual, deepMerge, deepMergeMany, deleteProperty as deleteObjectPropertyByPath, deleteProperty$1 as deleteProperty, escapePath, flatKeys, getProperty as getObjectValueByPath, getProperty$1 as getProperty, hasProperty as hasObjectValueByPath, hasProperty$1 as hasProperty, isEmptyObject, isObject, isPlainObject, keysToCamelCase, keysToSnakeCase, mapKeys, mapValues, omit, parsePath, pick, setObjectValueByPath, setProperty, stringifyPath, unflatten };
@@ -1 +1,18 @@
1
- const e=require(`./_virtual/rolldown_runtime.cjs`);let t=require(`@pixpilot/string`);t=e.__toESM(t);function n(e){if(Array.isArray(e))return e.map(n);if(typeof e!=`object`||!e)return e;let r={};for(let[i,a]of Object.entries(e)){let e=(0,t.toCamelCase)(i);r[e]=n(a)}return r}exports.keysToCamelCase=n;
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ let __pixpilot_string = require("@pixpilot/string");
3
+ __pixpilot_string = require_rolldown_runtime.__toESM(__pixpilot_string);
4
+
5
+ //#region src/keys-to-camel-case.ts
6
+ function keysToCamelCase(obj) {
7
+ if (Array.isArray(obj)) return obj.map(keysToCamelCase);
8
+ if (obj === null || typeof obj !== "object") return obj;
9
+ const result = {};
10
+ for (const [key, value] of Object.entries(obj)) {
11
+ const camelKey = (0, __pixpilot_string.toCamelCase)(key);
12
+ result[camelKey] = keysToCamelCase(value);
13
+ }
14
+ return result;
15
+ }
16
+
17
+ //#endregion
18
+ exports.keysToCamelCase = keysToCamelCase;
@@ -1 +1,16 @@
1
- import{toCamelCase as e}from"@pixpilot/string";function t(n){if(Array.isArray(n))return n.map(t);if(typeof n!=`object`||!n)return n;let r={};for(let[i,a]of Object.entries(n)){let n=e(i);r[n]=t(a)}return r}export{t as keysToCamelCase};
1
+ import { toCamelCase } from "@pixpilot/string";
2
+
3
+ //#region src/keys-to-camel-case.ts
4
+ function keysToCamelCase(obj) {
5
+ if (Array.isArray(obj)) return obj.map(keysToCamelCase);
6
+ if (obj === null || typeof obj !== "object") return obj;
7
+ const result = {};
8
+ for (const [key, value] of Object.entries(obj)) {
9
+ const camelKey = toCamelCase(key);
10
+ result[camelKey] = keysToCamelCase(value);
11
+ }
12
+ return result;
13
+ }
14
+
15
+ //#endregion
16
+ export { keysToCamelCase };
@@ -1 +1,21 @@
1
- const e=require(`./_virtual/rolldown_runtime.cjs`);let t=require(`@pixpilot/string`);t=e.__toESM(t);function n(e){if(Array.isArray(e))return e.map(n);if(typeof e!=`object`||!e)return e;let r={};for(let[i,a]of Object.entries(e)){let e=(0,t.toSnakeCase)(i);r[e]=n(a)}return r}exports.keysToSnakeCase=n;
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ let __pixpilot_string = require("@pixpilot/string");
3
+ __pixpilot_string = require_rolldown_runtime.__toESM(__pixpilot_string);
4
+
5
+ //#region src/keys-to-snake-case.ts
6
+ /**
7
+ * Converts object keys from camelCase to snake_case recursively
8
+ */
9
+ function keysToSnakeCase(obj) {
10
+ if (Array.isArray(obj)) return obj.map(keysToSnakeCase);
11
+ if (obj === null || typeof obj !== "object") return obj;
12
+ const result = {};
13
+ for (const [key, value] of Object.entries(obj)) {
14
+ const snakeKey = (0, __pixpilot_string.toSnakeCase)(key);
15
+ result[snakeKey] = keysToSnakeCase(value);
16
+ }
17
+ return result;
18
+ }
19
+
20
+ //#endregion
21
+ exports.keysToSnakeCase = keysToSnakeCase;
@@ -1 +1,19 @@
1
- import{toSnakeCase as e}from"@pixpilot/string";function t(n){if(Array.isArray(n))return n.map(t);if(typeof n!=`object`||!n)return n;let r={};for(let[i,a]of Object.entries(n)){let n=e(i);r[n]=t(a)}return r}export{t as keysToSnakeCase};
1
+ import { toSnakeCase } from "@pixpilot/string";
2
+
3
+ //#region src/keys-to-snake-case.ts
4
+ /**
5
+ * Converts object keys from camelCase to snake_case recursively
6
+ */
7
+ function keysToSnakeCase(obj) {
8
+ if (Array.isArray(obj)) return obj.map(keysToSnakeCase);
9
+ if (obj === null || typeof obj !== "object") return obj;
10
+ const result = {};
11
+ for (const [key, value] of Object.entries(obj)) {
12
+ const snakeKey = toSnakeCase(key);
13
+ result[snakeKey] = keysToSnakeCase(value);
14
+ }
15
+ return result;
16
+ }
17
+
18
+ //#endregion
19
+ export { keysToSnakeCase };
@@ -1 +1,151 @@
1
- const e=require(`./_virtual/rolldown_runtime.cjs`);let t=require(`dot-prop`);t=e.__toESM(t);function n(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function r(e,t){let n={...e};for(let e of t)delete n[e];return n}function i(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=>i(e));let t={};for(let[n,r]of Object.entries(e))t[n]=i(r);return t}function a(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)=>a(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=>a(e[n],t[n])):!1}return!1}function o(e,t){let n={};for(let[r,i]of Object.entries(e))n[r]=t(i,r);return n}function s(e,t){let n={};for(let[r,i]of Object.entries(e)){let e=t(r);n[e]=i}return n}const c=t.deepKeys;exports.deepClone=i,exports.deepEqual=a,exports.deleteProperty=t.deleteProperty,exports.escapePath=t.escapePath,exports.flatKeys=c,exports.getProperty=t.getProperty,exports.hasProperty=t.hasProperty,exports.mapKeys=s,exports.mapValues=o,exports.omit=r,exports.parsePath=t.parsePath,exports.pick=n,exports.setProperty=t.setProperty,exports.stringifyPath=t.stringifyPath,exports.unflatten=t.unflatten;
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ let dot_prop = require("dot-prop");
3
+ dot_prop = require_rolldown_runtime.__toESM(dot_prop);
4
+
5
+ //#region src/manipulation.ts
6
+ /**
7
+ * Pick specific keys from an object.
8
+ *
9
+ * @param obj - The source object
10
+ * @param keys - The keys to pick
11
+ * @returns A new object with only the specified keys
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const obj = { a: 1, b: 2, c: 3 };
16
+ * pick(obj, ['a', 'c']); // { a: 1, c: 3 }
17
+ * ```
18
+ */
19
+ function pick(obj, keys) {
20
+ const result = {};
21
+ for (const key of keys) if (key in obj) result[key] = obj[key];
22
+ return result;
23
+ }
24
+ /**
25
+ * Omit specific keys from an object.
26
+ *
27
+ * @param obj - The source object
28
+ * @param keys - The keys to omit
29
+ * @returns A new object without the specified keys
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * const obj = { a: 1, b: 2, c: 3 };
34
+ * omit(obj, ['b']); // { a: 1, c: 3 }
35
+ * ```
36
+ */
37
+ function omit(obj, keys) {
38
+ const result = { ...obj };
39
+ for (const key of keys) delete result[key];
40
+ return result;
41
+ }
42
+ /**
43
+ * Deep clone an object.
44
+ *
45
+ * @param obj - The object to clone
46
+ * @returns A deep clone of the object
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * const obj = { a: 1, b: { c: 2 } };
51
+ * const cloned = deepClone(obj);
52
+ * cloned.b.c = 3;
53
+ * console.log(obj.b.c); // 2 (original unchanged)
54
+ * ```
55
+ */
56
+ function deepClone(obj) {
57
+ if (obj === null || typeof obj !== "object") return obj;
58
+ if (obj instanceof Date) return new Date(obj.getTime());
59
+ if (obj instanceof RegExp) return new RegExp(obj.source, obj.flags);
60
+ if (Array.isArray(obj)) return obj.map((item) => deepClone(item));
61
+ const cloned = {};
62
+ for (const [key, value] of Object.entries(obj)) cloned[key] = deepClone(value);
63
+ return cloned;
64
+ }
65
+ /**
66
+ * Compare two objects for deep equality.
67
+ *
68
+ * @param obj1 - The first object
69
+ * @param obj2 - The second object
70
+ * @returns True if the objects are deeply equal, false otherwise
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * deepEqual({ a: 1, b: { c: 2 } }, { a: 1, b: { c: 2 } }); // true
75
+ * deepEqual({ a: 1 }, { a: 2 }); // false
76
+ * ```
77
+ */
78
+ function deepEqual(obj1, obj2) {
79
+ if (obj1 === obj2) return true;
80
+ if (typeof obj1 !== typeof obj2) return false;
81
+ if (obj1 === null || obj2 === null) return false;
82
+ if (obj1 instanceof Date && obj2 instanceof Date) return obj1.getTime() === obj2.getTime();
83
+ if (Array.isArray(obj1) && Array.isArray(obj2)) {
84
+ if (obj1.length !== obj2.length) return false;
85
+ return obj1.every((item, index) => deepEqual(item, obj2[index]));
86
+ }
87
+ if (typeof obj1 === "object" && typeof obj2 === "object") {
88
+ const keys1 = Object.keys(obj1);
89
+ const keys2 = Object.keys(obj2);
90
+ if (keys1.length !== keys2.length) return false;
91
+ return keys1.every((key) => deepEqual(obj1[key], obj2[key]));
92
+ }
93
+ return false;
94
+ }
95
+ /**
96
+ * Map over the values of an object.
97
+ *
98
+ * @param obj - The source object
99
+ * @param fn - The mapping function
100
+ * @returns A new object with mapped values
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * const obj = { a: 1, b: 2, c: 3 };
105
+ * mapValues(obj, (value) => value * 2); // { a: 2, b: 4, c: 6 }
106
+ * ```
107
+ */
108
+ function mapValues(obj, fn) {
109
+ const result = {};
110
+ for (const [key, value] of Object.entries(obj)) result[key] = fn(value, key);
111
+ return result;
112
+ }
113
+ /**
114
+ * Map over the keys of an object.
115
+ *
116
+ * @param obj - The source object
117
+ * @param fn - The mapping function
118
+ * @returns A new object with mapped keys
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * const obj = { a: 1, b: 2 };
123
+ * mapKeys(obj, (key) => key.toUpperCase()); // { A: 1, B: 2 }
124
+ * ```
125
+ */
126
+ function mapKeys(obj, fn) {
127
+ const result = {};
128
+ for (const [key, value] of Object.entries(obj)) {
129
+ const newKey = fn(key);
130
+ result[newKey] = value;
131
+ }
132
+ return result;
133
+ }
134
+ const flatKeys = dot_prop.deepKeys;
135
+
136
+ //#endregion
137
+ exports.deepClone = deepClone;
138
+ exports.deepEqual = deepEqual;
139
+ exports.deleteProperty = dot_prop.deleteProperty;
140
+ exports.escapePath = dot_prop.escapePath;
141
+ exports.flatKeys = flatKeys;
142
+ exports.getProperty = dot_prop.getProperty;
143
+ exports.hasProperty = dot_prop.hasProperty;
144
+ exports.mapKeys = mapKeys;
145
+ exports.mapValues = mapValues;
146
+ exports.omit = omit;
147
+ exports.parsePath = dot_prop.parsePath;
148
+ exports.pick = pick;
149
+ exports.setProperty = dot_prop.setProperty;
150
+ exports.stringifyPath = dot_prop.stringifyPath;
151
+ exports.unflatten = dot_prop.unflatten;
@@ -1 +1,135 @@
1
- import{deepKeys as e,deleteProperty as t,escapePath as n,getProperty as r,hasProperty as i,parsePath as a,setProperty as o,stringifyPath as s,unflatten as c}from"dot-prop";function l(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function u(e,t){let n={...e};for(let e of t)delete n[e];return n}function d(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=>d(e));let t={};for(let[n,r]of Object.entries(e))t[n]=d(r);return t}function f(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)=>f(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=>f(e[n],t[n])):!1}return!1}function p(e,t){let n={};for(let[r,i]of Object.entries(e))n[r]=t(i,r);return n}function m(e,t){let n={};for(let[r,i]of Object.entries(e)){let e=t(r);n[e]=i}return n}const h=e;export{d as deepClone,f as deepEqual,t as deleteProperty,n as escapePath,h as flatKeys,r as getProperty,i as hasProperty,m as mapKeys,p as mapValues,u as omit,a as parsePath,l as pick,o as setProperty,s as stringifyPath,c as unflatten};
1
+ import { deepKeys, deleteProperty, escapePath, getProperty, hasProperty, parsePath, setProperty, stringifyPath, unflatten } from "dot-prop";
2
+
3
+ //#region src/manipulation.ts
4
+ /**
5
+ * Pick specific keys from an object.
6
+ *
7
+ * @param obj - The source object
8
+ * @param keys - The keys to pick
9
+ * @returns A new object with only the specified keys
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const obj = { a: 1, b: 2, c: 3 };
14
+ * pick(obj, ['a', 'c']); // { a: 1, c: 3 }
15
+ * ```
16
+ */
17
+ function pick(obj, keys) {
18
+ const result = {};
19
+ for (const key of keys) if (key in obj) result[key] = obj[key];
20
+ return result;
21
+ }
22
+ /**
23
+ * Omit specific keys from an object.
24
+ *
25
+ * @param obj - The source object
26
+ * @param keys - The keys to omit
27
+ * @returns A new object without the specified keys
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * const obj = { a: 1, b: 2, c: 3 };
32
+ * omit(obj, ['b']); // { a: 1, c: 3 }
33
+ * ```
34
+ */
35
+ function omit(obj, keys) {
36
+ const result = { ...obj };
37
+ for (const key of keys) delete result[key];
38
+ return result;
39
+ }
40
+ /**
41
+ * Deep clone an object.
42
+ *
43
+ * @param obj - The object to clone
44
+ * @returns A deep clone of the object
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * const obj = { a: 1, b: { c: 2 } };
49
+ * const cloned = deepClone(obj);
50
+ * cloned.b.c = 3;
51
+ * console.log(obj.b.c); // 2 (original unchanged)
52
+ * ```
53
+ */
54
+ function deepClone(obj) {
55
+ if (obj === null || typeof obj !== "object") return obj;
56
+ if (obj instanceof Date) return new Date(obj.getTime());
57
+ if (obj instanceof RegExp) return new RegExp(obj.source, obj.flags);
58
+ if (Array.isArray(obj)) return obj.map((item) => deepClone(item));
59
+ const cloned = {};
60
+ for (const [key, value] of Object.entries(obj)) cloned[key] = deepClone(value);
61
+ return cloned;
62
+ }
63
+ /**
64
+ * Compare two objects for deep equality.
65
+ *
66
+ * @param obj1 - The first object
67
+ * @param obj2 - The second object
68
+ * @returns True if the objects are deeply equal, false otherwise
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * deepEqual({ a: 1, b: { c: 2 } }, { a: 1, b: { c: 2 } }); // true
73
+ * deepEqual({ a: 1 }, { a: 2 }); // false
74
+ * ```
75
+ */
76
+ function deepEqual(obj1, obj2) {
77
+ if (obj1 === obj2) return true;
78
+ if (typeof obj1 !== typeof obj2) return false;
79
+ if (obj1 === null || obj2 === null) return false;
80
+ if (obj1 instanceof Date && obj2 instanceof Date) return obj1.getTime() === obj2.getTime();
81
+ if (Array.isArray(obj1) && Array.isArray(obj2)) {
82
+ if (obj1.length !== obj2.length) return false;
83
+ return obj1.every((item, index) => deepEqual(item, obj2[index]));
84
+ }
85
+ if (typeof obj1 === "object" && typeof obj2 === "object") {
86
+ const keys1 = Object.keys(obj1);
87
+ const keys2 = Object.keys(obj2);
88
+ if (keys1.length !== keys2.length) return false;
89
+ return keys1.every((key) => deepEqual(obj1[key], obj2[key]));
90
+ }
91
+ return false;
92
+ }
93
+ /**
94
+ * Map over the values of an object.
95
+ *
96
+ * @param obj - The source object
97
+ * @param fn - The mapping function
98
+ * @returns A new object with mapped values
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * const obj = { a: 1, b: 2, c: 3 };
103
+ * mapValues(obj, (value) => value * 2); // { a: 2, b: 4, c: 6 }
104
+ * ```
105
+ */
106
+ function mapValues(obj, fn) {
107
+ const result = {};
108
+ for (const [key, value] of Object.entries(obj)) result[key] = fn(value, key);
109
+ return result;
110
+ }
111
+ /**
112
+ * Map over the keys of an object.
113
+ *
114
+ * @param obj - The source object
115
+ * @param fn - The mapping function
116
+ * @returns A new object with mapped keys
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * const obj = { a: 1, b: 2 };
121
+ * mapKeys(obj, (key) => key.toUpperCase()); // { A: 1, B: 2 }
122
+ * ```
123
+ */
124
+ function mapKeys(obj, fn) {
125
+ const result = {};
126
+ for (const [key, value] of Object.entries(obj)) {
127
+ const newKey = fn(key);
128
+ result[newKey] = value;
129
+ }
130
+ return result;
131
+ }
132
+ const flatKeys = deepKeys;
133
+
134
+ //#endregion
135
+ export { deepClone, deepEqual, deleteProperty, escapePath, flatKeys, getProperty, hasProperty, mapKeys, mapValues, omit, parsePath, pick, setProperty, stringifyPath, unflatten };
@@ -1 +1,27 @@
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;
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ let dot_prop = require("dot-prop");
3
+ dot_prop = require_rolldown_runtime.__toESM(dot_prop);
4
+
5
+ //#region src/set-object-value-by-path.ts
6
+ /**
7
+ * Set a nested value in an object using a path string.
8
+ *
9
+ * @param object - The target object
10
+ * @param path - The path to set the value at (e.g., 'a.b.c')
11
+ * @param value - The value to set
12
+ * @param options - Options for setting the value
13
+ * @param options.deleteUndefine - If true, delete the property when value is undefined
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const obj = { a: { b: {} } };
18
+ * setObjectValueByPath(obj, 'a.b.c', 42); // { a: { b: { c: 42 } } }
19
+ * ```
20
+ */
21
+ function setObjectValueByPath(object, path, value, options = {}) {
22
+ if (options.deleteUndefine && value === void 0) (0, dot_prop.deleteProperty)(object, path);
23
+ else (0, dot_prop.setProperty)(object, path, value);
24
+ }
25
+
26
+ //#endregion
27
+ exports.setObjectValueByPath = setObjectValueByPath;
@@ -1 +1,25 @@
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};
1
+ import { deleteProperty, setProperty } from "dot-prop";
2
+
3
+ //#region src/set-object-value-by-path.ts
4
+ /**
5
+ * Set a nested value in an object using a path string.
6
+ *
7
+ * @param object - The target object
8
+ * @param path - The path to set the value at (e.g., 'a.b.c')
9
+ * @param value - The value to set
10
+ * @param options - Options for setting the value
11
+ * @param options.deleteUndefine - If true, delete the property when value is undefined
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const obj = { a: { b: {} } };
16
+ * setObjectValueByPath(obj, 'a.b.c', 42); // { a: { b: { c: 42 } } }
17
+ * ```
18
+ */
19
+ function setObjectValueByPath(object, path, value, options = {}) {
20
+ if (options.deleteUndefine && value === void 0) deleteProperty(object, path);
21
+ else setProperty(object, path, value);
22
+ }
23
+
24
+ //#endregion
25
+ export { setObjectValueByPath };
@@ -1 +1,61 @@
1
- function e(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function t(t){if(!e(t))return!1;let n=Object.getPrototypeOf(t);return n===null||n===Object.prototype}function n(t){return e(t)&&Object.keys(t).length===0}exports.isEmptyObject=n,exports.isObject=e,exports.isPlainObject=t;
1
+
2
+ //#region src/type-guards.ts
3
+ /**
4
+ * Type guard to check if a value is an object (and not null or an array).
5
+ *
6
+ * @param value - The value to check
7
+ * @returns True if the value is an object, false otherwise
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * isObject({}); // true
12
+ * isObject({ key: 'value' }); // true
13
+ * isObject([]); // false
14
+ * isObject(null); // false
15
+ * isObject('string'); // false
16
+ * ```
17
+ */
18
+ function isObject(value) {
19
+ return typeof value === "object" && value !== null && !Array.isArray(value);
20
+ }
21
+ /**
22
+ * Type guard to check if a value is a plain object
23
+ * (created with {} or new Object(), not a class instance).
24
+ *
25
+ * @param value - The value to check
26
+ * @returns True if the value is a plain object, false otherwise
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * isPlainObject({}); // true
31
+ * isPlainObject({ key: 'value' }); // true
32
+ * isPlainObject(new Date()); // false
33
+ * isPlainObject([]); // false
34
+ * ```
35
+ */
36
+ function isPlainObject(value) {
37
+ if (!isObject(value)) return false;
38
+ const proto = Object.getPrototypeOf(value);
39
+ return proto === null || proto === Object.prototype;
40
+ }
41
+ /**
42
+ * Type guard to check if a value is an empty object.
43
+ *
44
+ * @param value - The value to check
45
+ * @returns True if the value is an empty object, false otherwise
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * isEmptyObject({}); // true
50
+ * isEmptyObject({ key: 'value' }); // false
51
+ * isEmptyObject([]); // false
52
+ * ```
53
+ */
54
+ function isEmptyObject(value) {
55
+ return isObject(value) && Object.keys(value).length === 0;
56
+ }
57
+
58
+ //#endregion
59
+ exports.isEmptyObject = isEmptyObject;
60
+ exports.isObject = isObject;
61
+ exports.isPlainObject = isPlainObject;
@@ -1 +1,58 @@
1
- function e(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function t(t){if(!e(t))return!1;let n=Object.getPrototypeOf(t);return n===null||n===Object.prototype}function n(t){return e(t)&&Object.keys(t).length===0}export{n as isEmptyObject,e as isObject,t as isPlainObject};
1
+ //#region src/type-guards.ts
2
+ /**
3
+ * Type guard to check if a value is an object (and not null or an array).
4
+ *
5
+ * @param value - The value to check
6
+ * @returns True if the value is an object, false otherwise
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * isObject({}); // true
11
+ * isObject({ key: 'value' }); // true
12
+ * isObject([]); // false
13
+ * isObject(null); // false
14
+ * isObject('string'); // false
15
+ * ```
16
+ */
17
+ function isObject(value) {
18
+ return typeof value === "object" && value !== null && !Array.isArray(value);
19
+ }
20
+ /**
21
+ * Type guard to check if a value is a plain object
22
+ * (created with {} or new Object(), not a class instance).
23
+ *
24
+ * @param value - The value to check
25
+ * @returns True if the value is a plain object, false otherwise
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * isPlainObject({}); // true
30
+ * isPlainObject({ key: 'value' }); // true
31
+ * isPlainObject(new Date()); // false
32
+ * isPlainObject([]); // false
33
+ * ```
34
+ */
35
+ function isPlainObject(value) {
36
+ if (!isObject(value)) return false;
37
+ const proto = Object.getPrototypeOf(value);
38
+ return proto === null || proto === Object.prototype;
39
+ }
40
+ /**
41
+ * Type guard to check if a value is an empty object.
42
+ *
43
+ * @param value - The value to check
44
+ * @returns True if the value is an empty object, false otherwise
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * isEmptyObject({}); // true
49
+ * isEmptyObject({ key: 'value' }); // false
50
+ * isEmptyObject([]); // false
51
+ * ```
52
+ */
53
+ function isEmptyObject(value) {
54
+ return isObject(value) && Object.keys(value).length === 0;
55
+ }
56
+
57
+ //#endregion
58
+ export { isEmptyObject, isObject, isPlainObject };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pixpilot/object",
3
3
  "type": "module",
4
- "version": "2.1.0",
4
+ "version": "2.1.1",
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",
@@ -27,7 +27,7 @@
27
27
  "dependencies": {
28
28
  "@fastify/deepmerge": "^3.1.0",
29
29
  "dot-prop": "^10.1.0",
30
- "@pixpilot/string": "2.3.0"
30
+ "@pixpilot/string": "2.4.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@manypkg/get-packages": "^3.1.0",
@@ -37,9 +37,9 @@
37
37
  "typescript": "^5.9.3",
38
38
  "@internal/eslint-config": "0.3.0",
39
39
  "@internal/prettier-config": "0.0.1",
40
- "@internal/vitest-config": "0.1.0",
41
40
  "@internal/tsconfig": "0.1.0",
42
- "@internal/tsdown-config": "0.1.0"
41
+ "@internal/tsdown-config": "0.1.0",
42
+ "@internal/vitest-config": "0.1.0"
43
43
  },
44
44
  "prettier": "@internal/prettier-config",
45
45
  "scripts": {