{"_id":"@gradecam/tsenum","_rev":"4079922","name":"@gradecam/tsenum","description":"Super simple typescript library for string-compatible enums","dist-tags":{"latest":"1.2.0"},"maintainers":[{"name":"bloveridge","email":""},{"name":"jaroml","email":""},{"name":"rgigger","email":""},{"name":"rumbcam","email":""},{"name":"taxilian","email":""}],"time":{"modified":"2025-10-16T23:04:57.000Z","created":"2019-08-14T20:04:19.398Z","1.2.0":"2019-08-21T00:40:02.746Z","1.1.0":"2019-08-20T20:02:57.827Z","1.0.0":"2019-08-14T20:04:19.398Z"},"users":{},"author":{"name":"Richard Bateman","email":"rbateman@gradecam.com"},"repository":{"type":"git","url":"git+https://github.com/gradecam/tsenum.git"},"versions":{"1.2.0":{"name":"@gradecam/tsenum","version":"1.2.0","description":"Super simple typescript library for string-compatible enums","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc -p .","clean":"rm -rf dist/","prepublish":"tsc -p .","test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/gradecam/tsenum.git"},"keywords":["typescript","enum"],"author":{"name":"Richard Bateman","email":"rbateman@gradecam.com"},"license":"ISC","bugs":{"url":"https://github.com/gradecam/tsenum/issues"},"devDependencies":{"bower":"^1.8.8","typescript":"~3.2.2"},"homepage":"https://github.com/gradecam/tsenum#readme","gitHead":"704599aa620504c6d1ad4213621ab31889564a1b","_id":"@gradecam/tsenum@1.2.0","_nodeVersion":"10.16.0","_npmVersion":"6.10.2","dist":{"shasum":"0c7c7c86e00e2d9ab8f242c695bec66b26b79319","size":2902,"noattachment":false,"key":"/@gradecam/tsenum/-/@gradecam/tsenum-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@gradecam/tsenum/download/@gradecam/tsenum-1.2.0.tgz"},"maintainers":[{"name":"bloveridge","email":""},{"name":"jaroml","email":""},{"name":"rgigger","email":""},{"name":"rumbcam","email":""},{"name":"taxilian","email":""}],"_npmUser":{"name":"taxilian","email":"taxilian@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/tsenum_1.2.0_1566348002603_0.11161209608848277"},"_hasShrinkwrap":false,"publish_time":1566348002746,"_cnpm_publish_time":1566348002746,"_cnpmcore_publish_time":"2021-12-16T15:49:02.801Z"},"1.1.0":{"name":"@gradecam/tsenum","version":"1.1.0","description":"Super simple typescript library for string-compatible enums","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc -p .","clean":"rm -rf dist/","prepublish":"tsc -p .","test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/gradecam/tsenum.git"},"keywords":["typescript","enum"],"author":{"name":"Richard Bateman","email":"rbateman@gradecam.com"},"license":"ISC","bugs":{"url":"https://github.com/gradecam/tsenum/issues"},"devDependencies":{"typescript":"~3.2.2"},"homepage":"https://github.com/gradecam/tsenum#readme","gitHead":"358c4b213fa35b75a2aad4ca19168a6918675206","_id":"@gradecam/tsenum@1.1.0","_nodeVersion":"10.16.0","_npmVersion":"6.10.2","dist":{"shasum":"4b6faa3bf763f5406ac6094593a222dc111e8d77","size":2774,"noattachment":false,"key":"/@gradecam/tsenum/-/@gradecam/tsenum-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@gradecam/tsenum/download/@gradecam/tsenum-1.1.0.tgz"},"maintainers":[{"name":"bloveridge","email":""},{"name":"jaroml","email":""},{"name":"rgigger","email":""},{"name":"rumbcam","email":""},{"name":"taxilian","email":""}],"_npmUser":{"name":"taxilian","email":"taxilian@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/tsenum_1.1.0_1566331373485_0.16475353262550918"},"_hasShrinkwrap":false,"publish_time":1566331377827,"_cnpm_publish_time":1566331377827,"_cnpmcore_publish_time":"2021-12-16T15:49:03.032Z"},"1.0.0":{"name":"@gradecam/tsenum","version":"1.0.0","description":"Super simple typescript library for string-compatible enums","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc -p .","clean":"rm -rf dist/","prepublish":"tsc -p .","test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/gradecam/tsenum.git"},"keywords":["typescript","enum"],"author":{"name":"Richard Bateman","email":"rbateman@gradecam.com"},"license":"ISC","bugs":{"url":"https://github.com/gradecam/tsenum/issues"},"devDependencies":{"typescript":"~3.2.2"},"homepage":"https://github.com/gradecam/tsenum#readme","gitHead":"7685720930425983644d596f5739de88d6057542","_id":"@gradecam/tsenum@1.0.0","_nodeVersion":"10.16.0","_npmVersion":"6.10.2","dist":{"shasum":"352ef6c284c93c314f86d634841d4c267faa9410","size":2038,"noattachment":false,"key":"/@gradecam/tsenum/-/@gradecam/tsenum-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@gradecam/tsenum/download/@gradecam/tsenum-1.0.0.tgz"},"maintainers":[{"name":"bloveridge","email":""},{"name":"jaroml","email":""},{"name":"rgigger","email":""},{"name":"rumbcam","email":""},{"name":"taxilian","email":""}],"_npmUser":{"name":"taxilian","email":"taxilian@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/tsenum_1.0.0_1565813059272_0.5802765658667663"},"_hasShrinkwrap":false,"publish_time":1565813059398,"_cnpm_publish_time":1565813059398,"_cnpmcore_publish_time":"2021-12-16T15:49:03.292Z"}},"readme":"\nDescription\n===========\n\nTypescript supports enum now, but there are times when you may want a little more flexibility than\nbuilt-in enums give you; this package was adapted from an example in a gist linked from a typescript\nissue which I cannot now find, but suffice it to say that though we have modified it a bit the idea\nis not original to us.\n\n\nInstalling\n==========\n\n    npm install --save @gradecam/tsenum\n\n\nBasic Usage\n===========\n\n    import {MakeEnum, TypeFromEnum} from 'tsenum';\n    \n    const Colors = MakeEnum({\n        Red: 'red',\n        Blue: 'blue',\n        Green: 'green',\n        Violet: 'violet',\n        Black: 'black'\n    });\n    type Colors = TypeFromEnum<typeof Colors>;\n\n    // type Colors = 'red' | 'blue' | 'green' | 'violet' | 'black'\n    // value Colors is a frozen object with the keys expected\n    // typeof Colors.Red is 'red', et al\n\n    carColor: Colors = 'red'; // valid\n    carColor = Colors.Green; // valid\n    carColor = 'yellow'; // typescript error, not a valid color\n\n\nCombining types\n===============\n\nMakeEnum will merge multiple enum objects into one (up to 9), allowing you to combine types.\n\n    import {MakeEnum, TypeFromEnum} from 'tsenum';\n    \n    const PrimaryColors = MakeEnum({\n        Red: 'red',\n        Blue: 'blue',\n        Green: 'green',\n    });\n    type PrimaryColors = TypeFromEnum<typeof PrimaryColors>;\n\n    const SecondaryColors = MakeEnum({\n        Yellow: 'yellow',\n        Cyan: 'cyan',\n        Magenta: 'magenta'\n    });\n    type SecondaryColors = TypeFromEnum<typeof SecondaryColors>;\n\n    const AllColors = MakeEnum(PrimaryColors, SecondaryColors);\n    type AllColors = TypeFromEnum<typeof AllColors>;\n    // type AllColors = 'red' | 'blue' | 'green' | 'yellow' | 'cyan' | 'magenta'\n\nGetting an array of possible values\n===================================\n\nSometimes you may want an array of possible values, such as when defining an enum type in a mongoose\nschema. Since the enum is an object, you can use `Object.values` to get that:\n\n    import {MakeEnum, TypeFromEnum} from 'tsenum';\n    \n    const PrimaryColors = MakeEnum({\n        Red: 'red',\n        Blue: 'blue',\n        Green: 'green',\n    });\n    type PrimaryColors = TypeFromEnum<typeof PrimaryColors>;\n\n    const PrimaryColorList = Object.values(PrimaryColors); // ['red', 'blue', 'green']\n    // typeof PrimaryColorList = Array<'red'|'blue'|'green'>\n\nAllowed value types\n===================\n\nCurrently you can use any string, number, or boolean as a value\n","_attachments":{},"homepage":"https://github.com/gradecam/tsenum#readme","bugs":{"url":"https://github.com/gradecam/tsenum/issues"},"license":"ISC"}