Socket
Book a DemoInstallSign in
Socket

snapdragon-position

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

snapdragon-position

Snapdragon util and plugin for patching the position on an AST node.

Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
3
-40%
Maintainers
1
Weekly downloads
 
Created
Source

snapdragon-position NPM version NPM monthly downloads NPM total downloads Linux Build Status

Snapdragon util and plugin for patching the position on an AST node.

Install

Install with npm:

$ npm install --save snapdragon-position

What is this?

Position is not always needed when parsing, and when converting an existing AST to a snapdragon AST the existing position information can be converted too.

This plugin adds a .position() method to the parser instance for cases when you do need position information on your AST nodes.

Usage

The main export if a function that is passed to snapdragon.use().

Example

var Snapdragon = require('snapdragon');
var position = require('snapdragon-position');
var parser = new Snapdragon.Parser();
parser.use(position());

position

Mark position and patch node.position with start and end line and column.

  • returns {Function}: Returns a function that takes node and is called before returning the node in a parser visitor function.

Example

parser.set('foo', function(node) {
  var pos = this.position();
  var match = this.match(/foo/);
  if (match) {
    // pass `pos` to `this.node` to patch position
    return pos(this.node(match[0]));
  }
});

About

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Please read the contributing guide for advice on opening issues, pull requests, and coding standards.

Building docs

(This document was generated by verb-generate-readme (a verb generator), please don't edit the readme directly. Any changes to the readme must be made in .verb.md.)

To generate the readme and API documentation with verb:

$ npm install -g verb verb-generate-readme && verb

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

Jon Schlinkert

License

Copyright © 2017, Jon Schlinkert. Released under the MIT license.

This file was generated by verb-generate-readme, v0.4.1, on January 20, 2017.

Keywords

generategenerator

FAQs

Package last updated on 21 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts