@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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@zelgadis87/utils-core",
4
- "version": "5.2.3",
4
+ "version": "5.2.4",
5
5
  "author": "Zelgadis87",
6
6
  "license": "ISC",
7
7
  "private": false,
@@ -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}` );