Skip to content
This repository was archived by the owner on Jul 15, 2021. It is now read-only.

Commit 7e9e4bf

Browse files
committed
Upgrade Tracer to ES2015. Refs #15
This isn't done but it is good enough to transpile now.
1 parent 5353b33 commit 7e9e4bf

File tree

2 files changed

+10
-118
lines changed

2 files changed

+10
-118
lines changed

lib/tracer.js

Lines changed: 0 additions & 108 deletions
This file was deleted.

src/tracer.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
* @copyright Code School 2015 {@link http://codeschool.com}
44
* @author Nick Wronski <nick@javascript.com>
55
*/
6-
var parserUtils = require('./parser-util');
6+
import {findLastIndex, takeWhile, findWhere, extend} from './parser-util';
77

8-
module.exports = (function (util) {
9-
Tracer = function Tracer() {
8+
export default (function () {
9+
function Tracer() {
1010
if (!(this instanceof Tracer)) {
1111
return new Tracer();
1212
}
@@ -31,8 +31,8 @@ module.exports = (function (util) {
3131
break;
3232
case 'rule.fail':
3333
// remove failed leaf
34-
lastIndex = util.findLastIndex(this.events, {rule: event.rule});
35-
lastWsIndex = util.findLastIndex(this.events, function (e) {
34+
lastIndex = findLastIndex(this.events, {rule: event.rule});
35+
lastWsIndex = findLastIndex(this.events, function (e) {
3636
return !that.whitespaceRule.test(e.rule);
3737
});
3838
if (that.whitespaceRule.test(event.rule) || lastIndex === lastWsIndex) {
@@ -58,7 +58,7 @@ module.exports = (function (util) {
5858
!that.whitespaceRule.test(e.rule);
5959
})
6060
.reverse();
61-
chain = util.takeWhile(namedEvents, function (elem) {
61+
chain = takeWhile(namedEvents, function (elem) {
6262
if (/^(sym\_semi)$/i.test(elem.rule)) {
6363
stmts += 1;
6464
}
@@ -77,10 +77,10 @@ module.exports = (function (util) {
7777
}
7878
return true;
7979
});
80-
80+
8181
if (chain.length) {
8282
location = bestNode.location;
83-
firstNode = util.findWhere(chain, function (elem) {
83+
firstNode = findWhere(chain, function (elem) {
8484
return that.firstNodeRule.test(elem.description) &&
8585
elem.description !== bestNode.description &&
8686
elem.indentation !== bestNode.indentation;
@@ -96,7 +96,7 @@ module.exports = (function (util) {
9696
chainDetail = bestNode.description;
9797
}
9898
message = 'Syntax error found near ' + chainDetail;
99-
util.extend(err, {
99+
extend(err, {
100100
'message': message,
101101
'location': location
102102
});
@@ -105,4 +105,4 @@ module.exports = (function (util) {
105105
};
106106

107107
return Tracer;
108-
})(parserUtils);
108+
})();

0 commit comments

Comments
 (0)