https://github.com/bencode/get-annotation
get annotation from source
https://github.com/bencode/get-annotation
Last synced: 6 months ago
JSON representation
get annotation from source
- Host: GitHub
- URL: https://github.com/bencode/get-annotation
- Owner: bencode
- Archived: true
- Created: 2016-05-18T15:50:26.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-06-22T02:25:05.000Z (almost 10 years ago)
- Last Synced: 2025-01-19T15:47:19.008Z (about 1 year ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# get-annotation
[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]
从源码中解析注解字段
```js
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
```
[npm-image]: https://img.shields.io/npm/v/get-annotation.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/get-annotation
[travis-image]: https://img.shields.io/travis/bencode/get-annotation/master.svg?style=flat-square
[travis-url]: https://travis-ci.org/bencode/get-annotation
[coveralls-image]: https://img.shields.io/codecov/c/github/bencode/get-annotation.svg?style=flat-square
[coveralls-url]: https://codecov.io/github/bencode/get-annotation?branch=master