* find if a array contains the object using indexOf or a simple polyFill * @param {Array} src * @param {String} find * @param {String} [findByKey] * @return {Boolean|Number} false when not found, or the index
(src, find, findByKey)
| 51629 | |
| 51630 | |
| 51631 | function inArray(src, find, findByKey) { |
| 51632 | if (src.indexOf && !findByKey) { |
| 51633 | return src.indexOf(find); |
| 51634 | } else { |
| 51635 | var i = 0; |
| 51636 | |
| 51637 | while (i < src.length) { |
| 51638 | if (findByKey && src[i][findByKey] == find || !findByKey && src[i] === find) { |
| 51639 | return i; |
| 51640 | } |
| 51641 | |
| 51642 | i++; |
| 51643 | } |
| 51644 | |
| 51645 | return -1; |
| 51646 | } |
| 51647 | } |
| 51648 | /** |
| 51649 | * convert array-like objects to real arrays |
| 51650 | * @param {Object} obj |
no outgoing calls
no test coverage detected