How to use the ember-runtime/utils.isArray function in ember-runtime

To help you get started, we’ve selected a few ember-runtime 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-htmlbars / lib / hooks / link-render-node.js View on Github external
let stream = chain(predicate, () => {
    let predicateVal = read(predicate);
    let lengthVal = read(length);
    let isTruthyVal = read(isTruthy);

    if (isArray(predicateVal)) {
      return lengthVal > 0 ? coercer(predicateVal) : false;
    }

    if (typeof isTruthyVal === 'boolean') {
      return isTruthyVal ? coercer(predicateVal) : false;
    }

    return coercer(predicateVal);
  }, 'ShouldDisplay');
github emberjs / ember.js / packages / ember-views / lib / views / select.js View on Github external
selectionDidChange: observer('selection.[]', function() {
    var selection = get(this, 'selection');
    if (get(this, 'multiple')) {
      if (!isArray(selection)) {
        set(this, 'selection', emberA([selection]));
        return;
      }
      this._selectionDidChangeMultiple();
    } else {
      this._selectionDidChangeSingle();
    }
  }),
github emberjs / ember.js / packages / ember-views / lib / views / select.js View on Github external
_changeMultiple(hasDOM) {
    var options = hasDOM !== false ? this.$('option:selected') : [];
    var prompt = get(this, 'prompt');
    var offset = prompt ? 1 : 0;
    var content = get(this, 'content');
    var selection = get(this, 'selection');

    if (!content) { return; }
    if (options) {
      var selectedIndexes = options.map(function() {
        return this.index - offset;
      });
      var newSelection = content.objectsAt([].slice.call(selectedIndexes));

      if (isArray(selection)) {
        replace(selection, 0, get(selection, 'length'), newSelection);
      } else {
        set(this, 'selection', newSelection);
      }
    }
  },
github emberjs / ember.js / packages / ember-htmlbars / lib / streams / should_display.js View on Github external
if (isStream(predicate)) {
    return new ShouldDisplayStream(predicate);
  }

  let type = typeof predicate;

  if (type === 'boolean') { return predicate; }

  if (type && type === 'object' && predicate !== null) {
    let isTruthy = get(predicate, 'isTruthy');
    if (typeof isTruthy === 'boolean') {
      return isTruthy;
    }
  }

  if (isArray(predicate)) {
    return get(predicate, 'length') !== 0;
  } else {
    return !!predicate;
  }
}
github emberjs / ember.js / packages / ember-htmlbars / lib / streams / should_display.js View on Github external
revalidate() {
    if (isArray(read(this.predicate))) {
      if (!this.lengthDep) {
        this.lengthDep = this.addMutableDependency(this.predicate.get('length'));
      }
    } else {
      if (this.lengthDep) {
        this.lengthDep.destroy();
        this.lengthDep = null;
      }
    }
  }
});