1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 1 1 1 419 419 1 49012 49012 149697 6946 6946 142751 1 1201 1201 1201 804 397 | module.exports = Position; var _ = require("lodash"); function Position() { this.line = 1; this.column = 0; } Position.prototype.push = function (str) { var self = this; _.each(str, function (cha) { if (cha === "\n") { self.line++; self.column = 0; } else { self.column++; } }); }; Position.prototype.unshift = function (str) { var self = this; _.each(str, function (cha) { if (cha === "\n") { self.line--; } else { self.column--; } }); }; |