@helpers4/object 2.0.0-alpha.1 → 2.0.0-alpha.10

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/meta/api.json ADDED
@@ -0,0 +1,331 @@
1
+ {
2
+ "category": "object",
3
+ "version": "2.0.0-alpha.10",
4
+ "functions": [
5
+ {
6
+ "name": "deepClone",
7
+ "kind": "function",
8
+ "description": "Creates a deep copy of an object or array",
9
+ "since": "1.9.0",
10
+ "signatures": [
11
+ {
12
+ "signature": "deepClone<T>(obj: T): T",
13
+ "description": "Creates a deep copy of an object or array",
14
+ "params": [
15
+ {
16
+ "name": "obj",
17
+ "type": "T",
18
+ "description": "The object to clone"
19
+ }
20
+ ],
21
+ "returns": {
22
+ "type": "T",
23
+ "description": "Deep cloned object"
24
+ },
25
+ "typeParameters": [
26
+ {
27
+ "name": "T"
28
+ }
29
+ ]
30
+ }
31
+ ],
32
+ "examples": [
33
+ {
34
+ "title": "Clone a nested object",
35
+ "description": "Creates a deep copy — modifying the clone does not affect the original.",
36
+ "code": "const original = { a: { b: 1 } };\nconst cloned = deepClone(original);\ncloned.a.b = 2;\n// original.a.b is still 1"
37
+ }
38
+ ],
39
+ "sourceFile": "deepClone.ts"
40
+ },
41
+ {
42
+ "name": "deepCompare",
43
+ "kind": "function",
44
+ "description": "Deep comparison of two objects that returns detailed information about differences.",
45
+ "since": "2.0.0",
46
+ "signatures": [
47
+ {
48
+ "signature": "deepCompare(objA: object | null | undefined, objB: object | null | undefined): boolean | DeepCompareResult",
49
+ "description": "Deep comparison of two objects that returns detailed information about differences.",
50
+ "params": [
51
+ {
52
+ "name": "objA",
53
+ "type": "object | null | undefined",
54
+ "description": "First object to compare (can be object, undefined, or null)"
55
+ },
56
+ {
57
+ "name": "objB",
58
+ "type": "object | null | undefined",
59
+ "description": "Second object to compare (can be object, undefined, or null)"
60
+ }
61
+ ],
62
+ "returns": {
63
+ "type": "boolean | DeepCompareResult",
64
+ "description": "`true` if objects are identical, `false` if incompatible types, or a `DeepCompareResult` object detailing differences"
65
+ }
66
+ }
67
+ ],
68
+ "examples": [
69
+ {
70
+ "title": "Compare nested objects",
71
+ "description": "Deeply compares two objects, returning true when they are structurally equal.",
72
+ "code": "deepCompare({ a: { b: 1 } }, { a: { b: 1 } })\n// => true"
73
+ },
74
+ {
75
+ "title": "Detect deep differences",
76
+ "description": "Returns a detailed diff object when nested values differ.",
77
+ "code": "deepCompare({ a: { b: 1 } }, { a: { b: 2 } })\n// => { a: { b: false } }"
78
+ }
79
+ ],
80
+ "sourceFile": "deepCompare.ts"
81
+ },
82
+ {
83
+ "name": "DeepCompareResult",
84
+ "kind": "interface",
85
+ "description": "Result type for deep comparison when objects are not identical",
86
+ "since": "2.0.0",
87
+ "signatures": [],
88
+ "examples": [],
89
+ "sourceFile": "deepCompare.ts"
90
+ },
91
+ {
92
+ "name": "deepMerge",
93
+ "kind": "function",
94
+ "description": "Merges two or more objects deeply",
95
+ "since": "1.9.0",
96
+ "signatures": [
97
+ {
98
+ "signature": "deepMerge<T extends Record<string, any>>(target: T, sources: Record<string, any>[]): T",
99
+ "description": "Merges two or more objects deeply",
100
+ "params": [
101
+ {
102
+ "name": "target",
103
+ "type": "T",
104
+ "description": "The target object"
105
+ },
106
+ {
107
+ "name": "sources",
108
+ "type": "Record<string, any>[]",
109
+ "description": "The source objects to merge"
110
+ }
111
+ ],
112
+ "returns": {
113
+ "type": "T",
114
+ "description": "The merged object"
115
+ },
116
+ "typeParameters": [
117
+ {
118
+ "name": "T",
119
+ "constraint": "Record<string, any>"
120
+ }
121
+ ]
122
+ }
123
+ ],
124
+ "examples": [
125
+ {
126
+ "title": "Merge two objects deeply",
127
+ "description": "Recursively merges source properties into the target object.",
128
+ "code": "deepMerge({ a: 1, b: { c: 2 } }, { b: { d: 3 }, e: 4 })\n// => { a: 1, b: { c: 2, d: 3 }, e: 4 }"
129
+ }
130
+ ],
131
+ "sourceFile": "deepMerge.ts"
132
+ },
133
+ {
134
+ "name": "get",
135
+ "kind": "function",
136
+ "description": "Gets a value from an object using a dot-notated path",
137
+ "since": "1.9.0",
138
+ "signatures": [
139
+ {
140
+ "signature": "get<T = any>(obj: any, path: string, defaultValue?: T): T | undefined",
141
+ "description": "Gets a value from an object using a dot-notated path",
142
+ "params": [
143
+ {
144
+ "name": "obj",
145
+ "type": "any",
146
+ "description": "The object to get value from"
147
+ },
148
+ {
149
+ "name": "path",
150
+ "type": "string",
151
+ "description": "The dot-notated path (e.g., 'a.b.c')"
152
+ },
153
+ {
154
+ "name": "defaultValue",
155
+ "type": "T",
156
+ "description": "Default value if path doesn't exist",
157
+ "optional": true
158
+ }
159
+ ],
160
+ "returns": {
161
+ "type": "T | undefined",
162
+ "description": "The value at the path or default value"
163
+ },
164
+ "typeParameters": [
165
+ {
166
+ "name": "T",
167
+ "default": "any"
168
+ }
169
+ ]
170
+ }
171
+ ],
172
+ "examples": [
173
+ {
174
+ "title": "Access a nested property",
175
+ "description": "Uses a dot-notated path to retrieve a deeply nested value.",
176
+ "code": "get({ a: { b: { c: 42 } } }, 'a.b.c')\n// => 42"
177
+ },
178
+ {
179
+ "title": "Return default for missing path",
180
+ "description": "Returns the default value when the path does not exist.",
181
+ "code": "get({ a: 1 }, 'b.c', 'default')\n// => 'default'"
182
+ }
183
+ ],
184
+ "sourceFile": "get.ts"
185
+ },
186
+ {
187
+ "name": "removeUndefinedNull",
188
+ "kind": "function",
189
+ "description": "Remove null and undefined values from an object.",
190
+ "since": "1.0.0",
191
+ "signatures": [
192
+ {
193
+ "signature": "removeUndefinedNull<T extends Record<string, string | number | boolean | null | undefined>>(obj: T): Partial<T>",
194
+ "description": "Remove null and undefined values from an object.",
195
+ "params": [
196
+ {
197
+ "name": "obj",
198
+ "type": "T",
199
+ "description": "an object"
200
+ }
201
+ ],
202
+ "returns": {
203
+ "type": "Partial<T>",
204
+ "description": "A shallow copy of the object without null or undefined values"
205
+ },
206
+ "typeParameters": [
207
+ {
208
+ "name": "T",
209
+ "constraint": "Record<string, string | number | boolean | null | undefined>"
210
+ }
211
+ ]
212
+ },
213
+ {
214
+ "signature": "removeUndefinedNull(obj: null): null",
215
+ "description": "Remove null and undefined values from an object.",
216
+ "params": [
217
+ {
218
+ "name": "obj",
219
+ "type": "null",
220
+ "description": "a null object"
221
+ }
222
+ ],
223
+ "returns": {
224
+ "type": "null",
225
+ "description": "null"
226
+ }
227
+ },
228
+ {
229
+ "signature": "removeUndefinedNull(obj: undefined): undefined",
230
+ "description": "Remove null and undefined values from an object.",
231
+ "params": [
232
+ {
233
+ "name": "obj",
234
+ "type": "undefined",
235
+ "description": "an undefined object"
236
+ }
237
+ ],
238
+ "returns": {
239
+ "type": "undefined",
240
+ "description": "undefined"
241
+ }
242
+ }
243
+ ],
244
+ "examples": [
245
+ {
246
+ "title": "Strip null and undefined values",
247
+ "description": "Returns a shallow copy of the object without null or undefined properties.",
248
+ "code": "removeUndefinedNull({ a: 1, b: null, c: undefined, d: 'ok' })\n// => { a: 1, d: 'ok' }"
249
+ }
250
+ ],
251
+ "sourceFile": "removeUndefinedNull.ts"
252
+ },
253
+ {
254
+ "name": "set",
255
+ "kind": "function",
256
+ "description": "Sets a value in an object using a dot-notated path",
257
+ "since": "1.9.0",
258
+ "signatures": [
259
+ {
260
+ "signature": "set(obj: Record<string, any>, path: string, value: any): Record<string, any>",
261
+ "description": "Sets a value in an object using a dot-notated path",
262
+ "params": [
263
+ {
264
+ "name": "obj",
265
+ "type": "Record<string, any>",
266
+ "description": "The object to set value in"
267
+ },
268
+ {
269
+ "name": "path",
270
+ "type": "string",
271
+ "description": "The dot-notated path (e.g., 'a.b.c')"
272
+ },
273
+ {
274
+ "name": "value",
275
+ "type": "any",
276
+ "description": "The value to set"
277
+ }
278
+ ],
279
+ "returns": {
280
+ "type": "Record<string, any>",
281
+ "description": "The modified object"
282
+ }
283
+ }
284
+ ],
285
+ "examples": [
286
+ {
287
+ "title": "Set a nested property",
288
+ "description": "Creates intermediate objects as needed along the dot-notated path.",
289
+ "code": "set({}, 'a.b.c', 42)\n// => { a: { b: { c: 42 } } }"
290
+ }
291
+ ],
292
+ "sourceFile": "set.ts"
293
+ },
294
+ {
295
+ "name": "shallowEquals",
296
+ "kind": "function",
297
+ "description": "Quick comparison of two objects using JSON.stringify.\nThis is a fast but simple comparison that may not work for all edge cases.",
298
+ "since": "2.0.0",
299
+ "signatures": [
300
+ {
301
+ "signature": "shallowEquals(objA: unknown, objB: unknown): boolean",
302
+ "description": "Quick comparison of two objects using JSON.stringify.\nThis is a fast but simple comparison that may not work for all edge cases.",
303
+ "params": [
304
+ {
305
+ "name": "objA",
306
+ "type": "unknown",
307
+ "description": "First object to compare"
308
+ },
309
+ {
310
+ "name": "objB",
311
+ "type": "unknown",
312
+ "description": "Second object to compare"
313
+ }
314
+ ],
315
+ "returns": {
316
+ "type": "boolean",
317
+ "description": "`true` if objects are identical according to JSON.stringify, `false` otherwise"
318
+ }
319
+ }
320
+ ],
321
+ "examples": [
322
+ {
323
+ "title": "Compare two equal objects",
324
+ "description": "Uses JSON.stringify for a fast comparison.",
325
+ "code": "shallowEquals({ a: 1, b: 2 }, { a: 1, b: 2 })\n// => true"
326
+ }
327
+ ],
328
+ "sourceFile": "shallowEquals.ts"
329
+ }
330
+ ]
331
+ }
@@ -0,0 +1,85 @@
1
+ {
2
+ "category": "object",
3
+ "functions": [
4
+ {
5
+ "name": "deepClone",
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 = deepClone(original);\ncloned.a.b = 2;\n// original.a.b is still 1"
11
+ }
12
+ ]
13
+ },
14
+ {
15
+ "name": "deepCompare",
16
+ "examples": [
17
+ {
18
+ "title": "Compare nested objects",
19
+ "description": "Deeply compares two objects, returning true when they are structurally equal.",
20
+ "code": "deepCompare({ a: { b: 1 } }, { a: { b: 1 } })\n// => true"
21
+ },
22
+ {
23
+ "title": "Detect deep differences",
24
+ "description": "Returns a detailed diff object when nested values differ.",
25
+ "code": "deepCompare({ a: { b: 1 } }, { a: { b: 2 } })\n// => { a: { b: false } }"
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
+ {
40
+ "name": "get",
41
+ "examples": [
42
+ {
43
+ "title": "Access a nested property",
44
+ "description": "Uses a dot-notated path to retrieve a deeply nested value.",
45
+ "code": "get({ a: { b: { c: 42 } } }, 'a.b.c')\n// => 42"
46
+ },
47
+ {
48
+ "title": "Return default for missing path",
49
+ "description": "Returns the default value when the path does not exist.",
50
+ "code": "get({ a: 1 }, 'b.c', 'default')\n// => 'default'"
51
+ }
52
+ ]
53
+ },
54
+ {
55
+ "name": "removeUndefinedNull",
56
+ "examples": [
57
+ {
58
+ "title": "Strip null and undefined values",
59
+ "description": "Returns a shallow copy of the object without null or undefined properties.",
60
+ "code": "removeUndefinedNull({ a: 1, b: null, c: undefined, d: 'ok' })\n// => { a: 1, d: 'ok' }"
61
+ }
62
+ ]
63
+ },
64
+ {
65
+ "name": "set",
66
+ "examples": [
67
+ {
68
+ "title": "Set a nested property",
69
+ "description": "Creates intermediate objects as needed along the dot-notated path.",
70
+ "code": "set({}, 'a.b.c', 42)\n// => { a: { b: { c: 42 } } }"
71
+ }
72
+ ]
73
+ },
74
+ {
75
+ "name": "shallowEquals",
76
+ "examples": [
77
+ {
78
+ "title": "Compare two equal objects",
79
+ "description": "Uses JSON.stringify for a fast comparison.",
80
+ "code": "shallowEquals({ a: 1, b: 2 }, { a: 1, b: 2 })\n// => true"
81
+ }
82
+ ]
83
+ }
84
+ ]
85
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "category": "object",
3
+ "dependencies": [
4
+ {
5
+ "name": "radashi",
6
+ "license": "MIT",
7
+ "homepage": "https://radashi.js.org",
8
+ "repository": "https://github.com/radashi-org/radashi"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,50 @@
1
+ {
2
+ "category": "object",
3
+ "functions": [
4
+ {
5
+ "name": "keys / values",
6
+ "libraries": [
7
+ "lodash",
8
+ "radashi",
9
+ "ramda"
10
+ ],
11
+ "native": "Object.keys() / Object.values()",
12
+ "since": "ES2017",
13
+ "example": "Object.keys(obj)\nObject.values(obj)",
14
+ "notes": "TypeScript types keys as string[]"
15
+ },
16
+ {
17
+ "name": "toPairs / fromPairs",
18
+ "libraries": [
19
+ "lodash",
20
+ "ramda"
21
+ ],
22
+ "native": "Object.entries() / Object.fromEntries()",
23
+ "since": "ES2019",
24
+ "example": "Object.entries(obj)\nObject.fromEntries(entries)"
25
+ },
26
+ {
27
+ "name": "has",
28
+ "libraries": [
29
+ "lodash",
30
+ "ramda"
31
+ ],
32
+ "native": "Object.hasOwn(obj, key)",
33
+ "since": "ES2022",
34
+ "example": "Object.hasOwn(obj, 'key')",
35
+ "notes": "Replaces obj.hasOwnProperty(key)"
36
+ },
37
+ {
38
+ "name": "merge (shallow)",
39
+ "libraries": [
40
+ "lodash",
41
+ "radashi",
42
+ "ramda"
43
+ ],
44
+ "native": "{ ...a, ...b } or Object.assign({}, a, b)",
45
+ "since": "ES2015",
46
+ "example": "const merged = { ...defaults, ...options }",
47
+ "notes": "For deep merge, use deepMerge from helpers4"
48
+ }
49
+ ]
50
+ }
package/package.json CHANGED
@@ -1,40 +1,52 @@
1
1
  {
2
2
  "name": "@helpers4/object",
3
- "version": "2.0.0-alpha.1",
3
+ "version": "2.0.0-alpha.10",
4
4
  "description": "A set of helpers in TS/JS, compatible with tree-shaking, for object.",
5
5
  "author": "baxyz <baxy@etik.com>",
6
- "license": "AGPL-3.0",
6
+ "license": "LGPL-3.0",
7
+ "homepage": "https://helpers4.dev/typescript/categories/object/",
7
8
  "repository": {
8
9
  "type": "git",
9
- "url": "git+https://github.com/helpers4/helpers4.git"
10
+ "url": "git+https://github.com/helpers4/typescript.git"
10
11
  },
11
12
  "type": "module",
13
+ "sideEffects": false,
12
14
  "main": "lib/index.js",
13
15
  "types": "lib/index.d.ts",
14
16
  "exports": {
15
17
  ".": {
16
18
  "types": "./lib/index.d.ts",
17
19
  "import": "./lib/index.js"
18
- }
20
+ },
21
+ "./meta/api.json": "./meta/api.json",
22
+ "./meta/examples.json": "./meta/examples.json",
23
+ "./meta/licenses.json": "./meta/licenses.json",
24
+ "./package.json": "./package.json"
19
25
  },
20
26
  "keywords": [
21
27
  "helpers",
22
28
  "object",
29
+ "deepClone",
30
+ "deepCompare",
23
31
  "deepMerge",
24
32
  "get",
25
- "deepClone",
33
+ "removeUndefinedNull",
26
34
  "set",
27
- "removeUndefinedNull"
35
+ "shallowEquals"
28
36
  ],
29
37
  "files": [
30
38
  "lib/index.js",
31
39
  "lib/index.d.ts",
32
40
  "lib/index.js.map",
41
+ "meta/",
33
42
  "LICENSE.md",
34
43
  "package.json",
35
44
  "README.md"
36
45
  ],
46
+ "engines": {
47
+ "node": ">=18.0.0"
48
+ },
37
49
  "peerDependencies": {
38
- "radashi": "^12.4.0"
50
+ "radashi": "^12.7.2"
39
51
  }
40
52
  }