mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-04 15:32:18 +02:00
Add iterate, fix each method in mock container
This commit is contained in:
parent
d5789105f3
commit
70b74e143e
@ -272,9 +272,24 @@ export default class MockContainer implements MockGameObject {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
each(method): this {
|
// biome-ignore lint/complexity/noBannedTypes: This matches the signature of the method it mocks
|
||||||
|
each(callback: Function, context?: object, ...args: any[]): this {
|
||||||
|
if (context !== undefined) {
|
||||||
|
callback = callback.bind(context);
|
||||||
|
}
|
||||||
|
for (const item of this.list.slice()) {
|
||||||
|
callback(item, ...args);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// biome-ignore lint/complexity/noBannedTypes: This matches the signature of the method it mocks
|
||||||
|
iterate(callback: Function, context?: object, ...args: any[]): this {
|
||||||
|
if (context !== undefined) {
|
||||||
|
callback = callback.bind(context);
|
||||||
|
}
|
||||||
for (const item of this.list) {
|
for (const item of this.list) {
|
||||||
method(item);
|
callback(item, ...args);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user