@helpers4/object 2.0.0-alpha.2 → 2.0.0-alpha.21
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/LICENSE.md +150 -650
- package/README.md +16 -7
- package/lib/index.d.ts +185 -5
- package/lib/index.js +450 -75
- package/lib/index.js.map +1 -0
- package/llms.txt +513 -0
- package/meta/api.json +623 -0
- package/meta/category.json +6 -0
- package/meta/examples.json +130 -0
- package/meta/licenses.json +4 -0
- package/meta/native-alternatives.json +50 -0
- package/package.json +23 -9
package/meta/api.json
ADDED
|
@@ -0,0 +1,623 @@
|
|
|
1
|
+
{
|
|
2
|
+
"category": "object",
|
|
3
|
+
"version": "2.0.0-alpha.21",
|
|
4
|
+
"functions": [
|
|
5
|
+
{
|
|
6
|
+
"name": "compact",
|
|
7
|
+
"kind": "function",
|
|
8
|
+
"description": "Removes all entries with falsy values (`false`, `null`, `undefined`, `0`, `\"\"`, `NaN`) from an object.",
|
|
9
|
+
"since": "2.0.0",
|
|
10
|
+
"signatures": [
|
|
11
|
+
{
|
|
12
|
+
"signature": "compact<T extends Record<string, unknown>>(obj: T): Partial<T>",
|
|
13
|
+
"description": "Removes all entries with falsy values (`false`, `null`, `undefined`, `0`, `\"\"`, `NaN`) from an object.",
|
|
14
|
+
"params": [
|
|
15
|
+
{
|
|
16
|
+
"name": "obj",
|
|
17
|
+
"type": "T",
|
|
18
|
+
"description": "The source object"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"returns": {
|
|
22
|
+
"type": "Partial<T>",
|
|
23
|
+
"description": "A new object containing only entries with truthy values"
|
|
24
|
+
},
|
|
25
|
+
"typeParameters": [
|
|
26
|
+
{
|
|
27
|
+
"name": "T",
|
|
28
|
+
"constraint": "Record<string, unknown>"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"signature": "compact(obj: undefined): undefined",
|
|
34
|
+
"description": "Removes all entries with falsy values (`false`, `null`, `undefined`, `0`, `\"\"`, `NaN`) from an object.",
|
|
35
|
+
"params": [
|
|
36
|
+
{
|
|
37
|
+
"name": "obj",
|
|
38
|
+
"type": "undefined",
|
|
39
|
+
"description": "The source object"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"returns": {
|
|
43
|
+
"type": "undefined",
|
|
44
|
+
"description": "A new object containing only entries with truthy values"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"signature": "compact(obj: null): null",
|
|
49
|
+
"description": "Removes all entries with falsy values (`false`, `null`, `undefined`, `0`, `\"\"`, `NaN`) from an object.",
|
|
50
|
+
"params": [
|
|
51
|
+
{
|
|
52
|
+
"name": "obj",
|
|
53
|
+
"type": "null",
|
|
54
|
+
"description": "The source object"
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
"returns": {
|
|
58
|
+
"type": "null",
|
|
59
|
+
"description": "A new object containing only entries with truthy values"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
"examples": [
|
|
64
|
+
{
|
|
65
|
+
"title": "Remove falsy values from object",
|
|
66
|
+
"description": "Removes all entries with falsy values (false, null, undefined, 0, \"\", NaN).",
|
|
67
|
+
"code": "compact({ a: 1, b: null, c: '', d: 0, e: 'hello' })\n// => { a: 1, e: 'hello' }"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"title": "Clean up API response",
|
|
71
|
+
"description": "Useful to strip empty or missing fields before sending data.",
|
|
72
|
+
"code": "compact({ name: 'Alice', email: '', age: 0, role: 'admin' })\n// => { name: 'Alice', role: 'admin' }"
|
|
73
|
+
}
|
|
74
|
+
],
|
|
75
|
+
"sourceFile": "compact.ts"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"name": "deepClone",
|
|
79
|
+
"kind": "function",
|
|
80
|
+
"description": "Creates a deep copy of an object or array",
|
|
81
|
+
"since": "1.9.0",
|
|
82
|
+
"signatures": [
|
|
83
|
+
{
|
|
84
|
+
"signature": "deepClone<T>(obj: T): T",
|
|
85
|
+
"description": "Creates a deep copy of an object or array",
|
|
86
|
+
"params": [
|
|
87
|
+
{
|
|
88
|
+
"name": "obj",
|
|
89
|
+
"type": "T",
|
|
90
|
+
"description": "The object to clone"
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
"returns": {
|
|
94
|
+
"type": "T",
|
|
95
|
+
"description": "Deep cloned object"
|
|
96
|
+
},
|
|
97
|
+
"typeParameters": [
|
|
98
|
+
{
|
|
99
|
+
"name": "T"
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
"examples": [
|
|
105
|
+
{
|
|
106
|
+
"title": "Clone a nested object",
|
|
107
|
+
"description": "Creates a deep copy — modifying the clone does not affect the original.",
|
|
108
|
+
"code": "const original = { a: { b: 1 } };\nconst cloned = deepClone(original);\ncloned.a.b = 2;\n// original.a.b is still 1"
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
"sourceFile": "deepClone.ts"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"name": "deepCompare",
|
|
115
|
+
"kind": "function",
|
|
116
|
+
"description": "Deep comparison of two objects that returns detailed information about differences.",
|
|
117
|
+
"since": "2.0.0",
|
|
118
|
+
"signatures": [
|
|
119
|
+
{
|
|
120
|
+
"signature": "deepCompare(objA: object | null | undefined, objB: object | null | undefined): boolean | DeepCompareResult",
|
|
121
|
+
"description": "Deep comparison of two objects that returns detailed information about differences.",
|
|
122
|
+
"params": [
|
|
123
|
+
{
|
|
124
|
+
"name": "objA",
|
|
125
|
+
"type": "object | null | undefined",
|
|
126
|
+
"description": "First object to compare (can be object, undefined, or null)"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"name": "objB",
|
|
130
|
+
"type": "object | null | undefined",
|
|
131
|
+
"description": "Second object to compare (can be object, undefined, or null)"
|
|
132
|
+
}
|
|
133
|
+
],
|
|
134
|
+
"returns": {
|
|
135
|
+
"type": "boolean | DeepCompareResult",
|
|
136
|
+
"description": "`true` if objects are identical, `false` if incompatible types, or a `DeepCompareResult` object detailing differences"
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
],
|
|
140
|
+
"examples": [
|
|
141
|
+
{
|
|
142
|
+
"title": "Compare nested objects",
|
|
143
|
+
"description": "Deeply compares two objects, returning true when they are structurally equal.",
|
|
144
|
+
"code": "deepCompare({ a: { b: 1 } }, { a: { b: 1 } })\n// => true"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"title": "Detect deep differences",
|
|
148
|
+
"description": "Returns a detailed diff object when nested values differ.",
|
|
149
|
+
"code": "deepCompare({ a: { b: 1 } }, { a: { b: 2 } })\n// => { a: { b: false } }"
|
|
150
|
+
}
|
|
151
|
+
],
|
|
152
|
+
"sourceFile": "deepCompare.ts",
|
|
153
|
+
"relatedTypes": [
|
|
154
|
+
{
|
|
155
|
+
"name": "DeepCompareResult",
|
|
156
|
+
"description": "Result type for deep comparison when objects are not identical",
|
|
157
|
+
"typeDefinition": "interface DeepCompareResult {}"
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"name": "deepMerge",
|
|
163
|
+
"kind": "function",
|
|
164
|
+
"description": "Merges two or more objects deeply",
|
|
165
|
+
"since": "1.9.0",
|
|
166
|
+
"signatures": [
|
|
167
|
+
{
|
|
168
|
+
"signature": "deepMerge<T extends Record<string, unknown>>(target: T, sources: Record<string, unknown>[]): T",
|
|
169
|
+
"description": "Merges two or more objects deeply",
|
|
170
|
+
"params": [
|
|
171
|
+
{
|
|
172
|
+
"name": "target",
|
|
173
|
+
"type": "T",
|
|
174
|
+
"description": "The target object"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"name": "sources",
|
|
178
|
+
"type": "Record<string, unknown>[]",
|
|
179
|
+
"description": "The source objects to merge"
|
|
180
|
+
}
|
|
181
|
+
],
|
|
182
|
+
"returns": {
|
|
183
|
+
"type": "T",
|
|
184
|
+
"description": "The merged object"
|
|
185
|
+
},
|
|
186
|
+
"typeParameters": [
|
|
187
|
+
{
|
|
188
|
+
"name": "T",
|
|
189
|
+
"constraint": "Record<string, unknown>"
|
|
190
|
+
}
|
|
191
|
+
]
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"signature": "deepMerge(target: undefined, sources: Record<string, unknown>[]): undefined",
|
|
195
|
+
"description": "Merges two or more objects deeply",
|
|
196
|
+
"params": [
|
|
197
|
+
{
|
|
198
|
+
"name": "target",
|
|
199
|
+
"type": "undefined",
|
|
200
|
+
"description": "The target object"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"name": "sources",
|
|
204
|
+
"type": "Record<string, unknown>[]",
|
|
205
|
+
"description": "The source objects to merge"
|
|
206
|
+
}
|
|
207
|
+
],
|
|
208
|
+
"returns": {
|
|
209
|
+
"type": "undefined",
|
|
210
|
+
"description": "The merged object"
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
"signature": "deepMerge(target: null, sources: Record<string, unknown>[]): null",
|
|
215
|
+
"description": "Merges two or more objects deeply",
|
|
216
|
+
"params": [
|
|
217
|
+
{
|
|
218
|
+
"name": "target",
|
|
219
|
+
"type": "null",
|
|
220
|
+
"description": "The target object"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"name": "sources",
|
|
224
|
+
"type": "Record<string, unknown>[]",
|
|
225
|
+
"description": "The source objects to merge"
|
|
226
|
+
}
|
|
227
|
+
],
|
|
228
|
+
"returns": {
|
|
229
|
+
"type": "null",
|
|
230
|
+
"description": "The merged object"
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
],
|
|
234
|
+
"examples": [
|
|
235
|
+
{
|
|
236
|
+
"title": "Merge two objects deeply",
|
|
237
|
+
"description": "Recursively merges source properties into the target object.",
|
|
238
|
+
"code": "deepMerge({ a: 1, b: { c: 2 } }, { b: { d: 3 }, e: 4 })\n// => { a: 1, b: { c: 2, d: 3 }, e: 4 }"
|
|
239
|
+
}
|
|
240
|
+
],
|
|
241
|
+
"sourceFile": "deepMerge.ts"
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
"name": "get",
|
|
245
|
+
"kind": "function",
|
|
246
|
+
"description": "Gets a value from an object using a dot-notated path",
|
|
247
|
+
"since": "1.9.0",
|
|
248
|
+
"signatures": [
|
|
249
|
+
{
|
|
250
|
+
"signature": "get<T = unknown>(obj: unknown, path: string, defaultValue?: T): T | undefined",
|
|
251
|
+
"description": "Gets a value from an object using a dot-notated path",
|
|
252
|
+
"params": [
|
|
253
|
+
{
|
|
254
|
+
"name": "obj",
|
|
255
|
+
"type": "unknown",
|
|
256
|
+
"description": "The object to get value from"
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
"name": "path",
|
|
260
|
+
"type": "string",
|
|
261
|
+
"description": "The dot-notated path (e.g., 'a.b.c')"
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"name": "defaultValue",
|
|
265
|
+
"type": "T",
|
|
266
|
+
"description": "Default value if path doesn't exist",
|
|
267
|
+
"optional": true
|
|
268
|
+
}
|
|
269
|
+
],
|
|
270
|
+
"returns": {
|
|
271
|
+
"type": "T | undefined",
|
|
272
|
+
"description": "The value at the path or default value"
|
|
273
|
+
},
|
|
274
|
+
"typeParameters": [
|
|
275
|
+
{
|
|
276
|
+
"name": "T",
|
|
277
|
+
"default": "unknown"
|
|
278
|
+
}
|
|
279
|
+
]
|
|
280
|
+
}
|
|
281
|
+
],
|
|
282
|
+
"examples": [
|
|
283
|
+
{
|
|
284
|
+
"title": "Access a nested property",
|
|
285
|
+
"description": "Uses a dot-notated path to retrieve a deeply nested value.",
|
|
286
|
+
"code": "get({ a: { b: { c: 42 } } }, 'a.b.c')\n// => 42"
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
"title": "Return default for missing path",
|
|
290
|
+
"description": "Returns the default value when the path does not exist.",
|
|
291
|
+
"code": "get({ a: 1 }, 'b.c', 'default')\n// => 'default'"
|
|
292
|
+
}
|
|
293
|
+
],
|
|
294
|
+
"sourceFile": "get.ts"
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
"name": "omit",
|
|
298
|
+
"kind": "function",
|
|
299
|
+
"description": "Creates a new object without the specified keys.",
|
|
300
|
+
"since": "2.0.0",
|
|
301
|
+
"signatures": [
|
|
302
|
+
{
|
|
303
|
+
"signature": "omit<T extends Record<string, unknown>, K extends string | number | symbol>(obj: T, keys: readonly K[]): Omit<T, K>",
|
|
304
|
+
"description": "Creates a new object without the specified keys.",
|
|
305
|
+
"params": [
|
|
306
|
+
{
|
|
307
|
+
"name": "obj",
|
|
308
|
+
"type": "T",
|
|
309
|
+
"description": "The source object"
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
"name": "keys",
|
|
313
|
+
"type": "readonly K[]",
|
|
314
|
+
"description": "The keys to omit"
|
|
315
|
+
}
|
|
316
|
+
],
|
|
317
|
+
"returns": {
|
|
318
|
+
"type": "Omit<T, K>",
|
|
319
|
+
"description": "A new object without the omitted keys"
|
|
320
|
+
},
|
|
321
|
+
"typeParameters": [
|
|
322
|
+
{
|
|
323
|
+
"name": "T",
|
|
324
|
+
"constraint": "Record<string, unknown>"
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
"name": "K",
|
|
328
|
+
"constraint": "string | number | symbol"
|
|
329
|
+
}
|
|
330
|
+
]
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
"signature": "omit(obj: undefined, keys: readonly string[]): undefined",
|
|
334
|
+
"description": "Creates a new object without the specified keys.",
|
|
335
|
+
"params": [
|
|
336
|
+
{
|
|
337
|
+
"name": "obj",
|
|
338
|
+
"type": "undefined",
|
|
339
|
+
"description": "The source object"
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
"name": "keys",
|
|
343
|
+
"type": "readonly string[]",
|
|
344
|
+
"description": "The keys to omit"
|
|
345
|
+
}
|
|
346
|
+
],
|
|
347
|
+
"returns": {
|
|
348
|
+
"type": "undefined",
|
|
349
|
+
"description": "A new object without the omitted keys"
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
"signature": "omit(obj: null, keys: readonly string[]): null",
|
|
354
|
+
"description": "Creates a new object without the specified keys.",
|
|
355
|
+
"params": [
|
|
356
|
+
{
|
|
357
|
+
"name": "obj",
|
|
358
|
+
"type": "null",
|
|
359
|
+
"description": "The source object"
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
"name": "keys",
|
|
363
|
+
"type": "readonly string[]",
|
|
364
|
+
"description": "The keys to omit"
|
|
365
|
+
}
|
|
366
|
+
],
|
|
367
|
+
"returns": {
|
|
368
|
+
"type": "null",
|
|
369
|
+
"description": "A new object without the omitted keys"
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
],
|
|
373
|
+
"examples": [
|
|
374
|
+
{
|
|
375
|
+
"title": "Omit specific keys",
|
|
376
|
+
"description": "Creates a new object without the specified keys.",
|
|
377
|
+
"code": "omit({ a: 1, b: 2, c: 3 }, ['b'])\n// => { a: 1, c: 3 }"
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
"title": "Remove sensitive fields",
|
|
381
|
+
"description": "Useful to strip sensitive data before sending to client.",
|
|
382
|
+
"code": "const user = { id: 1, name: 'Alice', password: 'secret', token: 'abc123' };\nomit(user, ['password', 'token'])\n// => { id: 1, name: 'Alice' }"
|
|
383
|
+
}
|
|
384
|
+
],
|
|
385
|
+
"sourceFile": "omit.ts"
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
"name": "pick",
|
|
389
|
+
"kind": "function",
|
|
390
|
+
"description": "Creates a new object with only the specified keys.",
|
|
391
|
+
"since": "2.0.0",
|
|
392
|
+
"signatures": [
|
|
393
|
+
{
|
|
394
|
+
"signature": "pick<T extends Record<string, unknown>, K extends string | number | symbol>(obj: T, keys: readonly K[]): Pick<T, K>",
|
|
395
|
+
"description": "Creates a new object with only the specified keys.",
|
|
396
|
+
"params": [
|
|
397
|
+
{
|
|
398
|
+
"name": "obj",
|
|
399
|
+
"type": "T",
|
|
400
|
+
"description": "The source object"
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
"name": "keys",
|
|
404
|
+
"type": "readonly K[]",
|
|
405
|
+
"description": "The keys to pick"
|
|
406
|
+
}
|
|
407
|
+
],
|
|
408
|
+
"returns": {
|
|
409
|
+
"type": "Pick<T, K>",
|
|
410
|
+
"description": "A new object with only the picked keys"
|
|
411
|
+
},
|
|
412
|
+
"typeParameters": [
|
|
413
|
+
{
|
|
414
|
+
"name": "T",
|
|
415
|
+
"constraint": "Record<string, unknown>"
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
"name": "K",
|
|
419
|
+
"constraint": "string | number | symbol"
|
|
420
|
+
}
|
|
421
|
+
]
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
"signature": "pick(obj: undefined, keys: readonly string[]): undefined",
|
|
425
|
+
"description": "Creates a new object with only the specified keys.",
|
|
426
|
+
"params": [
|
|
427
|
+
{
|
|
428
|
+
"name": "obj",
|
|
429
|
+
"type": "undefined",
|
|
430
|
+
"description": "The source object"
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
"name": "keys",
|
|
434
|
+
"type": "readonly string[]",
|
|
435
|
+
"description": "The keys to pick"
|
|
436
|
+
}
|
|
437
|
+
],
|
|
438
|
+
"returns": {
|
|
439
|
+
"type": "undefined",
|
|
440
|
+
"description": "A new object with only the picked keys"
|
|
441
|
+
}
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
"signature": "pick(obj: null, keys: readonly string[]): null",
|
|
445
|
+
"description": "Creates a new object with only the specified keys.",
|
|
446
|
+
"params": [
|
|
447
|
+
{
|
|
448
|
+
"name": "obj",
|
|
449
|
+
"type": "null",
|
|
450
|
+
"description": "The source object"
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
"name": "keys",
|
|
454
|
+
"type": "readonly string[]",
|
|
455
|
+
"description": "The keys to pick"
|
|
456
|
+
}
|
|
457
|
+
],
|
|
458
|
+
"returns": {
|
|
459
|
+
"type": "null",
|
|
460
|
+
"description": "A new object with only the picked keys"
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
],
|
|
464
|
+
"examples": [
|
|
465
|
+
{
|
|
466
|
+
"title": "Pick specific keys",
|
|
467
|
+
"description": "Creates a new object with only the specified keys.",
|
|
468
|
+
"code": "pick({ a: 1, b: 2, c: 3 }, ['a', 'c'])\n// => { a: 1, c: 3 }"
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
"title": "Extract user fields",
|
|
472
|
+
"description": "Useful to select only the fields you need from an object.",
|
|
473
|
+
"code": "const user = { id: 1, name: 'Alice', email: 'alice@example.com', password: 'secret' };\npick(user, ['id', 'name', 'email'])\n// => { id: 1, name: 'Alice', email: 'alice@example.com' }"
|
|
474
|
+
}
|
|
475
|
+
],
|
|
476
|
+
"sourceFile": "pick.ts"
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
"name": "removeUndefinedNull",
|
|
480
|
+
"kind": "function",
|
|
481
|
+
"description": "Remove null and undefined values from an object.",
|
|
482
|
+
"since": "1.0.0",
|
|
483
|
+
"signatures": [
|
|
484
|
+
{
|
|
485
|
+
"signature": "removeUndefinedNull<T extends Record<string, string | number | boolean | null | undefined>>(obj: T): Partial<T>",
|
|
486
|
+
"description": "Remove null and undefined values from an object.",
|
|
487
|
+
"params": [
|
|
488
|
+
{
|
|
489
|
+
"name": "obj",
|
|
490
|
+
"type": "T",
|
|
491
|
+
"description": "an object"
|
|
492
|
+
}
|
|
493
|
+
],
|
|
494
|
+
"returns": {
|
|
495
|
+
"type": "Partial<T>",
|
|
496
|
+
"description": "A shallow copy of the object without null or undefined values"
|
|
497
|
+
},
|
|
498
|
+
"typeParameters": [
|
|
499
|
+
{
|
|
500
|
+
"name": "T",
|
|
501
|
+
"constraint": "Record<string, string | number | boolean | null | undefined>"
|
|
502
|
+
}
|
|
503
|
+
]
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
"signature": "removeUndefinedNull(obj: null): null",
|
|
507
|
+
"description": "Remove null and undefined values from an object.",
|
|
508
|
+
"params": [
|
|
509
|
+
{
|
|
510
|
+
"name": "obj",
|
|
511
|
+
"type": "null",
|
|
512
|
+
"description": "a null object"
|
|
513
|
+
}
|
|
514
|
+
],
|
|
515
|
+
"returns": {
|
|
516
|
+
"type": "null",
|
|
517
|
+
"description": "null"
|
|
518
|
+
}
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
"signature": "removeUndefinedNull(obj: undefined): undefined",
|
|
522
|
+
"description": "Remove null and undefined values from an object.",
|
|
523
|
+
"params": [
|
|
524
|
+
{
|
|
525
|
+
"name": "obj",
|
|
526
|
+
"type": "undefined",
|
|
527
|
+
"description": "an undefined object"
|
|
528
|
+
}
|
|
529
|
+
],
|
|
530
|
+
"returns": {
|
|
531
|
+
"type": "undefined",
|
|
532
|
+
"description": "undefined"
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
],
|
|
536
|
+
"examples": [
|
|
537
|
+
{
|
|
538
|
+
"title": "Strip null and undefined values",
|
|
539
|
+
"description": "Returns a shallow copy of the object without null or undefined properties.",
|
|
540
|
+
"code": "removeUndefinedNull({ a: 1, b: null, c: undefined, d: 'ok' })\n// => { a: 1, d: 'ok' }"
|
|
541
|
+
}
|
|
542
|
+
],
|
|
543
|
+
"sourceFile": "removeUndefinedNull.ts"
|
|
544
|
+
},
|
|
545
|
+
{
|
|
546
|
+
"name": "set",
|
|
547
|
+
"kind": "function",
|
|
548
|
+
"description": "Sets a value in an object using a dot-notated path",
|
|
549
|
+
"since": "1.9.0",
|
|
550
|
+
"signatures": [
|
|
551
|
+
{
|
|
552
|
+
"signature": "set(obj: Record<string, unknown>, path: string, value: unknown): Record<string, unknown>",
|
|
553
|
+
"description": "Sets a value in an object using a dot-notated path",
|
|
554
|
+
"params": [
|
|
555
|
+
{
|
|
556
|
+
"name": "obj",
|
|
557
|
+
"type": "Record<string, unknown>",
|
|
558
|
+
"description": "The object to set value in"
|
|
559
|
+
},
|
|
560
|
+
{
|
|
561
|
+
"name": "path",
|
|
562
|
+
"type": "string",
|
|
563
|
+
"description": "The dot-notated path (e.g., 'a.b.c')"
|
|
564
|
+
},
|
|
565
|
+
{
|
|
566
|
+
"name": "value",
|
|
567
|
+
"type": "unknown",
|
|
568
|
+
"description": "The value to set"
|
|
569
|
+
}
|
|
570
|
+
],
|
|
571
|
+
"returns": {
|
|
572
|
+
"type": "Record<string, unknown>",
|
|
573
|
+
"description": "The modified object"
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
],
|
|
577
|
+
"examples": [
|
|
578
|
+
{
|
|
579
|
+
"title": "Set a nested property",
|
|
580
|
+
"description": "Creates intermediate objects as needed along the dot-notated path.",
|
|
581
|
+
"code": "set({}, 'a.b.c', 42)\n// => { a: { b: { c: 42 } } }"
|
|
582
|
+
}
|
|
583
|
+
],
|
|
584
|
+
"sourceFile": "set.ts"
|
|
585
|
+
},
|
|
586
|
+
{
|
|
587
|
+
"name": "shallowEquals",
|
|
588
|
+
"kind": "function",
|
|
589
|
+
"description": "Quick comparison of two objects using JSON.stringify.\nThis is a fast but simple comparison that may not work for all edge cases.",
|
|
590
|
+
"since": "2.0.0",
|
|
591
|
+
"signatures": [
|
|
592
|
+
{
|
|
593
|
+
"signature": "shallowEquals(objA: unknown, objB: unknown): boolean",
|
|
594
|
+
"description": "Quick comparison of two objects using JSON.stringify.\nThis is a fast but simple comparison that may not work for all edge cases.",
|
|
595
|
+
"params": [
|
|
596
|
+
{
|
|
597
|
+
"name": "objA",
|
|
598
|
+
"type": "unknown",
|
|
599
|
+
"description": "First object to compare"
|
|
600
|
+
},
|
|
601
|
+
{
|
|
602
|
+
"name": "objB",
|
|
603
|
+
"type": "unknown",
|
|
604
|
+
"description": "Second object to compare"
|
|
605
|
+
}
|
|
606
|
+
],
|
|
607
|
+
"returns": {
|
|
608
|
+
"type": "boolean",
|
|
609
|
+
"description": "`true` if objects are identical according to JSON.stringify, `false` otherwise"
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
],
|
|
613
|
+
"examples": [
|
|
614
|
+
{
|
|
615
|
+
"title": "Compare two equal objects",
|
|
616
|
+
"description": "Uses JSON.stringify for a fast comparison.",
|
|
617
|
+
"code": "shallowEquals({ a: 1, b: 2 }, { a: 1, b: 2 })\n// => true"
|
|
618
|
+
}
|
|
619
|
+
],
|
|
620
|
+
"sourceFile": "shallowEquals.ts"
|
|
621
|
+
}
|
|
622
|
+
]
|
|
623
|
+
}
|