How to use the ember-intl/utils/streams.Stream function in ember-intl

To help you get started, we’ve selected a few ember-intl 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 ember-intl / ember-intl / addon / helpers / -base-legacy.js View on Github external
return function legacyIntlHelper(params, hash, options, env) {
    let view = env.data.view;
    let intl = view.container.lookup('service:intl');
    let value = optionalGetValue(params, hash, intl);

    if (typeof value === 'undefined') {
      throw new Error(`format-${formatType} helper requires value`);
    }

    let formatter = view.container.lookup(`ember-intl@formatter:format-${formatType}`);

    let out = new Stream(() => {
      let seenHash = readHash(hash);
      let seenValue = read(value);
      let format = {};

      if (seenValue && seenValue instanceof LiteralWrapper) {
        seenValue = seenValue.value;
      }

      if (optionalReturnEmpty && optionalReturnEmpty(seenValue, seenHash)) {
        return;
      }

      if (seenHash && seenHash.format) {
        format = intl.getFormat(formatType, seenHash.format);
      }