var-find
Find and return indexes of variable declarations.
This was built to run inside of twolfson/sublime-js-var-shortcuts, a Sublime Text plugin to make dealing with adding/removing vars
easier.
Getting Started
Install the module with: npm install var-find
var varFind = ;;// [{// "start": 78,// "end": 92,// "vars": [{// "start": 82,// "end": 91// }]// }]
Documentation
varFind
is a function that takes in a JS source code.
;/** * varFind parses JS source code and returns locations of variable groups and declarations * @param * @returns * @returns * @returns * @returns * @returns * @returns * @returns * @returns */
Examples
For visual representation, variable groups begin and end with [
and ]
; for variable declarations, {
and }
.
Single definition:
var abc = 123; console;
Comma-last definition:
var abc def; console;
Comma-first definition:
var abc def; console;
Trailing whitespace (with semicolon):
Trailing whitespace without semicolon is considered another statement and ignored.
var abc = 123 ; console;
Donating
Support this project and others by twolfson via gittip.
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint via grunt and test via npm test
.
Unlicense
As of Sep 27 2013, Todd Wolfson has released this repository and its contents to the public domain.
It has been released under the UNLICENSE.