UNPKG

@newdash/newdash

Version:

javascript/typescript utility library

22 lines (21 loc) 784 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.indexOf = void 0; const baseIndexOf_1 = __importDefault(require("./.internal/baseIndexOf")); const toInteger_1 = __importDefault(require("./toInteger")); function indexOf(array, value, fromIndex) { const length = array == null ? 0 : array.length; if (!length) { return -1; } let index = fromIndex == null ? 0 : (0, toInteger_1.default)(fromIndex); if (index < 0) { index = Math.max(length + index, 0); } return (0, baseIndexOf_1.default)(array, value, index); } exports.indexOf = indexOf; exports.default = indexOf;