def truthy
cswap-bend-cli@0.1.0.0 · daemon/config.bend:97
import cswap-bend-cli@0.1.0.0/daemon/config.bend as Config
import Base
import cswap-bend-cli@0.1.0.0/json.bend as Json
97
98def truthy(+m: Maybe<&2, Json.Json>, +d: Bool) -> Bool:
99 match m:
100 case Some{Json.JBool{b}}:
101 b
102 case Some{Json.JNull{}}:
103 False{}
104 case Some{Json.JStr{s}}:
105 Bool.not(String.is_empty(s))
106 case Some{Json.JNum{t}}:
107 Bool.not(String.eq(t, "0") || String.eq(t, "0.0"))
108 case Some{j}:
109 True{}
110 case None{}:
111 d