How to use the @glimmer/util.assert function in @glimmer/util

To help you get started, we’ve selected a few @glimmer/util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github glimmerjs / glimmer-vm / packages / @glimmer / runtime / lib / compat / svg-inner-html-fix.ts View on Github external
function fixSVG(parent: Element, div: HTMLElement, html: string, reference: Node): Bounds {
  assert(html !== '', 'html cannot be empty');

  let source: Node;

  // This is important, because decendants of the 
github glimmerjs / glimmer-vm / packages / @glimmer / runtime / lib / compiled / opcodes / expressions.ts View on Github external
APPEND_OPCODES.add(Op.HasBlockParams, vm => {
  // FIXME(mmun): should only need to push the symbol table
  let block = vm.stack.pop();
  let scope = vm.stack.pop();
  check(block, CheckOption(CheckOr(CheckHandle, CheckCompilableBlock)));
  check(scope, CheckOption(CheckScope));
  let table = check(vm.stack.pop(), CheckOption(CheckBlockSymbolTable));

  assert(
    table === null || (table && typeof table === 'object' && Array.isArray(table.parameters)),
    stackAssert('Option', table)
  );

  let hasBlockParams = table && table.parameters.length;
  vm.stack.push(hasBlockParams ? TRUE_REFERENCE : FALSE_REFERENCE);
});
github glimmerjs / glimmer-vm / packages / @glimmer / test-helpers / lib / environment / modes / eager / modules.ts View on Github external
register(name: string, type: ModuleType, value: Dict) {
    assert(name.indexOf('ui/components/ui') === -1, `BUG: ui/components/ui shouldn't be a prefix`);
    assert(!name.match(/^[A-Z]/), 'BUG: Components should be nested under ui/components');
    this.registry[name] = new Module(value, type);
  }
github glimmerjs / glimmer-vm / packages / @glimmer / syntax / lib / hbs / parse / html.ts View on Github external
openAttribute(pos: number): void {
    assert(this.maybeAttribute === null, `cannot open an attribute if one is already open`);

    this.maybeAttribute = new ConstructingAttribute(pos);
  }
github glimmerjs / glimmer-vm / packages / @glimmer / bundle-compiler / lib / debug-constants.ts View on Github external
resolveHandle(s: number): T {
    assert(typeof s === 'number', 'Cannot resolve undefined as a handle');
    return ({ handle: s } as any) as T;
  }
github glimmerjs / glimmer-vm / packages / @glimmer / syntax / lib / hbs / lexing.ts View on Github external
case 'nothing':
        assert(
          this.tokenLen === 0,
          'you can only do nothing when there are no accumulated characters'
        );
        this.action(accum.action);
        return { type: 'continue' };

      case 'continue':
        this.action(accum.action);

        return { type: 'continue' };

      case 'skip':
        assert(
          this.tokenLen === 0,
          'you can only skip when there are no accumulated characters yet'
        );
        this.action(accum.action);

        this.startPos += this.tokenLen;
        this.tokenLen = 0;

        return { type: 'continue' };

      case 'emit':
        let { before, token } = accum;

        if (before !== undefined) {
          this.action(before);
        }
github glimmerjs / glimmer-vm / packages / @glimmer / opcode-compiler / lib / syntax.ts View on Github external
inlines.add('component', (_name, _params, hash, builder) => {
    assert(_params && _params.length, 'SYNTAX ERROR: component helper requires at least one argument');

    let [definition, ...params] = _params!;
    builder.dynamicComponent(definition, params, hash, true, null, null);

    return true;
  });
github glimmerjs / glimmer-vm / packages / @glimmer / syntax / lib / hbs / parse / html.ts View on Github external
finalize(pos: number): hbs.Root {
    assert(
      this.elements.length === 1,
      `must have exactly one element in the stack to finalize (TODO: error recovery)`
    );

    let frag = this.elements[0] as ConstructingFragment;

    return {
      type: 'Root',
      span: { start: 0, end: pos },
      body: frag.body,
    };
  }
github glimmerjs / glimmer-vm / packages / @glimmer / compiler / lib / template-compiler.ts View on Github external
prepareParams(params: AST.Expression[]) {
    if (!params.length) {
      this.opcode(['literal', null], null);
      return;
    }

    for (let i = params.length - 1; i >= 0; i--) {
      let param = params[i];

      assert(this[param.type], `Unimplemented ${param.type} on TemplateCompiler`);
      this[param.type](param as any);
    }

    this.opcode(['prepareArray', params.length], null);
  }
github glimmerjs / glimmer-vm / packages / @glimmer / runtime / lib / vm / element-builder.ts View on Github external
closeElement() {
    assert(false, 'Cannot closeElement directly inside a block list');
  }