@helpers4/object 2.0.0-alpha.2 → 2.0.0-alpha.22

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.
@@ -0,0 +1,6 @@
1
+ {
2
+ "category": "object",
3
+ "label": "Object",
4
+ "smallDescription": "Object manipulation utilities",
5
+ "description": "Utilities for working with objects including property removal, filtering, and object transformation"
6
+ }
@@ -0,0 +1,150 @@
1
+ {
2
+ "category": "object",
3
+ "functions": [
4
+ {
5
+ "name": "compact",
6
+ "examples": [
7
+ {
8
+ "title": "Remove falsy values from object",
9
+ "description": "Removes all entries with falsy values (false, null, undefined, 0, \"\", NaN).",
10
+ "code": "compact({ a: 1, b: null, c: '', d: 0, e: 'hello' })\n// => { a: 1, e: 'hello' }"
11
+ },
12
+ {
13
+ "title": "Clean up API response",
14
+ "description": "Useful to strip empty or missing fields before sending data.",
15
+ "code": "compact({ name: 'Alice', email: '', age: 0, role: 'admin' })\n// => { name: 'Alice', role: 'admin' }"
16
+ }
17
+ ]
18
+ },
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": "deepCompare",
31
+ "examples": [
32
+ {
33
+ "title": "Compare nested objects",
34
+ "description": "Deeply compares two objects, returning true when they are structurally equal.",
35
+ "code": "deepCompare({ a: { b: 1 } }, { a: { b: 1 } })\n// => true"
36
+ },
37
+ {
38
+ "title": "Detect deep differences",
39
+ "description": "Returns a detailed diff object when nested values differ.",
40
+ "code": "deepCompare({ a: { b: 1 } }, { a: { b: 2 } })\n// => { a: { b: false } }"
41
+ }
42
+ ]
43
+ },
44
+ {
45
+ "name": "deepMerge",
46
+ "examples": [
47
+ {
48
+ "title": "Merge two objects deeply",
49
+ "description": "Recursively merges source properties into the target object.",
50
+ "code": "deepMerge({ a: 1, b: { c: 2 } }, { b: { d: 3 }, e: 4 })\n// => { a: 1, b: { c: 2, d: 3 }, e: 4 }"
51
+ }
52
+ ]
53
+ },
54
+ {
55
+ "name": "get",
56
+ "examples": [
57
+ {
58
+ "title": "Access a nested property",
59
+ "description": "Uses a dot-notated path to retrieve a deeply nested value.",
60
+ "code": "get({ a: { b: { c: 42 } } }, 'a.b.c')\n// => 42"
61
+ },
62
+ {
63
+ "title": "Return default for missing path",
64
+ "description": "Returns the default value when the path does not exist.",
65
+ "code": "get({ a: 1 }, 'b.c', 'default')\n// => 'default'"
66
+ }
67
+ ]
68
+ },
69
+ {
70
+ "name": "omit",
71
+ "examples": [
72
+ {
73
+ "title": "Omit specific keys",
74
+ "description": "Creates a new object without the specified keys.",
75
+ "code": "omit({ a: 1, b: 2, c: 3 }, ['b'])\n// => { a: 1, c: 3 }"
76
+ },
77
+ {
78
+ "title": "Remove sensitive fields",
79
+ "description": "Useful to strip sensitive data before sending to client.",
80
+ "code": "const user = { id: 1, name: 'Alice', password: 'secret', token: 'abc123' };\nomit(user, ['password', 'token'])\n// => { id: 1, name: 'Alice' }"
81
+ }
82
+ ]
83
+ },
84
+ {
85
+ "name": "pick",
86
+ "examples": [
87
+ {
88
+ "title": "Pick specific keys",
89
+ "description": "Creates a new object with only the specified keys.",
90
+ "code": "pick({ a: 1, b: 2, c: 3 }, ['a', 'c'])\n// => { a: 1, c: 3 }"
91
+ },
92
+ {
93
+ "title": "Extract user fields",
94
+ "description": "Useful to select only the fields you need from an object.",
95
+ "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' }"
96
+ }
97
+ ]
98
+ },
99
+ {
100
+ "name": "removeUndefinedNull",
101
+ "examples": [
102
+ {
103
+ "title": "Strip null and undefined values",
104
+ "description": "Returns a shallow copy of the object without null or undefined properties.",
105
+ "code": "removeUndefinedNull({ a: 1, b: null, c: undefined, d: 'ok' })\n// => { a: 1, d: 'ok' }"
106
+ }
107
+ ]
108
+ },
109
+ {
110
+ "name": "safeJsonParse",
111
+ "examples": [
112
+ {
113
+ "title": "Parse valid JSON",
114
+ "description": "Returns the parsed value when the input is valid JSON.",
115
+ "code": "safeJsonParse<{ a: number }>('{\"a\":1}')\n// => { a: 1 }"
116
+ },
117
+ {
118
+ "title": "Return null on invalid input",
119
+ "description": "Returns null instead of throwing when JSON is malformed.",
120
+ "code": "safeJsonParse('invalid')\n// => null"
121
+ },
122
+ {
123
+ "title": "Use a fallback value",
124
+ "description": "Returns the provided fallback when parsing fails.",
125
+ "code": "safeJsonParse('invalid', [])\n// => []"
126
+ }
127
+ ]
128
+ },
129
+ {
130
+ "name": "set",
131
+ "examples": [
132
+ {
133
+ "title": "Set a nested property",
134
+ "description": "Creates intermediate objects as needed along the dot-notated path.",
135
+ "code": "set({}, 'a.b.c', 42)\n// => { a: { b: { c: 42 } } }"
136
+ }
137
+ ]
138
+ },
139
+ {
140
+ "name": "shallowEquals",
141
+ "examples": [
142
+ {
143
+ "title": "Compare two equal objects",
144
+ "description": "Uses JSON.stringify for a fast comparison.",
145
+ "code": "shallowEquals({ a: 1, b: 2 }, { a: 1, b: 2 })\n// => true"
146
+ }
147
+ ]
148
+ }
149
+ ]
150
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "category": "object",
3
+ "dependencies": []
4
+ }
@@ -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,55 @@
1
1
  {
2
2
  "name": "@helpers4/object",
3
- "version": "2.0.0-alpha.2",
3
+ "version": "2.0.0-alpha.22",
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
+ "./llms.txt": "./llms.txt",
25
+ "./package.json": "./package.json"
19
26
  },
20
27
  "keywords": [
21
28
  "helpers",
22
29
  "object",
23
- "get",
24
- "set",
30
+ "compact",
31
+ "deepClone",
32
+ "deepCompare",
25
33
  "deepMerge",
34
+ "get",
35
+ "omit",
36
+ "pick",
26
37
  "removeUndefinedNull",
27
- "deepClone"
38
+ "safeJsonParse",
39
+ "set",
40
+ "shallowEquals"
28
41
  ],
29
42
  "files": [
30
43
  "lib/index.js",
31
44
  "lib/index.d.ts",
32
45
  "lib/index.js.map",
46
+ "meta/",
47
+ "llms.txt",
33
48
  "LICENSE.md",
34
49
  "package.json",
35
50
  "README.md"
36
51
  ],
37
- "peerDependencies": {
38
- "radashi": "^12.4.0"
52
+ "engines": {
53
+ "node": ">=18.0.0"
39
54
  }
40
55
  }