<script src="node_modules/solid-choice/src/index.js"></script>
<script src="https://unpkg.com/solid-choice"></script>
<script>
choose([]);
</script>
import choose from 'solid-choice';
const choice = choose([
[{ object: { value: 'match' } }, object => 'object match'],
[string => string === 'valid', string => 'validation function match'],
[{ valid: v => v === 'valid', str: 'str' }, object => 'multiple type match']
]);
choice({ object: { value: 'match' } });
choice('valid');
choice({ valid: 'valid', str: 'str' });
choice(3);
choice('invalid');
import choose, {
is,
type,
empty,
any,
not,
and,
or
} from 'solid-choice';
const choice = choose([
[ or([ is(Number), is(String) ]), () => 'is number or string' ],
[ and([ type('object'), empty() ]), () => 'is null' ],
[ not(type('function')), () => 'not function' ],
[ any(), () => 'any non matched value' ]
]);
choice(1);
choice(null);
choice({});
choice(() => {});
import choose from 'solid-choice';
const choice = choose();
choice.where({ fromWhere: true }, () => 'from where');
choice({ fromWhere: true });
import choose, { is } from 'solid-choice';
const choice = choose([ [is(Number), () => 'is number'] ]);
choice.def(() => 'last resource');
choice(3);
choice('');