[Pkg-javascript-commits] [node-syntax-error] 42/47: ecma version 8

Bastien Roucariès rouca at moszumanska.debian.org
Fri Aug 25 19:30:03 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-syntax-error.

commit 7b5c83faaadc006fdfffc8bdb2ab0ef8017dcd01
Author: substack <substack at 9nTgtYmvW4HID6ayt6Icwc8WZxdifx5SlSKKIX/X/1g=.ed25519>
Date:   Wed Mar 1 12:51:46 2017 -1000

    ecma version 8
---
 index.js        | 13 +++++++------
 readme.markdown |  6 +++++-
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/index.js b/index.js
index 9048d77..fed565c 100644
--- a/index.js
+++ b/index.js
@@ -1,12 +1,13 @@
 var aparse = require('acorn').parse;
-function parse (src) {
+function parse (src, opts) {
+    if (!opts) opts = {}
     return aparse(src, {
-        ecmaVersion: 6,
+        ecmaVersion: opts.ecmaVersion || 8,
         allowHashBang: true
     });
 }
 
-module.exports = function (src, file) {
+module.exports = function (src, file,opts) {
     if (typeof src !== 'string') src = String(src);
     
     try {
@@ -16,12 +17,12 @@ module.exports = function (src, file) {
     catch (err) {
         if (err === 'STOP') return undefined;
         if (err.constructor.name !== 'SyntaxError') return err;
-        return errorInfo(src, file);
+        return errorInfo(src, file, opts);
     }
 };
 
-function errorInfo (src, file) {
-    try { parse(src) }
+function errorInfo (src, file, opts) {
+    try { parse(src,opts) }
     catch (err) {
         return new ParseError(err, src, file);
     }
diff --git a/readme.markdown b/readme.markdown
index d9acd73..7025150 100644
--- a/readme.markdown
+++ b/readme.markdown
@@ -45,7 +45,7 @@ ParseError: Unexpected identifier
 var check = require('syntax-error')
 ```
 
-## var err = check(src, file)
+## var err = check(src, file, opts={})
 
 Check the source code string `src` for syntax errors.
 Optionally you can specify a filename `file` that will show up in the output.
@@ -55,6 +55,10 @@ stringified.
 
 If there are no syntax errors in `src`, return `undefined`.
 
+Optionally set:
+
+* `opts.ecmaVersion` - default: 8
+
 ## err.toString()
 
 Return the long string description with a source snippet and a `^` under

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-syntax-error.git



More information about the Pkg-javascript-commits mailing list