esi-cap 1.7.31 → 1.7.33
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/dist/index.js +1 -1
- package/dist/lib/_classes/index.js +1 -1
- package/dist/lib/_config/index.js +1 -1
- package/dist/lib/_interface/appender/index.js +1 -1
- package/dist/lib/_interface/file/index.js +1 -1
- package/dist/lib/_interface/formatter/index.js +1 -1
- package/dist/lib/_interface/index.js +1 -1
- package/dist/lib/_interface/layout/index.js +1 -1
- package/dist/lib/_interface/log/index.js +1 -1
- package/dist/lib/_interface/path/index.js +1 -1
- package/dist/lib/connect/index.js +1 -1
- package/dist/lib/impl/index.js +1 -1
- package/dist/lib/log/index.js +1 -1
- package/dist/lib/query/index.js +1 -1
- package/dist/lib/service/index.js +1 -1
- package/dist/lib/utils/index.js +1 -1
- package/dist/lib/utils/index.md +483 -0
- package/package.json +2 -2
- package/types/lib/utils/index.d.ts +407 -41
- package/types/lib/utils/index.d.ts.map +1 -1
- package/types/lib/utils/index.md +483 -0
|
@@ -1,39 +1,314 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Date utility class providing date validation helpers.
|
|
3
|
+
* @class
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export class date {
|
|
7
|
+
/**
|
|
8
|
+
* Validates whether a given string is a valid date.
|
|
9
|
+
* Attempts to parse the string into a Date object and checks for validity.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
* @static
|
|
13
|
+
* @param {string} sDate - The date string to validate (e.g., "2026-04-20", "April 20, 2026").
|
|
14
|
+
* @returns {Promise<boolean>} Resolves to `true` if the string represents a valid date, `false` otherwise.
|
|
15
|
+
* @example
|
|
16
|
+
* await date.isValid("2026-04-20"); // true
|
|
17
|
+
* await date.isValid("not-a-date"); // false
|
|
18
|
+
*/
|
|
19
|
+
public static isValid(sDate: string): Promise<boolean>;
|
|
3
20
|
}
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
21
|
+
/**
|
|
22
|
+
* XML utility class providing XML validation helpers.
|
|
23
|
+
* Uses the `xml2js` library for parsing and validation.
|
|
24
|
+
* @class
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export class xml {
|
|
28
|
+
/**
|
|
29
|
+
* Validates whether the given input is well-formed XML.
|
|
30
|
+
* Parses the XML string using xml2js and logs the result.
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
* @static
|
|
34
|
+
* @param {string|object} oXML - The XML string or object to validate.
|
|
35
|
+
* @returns {Promise<boolean>} Resolves to `true` if the XML is valid, `false` otherwise.
|
|
36
|
+
* @example
|
|
37
|
+
* await xml.isValid("<root><item>value</item></root>"); // true
|
|
38
|
+
* await xml.isValid("not xml"); // false
|
|
39
|
+
*/
|
|
40
|
+
public static isValid(oXML: object): Promise<boolean>;
|
|
7
41
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
42
|
+
/**
|
|
43
|
+
* JSON utility class providing a comprehensive set of JSON/object manipulation helpers.
|
|
44
|
+
* Includes validation, deep copy, recursive replacement, property access, deduplication,
|
|
45
|
+
* key ordering, projection, mapping, merging, flattening, and stripping of undefined values.
|
|
46
|
+
* @class
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
export class json {
|
|
50
|
+
/**
|
|
51
|
+
* Checks whether a given value is valid JSON by attempting to parse it.
|
|
52
|
+
*
|
|
53
|
+
* @public
|
|
54
|
+
* @static
|
|
55
|
+
* @param {string|object} oJson - The value to validate (typically a JSON string).
|
|
56
|
+
* @returns {boolean} `true` if the value can be parsed as JSON, `false` otherwise.
|
|
57
|
+
* @example
|
|
58
|
+
* json.isValid('{"key":"value"}'); // true
|
|
59
|
+
* json.isValid('not json'); // false
|
|
60
|
+
*/
|
|
61
|
+
public static isValid(oJson: object): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Creates a deep copy of a JSON-parseable value using `structuredClone`.
|
|
64
|
+
* If the value is not valid JSON, returns the original reference.
|
|
65
|
+
*
|
|
66
|
+
* @public
|
|
67
|
+
* @static
|
|
68
|
+
* @param {object} oJson - The object or value to copy.
|
|
69
|
+
* @returns {object} A deep clone if the input is valid JSON, otherwise the original value.
|
|
70
|
+
* @example
|
|
71
|
+
* const copy = json.copy(originalObject);
|
|
72
|
+
*/
|
|
73
|
+
public static copy(oJson: object): object;
|
|
74
|
+
/**
|
|
75
|
+
* Recursively replaces all occurrences of a string value within a nested JSON structure
|
|
76
|
+
* (objects and arrays). Optionally evaluates the replaced value as a property path on
|
|
77
|
+
* a provided evaluation context object.
|
|
78
|
+
*
|
|
79
|
+
* @public
|
|
80
|
+
* @static
|
|
81
|
+
* @param {object|Array} oJson - The JSON object or array to perform replacements in (mutated in place).
|
|
82
|
+
* @param {string} sOldValue - The substring to search for.
|
|
83
|
+
* @param {string} sNewValue - The substring to replace with.
|
|
84
|
+
* @param {object} [oEvaluate=undefined] - Optional context object; when provided, the replaced
|
|
85
|
+
* string is resolved as a property path via {@link json.getValue}.
|
|
86
|
+
* @returns {void} The input object is mutated in place.
|
|
87
|
+
* @example
|
|
88
|
+
* const data = { greeting: "Hello {{name}}" };
|
|
89
|
+
* json.replace(data, "{{name}}", "World");
|
|
90
|
+
* // data.greeting === "Hello World"
|
|
91
|
+
*/
|
|
92
|
+
public static replace(oJson: object, sOldValue: string, sNewValue: string, oEvaluate?: object): void;
|
|
93
|
+
/**
|
|
94
|
+
* Retrieves a deeply nested property value from an object using a dot-separated path.
|
|
95
|
+
*
|
|
96
|
+
* @public
|
|
97
|
+
* @static
|
|
98
|
+
* @param {object} oJson - The source object to traverse.
|
|
99
|
+
* @param {string} sPropertyPath - Dot-separated property path (e.g., "level1.level2.prop").
|
|
100
|
+
* @returns {*} The value at the specified path, or `undefined` if any segment is missing.
|
|
101
|
+
* @example
|
|
102
|
+
* json.getValue({ a: { b: 42 } }, "a.b"); // 42
|
|
103
|
+
*/
|
|
104
|
+
public static getValue(oJson: object, sPropertyPath: string): any;
|
|
105
|
+
/**
|
|
106
|
+
* Flattens a nested array and returns only unique elements (deep equality via JSON serialization).
|
|
107
|
+
*
|
|
108
|
+
* @public
|
|
109
|
+
* @static
|
|
110
|
+
* @param {any[]} oNestedArray - A potentially nested array.
|
|
111
|
+
* @returns {any[]} A flat array of unique elements, or the original input if not an array.
|
|
112
|
+
* @example
|
|
113
|
+
* json.unique([[1,2],[2,3]]); // [1, 2, 3]
|
|
114
|
+
*/
|
|
115
|
+
public static unique(oNestedArray: any[]): any[];
|
|
116
|
+
/**
|
|
117
|
+
* Reorders the keys of a JSON object according to a specified key order.
|
|
118
|
+
* Keys listed in `oKeyOrder` appear first; remaining keys follow in their original order.
|
|
119
|
+
*
|
|
120
|
+
* @public
|
|
121
|
+
* @static
|
|
122
|
+
* @param {object} oJson - The source object to reorder.
|
|
123
|
+
* @param {string[]} oKeyOrder - Desired key order (priority keys listed first).
|
|
124
|
+
* @returns {object} A new object with keys arranged in the specified order.
|
|
125
|
+
* @example
|
|
126
|
+
* json.order({ c: 3, a: 1, b: 2 }, ["a", "b"]); // { a: 1, b: 2, c: 3 }
|
|
127
|
+
*/
|
|
128
|
+
public static order(oJson: object, oKeyOrder: string[]): object;
|
|
129
|
+
/**
|
|
130
|
+
* Projects (filters) an object's properties to only include the specified column names.
|
|
131
|
+
* Optionally includes association-prefixed keys (e.g., `key_assoc`).
|
|
132
|
+
*
|
|
133
|
+
* @public
|
|
134
|
+
* @static
|
|
135
|
+
* @param {object} oJson - The source object.
|
|
136
|
+
* @param {string[]} oColumns - List of property names to include.
|
|
137
|
+
* @param {boolean} [bHasAssociattion=false] - When `true`, also includes keys where a column starts with `key_`.
|
|
138
|
+
* @returns {object} A new object containing only the projected properties.
|
|
139
|
+
* @example
|
|
140
|
+
* json.projection({ a: 1, b: 2, c: 3 }, ["a", "c"]); // { a: 1, c: 3 }
|
|
141
|
+
*/
|
|
142
|
+
public static projection(oJson: object, oColumns: string[], bHasAssociattion?: boolean): object;
|
|
143
|
+
/**
|
|
144
|
+
* Maps properties from a source object to a new object based on a mapping definition.
|
|
145
|
+
* Supports one-level and two-level dot-notation paths in the mapping values.
|
|
146
|
+
*
|
|
147
|
+
* @public
|
|
148
|
+
* @static
|
|
149
|
+
* @param {object} oJson - The source data object.
|
|
150
|
+
* @param {object} oMap - Mapping definition where keys are target property names and values
|
|
151
|
+
* are dot-separated source paths (e.g., `{ fullName: "user.name" }`).
|
|
152
|
+
* @returns {object} A new object with mapped properties.
|
|
153
|
+
* @example
|
|
154
|
+
* json.map({ user: { name: "John" } }, { fullName: "user.name" }); // { fullName: "John" }
|
|
155
|
+
*/
|
|
156
|
+
public static map(oJson: object, oMap: object): object;
|
|
157
|
+
/**
|
|
158
|
+
* Deep-merges two objects using Lodash's `_.merge`. Returns an empty object if either input is not an object.
|
|
159
|
+
*
|
|
160
|
+
* @public
|
|
161
|
+
* @static
|
|
162
|
+
* @param {object} oJson1 - The base object.
|
|
163
|
+
* @param {object} oJson2 - The object to merge into the base.
|
|
164
|
+
* @returns {object} A new deeply merged object.
|
|
165
|
+
* @example
|
|
166
|
+
* json.merge({ a: { x: 1 } }, { a: { y: 2 } }); // { a: { x: 1, y: 2 } }
|
|
167
|
+
*/
|
|
168
|
+
public static merge(oJson1: object, oJson2: object): object;
|
|
169
|
+
/**
|
|
170
|
+
* Flattens a single nested property of an object into the parent level.
|
|
171
|
+
* All keys from the nested property are spread into the resulting object.
|
|
172
|
+
*
|
|
173
|
+
* @public
|
|
174
|
+
* @static
|
|
175
|
+
* @param {object} oJson - The source object.
|
|
176
|
+
* @param {string} sFlattenedProperty - The property name whose contents should be flattened.
|
|
177
|
+
* @returns {object} A new object with the specified property's contents promoted to the top level.
|
|
178
|
+
* @example
|
|
179
|
+
* json.flat({ id: 1, details: { name: "A" } }, "details"); // { id: 1, name: "A" }
|
|
180
|
+
*/
|
|
181
|
+
public static flat(oJson: object, sFlattenedProperty: string): object;
|
|
182
|
+
/**
|
|
183
|
+
* Removes all properties with `undefined`, `null`, or empty string values from an object.
|
|
184
|
+
*
|
|
185
|
+
* @public
|
|
186
|
+
* @static
|
|
187
|
+
* @param {object} oSourceJson - The source object to strip.
|
|
188
|
+
* @returns {object} A new object containing only defined, non-null, non-empty properties.
|
|
189
|
+
* @example
|
|
190
|
+
* json.stripUndefined({ a: 1, b: null, c: "" }); // { a: 1 }
|
|
191
|
+
*/
|
|
192
|
+
public static stripUndefined(oSourceJson: object): object;
|
|
21
193
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
194
|
+
/**
|
|
195
|
+
* Array utility class providing operations for sorting, filtering, mapping, projecting,
|
|
196
|
+
* flattening, deduplication, grouping, and structural transformations on arrays.
|
|
197
|
+
* Many methods gracefully handle single-object inputs by delegating to the `json` class.
|
|
198
|
+
* @class
|
|
199
|
+
* @public
|
|
200
|
+
*/
|
|
201
|
+
export class array {
|
|
202
|
+
/**
|
|
203
|
+
* Appends one or more items to an array. Accepts both single values and arrays.
|
|
204
|
+
*
|
|
205
|
+
* @public
|
|
206
|
+
* @static
|
|
207
|
+
* @param {any[]} oArray - The target array to append to (mutated in place).
|
|
208
|
+
* @param {any|any[]} oItem - The item(s) to add.
|
|
209
|
+
* @returns {any[]} The modified array.
|
|
210
|
+
* @example
|
|
211
|
+
* array.add([1, 2], 3); // [1, 2, 3]
|
|
212
|
+
* array.add([1, 2], [3, 4]); // [1, 2, 3, 4]
|
|
213
|
+
*/
|
|
214
|
+
public static add(oArray: any[], oItem: any): any[];
|
|
215
|
+
/**
|
|
216
|
+
* Returns the first N elements from a (pre-sorted) array.
|
|
217
|
+
*
|
|
218
|
+
* @public
|
|
219
|
+
* @static
|
|
220
|
+
* @param {any[]} oSortedArray - The sorted array to slice.
|
|
221
|
+
* @param {number} iTop - The number of elements to return.
|
|
222
|
+
* @returns {any[]} The top N elements.
|
|
223
|
+
* @example
|
|
224
|
+
* array.topN([10, 20, 30, 40], 2); // [10, 20]
|
|
225
|
+
*/
|
|
226
|
+
public static topN(oSortedArray: any[], iTop: number): any[];
|
|
227
|
+
/**
|
|
228
|
+
* Flattens a specified nested property for each element in an array.
|
|
229
|
+
* If the input is a single object, delegates to {@link json.flat}.
|
|
230
|
+
*
|
|
231
|
+
* @public
|
|
232
|
+
* @static
|
|
233
|
+
* @param {any[]|object} oArray - The array (or single object) to flatten.
|
|
234
|
+
* @param {string} sFlattenedProperty - The property name whose contents should be promoted.
|
|
235
|
+
* @returns {any[]} An array of flattened objects.
|
|
236
|
+
*/
|
|
237
|
+
public static flat(oArray: any[], sFlattenedProperty: string): any[];
|
|
238
|
+
/**
|
|
239
|
+
* Returns a new array with duplicate elements removed (deep equality comparison via Lodash).
|
|
240
|
+
*
|
|
241
|
+
* @public
|
|
242
|
+
* @static
|
|
243
|
+
* @param {any[]} oArray - The array to deduplicate.
|
|
244
|
+
* @returns {any[]} A new array with only unique elements.
|
|
245
|
+
*/
|
|
246
|
+
public static unique(oArray: any[]): any[];
|
|
247
|
+
/**
|
|
248
|
+
* Reorders the keys of each object in an array according to the specified key order.
|
|
249
|
+
* If the input is a single object, delegates to {@link json.order}.
|
|
250
|
+
*
|
|
251
|
+
* @public
|
|
252
|
+
* @static
|
|
253
|
+
* @param {any[]|object} oArray - The array (or single object) to reorder.
|
|
254
|
+
* @param {string[]} oOrder - The desired key order.
|
|
255
|
+
* @returns {any[]} An array of objects with reordered keys.
|
|
256
|
+
*/
|
|
257
|
+
public static order(oArray: any[], oOrder: string[]): any[];
|
|
258
|
+
/**
|
|
259
|
+
* Projects each element in an array to only include specified columns.
|
|
260
|
+
* Works with both arrays and single objects.
|
|
261
|
+
*
|
|
262
|
+
* @public
|
|
263
|
+
* @static
|
|
264
|
+
* @param {any[]|object} oArray - The array or single object to project.
|
|
265
|
+
* @param {string[]} oColumns - The column names to keep.
|
|
266
|
+
* @param {boolean} [bHasAssociattion=false] - When true, includes association-prefixed keys.
|
|
267
|
+
* @returns {any[]} Projected results.
|
|
268
|
+
*/
|
|
269
|
+
public static projection(oArray: any[], oColumns: string[], bHasAssociattion?: boolean): any[];
|
|
270
|
+
/**
|
|
271
|
+
* Maps each element in an array using a property mapping definition.
|
|
272
|
+
* Works with both arrays and single objects.
|
|
273
|
+
*
|
|
274
|
+
* @public
|
|
275
|
+
* @static
|
|
276
|
+
* @param {any[]|object} oArray - The array or single object to map.
|
|
277
|
+
* @param {object} oMap - Mapping definition (see {@link json.map}).
|
|
278
|
+
* @returns {any[]} Mapped results.
|
|
279
|
+
*/
|
|
280
|
+
public static map(oArray: any[], oMap: any[]): any[];
|
|
281
|
+
/**
|
|
282
|
+
* Sorts an array of objects by one or more columns with optional type coercion.
|
|
283
|
+
* Supports `Date` and `parseFloat` coercion functions, and `asc`/`desc` sort directions.
|
|
284
|
+
* Uses Lodash `_.orderBy` internally.
|
|
285
|
+
*
|
|
286
|
+
* @public
|
|
287
|
+
* @static
|
|
288
|
+
* @param {any[]} oArray - The array to sort.
|
|
289
|
+
* @param {Array<{ref: string[], sort?: 'asc'|'desc', function?: 'Date'|'parseFloat'}>} oOrderBy -
|
|
290
|
+
* Sort specification. Each entry has `ref` (column path), optional `sort` direction, and
|
|
291
|
+
* optional `function` for type coercion.
|
|
292
|
+
* @returns {any[]} A new sorted array.
|
|
293
|
+
* @example
|
|
294
|
+
* array.sort(items, [{ ref: ["price"], sort: "desc", function: "parseFloat" }]);
|
|
295
|
+
*/
|
|
296
|
+
public static sort(oArray: any[], oOrderBy: object): any[];
|
|
297
|
+
/**
|
|
298
|
+
* Filters an array of objects based on a set of filter conditions.
|
|
299
|
+
* Each condition specifies a property name, comparison operator, and value.
|
|
300
|
+
*
|
|
301
|
+
* @public
|
|
302
|
+
* @static
|
|
303
|
+
* @typedef {Object} FilterCondition
|
|
304
|
+
* @property {string} name - The property name to filter by.
|
|
305
|
+
* @property {'=' | '!=' | '>' | '<' | '>=' | '<='} op - The comparison operator.
|
|
306
|
+
* @property {string | number | boolean} value - The value to compare against.
|
|
307
|
+
* @param {any[]} oArray - The array to filter.
|
|
308
|
+
* @param {FilterCondition[]} oFilterCondition - The filter conditions to apply.
|
|
309
|
+
* @returns {any[]} A filtered array containing only elements matching all conditions.
|
|
310
|
+
*/
|
|
311
|
+
public static filter(oArray: any[], oFilterCondition: {
|
|
37
312
|
/**
|
|
38
313
|
* - The property name to filter by.
|
|
39
314
|
*/
|
|
@@ -47,16 +322,107 @@ export namespace array {
|
|
|
47
322
|
*/
|
|
48
323
|
value: string | number | boolean;
|
|
49
324
|
}[]): any[];
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
325
|
+
/**
|
|
326
|
+
* Checks if an array contains a specific element (strict equality).
|
|
327
|
+
*
|
|
328
|
+
* @public
|
|
329
|
+
* @static
|
|
330
|
+
* @param {any[]} oArray - The array to search.
|
|
331
|
+
* @param {*} oElement - The element to look for.
|
|
332
|
+
* @returns {boolean} `true` if the element exists in the array.
|
|
333
|
+
*/
|
|
334
|
+
public static hasElement(oArray: any[], oElement: any): boolean;
|
|
335
|
+
/**
|
|
336
|
+
* Ensures the input is always returned as an array.
|
|
337
|
+
* Returns `[]` for `undefined`, wraps non-array values in an array, passes arrays through.
|
|
338
|
+
*
|
|
339
|
+
* @public
|
|
340
|
+
* @static
|
|
341
|
+
* @param {*} oArray - The value to coerce into an array.
|
|
342
|
+
* @returns {any[]} The input as an array.
|
|
343
|
+
* @example
|
|
344
|
+
* array.toArray("hello"); // ["hello"]
|
|
345
|
+
* array.toArray(undefined); // []
|
|
346
|
+
* array.toArray([1, 2]); // [1, 2]
|
|
347
|
+
*/
|
|
348
|
+
public static toArray(oArray: any): any[];
|
|
349
|
+
/**
|
|
350
|
+
* Unwraps a single-element array to its contained value.
|
|
351
|
+
* If the array has more than one element, returns the array as-is.
|
|
352
|
+
*
|
|
353
|
+
* @public
|
|
354
|
+
* @static
|
|
355
|
+
* @param {any[]} oArray - The array to potentially unwrap.
|
|
356
|
+
* @returns {*|any[]} The single element or the original array.
|
|
357
|
+
* @example
|
|
358
|
+
* array.toDisArray([42]); // 42
|
|
359
|
+
* array.toDisArray([1, 2]); // [1, 2]
|
|
360
|
+
*/
|
|
361
|
+
public static toDisArray(oArray: any[]): any | any[];
|
|
362
|
+
/**
|
|
363
|
+
* Creates a new array with a separator element inserted between every two elements.
|
|
364
|
+
*
|
|
365
|
+
* @public
|
|
366
|
+
* @static
|
|
367
|
+
* @param {any[]} oArray - The source array.
|
|
368
|
+
* @param {*} oElement - The separator element to interleave.
|
|
369
|
+
* @returns {any[]} A new array with the separator interleaved.
|
|
370
|
+
* @example
|
|
371
|
+
* array.toInterleavedArray(["a", "b", "c"], "-"); // ["a", ["-"], "b", ["-"], "c"]
|
|
372
|
+
*/
|
|
373
|
+
public static toInterleavedArray(oArray: any[], oElement: any): any[];
|
|
374
|
+
/**
|
|
375
|
+
* Extracts a single property value from each element, returning a flat array of those values.
|
|
376
|
+
*
|
|
377
|
+
* @public
|
|
378
|
+
* @static
|
|
379
|
+
* @param {any[]} oArray - The source array of objects.
|
|
380
|
+
* @param {string} sProjectionFieldName - The property name to extract.
|
|
381
|
+
* @returns {any[]} An array of the extracted property values.
|
|
382
|
+
* @example
|
|
383
|
+
* array.toArrayProjection([{ id: 1 }, { id: 2 }], "id"); // [1, 2]
|
|
384
|
+
*/
|
|
385
|
+
public static toArrayProjection(oArray: any[], sProjectionFieldName: string): any[];
|
|
386
|
+
/**
|
|
387
|
+
* Recursively searches for a property in a nested JSON Array.
|
|
388
|
+
*
|
|
389
|
+
* @public
|
|
390
|
+
* @static
|
|
391
|
+
* @param {any[]} oArray - The JSON Array to search.
|
|
392
|
+
* @param {string} sProjectionFieldName - The property name to look for.
|
|
393
|
+
* @returns {Array} An array of all matching values found.
|
|
394
|
+
*/
|
|
395
|
+
public static findProperty(oArray: any[], sProjectionFieldName: string): any[];
|
|
396
|
+
/**
|
|
397
|
+
* Groups array elements into an object keyed by the value of a specified property.
|
|
398
|
+
*
|
|
399
|
+
* @public
|
|
400
|
+
* @static
|
|
401
|
+
* @param {any[]} oArray - The array to group.
|
|
402
|
+
* @param {string} sPropertyName - The property name to group by.
|
|
403
|
+
* @returns {Object<string, any[]>} An object where keys are property values and values are arrays of matching elements.
|
|
404
|
+
* @example
|
|
405
|
+
* array.toGroupByPropertyName([{ type: "A", v: 1 }, { type: "A", v: 2 }, { type: "B", v: 3 }], "type");
|
|
406
|
+
* // { A: [{ type: "A", v: 1 }, { type: "A", v: 2 }], B: [{ type: "B", v: 3 }] }
|
|
407
|
+
*/
|
|
408
|
+
public static toGroupByPropertyName(oArray: any[], sPropertyName: string): {
|
|
57
409
|
[x: string]: any[];
|
|
58
410
|
};
|
|
59
|
-
|
|
411
|
+
/**
|
|
412
|
+
* Groups array elements by a composite key formed from multiple property values.
|
|
413
|
+
* Supports dot-notation and recursive deep property lookup.
|
|
414
|
+
* The composite key is formed by joining values with `##`.
|
|
415
|
+
*
|
|
416
|
+
* @public
|
|
417
|
+
* @static
|
|
418
|
+
* @param {any[]} oArray - The array to group.
|
|
419
|
+
* @param {string[]} oPropertyList - List of property names/paths to form the composite key.
|
|
420
|
+
* @returns {Object<string, any[]>} An object where keys are composite values and values are arrays of matching elements.
|
|
421
|
+
* @example
|
|
422
|
+
* array.toGroupByPropertyList(data, ["region", "category"]);
|
|
423
|
+
* // { "US##Electronics": [...], "EU##Clothing": [...] }
|
|
424
|
+
*/
|
|
425
|
+
public static toGroupByPropertyList(oArray: any[], oPropertyList: string[]): {
|
|
60
426
|
[x: string]: any[];
|
|
61
427
|
};
|
|
62
428
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../.types/lib/utils/index.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../.types/lib/utils/index.js"],"names":[],"mappings":"AAsBA;;;;GAIG;AACH;IACI;;;;;;;;;;;OAWG;IACH,6BAAgC,MAAM,GALzB,OAAO,CAAC,OAAO,CAAC,CAc5B;CACJ;AAED;;;;;GAKG;AACH;IACI;;;;;;;;;;;OAWG;IACH,4BAAgC,MAAM,GALzB,OAAO,CAAC,OAAO,CAAC,CAgB5B;CACJ;AAED;;;;;;GAMG;AACH;IACI;;;;;;;;;;OAUG;IACH,6BAA0B,MAAM,GALnB,OAAO,CAanB;IAED;;;;;;;;;;OAUG;IACH,0BAAuB,MAAM,GAJhB,MAAM,CAMlB;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,6BAA0B,MAAM,aAAsB,MAAM,aAA0B,MAAM,cAA0B,MAAM,GAN/G,IAAI,CA0BhB;IAED;;;;;;;;;;OAUG;IACH,8BAA2B,MAAM,iBAAsB,MAAM,GAJhD,GAAC,CAMb;IAED;;;;;;;;;OASG;IACH,mCAAyB,GAAG,EAAE,GAJjB,GAAG,EAAE,CAoBjB;IAED;;;;;;;;;;;OAWG;IACH,2BAAwB,MAAM,aAAsB,MAAM,EAAE,GAJ/C,MAAM,CAqBlB;IAED;;;;;;;;;;;;OAYG;IACH,gCAA6B,MAAM,YAAsB,MAAM,EAAE,+BAJpD,MAAM,CAMlB;IAED;;;;;;;;;;;;OAYG;IACH,yBAAsB,MAAM,QAAsB,MAAM,GAJ3C,MAAM,CAgBlB;IAED;;;;;;;;;;OAUG;IACH,4BAAwB,MAAM,UAAuB,MAAM,GAJ9C,MAAM,CAMlB;IAED;;;;;;;;;;;OAWG;IACH,0BAAuB,MAAM,sBAAsB,MAAM,GAJ5C,MAAM,CAalB;IAED;;;;;;;;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