Files
babel/src/babel/generation/position.js
Sebastian McKenzie 553eb2d45e more classes!
2015-02-26 12:19:28 +11:00

28 lines
452 B
JavaScript

export default class Position {
constructor() {
this.line = 1;
this.column = 0;
}
push(str) {
for (var i = 0; i < str.length; i++) {
if (str[i] === "\n") {
this.line++;
this.column = 0;
} else {
this.column++;
}
}
}
unshift(str) {
for (var i = 0; i < str.length; i++) {
if (str[i] === "\n") {
this.line--;
} else {
this.column--;
}
}
}
}