swc/bundler/tests/.cache/deno/fd15bc013d4193c11121d419363a38f336be6c8e.ts
강동윤 bbaf619f63
fix(bundler): Fix bugs (#1437)
swc_bundler:
 - [x] Fix wrapped esms. (denoland/deno#9307)
 - [x] Make test secure.
2021-03-02 17:33:03 +09:00

43 lines
1.1 KiB
TypeScript

// Loaded from https://deno.land/x/ramda@v0.27.2/source/findIndex.js
import _curry2 from './internal/_curry2.js';
import _dispatchable from './internal/_dispatchable.js';
import _xfindIndex from './internal/_xfindIndex.js';
/**
* Returns the index of the first element of the list which matches the
* predicate, or `-1` if no element matches.
*
* Acts as a transducer if a transformer is given in list position.
*
* @func
* @memberOf R
* @since v0.1.1
* @category List
* @sig (a -> Boolean) -> [a] -> Number
* @param {Function} fn The predicate function used to determine if the element is the
* desired one.
* @param {Array} list The array to consider.
* @return {Number} The index of the element found, or `-1`.
* @see R.transduce
* @example
*
* const xs = [{a: 1}, {a: 2}, {a: 3}];
* R.findIndex(R.propEq('a', 2))(xs); //=> 1
* R.findIndex(R.propEq('a', 4))(xs); //=> -1
*/
var findIndex = _curry2(_dispatchable([], _xfindIndex, function findIndex(fn, list) {
var idx = 0;
var len = list.length;
while (idx < len) {
if (fn(list[idx])) {
return idx;
}
idx += 1;
}
return -1;
}));
export default findIndex;