{"_id":"@amarajs/plugin-doclet","_rev":"3-8fa6537e66e4d0799de046b3404b286f","name":"@amarajs/plugin-doclet","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@amarajs/plugin-doclet","version":"0.1.0","description":"Server-side plugin to provide doclet args to features.","main":"dist/amara-plugin-doclet.js","umd:main":"dist/amara-plugin-doclet.umd.js","jsnext:main":"src/index.js","scripts":{"build":"npm-run-all -p rollup:* -p minify:*","rollup:cjs":"rollup -c rollup.config.js -i src/index.js -f cjs -o dist/amara-plugin-doclet.js","rollup:umd":"rollup -c rollup.config.js -i src/index.js -f umd -o dist/amara-plugin-doclet.umd.js -n AmaraDoclet","minify:cjs":"uglifyjs dist/amara-plugin-doclet.js -cm toplevel -o dist/amara-plugin-doclet.min.js --source-map filename=dist/amara-plugin-doclet.min.js.map","minify:umd":"uglifyjs dist/amara-plugin-doclet.umd.js -cm toplevel -o dist/amara-plugin-doclet.umd.min.js --source-map filename=dist/amara-plugin-doclet.umd.min.js.map"},"keywords":["amarajs","server","plugin","doclet"],"author":{"name":"Dan Barnes","email":"amarajs.framework@gmail.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/amarajs/plugin-bundle.git"},"files":["src","dist"],"devDependencies":{"npm-run-all":"^4.1.2","rollup":"^0.57.1","rollup-plugin-buble":"^0.15.0","uglify-js":"^3.3.21"},"gitHead":"dcd6ea4891d79e7078e15a47093fc1624bc5007c","bugs":{"url":"https://github.com/amarajs/plugin-bundle/issues"},"homepage":"https://github.com/amarajs/plugin-bundle#readme","_id":"@amarajs/plugin-doclet@0.1.0","_npmVersion":"5.6.0","_nodeVersion":"8.9.4","_npmUser":{"name":"amarajs-dan","email":"amarajs.framework@gmail.com"},"dist":{"integrity":"sha512-a9Ikbpna1pNV7oo0QJjGpBQnNo1bWzQ97b6DUsmbZYz1T1dTfjcCHEmcO03S41fK7nZL9jzmQO0BnqtelPSTkg==","shasum":"a48bd8a460bb780eb0e97659f91bcf329a6435d4","tarball":"https://registry.npmjs.org/@amarajs/plugin-doclet/-/plugin-doclet-0.1.0.tgz","fileCount":10,"unpackedSize":12487,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCnorMem9j4GexUL+3IX4dIrOahwQ8Y6gLfvq7fKGOmcgIhAMKdRS0nKFKPs5sR1bzsgxZBOk1uZNLad611uPgngFaT"}]},"maintainers":[{"name":"amarajs-dan","email":"amarajs.framework@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/plugin-doclet_0.1.0_1523579260531_0.6755341082855479"},"_hasShrinkwrap":false},"0.1.1":{"name":"@amarajs/plugin-doclet","version":"0.1.1","description":"Server-side plugin to provide doclet args to features.","main":"dist/amara-plugin-doclet.js","umd:main":"dist/amara-plugin-doclet.umd.js","jsnext:main":"src/index.js","scripts":{"build":"npm-run-all -p rollup:* -p minify:*","rollup:cjs":"rollup -c rollup.config.js -i src/index.js -f cjs -o dist/amara-plugin-doclet.js","rollup:umd":"rollup -c rollup.config.js -i src/index.js -f umd -o dist/amara-plugin-doclet.umd.js -n AmaraDoclet","minify:cjs":"uglifyjs dist/amara-plugin-doclet.js -cm toplevel -o dist/amara-plugin-doclet.min.js --source-map filename=dist/amara-plugin-doclet.min.js.map","minify:umd":"uglifyjs dist/amara-plugin-doclet.umd.js -cm toplevel -o dist/amara-plugin-doclet.umd.min.js --source-map filename=dist/amara-plugin-doclet.umd.min.js.map"},"keywords":["amarajs","server","plugin","doclet"],"author":{"name":"Dan Barnes","email":"amarajs.framework@gmail.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/amarajs/plugin-doclet.git"},"files":["src","dist"],"devDependencies":{"npm-run-all":"^4.1.2","rollup":"^0.57.1","rollup-plugin-buble":"^0.15.0","uglify-js":"^3.3.21"},"gitHead":"1f6bbd31fe4da5b5aba7f3ee28ac1b7930cd86e7","bugs":{"url":"https://github.com/amarajs/plugin-doclet/issues"},"homepage":"https://github.com/amarajs/plugin-doclet#readme","_id":"@amarajs/plugin-doclet@0.1.1","_npmVersion":"5.6.0","_nodeVersion":"8.9.4","_npmUser":{"name":"amarajs-dan","email":"amarajs.framework@gmail.com"},"dist":{"integrity":"sha512-WD9SCYN8TZ3ns7zlhANP9aZRnWd8xDXAsIASTMD18TzKz13Lf7/3EgNf42S+FyfB3NgeVyzs5h5MfTCjnrxWAA==","shasum":"d3c6ae1c9d0e7501eb3f2374ba033c4cf51dced5","tarball":"https://registry.npmjs.org/@amarajs/plugin-doclet/-/plugin-doclet-0.1.1.tgz","fileCount":10,"unpackedSize":12487,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHePTUaFECldqKXbPov37SXKqwfH/ewxkuXK/tyU212XAiBxexhFxnA0V00tBhE4Gx9WJ27hdnXzDybZqIEofB7c/A=="}]},"maintainers":[{"name":"amarajs-dan","email":"amarajs.framework@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/plugin-doclet_0.1.1_1523579942707_0.13897434465101277"},"_hasShrinkwrap":false}},"time":{"created":"2018-04-13T00:27:40.482Z","0.1.0":"2018-04-13T00:27:40.625Z","modified":"2022-04-04T13:43:42.698Z","0.1.1":"2018-04-13T00:39:02.805Z"},"maintainers":[{"name":"amarajs-dan","email":"amarajs.framework@gmail.com"}],"description":"Server-side plugin to provide doclet args to features.","homepage":"https://github.com/amarajs/plugin-doclet#readme","keywords":["amarajs","server","plugin","doclet"],"repository":{"type":"git","url":"git+https://github.com/amarajs/plugin-doclet.git"},"author":{"name":"Dan Barnes","email":"amarajs.framework@gmail.com"},"bugs":{"url":"https://github.com/amarajs/plugin-doclet/issues"},"license":"MIT","readme":"## [@amarajs/plugin-doclet](https://github.com/amarajs/plugin-doclet)\n\nServer-side plugin to provide `doclets` args to features.\n\n### Installation\n\n`npm install --save @amarajs/plugin-doclet`\n\n### Usage\n\n```javascript\nconst Amara = require('@amarajs/core');\nconst AmaraPluginDoclet = require('@amarajs/plugin-doclet');\nconst AmaraPluginEngineServer = require('@amarajs/plugin-engine-server');\nconst amara = Amara([\n    AmaraPluginEngineServer(server),\n    AmaraPluginDoclet()\n]);\n```\n\n### Feature Type\n\nThe `@amarajs/plugin-doclet` middleware allows creates no new feature types; however, it does register a new `doclets` arg provider for use in your features. The doclets are determined by reading the file at the requested path and parsing any JSDoc-like doclets in the form:\n\n```javascript\n/**\n * @doclet QUANTIFIER value1 value2 ...\n */\n```\n\nWhere `QUANTIFIER` can be `ALL`, `NONE`, or `ANY` (aka `SOME`). If not provided, the default is `ALL`. Values will be converted to upper-case. For example:\n\n```javascript\n/**\n * @feature feature-123 feature-456\n * @role any admin power-user\n */\n```\n\nWould parse into the following `doclets` value:\n\n```javascript\ndoclets: {\n    feature: {\n        quantifier: 'ALL',\n        value: 'feature-123 feature-456'\n    },\n    role: {\n        quantifier: 'ANY',\n        value: 'admin power-user'\n    }\n}\n```\n\n#### Example Usage\n\n```javascript\n// exclude file content where the feature isn't configured\n\nconst switches = require('.config').switches;\nconst isActive = (feature) => !!switches[feature];\nconst whitespace = /\\s+/g;\nconst trim = (s) => s.trim();\n\namara.add({\n    type: 'transform', // from @amarajs/plugin-bundle\n    targets: ['GET /features/**/*.js'],\n    args: { feature: ({doclets}) => doclets.feature },\n    apply: ({feature}) => (code) => {\n        if (!feature) return code;\n        let active = false;\n        const {value = '', quantifier = 'ALL'} = feature;\n        const features = value.split(whitespace).map(trim);\n        switch (quantifier) {\n        case 'NONE':\n            active = !features.some(isActive);\n        case 'ANY':\n        case 'SOME':\n            active = features.some(isActive);\n        case 'ALL':\n            active = features.every(isActive);\n        }\n        return active ? code : '';\n    }\n});\n```\n\n### Customization\n\nThis plugin has no customization options.\n\n### Contributing\n\nIf you have a feature request, please create a new issue so the community can discuss it.\n\nIf you find a defect, please submit a bug report that includes a working link to reproduce the problem (for example, using [this fiddle](https://jsfiddle.net/04f3v2x4/)). Of course, pull requests to fix open issues are always welcome!\n\n### License\n\nThe MIT License (MIT)\n\nCopyright (c) Dan Barnes\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","readmeFilename":"README.md"}