1.1.0 • Published 8 years ago

get-annotation v1.1.0

Weekly downloads
3
License
ISC
Repository
github
Last release
8 years ago

get-annotation

NPM version build status Test coverage

从源码中解析注解字段

const body = `
/*
 *
 * @entry
 *
 * @path: /a/b-c/hello
 *
 * @lessbuild: false
 *
 * @ignore: true
 *
 * @webpack.entry
 *
 * @server.url: http://www.google.com
 *
 * @count: 1234
 * @price: 12.34
 */
...some code
`

const getAnnotation = require('get-annotation');

getAnnotation(body, 'entry')            // true
getAnnotation(body, 'path')             // '/a/b-c/hello'
getAnnotation(body, 'lessbuild')        // false
getAnnotation(body, 'ignore')           // true
getAnnotation(body, 'webpack.entry')    // true
getAnnotation(body, 'server.url')       // 'http://www.google.com'
getAnnotation(body, 'count')            // 1234
getAnnotation(body, 'price')            // 12.34