in packages/sqrl-common/src/SqrlObject.ts [48:69]
static isTruthy(obj) {
if (!obj) {
// Any javascript falsy values are 'falsy'
return false;
} else if (typeof obj !== "object") {
// Any truthy non-objects are 'truthy'
return true;
} else if (obj instanceof Buffer) {
// Arrays/Buffers are truthy if their length>0
return obj.length > 0;
} else if (Array.isArray(obj)) {
// Truthy arrays must contain at least one non null value.
return obj.some((v) => v !== null);
} else if (obj instanceof Set) {
// Sets are truthy if their size>0
return obj.size > 0;
} else {
// @TODO: We should invariant on SqrlObject or simple object here, but
// that is not enforcable (yet.)
return !isEmptyObject(obj);
}
}