]> git.r.bdr.sh - rbdr/dotfiles/blob
80864d0666168a44e2ff28261ab04ed1586d543c
[rbdr/dotfiles] /
1 'use strict';
2
3 var toPosInt = require('../../number/to-pos-integer')
4 , value = require('../../object/valid-value')
5
6 , indexOf = Array.prototype.indexOf
7 , hasOwnProperty = Object.prototype.hasOwnProperty
8 , abs = Math.abs, floor = Math.floor;
9
10 module.exports = function (searchElement/*, fromIndex*/) {
11 var i, l, fromIndex, val;
12 if (searchElement === searchElement) { //jslint: ignore
13 return indexOf.apply(this, arguments);
14 }
15
16 l = toPosInt(value(this).length);
17 fromIndex = arguments[1];
18 if (isNaN(fromIndex)) fromIndex = 0;
19 else if (fromIndex >= 0) fromIndex = floor(fromIndex);
20 else fromIndex = toPosInt(this.length) - floor(abs(fromIndex));
21
22 for (i = fromIndex; i < l; ++i) {
23 if (hasOwnProperty.call(this, i)) {
24 val = this[i];
25 if (val !== val) return i; //jslint: ignore
26 }
27 }
28 return -1;
29 };