UNPKG

iteragain

Version:

Javascript Iterable/Iterator/Generator-function utilities.

18 lines 552 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.findIndex = findIndex; const toIterator_1 = require("./toIterator"); function findIndex(...args) { if (args.length === 1) return it => findIndex(it, args[0]); const it = (0, toIterator_1.default)(args[0]); const predicate = args[1]; let next; let i = -1; while ((i++, !(next = it.next()).done)) if (predicate(next.value)) return i; return -1; } exports.default = findIndex; //# sourceMappingURL=findIndex.js.map