MCPcopy Create free account
hub / github.com/microsoft/SandDance / inArray

Function inArray

docs/tests/v2/es6/js/sanddance.js:51631–51647  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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

Callers 2

uniqueArrayFunction · 0.70
sanddance.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected