|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.0 KB
|
| Line | |
|---|
| 1 | define(['./_getLength', './_setup', './isNaN'], function (_getLength, _setup, _isNaN) {
|
|---|
| 2 |
|
|---|
| 3 | // Internal function to generate the `_.indexOf` and `_.lastIndexOf` functions.
|
|---|
| 4 | function createIndexFinder(dir, predicateFind, sortedIndex) {
|
|---|
| 5 | return function(array, item, idx) {
|
|---|
| 6 | var i = 0, length = _getLength(array);
|
|---|
| 7 | if (typeof idx == 'number') {
|
|---|
| 8 | if (dir > 0) {
|
|---|
| 9 | i = idx >= 0 ? idx : Math.max(idx + length, i);
|
|---|
| 10 | } else {
|
|---|
| 11 | length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1;
|
|---|
| 12 | }
|
|---|
| 13 | } else if (sortedIndex && idx && length) {
|
|---|
| 14 | idx = sortedIndex(array, item);
|
|---|
| 15 | return array[idx] === item ? idx : -1;
|
|---|
| 16 | }
|
|---|
| 17 | if (item !== item) {
|
|---|
| 18 | idx = predicateFind(_setup.slice.call(array, i, length), _isNaN);
|
|---|
| 19 | return idx >= 0 ? idx + i : -1;
|
|---|
| 20 | }
|
|---|
| 21 | for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) {
|
|---|
| 22 | if (array[idx] === item) return idx;
|
|---|
| 23 | }
|
|---|
| 24 | return -1;
|
|---|
| 25 | };
|
|---|
| 26 | }
|
|---|
| 27 |
|
|---|
| 28 | return createIndexFinder;
|
|---|
| 29 |
|
|---|
| 30 | });
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.