You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The purpose of this function is to validate ranges in the form of [startIndex, endIndex). Where [ includes startIndex and ) excludes endIndex.
The fix will allow the following ranges to be validated:
[n, Array.length), n = {1, ..., Array.length-1}, Array.length > 1
[n, m), n = {1, ..., Array.length - 1}, m = {n+1, ..., Array.length}, Array.length > 1
For example,
vararr=[0,1,2,3,4];console.log(Phaser.Utils.Array.SafeRange(arr,0,arr.length));// true, since [0, 5) is a valid range for arr that gives [0, 1, 2, 3, 4]console.log(Phaser.Utils.Array.SafeRange(arr,1,arr.length));// false, but should be true since [1, 5) is a valid range for arr that gives [1, 2, 3, 4]console.log(Phaser.Utils.Array.SafeRange(arr,2,4));// false, but should be true since [2, 4) is a valid range for arr that gives [2, 3]
It restricts the following static methods in Phaser.Utils.Arrays: CountAllMatching, EachInRange, GetAll, GetFirst, RemoveBetween, SetAll.
The proposed fix will allow these methods to be able to operate on the aforementioned ranges.
For example, this code snippet demonstrates the change for GetAll (Phaser.GameObjects.Group::getMatching) https://jsfiddle.net/z7w96k53/1/
Thanks for opening this issue, and for submitting a PR to fix it. We have merged your PR into the master branch and attributed the work to you in the Change Log. If you need to tweak the code for whatever reason please submit a new PR.
Version
Description
The condition
startIndex + endIndex > len
, in SafeRange.js is not necessary, and it restricts valid ranges.The purpose of this function is to validate ranges in the form of [startIndex, endIndex). Where [ includes startIndex and ) excludes endIndex.
The fix will allow the following ranges to be validated:
For example,
It restricts the following static methods in Phaser.Utils.Arrays: CountAllMatching, EachInRange, GetAll, GetFirst, RemoveBetween, SetAll.
The proposed fix will allow these methods to be able to operate on the aforementioned ranges.
For example, this code snippet demonstrates the change for GetAll (Phaser.GameObjects.Group::getMatching)
https://jsfiddle.net/z7w96k53/1/
Example Test Code
This snippet contains the unit tests: https://jsfiddle.net/7x5Lpse1/16/
The text was updated successfully, but these errors were encountered: