All new
alle new
This commit is contained in:
1 parent
da64472251
commit
5b20adee48
1605 files changed
+396517
-1674
No files matched your search
+28
@@ -0,0 +1,28 @@
|
||||
var TokenIterator = module.exports = function(tokens, startIndex) {
|
||||
this._tokens = tokens;
|
||||
this._startIndex = startIndex || 0;
|
||||
};
|
||||
|
||||
TokenIterator.prototype.head = function() {
|
||||
return this._tokens[this._startIndex];
|
||||
};
|
||||
|
||||
TokenIterator.prototype.tail = function(startIndex) {
|
||||
return new TokenIterator(this._tokens, this._startIndex + 1);
|
||||
};
|
||||
|
||||
TokenIterator.prototype.toArray = function() {
|
||||
return this._tokens.slice(this._startIndex);
|
||||
};
|
||||
|
||||
TokenIterator.prototype.end = function() {
|
||||
return this._tokens[this._tokens.length - 1];
|
||||
};
|
||||
|
||||
// TODO: doesn't need to be a method, can be a separate function,
|
||||
// which simplifies implementation of the TokenIterator interface
|
||||
TokenIterator.prototype.to = function(end) {
|
||||
var start = this.head().source;
|
||||
var endToken = end.head() || end.end();
|
||||
return start.to(endToken.source);
|
||||
};
|
||||
Reference in new issue
Block a user