MCPcopy Create free account
hub / github.com/melonjs/melonJS / forEach

Method forEach

packages/melonjs/src/renderable/container.js:509–523  ·  view source on GitHub ↗

* The forEach() method executes a provided function once per child element. * the callback function is invoked with three arguments: * - The current element being processed in the array * - The index of element in the array. * - The array forEach() was called upo

(callback, thisArg)

Source from the content-addressed store, hash-verified

507 * container.forEach((child, index, array) => { ... }, thisArg);
508 */
509 forEach(callback, thisArg) {
510 let i = 0;
511 const children = this.getChildren();
512
513 const len = children.length;
514
515 if (typeof callback !== "function") {
516 throw new Error(callback + " is not a function");
517 }
518
519 while (i < len) {
520 callback.call(thisArg ?? this, children[i], i, children);
521 i++;
522 }
523 }
524
525 /**
526 * Swaps the position (z-index) of 2 children

Callers 11

getChildByPropMethod · 0.95
getChildByTypeMethod · 0.95
updateBoundsMethod · 0.95
onActivateEventMethod · 0.95
setChildsPropertyMethod · 0.95
sortMethod · 0.95
onDeactivateEventMethod · 0.95
addChildMethod · 0.45
addChildAtMethod · 0.45
updateMethod · 0.45
addAnimationMethod · 0.45

Calls 1

getChildrenMethod · 0.95

Tested by

no test coverage detected