[Pkg-javascript-commits] [node-syntax-error] 02/47: working example
Bastien Roucariès
rouca at moszumanska.debian.org
Fri Aug 25 19:29:57 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 73005127bf696d23117893579ceef1fc083a5b5d
Author: James Halliday <mail at substack.net>
Date: Thu Aug 2 00:01:33 2012 -0700
working example
---
example/check.js | 12 ++++++++++++
example/src.js | 9 +++++++++
index.js | 7 +------
3 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/example/check.js b/example/check.js
new file mode 100644
index 0000000..a6d51fc
--- /dev/null
+++ b/example/check.js
@@ -0,0 +1,12 @@
+var fs = require('fs');
+var check = require('../');
+
+var file = __dirname + '/src.js';
+var src = fs.readFileSync(file);
+
+var err = check(src, file);
+if (err) {
+ console.error('ERROR DETECTED' + Array(62).join('!'));
+ console.error(err);
+ console.error(Array(76).join('-'));
+}
diff --git a/example/src.js b/example/src.js
new file mode 100644
index 0000000..51a63e7
--- /dev/null
+++ b/example/src.js
@@ -0,0 +1,9 @@
+module.exports = function (xs, fn) {
+ var res = [];
+ for (var i = 0; i < xs.length; i++) {
+ var x = fn(xs[i], i);
+ if (Array.isArray(x) res.push.apply(res, x);
+ else res.push(x);
+ }
+ return res;
+};
diff --git a/index.js b/index.js
index 190ff37..030d6f2 100644
--- a/index.js
+++ b/index.js
@@ -50,10 +50,5 @@ ParseError.prototype.toString = function () {
};
ParseError.prototype.inspect = function () {
- return '[ParseError: '
- + this.message
- + ', '
- + '(line ' + this.line + ', column ' + this.column + ')'
- + ']'
- ;
+ return this.annotated;
};
--
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