when-switch
when-switch copied to clipboard
Enable syntax `when.true`
To replace this use of the syntax :
when(true)
.is(assertion, value)
.is(assertion, value)
.else(defaultValue)
Update when-switch to enable this syntax :
when
.true(assertion, value)
.true(assertion, value)
.else(defaultValue)
To permit lazy evaluation in case of side effects of assertion or simply to prevent unnecessary calculation, (e.g. if needs to call a function), permit assertion to be wrapped in a thunk.
when
.true(obj.isBuffer(), true)
.else(defaultValue)
Becomes
when
.true(() => obj.isBuffer(), true)
.else(defaultValue)
Then the thunk will be unwrapped only when evaluating the true node.
#7 Hi, I know that this issue is already 3 years old but from all similar libraries I liked this one the most, so I wanted to improve it and I made an implementation of this syntax.