mirror of
https://github.com/discourse/discourse.git
synced 2024-12-14 15:01:07 +08:00
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;
|
||
|
}
|
||
|
}
|