@xylabs/array 5.0.80 → 5.0.82

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/README.md CHANGED
@@ -181,7 +181,7 @@ The elements of an array that meet the condition specified in a callback functio
181
181
  ***
182
182
 
183
183
  ```ts
184
- function findAs<In, Out>(x, predicate): undefined | NonNullable<Out>;
184
+ function findAs<In, Out>(x, predicate): NonNullable<Out> | undefined;
185
185
  ```
186
186
 
187
187
  ## Type Parameters
@@ -206,7 +206,7 @@ function findAs<In, Out>(x, predicate): undefined | NonNullable<Out>;
206
206
 
207
207
  ## Returns
208
208
 
209
- `undefined` \| `NonNullable`\<`Out`\>
209
+ `NonNullable`\<`Out`\> \| `undefined`
210
210
 
211
211
  ### <a id="findLastAs"></a>findLastAs
212
212
 
@@ -215,7 +215,7 @@ function findAs<In, Out>(x, predicate): undefined | NonNullable<Out>;
215
215
  ***
216
216
 
217
217
  ```ts
218
- function findLastAs<In, Out>(x, predicate): undefined | NonNullable<Out>;
218
+ function findLastAs<In, Out>(x, predicate): NonNullable<Out> | undefined;
219
219
  ```
220
220
 
221
221
  ## Type Parameters
@@ -240,7 +240,7 @@ function findLastAs<In, Out>(x, predicate): undefined | NonNullable<Out>;
240
240
 
241
241
  ## Returns
242
242
 
243
- `undefined` \| `NonNullable`\<`Out`\>
243
+ `NonNullable`\<`Out`\> \| `undefined`
244
244
 
245
245
  ### <a id="flatten"></a>flatten
246
246
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xylabs/array",
3
- "version": "5.0.80",
3
+ "version": "5.0.82",
4
4
  "description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
5
5
  "keywords": [
6
6
  "xylabs",
@@ -28,28 +28,25 @@
28
28
  "exports": {
29
29
  ".": {
30
30
  "types": "./dist/neutral/index.d.ts",
31
- "source": "./src/index.ts",
32
31
  "default": "./dist/neutral/index.mjs"
33
32
  },
34
33
  "./package.json": "./package.json"
35
34
  },
36
35
  "module": "./dist/neutral/index.mjs",
37
- "source": "./src/index.ts",
38
36
  "types": "./dist/neutral/index.d.ts",
39
37
  "files": [
40
38
  "dist",
41
- "src",
42
39
  "!**/*.bench.*",
43
40
  "!**/*.spec.*",
44
41
  "!**/*.test.*"
45
42
  ],
46
43
  "dependencies": {
47
- "@xylabs/exists": "~5.0.80"
44
+ "@xylabs/exists": "~5.0.82",
45
+ "@xylabs/vitest-extended": "~5.0.82"
48
46
  },
49
47
  "devDependencies": {
50
- "@xylabs/ts-scripts-yarn3": "~7.3.2",
51
- "@xylabs/tsconfig": "~7.3.2",
52
- "@xylabs/vitest-extended": "~5.0.80",
48
+ "@xylabs/ts-scripts-yarn3": "~7.4.11",
49
+ "@xylabs/tsconfig": "~7.4.11",
53
50
  "typescript": "~5.9.3",
54
51
  "vitest": "~4.0.18"
55
52
  },
@@ -1 +0,0 @@
1
- export const containsAll = <T>(source: T[], target: T[]) => target.every(i => source.includes(i))
package/src/distinct.ts DELETED
@@ -1,10 +0,0 @@
1
- export const distinct = <T>(value: T, index: number, array: T[]): boolean => {
2
- // Special case for NaN
3
- if (Number.isNaN(value)) {
4
- // Return true for the first NaN only
5
- return array.findIndex(item => Number.isNaN(item)) === index
6
- }
7
-
8
- // Standard distinct logic for other values
9
- return array.indexOf(value) === index
10
- }
package/src/filterAs.ts DELETED
@@ -1,5 +0,0 @@
1
- import { exists } from '@xylabs/exists'
2
-
3
- export const filterAs = <In, Out>(x: In[], predicate: (a: In) => Out) => {
4
- return x.map(predicate).filter(exists)
5
- }
@@ -1,13 +0,0 @@
1
- /**
2
- * Returns the elements of an array that meet the condition specified in a callback function.
3
- * @param array The array to filter.
4
- * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.
5
- * @returns The elements of an array that meet the condition specified in a callback function.
6
- */
7
- export const filterAsync = async <T>(
8
- array: T[],
9
- predicate: (value: T, index: number, array: T[]) => Promise<boolean>,
10
- ): Promise<T[]> => {
11
- const results = await Promise.all(array.map(predicate))
12
- return array.filter((_, index) => results[index])
13
- }
package/src/findAs.ts DELETED
@@ -1,9 +0,0 @@
1
- import { exists } from '@xylabs/exists'
2
-
3
- export const findAs = <In, Out>(x: In[], predicate: (a: In) => Out) => {
4
- return x.map(predicate).find(exists)
5
- }
6
-
7
- export const findLastAs = <In, Out>(x: In[], predicate: (a: In) => Out) => {
8
- return x.map(predicate).findLast(exists)
9
- }
package/src/flatten.ts DELETED
@@ -1,6 +0,0 @@
1
- import { exists } from '@xylabs/exists'
2
-
3
- export const flatten = <T>(a?: T | ConcatArray<T>, b?: T | ConcatArray<T>): T[] => {
4
- // eslint-disable-next-line unicorn/prefer-spread
5
- return ([] as (T | undefined)[]).concat(a).concat(b).filter(exists)
6
- }
package/src/index.ts DELETED
@@ -1,7 +0,0 @@
1
- export * from './containsAll.ts'
2
- export * from './distinct.ts'
3
- export * from './filterAs.ts'
4
- export * from './filterAsync.ts'
5
- export * from './findAs.ts'
6
- export * from './flatten.ts'
7
- export * from './uniq.ts'
package/src/uniq.ts DELETED
@@ -1,15 +0,0 @@
1
- export const uniq = <T>(arr: T[]): T[] => {
2
- return [...new Set(arr)]
3
- }
4
-
5
- export const uniqBy = <T, I>(arr: T[], iteratee: (item: T) => I): T[] => {
6
- const seen = new Set()
7
- return arr.filter((item) => {
8
- const key = iteratee(item)
9
- if (!seen.has(key)) {
10
- seen.add(key)
11
- return true
12
- }
13
- return false
14
- })
15
- }