1.1.0 • Published 10 years ago

js-code-context v1.1.0

Weekly downloads
1
License
-
Repository
github
Last release
10 years ago

js-code-context

RegExp expressions to parse javascript code context - for node and the browser.

NPM version Using ferver Build Status

Install Nodei.co stats

Install with npm

$ npm install js-code-context

Usage & Example

For a more comprehensive examples, see the tests.

var fs = require('fs');
var parseCodeContext = require('js-code-context');
var context = fs.readFileSync('./fixture.js','utf-8');

parseCodeContext(context, function(err, obj) {
  console.log(obj)
  //=> returns array of parsed objects
});

parseCodeContext(context, 6, function(err, obj) {
  console.log(obj)
  //=> returns array with 1 object for parsed 7th line of context
});

var response = parseCodeContext.sync(context, 6);
//=> returns array with 1 object for parsed 7th line of context
//=> or array with error object

CLI

CLI uses .sync method. But it's not so sync, if we must be honest - in fact it's asynchronous. It just returns resulted array in variable, not in callback.

$ npm install --global js-code-context
$ jsCodeContext --help

Options
  --help | -h  show help
  --line | -l  specify which line to parse
  --file | -f  file that want to parse

Example
  $ jsCodeContext -f ./test/fixture.js -l 6
  //=> array with one object

Tests

As usual - npm test or if you have mocha globally - mocha.

$ npm test

Authors & Contributors author tips

Charlike Mike Reagent

License MIT license

Copyright (c) 2014 Charlike Mike Reagent, contributors.
Released under the MIT license.

1.1.0

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.0.1

10 years ago