Skip to content

Commit 5fd066c

Browse files
committed
ArraySet.getByKey gets an item from the set based on the property strictly equaling the value given.
1 parent 8d71e8a commit 5fd066c

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ We've also removed functions and properties from Pixi classes that Phaser doesn'
157157
* Tween.repeat has a new parameter `repeatDelay` which allows you to set the delay (in ms) before a tween will repeat itself.
158158
* Tween.yoyo has a new parameter `yoyoDelay` which allows you to set the delay (in ms) before a tween will start a yoyo.
159159
* Tween.interpolation has a new parameter `context` which allows you to define the context in which the interpolation function will run.
160+
* ArraySet.getByKey gets an item from the set based on the property strictly equaling the value given.
160161

161162
### Bug Fixes
162163

src/utils/ArraySet.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,31 @@ Phaser.ArraySet.prototype = {
6767

6868
},
6969

70+
/**
71+
* Gets an item from the set based on the property strictly equaling the value given.
72+
* Returns null if not found.
73+
*
74+
* @method Phaser.ArraySet#getByKey
75+
* @param {string} property - The property to check against the value.
76+
* @param {any} value - The value to check if the property strictly equals.
77+
* @return {any} The item that was found, or null if nothing matched.
78+
*/
79+
getByKey: function (property, value) {
80+
81+
var i = this.list.length;
82+
83+
while (i--)
84+
{
85+
if (this.list[i][property] === value)
86+
{
87+
return this.list[i];
88+
}
89+
}
90+
91+
return null;
92+
93+
},
94+
7095
/**
7196
* Checks for the item within this list.
7297
*

0 commit comments

Comments
 (0)