Functional enum type for javascript with pattern matching
Read more about SumTypes using EnumFP in this blog post
To add this package to your project
yarn add enum-fp
Or if you are one of those npm or pnpm nuts
npm i --save enum-fp
pnpm i --save enum-fp
Import it to your file
import Enum from 'enum-fp';
const Action = Enum([ 'Add', 'Edit', 'Delete', 'Get' ]);
// Or with a fixed number of arguments
const Maybe = Enum({
Just: [ 'value' ],
Nothing: [],
});
const action = Action.Edit(2, 'Hello world');