Permalink
Browse files

pass options directly to esprima

  • Loading branch information...
1 parent 7546a5e commit a9d1ebe71696b7bd57a776e53bcc59b2a96c62c1 @substack committed May 15, 2012
Showing with 9 additions and 1 deletion.
  1. +9 −1 index.js
View
@@ -1,8 +1,16 @@
var parse = require('esprima').parse;
module.exports = function (src, fn) {
+ var opts = {};
+ if (typeof src === 'object') {
+ opts = src;
+ src = opts.source;
+ delete opts.source;
+ }
+ opts.range = true;
if (typeof src !== 'string') src = String(src);
- var ast = parse(src, { range : true });
+
+ var ast = parse(src, opts);
var output = src.split('');
var index = 0;

0 comments on commit a9d1ebe

Please sign in to comment.