get-annotation

1.1.0 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i get-annotation

Weekly Downloads

5

Version

1.1.0

License

ISC

Last publish

Collaborators

  • bencode