UNPKG

1.09 kBJavaScriptView Raw
1export const frameStack = [];
2export function topmost() {
3 if (frameStack.length > 0) {
4 return frameStack[frameStack.length - 1];
5 }
6 return undefined;
7}
8export function _pushInFrameStack(frame) {
9 if (frame._isInFrameStack && frameStack[frameStack.length - 1] === frame) {
10 return;
11 }
12 if (frame._isInFrameStack) {
13 const indexOfFrame = frameStack.indexOf(frame);
14 frameStack.splice(indexOfFrame, 1);
15 }
16 frameStack.push(frame);
17 frame._isInFrameStack = true;
18}
19export function _popFromFrameStack(frame) {
20 if (!frame._isInFrameStack) {
21 return;
22 }
23 const top = topmost();
24 if (top !== frame) {
25 throw new Error('Cannot pop a Frame which is not at the top of the navigation stack.');
26 }
27 frameStack.pop();
28 frame._isInFrameStack = false;
29}
30export function _removeFromFrameStack(frame) {
31 if (!frame._isInFrameStack) {
32 return;
33 }
34 const index = frameStack.indexOf(frame);
35 frameStack.splice(index, 1);
36 frame._isInFrameStack = false;
37}
38//# sourceMappingURL=frame-stack.js.map
\No newline at end of file