mirror of
https://github.com/discourse/discourse.git
synced 2024-12-04 05:13:39 +08:00
18777d9108
The implemented helpers, are helper which might be in Ember core in the future: - and - or - not - eq - not-eq - lt - lte - gt - gte They follow the implementation of ember-truth-helpers: https://github.com/jmurphyau/ember-truth-helpers Note 1: Ember rfcs are still debating going with {{not-eq}} or {{neq}}, should be easy to support in the future whatever is finally chosen. Note 2: this commit also moves it to its own addon, and removes the {{not}} test, to simplify further updates.
16 lines
341 B
JavaScript
16 lines
341 B
JavaScript
import { isArray } from "@ember/array";
|
|
import { get } from "@ember/object";
|
|
|
|
export default function truthConvert(result) {
|
|
const truthy = result && get(result, "isTruthy");
|
|
if (typeof truthy === "boolean") {
|
|
return truthy;
|
|
}
|
|
|
|
if (isArray(result)) {
|
|
return get(result, "length") !== 0;
|
|
} else {
|
|
return !!result;
|
|
}
|
|
}
|