santinic/pampy.js

An option to fall through all the matchers

avalanche1 opened this issue · 0 comments

I would like a feature to be able to not stop matching if any pattern matches and continue to run matchers (except for the default _, of course).

match(id,
        () => typeof id === 'string', () => doEffect1,
        () => typeof id === 'string' && id.length > 5, () => doEffect2,
        () => typeof id === 'number', () => doEffect3,
        _,  (x) => x
);

Here if id === 'foobar' I would like to effects 1 and 2 to run.
In cur lib version it would do effect 1 and stop.
What I ask is similar to switch statement without breaks.