chore: cleanup

This commit is contained in:
Nathan Walker
2020-07-06 14:25:11 -07:00
parent 94cf5c4706
commit 6336eac4b5
477 changed files with 59087 additions and 74961 deletions

View File

@@ -1,52 +1,50 @@
// Types.
import { FrameBase } from "./frame-common";
import { FrameBase } from './frame-common';
export let frameStack: Array<FrameBase> = [];
export function topmost(): FrameBase {
if (frameStack.length > 0) {
return frameStack[frameStack.length - 1];
}
if (frameStack.length > 0) {
return frameStack[frameStack.length - 1];
}
return undefined;
return undefined;
}
export function _pushInFrameStack(frame: FrameBase): void {
if (frame._isInFrameStack && frameStack[frameStack.length - 1] === frame) {
return;
}
if (frame._isInFrameStack && frameStack[frameStack.length - 1] === frame) {
return;
}
if (frame._isInFrameStack) {
const indexOfFrame = frameStack.indexOf(frame);
frameStack.splice(indexOfFrame, 1);
}
if (frame._isInFrameStack) {
const indexOfFrame = frameStack.indexOf(frame);
frameStack.splice(indexOfFrame, 1);
}
frameStack.push(frame);
frame._isInFrameStack = true;
frameStack.push(frame);
frame._isInFrameStack = true;
}
export function _popFromFrameStack(frame: FrameBase): void {
if (!frame._isInFrameStack) {
return;
}
if (!frame._isInFrameStack) {
return;
}
const top = topmost();
if (top !== frame) {
throw new Error(
"Cannot pop a Frame which is not at the top of the navigation stack."
);
}
const top = topmost();
if (top !== frame) {
throw new Error('Cannot pop a Frame which is not at the top of the navigation stack.');
}
frameStack.pop();
frame._isInFrameStack = false;
frameStack.pop();
frame._isInFrameStack = false;
}
export function _removeFromFrameStack(frame: FrameBase): void {
if (!frame._isInFrameStack) {
return;
}
if (!frame._isInFrameStack) {
return;
}
const index = frameStack.indexOf(frame);
frameStack.splice(index, 1);
frame._isInFrameStack = false;
const index = frameStack.indexOf(frame);
frameStack.splice(index, 1);
frame._isInFrameStack = false;
}