UNPKG

947 BJavaScriptView Raw
1var _curry2 =
2/*#__PURE__*/
3require("./internal/_curry2");
4
5var _indexOf =
6/*#__PURE__*/
7require("./internal/_indexOf");
8
9var _isArray =
10/*#__PURE__*/
11require("./internal/_isArray");
12/**
13 * Returns the position of the first occurrence of an item in an array, or -1
14 * if the item is not included in the array. [`R.equals`](#equals) is used to
15 * determine equality.
16 *
17 * @func
18 * @memberOf R
19 * @since v0.1.0
20 * @category List
21 * @sig a -> [a] -> Number
22 * @param {*} target The item to find.
23 * @param {Array} xs The array to search in.
24 * @return {Number} the index of the target, or -1 if the target is not found.
25 * @see R.lastIndexOf
26 * @example
27 *
28 * R.indexOf(3, [1,2,3,4]); //=> 2
29 * R.indexOf(10, [1,2,3,4]); //=> -1
30 */
31
32
33var indexOf =
34/*#__PURE__*/
35_curry2(function indexOf(target, xs) {
36 return typeof xs.indexOf === 'function' && !_isArray(xs) ? xs.indexOf(target) : _indexOf(xs, target, 0);
37});
38
39module.exports = indexOf;
\No newline at end of file