Acme.BookStore.HttpApi.Host/node_modules/snapdragon-node/README.md
(开头部分) 11KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
# snapdragon-node [](https://www.npmjs.com/package/snapdragon-node) [](https://npmjs.org/package/snapdragon-node) [](https://npmjs.org/package/snapdragon-node) [](https://travis-ci.org/jonschlinkert/snapdragon-node)
> Snapdragon utility for creating a new AST node in custom code, such as plugins.
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install --save snapdragon-node
```
## Usage
With [snapdragon](https://github.com/jonschlinkert/snapdragon) v0.9.0 and higher you can use `this.node()` to create a new `Node`, whenever it makes sense.
```js
var Node = require('snapdragon-node');
var Snapdragon = require('snapdragon');
var snapdragon = new Snapdragon();
// example usage inside a parser visitor function
snapdragon.parser.set('foo', function() {
// get the current "start" position
var pos = this.position();
// returns the match if regex matches the substring
// at the current position on `parser.input`
var match = this.match(/foo/);
if (match) {
// call "pos" on the node, to set the start and end
// positions, and return the node to push it onto the AST
// (snapdragon will push the node onto the correct
// nodes array, based on the stack)
return pos(new Node({type: 'bar', val: match[0]}));
}
});
```
## API
### [Node](index.js#L22)
Create a new AST `Node` with the given `val` and `type`.
**Params**
* `val` **{String|Object}**: Pass a matched substring, or an object to merge onto the node.
* `type` **{String}**: The node type to use when `val` is a string.
* `returns` **{Object}**: node instance
**Example**
```js
var node = new Node('*', 'Star');
var node = new Node({type: 'star', val: '*'});
```
### [.isNode](index.js#L61)
后面还有 393 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
