(array, startIndex, endIndex, throwError)
| 21 | * @return {boolean} True if the range is safe, otherwise false. |
| 22 | */ |
| 23 | var SafeRange = function (array, startIndex, endIndex, throwError) |
| 24 | { |
| 25 | var len = array.length; |
| 26 | |
| 27 | if (startIndex < 0 || |
| 28 | startIndex >= len || |
| 29 | startIndex >= endIndex || |
| 30 | endIndex > len) |
| 31 | { |
| 32 | if (throwError) |
| 33 | { |
| 34 | throw new Error('Range Error: Values outside acceptable range'); |
| 35 | } |
| 36 | |
| 37 | return false; |
| 38 | } |
| 39 | else |
| 40 | { |
| 41 | return true; |
| 42 | } |
| 43 | }; |
| 44 | |
| 45 | module.exports = SafeRange; |
no outgoing calls
no test coverage detected
searching dependent graphs…