Parse pragma and its content from JavaScript comments
npm install pragma   
> Parse pragma and its content from JavaScript comments
``bash`
yarn add pragma
`js
const pragma = require('pragma')
pragma(
function foo() {}
/* @babel {
presets: ['es2015']
} */
function bar() {}
/* @server {
port: 3000
}
*/)
//=> what you get:
{
babel: {
presets: ['es2015']
},
server: {
port: 3000
}
}
`
Both multi-line / ... / and single-line // ... comments are supported.
#### input
Type: stringtrue
Required:
#### options
#### parseContent
Type: function
Default: source => new Function(`return ${source}`)()
The function to process source content, for example: //@server {port: 1}, the source content is {port: 1} and it will be evaluated.
1. Fork it!
2. Create your feature branch: git checkout -b my-new-featuregit commit -am 'Add some feature'
3. Commit your changes: git push origin my-new-feature`
4. Push to the branch:
5. Submit a pull request :D
pragma © egoist, Released under the MIT License.
Authored and maintained by egoist with help from contributors (list).
> egoistian.com · GitHub @egoist · Twitter @rem_rin_rin