How to use the @glimmer/util.dict 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 emberjs / ember.js / packages / @ember / -internals / glimmer / lib / syntax / outlet.ts View on Github external
constructor(
    private outletRef: VersionedPathReference,
    env: Environment
  ) {
    // The router always dirties the root state.
    let tag = (this.tag = outletRef.tag);

    if (EMBER_ROUTING_MODEL_ARG) {
      let modelRef = new OutletModelReference(outletRef, env);
      let map = dict();
      map.model = modelRef;

      // TODO: the functionailty to create a proper CapturedArgument should be
      // exported by glimmer, or that it should provide an overload for `curry`
      // that takes `PreparedArguments`
      this.args = {
        tag,
        positional: EMPTY_ARGS.positional,
        named: {
          tag,
          map,
          names: ['model'],
          references: [modelRef],
          length: 1,
          has(key: string): boolean {
            return key === 'model';
github glimmerjs / glimmer-vm / packages / @glimmer / integration-tests / lib / dom / assertions.ts View on Github external
for (let prop in attributes) {
    expectedCount++;
    let expected = attributes[prop];

    let matcher: Matcher = isMatcher(expected) ? expected : equalsAttr(expected);
    expectedAttrs[prop] = matcher;

    QUnit.assert.pushResult({
      result: expectedAttrs[prop].match(element && element.getAttribute(prop)),
      actual: matcher.fail(element && element.getAttribute(prop)),
      expected: matcher.fail(element && element.getAttribute(prop)),
      message: `Expected ${description}'s ${prop} attribute ${matcher.expected()}`,
    });
  }

  let actualAttributes = dict();
  if (element) {
    for (let i = 0, l = element.attributes.length; i < l; i++) {
      actualAttributes[element.attributes[i].name] = element.attributes[i].value;
    }
  }

  if (!(element instanceof HTMLElement)) {
    QUnit.assert.pushResult({
      result: element instanceof HTMLElement,
      actual: null,
      expected: null,
      message: 'Element must be an HTML Element, not an SVG Element',
    });
  } else {
    QUnit.assert.pushResult({
      result: element.attributes.length === expectedCount,
github glimmerjs / glimmer-vm / packages / @glimmer / test-helpers / lib / environment.ts View on Github external
result: false,
      actual: element,
      expected: true,
      message: `failed - expected element to not be null`
    });
    return;
  }

  QUnit.assert.pushResult({
    result: element.tagName === tagName.toUpperCase(),
    actual: element.tagName.toLowerCase(),
    expected: tagName,
    message: `expect tagName to be ${tagName}`
  });

  let expectedAttrs: Dict = dict();

  let expectedCount = 0;
  for (let prop in attributes) {
    expectedCount++;
    let expected = attributes[prop];

    let matcher: Matcher = typeof expected === 'object' && MATCHER in expected ? expected : equalsAttr(expected);
    expectedAttrs[prop] = matcher;

    QUnit.assert.pushResult({
      result: expectedAttrs[prop].match(element && element.getAttribute(prop)),
      actual: matcher.fail(element && element.getAttribute(prop)),
      expected: matcher.fail(element && element.getAttribute(prop)),
      message: `Expected element's ${prop} attribute ${matcher.expected()}`
    });
  }
github glimmerjs / glimmer-vm / packages / @glimmer / compiler / lib / builder-interface.ts View on Github external
function mapObject(
  object: T,
  callback: (value: T[K], key: K) => U[K]
): U {
  let out: any = dict();

  Object.keys(object).forEach(k => {
    out[k] = callback(object[k] as any, k);
  });

  return out;
}
github glimmerjs / glimmer-vm / packages / @glimmer / bundle-compiler / lib / specifiers.ts View on Github external
export function specifierFor(module: ModuleName, name: NamedExport = 'default'): Specifier {
  let specifiers = SPECIFIERS[module];

  if (!specifiers) specifiers = SPECIFIERS[module] = dict();

  let specifier = specifiers[name];

  if (!specifier) specifier = specifiers[name] = { module, name };

  return specifier;
}
github glimmerjs / glimmer-vm / packages / @glimmer / compiler / lib / builder-interface.ts View on Github external
entries(hash, (key, value) => {
    if (key === 'as') {
      blockParams = Array.isArray(value) ? value : [value];
    } else {
      out = out || dict();
      out[key] = normalizeExpression(value as BuilderExpression);
    }
  });
github glimmerjs / glimmer.js / packages / @glimmer / tracking / src / tracked.ts View on Github external
constructor(parent: Meta) {
    this.tags = dict();
    this.trackedProperties = parent ? Object.create(parent.trackedProperties) : dict();
  }
github glimmerjs / glimmer-vm / packages / @glimmer / compiler / lib / wire-format-debug.ts View on Github external
private formatHash(hash: WireFormat.Core.Hash): Option {
    if (hash === null) return null;

    return hash[0].reduce((accum, key, index) => {
      accum[key] = this.formatOpcode(hash[1][index]);
      return accum;
    }, dict());
  }
github glimmerjs / glimmer-vm / packages / @glimmer / compiler / lib / builder-interface.ts View on Github external
export function normalizeBuilderBlockStatement(
  statement: BuilderBlockStatement
): NormalizedBuilderBlockStatement {
  let head = statement[0];
  let blocks: NormalizedBlocks = dict();
  let params: Option = null;
  let hash: Option = null;
  let blockParams: Option = null;

  if (statement.length === 2) {
    blocks = normalizeBlocks(statement[1]);
  } else if (statement.length === 3) {
    if (Array.isArray(statement[1])) {
      params = normalizeParams(statement[1]);
    } else {
      ({ hash, blockParams } = normalizeBlockHash(statement[1]));
    }

    blocks = normalizeBlocks(statement[2]);
  } else if (statement.length === 4) {
    params = normalizeParams(statement[1]);
github glimmerjs / glimmer-vm / packages / @glimmer / object-reference / lib / meta.ts View on Github external
getReferenceTypes(): Dict> {
    this.referenceTypes = this.referenceTypes || dict>();
    return this.referenceTypes;
  }