MCPcopy Index your code
hub / github.com/phaserjs/phaser / GetFirst

Function GetFirst

src/utils/array/GetFirst.js:34–76  ·  view source on GitHub ↗
(array, property, value, startIndex, endIndex)

Source from the content-addressed store, hash-verified

32 * @return {?object} The first matching element from the array, or `null` if no element could be found in the range given.
33 */
34var GetFirst = function (array, property, value, startIndex, endIndex)
35{
36 if (startIndex === undefined) { startIndex = 0; }
37 if (endIndex === undefined) { endIndex = array.length; }
38
39 var i;
40 var child;
41
42 if (startIndex !== -1)
43 {
44 if (SafeRange(array, startIndex, endIndex))
45 {
46 for (i = startIndex; i < endIndex; i++)
47 {
48 child = array[i];
49
50 if (!property ||
51 (property && value === undefined && child.hasOwnProperty(property)) ||
52 (property && value !== undefined && child[property] === value))
53 {
54 return child;
55 }
56 }
57 }
58 }
59 else
60 if (SafeRange(array, 0, endIndex))
61 {
62 for (i = endIndex; i >= 0; i--)
63 {
64 child = array[i];
65
66 if (!property ||
67 (property && value === undefined && child.hasOwnProperty(property)) ||
68 (property && value !== undefined && child[property] === value))
69 {
70 return child;
71 }
72 }
73 }
74
75 return null;
76};
77
78module.exports = GetFirst;

Callers

nothing calls this directly

Calls 1

SafeRangeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…