@zelgadis87/utils-core 5.2.3 → 5.2.4
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/CHANGELOG.md +6 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/arrays.d.ts +1 -0
- package/esbuild/index.cjs +6 -0
- package/esbuild/index.cjs.map +2 -2
- package/esbuild/index.mjs +5 -0
- package/esbuild/index.mjs.map +2 -2
- package/package.json +1 -1
- package/src/utils/arrays.ts +5 -0
package/package.json
CHANGED
package/src/utils/arrays.ts
CHANGED
|
@@ -177,6 +177,11 @@ export function findInArray<T>( arr: T[], predicate: TPredicate<T> ): TOptional<
|
|
|
177
177
|
return Optional.ofNullable( arr.find( predicate ) );
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
+
export function findIndexInArray<T>( arr: T[], predicate: TPredicate<T> ): TOptional<number> {
|
|
181
|
+
const idx = arr.findIndex( predicate );
|
|
182
|
+
return idx === -1 ? Optional.empty() : Optional.of( idx );
|
|
183
|
+
}
|
|
184
|
+
|
|
180
185
|
export function zip<T, R>( ts: T[], rs: R[] ): [ T, R ][] {
|
|
181
186
|
if ( ts.length !== rs.length )
|
|
182
187
|
throw new Error( `Arrays must have the same length. Got ${ts.length} and ${rs.length}` );
|