[Navigation]: Add a method to map the stack routes to an array.

Summary:
Add a method to map the stack routes to an array.
This commit is contained in:
Hedger Wang
2015-08-06 01:51:37 -07:00
parent a6ff11f1d2
commit 8463625bd9
2 changed files with 46 additions and 11 deletions

View File

@@ -202,11 +202,19 @@ class RouteStack {
var nodes = this._routeNodes;
while (ii < nodes.size) {
var node = nodes.get(ii);
callback(node.value, ii, node.key);
callback.call(context, node.value, ii, node.key);
ii++;
}
}
mapToArray(callback: IterationCallback, context: ?Object): Array<any> {
var result = [];
this.forEach((route, index, key) => {
result.push(callback.call(context, route, index, key));
});
return result;
}
/**
* Returns a Set excluding any routes contained within the stack given.
*/