@xylabs/array 5.0.94 → 5.0.96

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 (2) hide show
  1. package/README.md +188 -146
  2. package/package.json +9 -12
package/README.md CHANGED
@@ -1,68 +1,82 @@
1
1
  # @xylabs/array
2
2
 
3
- [![logo][]](https://xylabs.com)
3
+ [![npm][npm-badge]][npm-link]
4
+ [![license][license-badge]][license-link]
4
5
 
5
- [![main-build][]][main-build-link]
6
- [![npm-badge][]][npm-link]
7
- [![npm-downloads-badge][]][npm-link]
8
- [![jsdelivr-badge][]][jsdelivr-link]
9
- [![npm-license-badge][]](LICENSE)
10
- [![codacy-badge][]][codacy-link]
11
- [![codeclimate-badge][]][codeclimate-link]
12
- [![snyk-badge][]][snyk-link]
13
- [![socket-badge][]][socket-link]
6
+ > Base functionality used throughout XY Labs TypeScript/JavaScript libraries
14
7
 
8
+ ## Install
15
9
 
16
- Base functionality used throughout XY Labs TypeScript/JavaScript libraries
10
+ Using npm:
17
11
 
12
+ ```sh
13
+ npm install {{name}}
14
+ ```
18
15
 
16
+ Using yarn:
19
17
 
20
- ## Reference
18
+ ```sh
19
+ yarn add {{name}}
20
+ ```
21
21
 
22
- **@xylabs/array**
22
+ Using pnpm:
23
23
 
24
- ***
24
+ ```sh
25
+ pnpm add {{name}}
26
+ ```
25
27
 
26
- ## Functions
28
+ Using bun:
27
29
 
28
- | Function | Description |
29
- | ------ | ------ |
30
- | [containsAll](#functions/containsAll) | Checks whether the source array contains every element in the target array. |
31
- | [distinct](#functions/distinct) | Array filter callback that removes duplicate values, with correct NaN handling. Use with `array.filter(distinct)`. |
32
- | [filterAs](#functions/filterAs) | Maps each element using the predicate and filters out nullish results. |
33
- | [filterAsync](#functions/filterAsync) | Returns the elements of an array that meet the condition specified in a callback function. |
34
- | [findAs](#functions/findAs) | Maps each element using the predicate and returns the first non-nullish result. |
35
- | [findLastAs](#functions/findLastAs) | Maps each element using the predicate and returns the last non-nullish result. |
36
- | [flatten](#functions/flatten) | Concatenates two values or arrays into a single flat array, filtering out nullish entries. |
37
- | [uniq](#functions/uniq) | Returns a new array with duplicate values removed. |
38
- | [uniqBy](#functions/uniqBy) | Returns a new array with duplicates removed, using a key function for comparison. |
30
+ ```sh
31
+ bun add {{name}}
32
+ ```
39
33
 
40
- ### functions
41
34
 
42
- ### <a id="containsAll"></a>containsAll
35
+ ## License
36
+
37
+ See the [LICENSE](LICENSE) file for license rights and limitations (LGPL-3.0-only).
38
+
39
+ ## Reference
40
+
41
+ ### packages
42
+
43
+ ### array
44
+
45
+ ### .temp-typedoc
46
+
47
+ ### functions
48
+
49
+ ### <a id="containsAll"></a>containsAll
43
50
 
44
51
  [**@xylabs/array**](#../README)
45
52
 
46
53
  ***
47
54
 
48
55
  ```ts
49
- function containsAll<T>(source: T[], target: T[]): boolean;
56
+ function containsAll<T>(source, target): boolean;
50
57
  ```
51
58
 
52
59
  Checks whether the source array contains every element in the target array.
53
60
 
54
61
  ## Type Parameters
55
62
 
56
- | Type Parameter |
57
- | ------ |
58
- | `T` |
63
+ ### T
64
+
65
+ `T`
59
66
 
60
67
  ## Parameters
61
68
 
62
- | Parameter | Type | Description |
63
- | ------ | ------ | ------ |
64
- | `source` | `T`[] | The array to search within |
65
- | `target` | `T`[] | The elements that must all be present |
69
+ ### source
70
+
71
+ `T`[]
72
+
73
+ The array to search within
74
+
75
+ ### target
76
+
77
+ `T`[]
78
+
79
+ The elements that must all be present
66
80
 
67
81
  ## Returns
68
82
 
@@ -70,7 +84,7 @@ Checks whether the source array contains every element in the target array.
70
84
 
71
85
  True if every target element exists in source
72
86
 
73
- ### <a id="distinct"></a>distinct
87
+ ### <a id="distinct"></a>distinct
74
88
 
75
89
  [**@xylabs/array**](#../README)
76
90
 
@@ -78,9 +92,9 @@ True if every target element exists in source
78
92
 
79
93
  ```ts
80
94
  function distinct<T>(
81
- value: T,
82
- index: number,
83
- array: T[]): boolean;
95
+ value,
96
+ index,
97
+ array): boolean;
84
98
  ```
85
99
 
86
100
  Array filter callback that removes duplicate values, with correct NaN handling.
@@ -88,47 +102,63 @@ Use with `array.filter(distinct)`.
88
102
 
89
103
  ## Type Parameters
90
104
 
91
- | Type Parameter |
92
- | ------ |
93
- | `T` |
105
+ ### T
106
+
107
+ `T`
94
108
 
95
109
  ## Parameters
96
110
 
97
- | Parameter | Type |
98
- | ------ | ------ |
99
- | `value` | `T` |
100
- | `index` | `number` |
101
- | `array` | `T`[] |
111
+ ### value
112
+
113
+ `T`
114
+
115
+ ### index
116
+
117
+ `number`
118
+
119
+ ### array
120
+
121
+ `T`[]
102
122
 
103
123
  ## Returns
104
124
 
105
125
  `boolean`
106
126
 
107
- ### <a id="filterAs"></a>filterAs
127
+ ### <a id="filterAs"></a>filterAs
108
128
 
109
129
  [**@xylabs/array**](#../README)
110
130
 
111
131
  ***
112
132
 
113
133
  ```ts
114
- function filterAs<In, Out>(x: In[], predicate: (a: In) => Out): NonNullable<Out>[];
134
+ function filterAs<In, Out>(x, predicate): NonNullable<Out>[];
115
135
  ```
116
136
 
117
137
  Maps each element using the predicate and filters out nullish results.
118
138
 
119
139
  ## Type Parameters
120
140
 
121
- | Type Parameter |
122
- | ------ |
123
- | `In` |
124
- | `Out` |
141
+ ### In
142
+
143
+ `In`
144
+
145
+ ### Out
146
+
147
+ `Out`
125
148
 
126
149
  ## Parameters
127
150
 
128
- | Parameter | Type | Description |
129
- | ------ | ------ | ------ |
130
- | `x` | `In`[] | The input array |
131
- | `predicate` | (`a`: `In`) => `Out` | Transform function applied to each element |
151
+ ### x
152
+
153
+ `In`[]
154
+
155
+ The input array
156
+
157
+ ### predicate
158
+
159
+ (`a`) => `Out`
160
+
161
+ Transform function applied to each element
132
162
 
133
163
  ## Returns
134
164
 
@@ -136,30 +166,37 @@ Maps each element using the predicate and filters out nullish results.
136
166
 
137
167
  Array of non-nullish transformed values
138
168
 
139
- ### <a id="filterAsync"></a>filterAsync
169
+ ### <a id="filterAsync"></a>filterAsync
140
170
 
141
171
  [**@xylabs/array**](#../README)
142
172
 
143
173
  ***
144
174
 
145
175
  ```ts
146
- function filterAsync<T>(array: T[], predicate: (value: T, index: number, array: T[]) => Promise<boolean>): Promise<T[]>;
176
+ function filterAsync<T>(array, predicate): Promise<T[]>;
147
177
  ```
148
178
 
149
179
  Returns the elements of an array that meet the condition specified in a callback function.
150
180
 
151
181
  ## Type Parameters
152
182
 
153
- | Type Parameter |
154
- | ------ |
155
- | `T` |
183
+ ### T
184
+
185
+ `T`
156
186
 
157
187
  ## Parameters
158
188
 
159
- | Parameter | Type | Description |
160
- | ------ | ------ | ------ |
161
- | `array` | `T`[] | The array to filter. |
162
- | `predicate` | (`value`: `T`, `index`: `number`, `array`: `T`[]) => `Promise`\<`boolean`\> | A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. |
189
+ ### array
190
+
191
+ `T`[]
192
+
193
+ The array to filter.
194
+
195
+ ### predicate
196
+
197
+ (`value`, `index`, `array`) => `Promise`\<`boolean`\>
198
+
199
+ A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.
163
200
 
164
201
  ## Returns
165
202
 
@@ -167,31 +204,41 @@ Returns the elements of an array that meet the condition specified in a callback
167
204
 
168
205
  The elements of an array that meet the condition specified in a callback function.
169
206
 
170
- ### <a id="findAs"></a>findAs
207
+ ### <a id="findAs"></a>findAs
171
208
 
172
209
  [**@xylabs/array**](#../README)
173
210
 
174
211
  ***
175
212
 
176
213
  ```ts
177
- function findAs<In, Out>(x: In[], predicate: (a: In) => Out): NonNullable<Out> | undefined;
214
+ function findAs<In, Out>(x, predicate): NonNullable<Out> | undefined;
178
215
  ```
179
216
 
180
217
  Maps each element using the predicate and returns the first non-nullish result.
181
218
 
182
219
  ## Type Parameters
183
220
 
184
- | Type Parameter |
185
- | ------ |
186
- | `In` |
187
- | `Out` |
221
+ ### In
222
+
223
+ `In`
224
+
225
+ ### Out
226
+
227
+ `Out`
188
228
 
189
229
  ## Parameters
190
230
 
191
- | Parameter | Type | Description |
192
- | ------ | ------ | ------ |
193
- | `x` | `In`[] | The input array |
194
- | `predicate` | (`a`: `In`) => `Out` | Transform function applied to each element |
231
+ ### x
232
+
233
+ `In`[]
234
+
235
+ The input array
236
+
237
+ ### predicate
238
+
239
+ (`a`) => `Out`
240
+
241
+ Transform function applied to each element
195
242
 
196
243
  ## Returns
197
244
 
@@ -199,31 +246,41 @@ Maps each element using the predicate and returns the first non-nullish result.
199
246
 
200
247
  The first non-nullish transformed value, or undefined
201
248
 
202
- ### <a id="findLastAs"></a>findLastAs
249
+ ### <a id="findLastAs"></a>findLastAs
203
250
 
204
251
  [**@xylabs/array**](#../README)
205
252
 
206
253
  ***
207
254
 
208
255
  ```ts
209
- function findLastAs<In, Out>(x: In[], predicate: (a: In) => Out): NonNullable<Out> | undefined;
256
+ function findLastAs<In, Out>(x, predicate): NonNullable<Out> | undefined;
210
257
  ```
211
258
 
212
259
  Maps each element using the predicate and returns the last non-nullish result.
213
260
 
214
261
  ## Type Parameters
215
262
 
216
- | Type Parameter |
217
- | ------ |
218
- | `In` |
219
- | `Out` |
263
+ ### In
264
+
265
+ `In`
266
+
267
+ ### Out
268
+
269
+ `Out`
220
270
 
221
271
  ## Parameters
222
272
 
223
- | Parameter | Type | Description |
224
- | ------ | ------ | ------ |
225
- | `x` | `In`[] | The input array |
226
- | `predicate` | (`a`: `In`) => `Out` | Transform function applied to each element |
273
+ ### x
274
+
275
+ `In`[]
276
+
277
+ The input array
278
+
279
+ ### predicate
280
+
281
+ (`a`) => `Out`
282
+
283
+ Transform function applied to each element
227
284
 
228
285
  ## Returns
229
286
 
@@ -231,30 +288,37 @@ Maps each element using the predicate and returns the last non-nullish result.
231
288
 
232
289
  The last non-nullish transformed value, or undefined
233
290
 
234
- ### <a id="flatten"></a>flatten
291
+ ### <a id="flatten"></a>flatten
235
292
 
236
293
  [**@xylabs/array**](#../README)
237
294
 
238
295
  ***
239
296
 
240
297
  ```ts
241
- function flatten<T>(a?: T | ConcatArray<T>, b?: T | ConcatArray<T>): T[];
298
+ function flatten<T>(a?, b?): T[];
242
299
  ```
243
300
 
244
301
  Concatenates two values or arrays into a single flat array, filtering out nullish entries.
245
302
 
246
303
  ## Type Parameters
247
304
 
248
- | Type Parameter |
249
- | ------ |
250
- | `T` |
305
+ ### T
306
+
307
+ `T`
251
308
 
252
309
  ## Parameters
253
310
 
254
- | Parameter | Type | Description |
255
- | ------ | ------ | ------ |
256
- | `a?` | `T` \| `ConcatArray`\<`T`\> | First value or array |
257
- | `b?` | `T` \| `ConcatArray`\<`T`\> | Second value or array |
311
+ ### a?
312
+
313
+ `T` \| `ConcatArray`\<`T`\>
314
+
315
+ First value or array
316
+
317
+ ### b?
318
+
319
+ `T` \| `ConcatArray`\<`T`\>
320
+
321
+ Second value or array
258
322
 
259
323
  ## Returns
260
324
 
@@ -262,29 +326,31 @@ Concatenates two values or arrays into a single flat array, filtering out nullis
262
326
 
263
327
  A flat array of non-nullish elements
264
328
 
265
- ### <a id="uniq"></a>uniq
329
+ ### <a id="uniq"></a>uniq
266
330
 
267
331
  [**@xylabs/array**](#../README)
268
332
 
269
333
  ***
270
334
 
271
335
  ```ts
272
- function uniq<T>(arr: T[]): T[];
336
+ function uniq<T>(arr): T[];
273
337
  ```
274
338
 
275
339
  Returns a new array with duplicate values removed.
276
340
 
277
341
  ## Type Parameters
278
342
 
279
- | Type Parameter |
280
- | ------ |
281
- | `T` |
343
+ ### T
344
+
345
+ `T`
282
346
 
283
347
  ## Parameters
284
348
 
285
- | Parameter | Type | Description |
286
- | ------ | ------ | ------ |
287
- | `arr` | `T`[] | The input array |
349
+ ### arr
350
+
351
+ `T`[]
352
+
353
+ The input array
288
354
 
289
355
  ## Returns
290
356
 
@@ -292,74 +358,50 @@ Returns a new array with duplicate values removed.
292
358
 
293
359
  A deduplicated array
294
360
 
295
- ### <a id="uniqBy"></a>uniqBy
361
+ ### <a id="uniqBy"></a>uniqBy
296
362
 
297
363
  [**@xylabs/array**](#../README)
298
364
 
299
365
  ***
300
366
 
301
367
  ```ts
302
- function uniqBy<T, I>(arr: T[], iteratee: (item: T) => I): T[];
368
+ function uniqBy<T, I>(arr, iteratee): T[];
303
369
  ```
304
370
 
305
371
  Returns a new array with duplicates removed, using a key function for comparison.
306
372
 
307
373
  ## Type Parameters
308
374
 
309
- | Type Parameter |
310
- | ------ |
311
- | `T` |
312
- | `I` |
375
+ ### T
313
376
 
314
- ## Parameters
377
+ `T`
315
378
 
316
- | Parameter | Type | Description |
317
- | ------ | ------ | ------ |
318
- | `arr` | `T`[] | The input array |
319
- | `iteratee` | (`item`: `T`) => `I` | Function that returns the key to compare by |
379
+ ### I
320
380
 
321
- ## Returns
381
+ `I`
322
382
 
323
- `T`[]
383
+ ## Parameters
324
384
 
325
- A deduplicated array keeping the first occurrence of each key
385
+ ### arr
326
386
 
387
+ `T`[]
327
388
 
328
- Part of [sdk-js](https://www.npmjs.com/package/@xyo-network/sdk-js)
389
+ The input array
329
390
 
330
- ## Maintainers
391
+ ### iteratee
331
392
 
332
- - [Arie Trouw](https://github.com/arietrouw) ([arietrouw.com](https://arietrouw.com))
333
- - [Matt Jones](https://github.com/jonesmac)
334
- - [Joel Carter](https://github.com/JoelBCarter)
335
- - [Jordan Trouw](https://github.com/jordantrouw)
393
+ (`item`) => `I`
336
394
 
337
- ## License
395
+ Function that returns the key to compare by
338
396
 
339
- > See the [LICENSE](LICENSE) file for license details
397
+ ## Returns
340
398
 
341
- ## Credits
399
+ `T`[]
342
400
 
343
- [Made with 🔥 and ❄️ by XYLabs](https://xylabs.com)
401
+ A deduplicated array keeping the first occurrence of each key
344
402
 
345
- [logo]: https://cdn.xy.company/img/brand/XYPersistentCompany_Logo_Icon_Colored.svg
346
403
 
347
- [main-build]: https://github.com/xylabs/sdk-js/actions/workflows/build.yml/badge.svg
348
- [main-build-link]: https://github.com/xylabs/sdk-js/actions/workflows/build.yml
349
404
  [npm-badge]: https://img.shields.io/npm/v/@xylabs/array.svg
350
405
  [npm-link]: https://www.npmjs.com/package/@xylabs/array
351
- [codacy-badge]: https://app.codacy.com/project/badge/Grade/c8e15e14f37741c18cfb47ac7245c698
352
- [codacy-link]: https://www.codacy.com/gh/xylabs/sdk-js/dashboard?utm_source=github.com&utm_medium=referral&utm_content=xylabs/sdk-js&utm_campaign=Badge_Grade
353
- [codeclimate-badge]: https://api.codeclimate.com/v1/badges/c5eb068f806f0b047ea7/maintainability
354
- [codeclimate-link]: https://codeclimate.com/github/xylabs/sdk-js/maintainability
355
- [snyk-badge]: https://snyk.io/test/github/xylabs/sdk-js/badge.svg?targetFile=package.json
356
- [snyk-link]: https://snyk.io/test/github/xylabs/sdk-js?targetFile=package.json
357
-
358
- [npm-downloads-badge]: https://img.shields.io/npm/dw/@xylabs/array
359
- [npm-license-badge]: https://img.shields.io/npm/l/@xylabs/array
360
-
361
- [jsdelivr-badge]: https://data.jsdelivr.com/v1/package/npm/@xylabs/array/badge
362
- [jsdelivr-link]: https://www.jsdelivr.com/package/npm/@xylabs/array
363
-
364
- [socket-badge]: https://socket.dev/api/badge/npm/package/@xylabs/array
365
- [socket-link]: https://socket.dev/npm/package/@xylabs/array
406
+ [license-badge]: https://img.shields.io/npm/l/@xylabs/array.svg
407
+ [license-link]: https://github.com/xylabs/sdk-js/blob/main/LICENSE
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xylabs/array",
3
- "version": "5.0.94",
3
+ "version": "5.0.96",
4
4
  "description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
5
5
  "keywords": [
6
6
  "xylabs",
@@ -28,12 +28,10 @@
28
28
  "exports": {
29
29
  ".": {
30
30
  "types": "./dist/neutral/index.d.ts",
31
- "import": "./dist/neutral/index.mjs",
32
31
  "default": "./dist/neutral/index.mjs"
33
32
  },
34
33
  "./package.json": "./package.json"
35
34
  },
36
- "types": "./dist/neutral/index.d.ts",
37
35
  "files": [
38
36
  "dist",
39
37
  "!**/*.bench.*",
@@ -42,19 +40,18 @@
42
40
  "README.md"
43
41
  ],
44
42
  "dependencies": {
45
- "@xylabs/exists": "~5.0.94"
43
+ "@xylabs/exists": "~5.0.96"
46
44
  },
47
45
  "devDependencies": {
48
- "@types/node": "^25.5.2",
49
- "@xylabs/ts-scripts-common": "~7.7.3",
50
- "@xylabs/ts-scripts-pnpm": "~7.7.3",
51
- "@xylabs/tsconfig": "~7.7.3",
52
- "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0",
46
+ "@types/node": "^25.6.0",
47
+ "@xylabs/toolchain": "~7.10.4",
48
+ "@xylabs/tsconfig": "~7.10.4",
53
49
  "esbuild": "^0.28.0",
54
50
  "typescript": "^5",
55
- "vite": "^6.0.0 || ^7.0.0 || ^8.0.0",
56
- "vitest": "^4.1.2",
57
- "@xylabs/vitest-extended": "~5.0.94"
51
+ "vite": "^8.0.8",
52
+ "vitest": "^4.1.4",
53
+ "@xylabs/vitest-matchers": "~5.0.96",
54
+ "@xylabs/vitest-extended": "~5.0.96"
58
55
  },
59
56
  "engines": {
60
57
  "node": ">=18"