@socketsecurity/lib 4.4.0 → 5.0.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.
Files changed (47) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/README.md +1 -1
  3. package/dist/constants/node.js +1 -1
  4. package/dist/{package-default-node-range.js → constants/package-default-node-range.js} +1 -1
  5. package/dist/constants/packages.js +3 -3
  6. package/dist/{dlx-binary.d.ts → dlx/binary.d.ts} +2 -2
  7. package/dist/{dlx-binary.js → dlx/binary.js} +17 -17
  8. package/dist/dlx/cache.d.ts +25 -0
  9. package/dist/dlx/cache.js +32 -0
  10. package/dist/dlx/dir.d.ts +24 -0
  11. package/dist/dlx/dir.js +79 -0
  12. package/dist/{dlx-manifest.js → dlx/manifest.js} +7 -7
  13. package/dist/{dlx-package.d.ts → dlx/package.d.ts} +2 -2
  14. package/dist/{dlx-package.js → dlx/package.js} +16 -16
  15. package/dist/dlx/packages.d.ts +24 -0
  16. package/dist/dlx/packages.js +125 -0
  17. package/dist/dlx/paths.d.ts +31 -0
  18. package/dist/dlx/paths.js +75 -0
  19. package/dist/fs.d.ts +34 -22
  20. package/dist/fs.js +3 -3
  21. package/dist/http-request.d.ts +46 -0
  22. package/dist/http-request.js +18 -1
  23. package/dist/json/edit.d.ts +16 -0
  24. package/dist/json/edit.js +248 -0
  25. package/dist/json/format.d.ts +140 -0
  26. package/dist/json/format.js +121 -0
  27. package/dist/json/parse.d.ts +76 -0
  28. package/dist/{json.js → json/parse.js} +4 -4
  29. package/dist/json/types.d.ts +229 -0
  30. package/dist/json/types.js +17 -0
  31. package/dist/packages/{editable.js → edit.js} +18 -32
  32. package/dist/packages/operations.js +3 -3
  33. package/dist/packages.d.ts +2 -2
  34. package/dist/packages.js +5 -5
  35. package/package.json +62 -37
  36. package/dist/dlx.d.ts +0 -104
  37. package/dist/dlx.js +0 -220
  38. package/dist/json.d.ts +0 -196
  39. /package/dist/{lifecycle-script-names.d.ts → constants/lifecycle-script-names.d.ts} +0 -0
  40. /package/dist/{lifecycle-script-names.js → constants/lifecycle-script-names.js} +0 -0
  41. /package/dist/{maintained-node-versions.d.ts → constants/maintained-node-versions.d.ts} +0 -0
  42. /package/dist/{maintained-node-versions.js → constants/maintained-node-versions.js} +0 -0
  43. /package/dist/{package-default-node-range.d.ts → constants/package-default-node-range.d.ts} +0 -0
  44. /package/dist/{package-default-socket-categories.d.ts → constants/package-default-socket-categories.d.ts} +0 -0
  45. /package/dist/{package-default-socket-categories.js → constants/package-default-socket-categories.js} +0 -0
  46. /package/dist/{dlx-manifest.d.ts → dlx/manifest.d.ts} +0 -0
  47. /package/dist/packages/{editable.d.ts → edit.d.ts} +0 -0
package/dist/json.d.ts DELETED
@@ -1,196 +0,0 @@
1
- /**
2
- * JSON primitive types: `null`, `boolean`, `number`, or `string`.
3
- *
4
- * @example
5
- * ```ts
6
- * const primitives: JsonPrimitive[] = [null, true, 42, 'hello']
7
- * ```
8
- */
9
- export type JsonPrimitive = null | boolean | number | string;
10
- /**
11
- * Any valid JSON value: primitive, object, or array.
12
- *
13
- * @example
14
- * ```ts
15
- * const values: JsonValue[] = [
16
- * null,
17
- * true,
18
- * 42,
19
- * 'hello',
20
- * { key: 'value' },
21
- * [1, 2, 3]
22
- * ]
23
- * ```
24
- */
25
- export type JsonValue = JsonPrimitive | JsonObject | JsonArray;
26
- /**
27
- * A JSON object with string keys and JSON values.
28
- *
29
- * @example
30
- * ```ts
31
- * const obj: JsonObject = {
32
- * name: 'example',
33
- * count: 42,
34
- * active: true,
35
- * nested: { key: 'value' }
36
- * }
37
- * ```
38
- */
39
- export interface JsonObject {
40
- [key: string]: JsonValue;
41
- }
42
- /**
43
- * A JSON array containing JSON values.
44
- *
45
- * @example
46
- * ```ts
47
- * const arr: JsonArray = [1, 'two', { three: 3 }, [4, 5]]
48
- * ```
49
- */
50
- export interface JsonArray extends Array<JsonValue> {
51
- }
52
- /**
53
- * Reviver function for transforming parsed JSON values.
54
- * Called for each key-value pair during parsing.
55
- *
56
- * @param key - The object key or array index being parsed
57
- * @param value - The parsed value
58
- * @returns The transformed value (or original if no transform needed)
59
- *
60
- * @example
61
- * ```ts
62
- * // Convert date strings to Date objects
63
- * const reviver: JsonReviver = (key, value) => {
64
- * if (typeof value === 'string' && /^\d{4}-\d{2}-\d{2}/.test(value)) {
65
- * return new Date(value)
66
- * }
67
- * return value
68
- * }
69
- * ```
70
- */
71
- export type JsonReviver = (key: string, value: unknown) => unknown;
72
- /**
73
- * Options for JSON parsing operations.
74
- */
75
- export interface JsonParseOptions {
76
- /**
77
- * Optional filepath for improved error messages.
78
- * When provided, errors will be prefixed with the filepath.
79
- *
80
- * @example
81
- * ```ts
82
- * // Error message will be: "config.json: Unexpected token } in JSON"
83
- * jsonParse('invalid', { filepath: 'config.json' })
84
- * ```
85
- */
86
- filepath?: string | undefined;
87
- /**
88
- * Optional reviver function to transform parsed values.
89
- * Called for each key-value pair during parsing.
90
- *
91
- * @example
92
- * ```ts
93
- * // Convert ISO date strings to Date objects
94
- * const options = {
95
- * reviver: (key, value) => {
96
- * if (typeof value === 'string' && /^\d{4}-\d{2}-\d{2}/.test(value)) {
97
- * return new Date(value)
98
- * }
99
- * return value
100
- * }
101
- * }
102
- * ```
103
- */
104
- reviver?: JsonReviver | undefined;
105
- /**
106
- * Whether to throw on parse errors.
107
- * When `false`, returns `undefined` instead of throwing.
108
- *
109
- * @default true
110
- *
111
- * @example
112
- * ```ts
113
- * // Throws error
114
- * jsonParse('invalid', { throws: true })
115
- *
116
- * // Returns undefined
117
- * const result = jsonParse('invalid', { throws: false })
118
- * ```
119
- */
120
- throws?: boolean | undefined;
121
- }
122
- /**
123
- * Check if a value is a JSON primitive type.
124
- * JSON primitives are: `null`, `boolean`, `number`, or `string`.
125
- *
126
- * @param value - Value to check
127
- * @returns `true` if value is a JSON primitive, `false` otherwise
128
- *
129
- * @example
130
- * ```ts
131
- * isJsonPrimitive(null) // => true
132
- * isJsonPrimitive(true) // => true
133
- * isJsonPrimitive(42) // => true
134
- * isJsonPrimitive('hello') // => true
135
- * isJsonPrimitive({}) // => false
136
- * isJsonPrimitive([]) // => false
137
- * isJsonPrimitive(undefined) // => false
138
- * ```
139
- */
140
- /*@__NO_SIDE_EFFECTS__*/
141
- export declare function isJsonPrimitive(value: unknown): value is JsonPrimitive;
142
- /**
143
- * Parse JSON content with automatic Buffer handling and BOM stripping.
144
- * Provides safer JSON parsing with helpful error messages and optional error suppression.
145
- *
146
- * Features:
147
- * - Automatic UTF-8 Buffer conversion
148
- * - BOM (Byte Order Mark) stripping for cross-platform compatibility
149
- * - Enhanced error messages with filepath context
150
- * - Optional error suppression (returns `undefined` instead of throwing)
151
- * - Optional reviver for transforming parsed values
152
- *
153
- * @param content - JSON string or Buffer to parse
154
- * @param options - Optional parsing configuration
155
- * @returns Parsed JSON value, or `undefined` if parsing fails and `throws` is `false`
156
- *
157
- * @throws {SyntaxError} When JSON is invalid and `throws` is `true` (default)
158
- *
159
- * @example
160
- * ```ts
161
- * // Basic usage
162
- * const data = jsonParse('{"name":"example"}')
163
- * console.log(data.name) // => 'example'
164
- *
165
- * // Parse Buffer with UTF-8 BOM
166
- * const buffer = Buffer.from('\uFEFF{"value":42}')
167
- * const data = jsonParse(buffer)
168
- * console.log(data.value) // => 42
169
- *
170
- * // Enhanced error messages with filepath
171
- * try {
172
- * jsonParse('invalid', { filepath: 'config.json' })
173
- * } catch (err) {
174
- * console.error(err.message)
175
- * // => "config.json: Unexpected token i in JSON at position 0"
176
- * }
177
- *
178
- * // Suppress errors
179
- * const result = jsonParse('invalid', { throws: false })
180
- * console.log(result) // => undefined
181
- *
182
- * // Transform values with reviver
183
- * const json = '{"created":"2024-01-15T10:30:00Z"}'
184
- * const data = jsonParse(json, {
185
- * reviver: (key, value) => {
186
- * if (key === 'created' && typeof value === 'string') {
187
- * return new Date(value)
188
- * }
189
- * return value
190
- * }
191
- * })
192
- * console.log(data.created instanceof Date) // => true
193
- * ```
194
- */
195
- /*@__NO_SIDE_EFFECTS__*/
196
- export declare function jsonParse(content: string | Buffer, options?: JsonParseOptions | undefined): JsonValue | undefined;
File without changes
File without changes