not
import { not } from 'patronum';// orimport { not } from 'patronum/not';
Motivation
The method allows to apply boolean NOT to a value.
Actually converts any “falsey” value into true
(null, 0, empty string).
But undefined
is not present, because Store cannot hold it inside.
Formulae
$result = not($value);
$result
store containsfalse
if$value
contains any “truthy” value, otherwise there will betrue
Arguments
$value: Store<T>
— Any value, that required to be “inverted”
Returns
$result: Store<boolean>
Example
const $isFinished = createStore(false);const $stillGoingOn = not($isFinished);
console.assert(true === $stillGoingOn.getState());
Alternative
const $isFinished = createStore(false);const $stillGoingOn = $isFinished.map((isFinished) => !isFinished);
console.assert(true === $stillGoingOn.getState());