MCPcopy Create free account
hub / github.com/CashScript/cashscript / findLastIndex

Function findLastIndex

packages/cashscript/src/utils.ts:411–417  ·  view source on GitHub ↗
(array: Array<T>, predicate: (value: T, index: number, obj: T[]) => boolean)

Source from the content-addressed store, hash-verified

409
410// https://stackoverflow.com/questions/40929260/find-last-index-of-element-inside-array-by-certain-condition
411export function findLastIndex<T>(array: Array<T>, predicate: (value: T, index: number, obj: T[]) => boolean): number {
412 let l = array.length;
413 while (l--) {
414 if (predicate(array[l], l, array)) return l;
415 }
416 return -1;
417}
418
419// JSON.stringify version that can serialize otherwise unsupported types (bigint and Uint8Array)
420export const extendedStringify = (obj: any, spaces?: number): string => JSON.stringify(

Callers 1

debugSingleScenarioFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected