(array, property, value, startIndex, endIndex)
| 29 | * @return {array} All matching elements from the array. |
| 30 | */ |
| 31 | var GetAll = function (array, property, value, startIndex, endIndex) |
| 32 | { |
| 33 | if (startIndex === undefined) { startIndex = 0; } |
| 34 | if (endIndex === undefined) { endIndex = array.length; } |
| 35 | |
| 36 | var output = []; |
| 37 | |
| 38 | if (SafeRange(array, startIndex, endIndex)) |
| 39 | { |
| 40 | for (var i = startIndex; i < endIndex; i++) |
| 41 | { |
| 42 | var child = array[i]; |
| 43 | |
| 44 | if (!property || |
| 45 | (property && value === undefined && child.hasOwnProperty(property)) || |
| 46 | (property && value !== undefined && child[property] === value)) |
| 47 | { |
| 48 | output.push(child); |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | return output; |
| 54 | }; |
| 55 | |
| 56 | module.exports = GetAll; |
no test coverage detected
searching dependent graphs…