(array, property, value, startIndex, endIndex)
| 32 | * @return {?object} The first matching element from the array, or `null` if no element could be found in the range given. |
| 33 | */ |
| 34 | var 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 | |
| 78 | module.exports = GetFirst; |
nothing calls this directly
no test coverage detected
searching dependent graphs…