@helpers4/object 2.0.3 → 2.1.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.
@@ -1,6 +1,16 @@
1
1
  {
2
2
  "category": "object",
3
3
  "functions": [
4
+ {
5
+ "name": "cloneDeep",
6
+ "examples": [
7
+ {
8
+ "title": "Clone a nested object",
9
+ "description": "Creates a deep copy — modifying the clone does not affect the original.",
10
+ "code": "const original = { a: { b: 1 } };\nconst cloned = cloneDeep(original);\ncloned.a.b = 2;\n// original.a.b is still 1"
11
+ }
12
+ ]
13
+ },
4
14
  {
5
15
  "name": "compact",
6
16
  "examples": [
@@ -16,26 +26,6 @@
16
26
  }
17
27
  ]
18
28
  },
19
- {
20
- "name": "deepClone",
21
- "examples": [
22
- {
23
- "title": "Clone a nested object",
24
- "description": "Creates a deep copy — modifying the clone does not affect the original.",
25
- "code": "const original = { a: { b: 1 } };\nconst cloned = deepClone(original);\ncloned.a.b = 2;\n// original.a.b is still 1"
26
- }
27
- ]
28
- },
29
- {
30
- "name": "deepMerge",
31
- "examples": [
32
- {
33
- "title": "Merge two objects deeply",
34
- "description": "Recursively merges source properties into the target object.",
35
- "code": "deepMerge({ a: 1, b: { c: 2 } }, { b: { d: 3 }, e: 4 })\n// => { a: 1, b: { c: 2, d: 3 }, e: 4 }"
36
- }
37
- ]
38
- },
39
29
  {
40
30
  "name": "diff",
41
31
  "examples": [
@@ -88,6 +78,11 @@
88
78
  "title": "Return default for missing path",
89
79
  "description": "Returns the default value when the path does not exist.",
90
80
  "code": "get({ a: 1 }, 'b.c', 'default')\n// => 'default'"
81
+ },
82
+ {
83
+ "title": "Get via key array (supports symbols)",
84
+ "description": "Pass an explicit PropertyKey[] to bypass parsing. Supports string, number, and symbol keys.",
85
+ "code": "const id = Symbol('id')\nget({ [id]: 'alice' }, [id])\n// => 'alice'"
91
86
  }
92
87
  ]
93
88
  },
@@ -171,6 +166,16 @@
171
166
  }
172
167
  ]
173
168
  },
169
+ {
170
+ "name": "mergeDeep",
171
+ "examples": [
172
+ {
173
+ "title": "Merge two objects deeply",
174
+ "description": "Returns a new object — neither input is mutated.",
175
+ "code": "mergeDeep({ a: 1, b: { c: 2 } }, { b: { d: 3 }, e: 4 })\n// => { a: 1, b: { c: 2, d: 3 }, e: 4 }"
176
+ }
177
+ ]
178
+ },
174
179
  {
175
180
  "name": "omit",
176
181
  "examples": [
@@ -235,9 +240,19 @@
235
240
  "name": "set",
236
241
  "examples": [
237
242
  {
238
- "title": "Set a nested property",
239
- "description": "Creates intermediate objects as needed along the dot-notated path.",
240
- "code": "set({}, 'a.b.c', 42)\n// => { a: { b: { c: 42 } } }"
243
+ "title": "Set a nested property (dot notation)",
244
+ "description": "Creates intermediate objects as needed. All segments are string keys — including numeric-looking ones like \"1\".",
245
+ "code": "set({}, 'a.b.c', 42)\n// => { a: { b: { c: 42 } } }\n\nset({}, 'layers.1.name', 'bg')\n// => { layers: { '1': { name: 'bg' } } } // '1' is a string key"
246
+ },
247
+ {
248
+ "title": "Set via bracket notation",
249
+ "description": "Square-bracket indices become numeric keys. Useful when the path targets an array element.",
250
+ "code": "const obj = { layers: [{}, { name: 'old' }] }\nset(obj, 'layers[1].name', 'new')\n// => { layers: [{}, { name: 'new' }] }"
251
+ },
252
+ {
253
+ "title": "Set via key array (supports symbols)",
254
+ "description": "Pass an explicit PropertyKey[] to bypass parsing. Supports string, number, and symbol keys.",
255
+ "code": "const id = Symbol('id')\nset({}, ['user', id], 'alice')\n// => { user: { [id]: 'alice' } }"
241
256
  }
242
257
  ]
243
258
  }
@@ -44,7 +44,7 @@
44
44
  "native": "{ ...a, ...b } or Object.assign({}, a, b)",
45
45
  "since": "ES2015",
46
46
  "example": "const merged = { ...defaults, ...options }",
47
- "notes": "For deep merge, use deepMerge from helpers4"
47
+ "notes": "For deep merge, use mergeDeep from helpers4"
48
48
  }
49
49
  ]
50
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helpers4/object",
3
- "version": "2.0.3",
3
+ "version": "2.1.0",
4
4
  "description": "A set of helpers in TS/JS, compatible with tree-shaking, for object.",
5
5
  "author": "baxyz <baxy@etik.com>",
6
6
  "license": "LGPL-3.0",
@@ -27,9 +27,8 @@
27
27
  "keywords": [
28
28
  "helpers",
29
29
  "object",
30
+ "cloneDeep",
30
31
  "compact",
31
- "deepClone",
32
- "deepMerge",
33
32
  "diff",
34
33
  "equalsDeep",
35
34
  "equalsShallow",
@@ -39,6 +38,7 @@
39
38
  "isEmpty",
40
39
  "isNonEmpty",
41
40
  "map",
41
+ "mergeDeep",
42
42
  "omit",
43
43
  "pick",
44
44
  "removeUndefinedNull",