UNPKG

1.26 kBSource Map (JSON)View Raw
1{"version":3,"sources":["iterable/findindex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAYxD,MAAM,UAAU,SAAS,CACvB,MAAmB,EACnB,SAA+C,EAC/C,OAAa;IAEb,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE;QACnC,MAAM,IAAI,SAAS,EAAE,CAAC;KACvB;IACD,MAAM,CAAC,GAAG,YAAY,CAAC,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IAC9C,IAAI,CAAC,GAAG,CAAC,CAAC;IAEV,KAAK,IAAI,IAAI,IAAI,MAAM,EAAE;QACvB,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE;YAChB,OAAO,CAAC,CAAC;SACV;KACF;IACD,OAAO,CAAC,CAAC,CAAC;AACZ,CAAC","file":"findindex.js","sourcesContent":["import { bindCallback } from '../internal/bindcallback';\n\nexport function findIndex<T, S extends T>(\n source: Iterable<T>,\n predicate: (value: T, index: number) => value is S,\n thisArg?: any\n): number;\nexport function findIndex<T>(\n source: Iterable<T>,\n predicate: (value: T, index: number) => boolean,\n thisArg?: any\n): number;\nexport function findIndex<T>(\n source: Iterable<T>,\n predicate: (value: T, index: number) => boolean,\n thisArg?: any\n): number {\n if (typeof predicate !== 'function') {\n throw new TypeError();\n }\n const f = bindCallback(predicate, thisArg, 2);\n let i = 0;\n\n for (let item of source) {\n if (f(item, i++)) {\n return i;\n }\n }\n return -1;\n}\n"]}
\No newline at end of file