Created
April 24, 2018 02:17
-
-
Save Devcon4/0d7a6783a72d93dbb972bb2ff5b6f140 to your computer and use it in GitHub Desktop.
Fun with dynamic literals!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const number = /(?:sbyte|ushort|short|uint|int|ulong|long|float|double|decimal|byte)/; | |
| const string = /(?:char|string)/; | |
| const bool = /(?:bool)/; | |
| const date = /(?:DateTime)/; | |
| let builder = { | |
| accessModifier: 'public', | |
| name: 'test', | |
| type: 'int' | |
| }; | |
| let checkObj = { | |
| [+true]: 'Any', | |
| [+number.test(builder.type)]: 'number', | |
| [+string.test(builder.type)]: 'string', | |
| [+bool.test(builder.type)]: 'boolean', | |
| [+date.test(builder.type)]: 'moment.Moment', | |
| }; | |
| return `${builder.accessModifier} ${builder.name}: ${checkObj[+true]}`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment