Uploading the main structure

هذا الالتزام موجود في:
2025-08-18 23:23:28 +03:00
التزام e696f2f4cd
1011 ملفات معدلة مع 275020 إضافات و0 حذوفات

30
node_modules/token-stream/index.js مولّد مباع Normal file
عرض الملف

@@ -0,0 +1,30 @@
'use strict';
module.exports = TokenStream;
function TokenStream(tokens) {
if (!Array.isArray(tokens)) {
throw new TypeError('tokens must be passed to TokenStream as an array.');
}
this._tokens = tokens;
}
TokenStream.prototype.lookahead = function (index) {
if (this._tokens.length <= index) {
throw new Error('Cannot read past the end of a stream');
}
return this._tokens[index];
};
TokenStream.prototype.peek = function () {
if (this._tokens.length === 0) {
throw new Error('Cannot read past the end of a stream');
}
return this._tokens[0];
};
TokenStream.prototype.advance = function () {
if (this._tokens.length === 0) {
throw new Error('Cannot read past the end of a stream');
}
return this._tokens.shift();
};
TokenStream.prototype.defer = function (token) {
this._tokens.unshift(token);
};