Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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');
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();
}
}),
_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);
}
}
},
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;
}
}
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;
}
}
}
});