REFACTOR: computed lib (#7702)

This commit is contained in:
Joffrey JAFFEUX 2019-06-05 15:50:22 +02:00 committed by GitHub
parent df95457468
commit 0082a57718
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 9 deletions

View File

@ -103,17 +103,13 @@ export function endWith() {
const args = Array.prototype.slice.call(arguments, 0); const args = Array.prototype.slice.call(arguments, 0);
const substring = args.pop(); const substring = args.pop();
const computed = Ember.computed(function() { const computed = Ember.computed(function() {
const self = this; return args
return _.every( .map(a => this.get(a))
args.map(function(a) { .every(s => {
return self.get(a);
}),
function(s) {
const position = s.length - substring.length, const position = s.length - substring.length,
lastIndex = s.lastIndexOf(substring); lastIndex = s.lastIndexOf(substring);
return lastIndex !== -1 && lastIndex === position; return lastIndex !== -1 && lastIndex === position;
} });
);
}); });
return computed.property.apply(computed, args); return computed.property.apply(computed, args);
} }
@ -128,5 +124,5 @@ export function endWith() {
export function setting(name) { export function setting(name) {
return Ember.computed(function() { return Ember.computed(function() {
return Discourse.SiteSettings[name]; return Discourse.SiteSettings[name];
}).property(); });
} }