Add runtime.getTargetById helper

This commit is contained in:
Tim Mickel 2016-08-31 12:18:24 -04:00
parent d4a43639f3
commit 23d9999a9f

View file

@ -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. * Handle an animation frame from the main thread.
*/ */