Sha256: eff738cfb579643844d67a33d5adb9e6383bfdb23564b3deb76f845901619e2b

Contents?: true

Size: 1.53 KB

Versions: 3

Compression:

Stored size: 1.53 KB

Contents

// @ts-check
import { DEBUG } from '@glimmer/env';
let DebugStack;
if (DEBUG) {
    class Element {
        constructor(name) {
            this.name = name;
        }
    }
    class TemplateElement extends Element {
    }
    class EngineElement extends Element {
    }
    // tslint:disable-next-line:no-shadowed-variable
    DebugStack = class DebugStack {
        constructor() {
            this._stack = [];
        }
        push(name) {
            this._stack.push(new TemplateElement(name));
        }
        pushEngine(name) {
            this._stack.push(new EngineElement(name));
        }
        pop() {
            let element = this._stack.pop();
            if (element) {
                return element.name;
            }
        }
        peek() {
            let template = this._currentTemplate();
            let engine = this._currentEngine();
            if (engine) {
                return `"${template}" (in "${engine}")`;
            }
            else if (template) {
                return `"${template}"`;
            }
        }
        _currentTemplate() {
            return this._getCurrentByType(TemplateElement);
        }
        _currentEngine() {
            return this._getCurrentByType(EngineElement);
        }
        _getCurrentByType(type) {
            for (let i = this._stack.length; i >= 0; i--) {
                let element = this._stack[i];
                if (element instanceof type) {
                    return element.name;
                }
            }
        }
    };
}
export default DebugStack;

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
discourse-ember-source-3.6.0.0 dist/es/@ember/-internals/glimmer/lib/utils/debug-stack.js
discourse-ember-source-3.5.1.1 dist/es/ember-glimmer/lib/utils/debug-stack.js
discourse-ember-source-3.5.1.0 dist/dist/es/ember-glimmer/lib/utils/debug-stack.js