Refactor navigation bar

This commit is contained in:
Andy Hanson
2016-06-17 07:42:26 -07:00
parent 0e6f8eb2bc
commit 166bc49f0c
27 changed files with 1416 additions and 1053 deletions
+11
View File
@@ -138,6 +138,17 @@ namespace ts {
return result;
}
export function filterMutate<T>(array: T[], f: (x: T) => boolean): void {
let outIndex = 0;
for (const item of array) {
if (f(item)) {
array[outIndex] = item;
outIndex++;
}
}
array.length = outIndex;
}
export function map<T, U>(array: T[], f: (x: T) => U): U[] {
let result: U[];
if (array) {
+4 -4
View File
@@ -17,19 +17,19 @@ namespace ts {
}
function visitNode<T>(cbNode: (node: Node) => T, node: Node): T {
if (node) {
if (node !== void 0) {
return cbNode(node);
}
}
function visitNodeArray<T>(cbNodes: (nodes: Node[]) => T, nodes: Node[]) {
if (nodes) {
if (nodes !== void 0) {
return cbNodes(nodes);
}
}
function visitEachNode<T>(cbNode: (node: Node) => T, nodes: Node[]) {
if (nodes) {
if (nodes !== void 0) {
for (const node of nodes) {
const result = cbNode(node);
if (result) {
@@ -44,7 +44,7 @@ namespace ts {
// embedded arrays are flattened and the 'cbNode' callback is invoked for each element. If a callback returns
// a truthy value, iteration stops and that value is returned. Otherwise, undefined is returned.
export function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T {
if (!node) {
if (node === void 0) {
return;
}
// The visitXXX functions could be written as local functions that close over the cbNode and cbNodeArray