Enumify modification by proposal http://goo.gl/XCh8Lc
npm install enumify-modA JavaScript / TypeScript library for enums - mod of Enumify.
```
npm i enumify-mod --save
- enumify implementation in typescript
- Support valueOf method`
javascript`
const Color = Enum.create('Color', ['RED', 'GREEN', 'BLUE']);
Color.GREEN.valueOf() === 1 // true
fromValue
- Support method`
javascript`
const Color = Enum.create('Color', {
RED: '#F00',
GREEN: '#0F0',
BLUE: {
alias: 'blue',
},
});
Color.fromValue('#0F0') === Color.GREEN // true
Color.fromValue(2) === Color.BLUE // true
fromName
- Support method`
javascript`
Color.fromName('GREEN') === Color.GREEN // true
Color.fromName('BLUE') === Color.BLUE // true
`
- Require repeating all values for avoiding creating additional type
`
class YesNoEnum extends Enum {
static YES;
static NO;
}
YesNoEnum.initEnum({
YES: true,
NO: false
});
YesNoEnum.YES.valueOf() === true // true
- npm t: Run test suitenpm start
- : Runs npm run build in watch modenpm run test:watch
- : Run test suite in interactive watch modenpm run test:prod
- : Run linting and generate coveragenpm run build
- : Generage bundles and typings, create docsnpm run lint
- : Lints codenpm run commit`: Commit using conventional commit style (husky will tell you to use it if you haven't :wink:)
-
@alexjoverm for nice TypeScript library starter