From 23d9999a9f6a20b2634d7b41e6743c3eff7a9bb0 Mon Sep 17 00:00:00 2001 From: Tim Mickel Date: Wed, 31 Aug 2016 12:18:24 -0400 Subject: [PATCH] Add `runtime.getTargetById` helper --- src/engine/runtime.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/engine/runtime.js b/src/engine/runtime.js index 1de5a9bc2..43d6b35b9 100644 --- a/src/engine/runtime.js +++ b/src/engine/runtime.js @@ -260,6 +260,20 @@ Runtime.prototype.targetForThread = function (thread) { } }; +/** + * Get a target by its id. + * @param {string} targetId Id of target to find. + * @return {?Target} The target, if found. + */ +Runtime.prototype.getTargetById = function (targetId) { + for (var i = 0; i < this.targets.length; i++) { + var target = this.targets[i]; + if (target.id == targetId) { + return target; + } + } +}; + /** * Handle an animation frame from the main thread. */