{"_id":"token-stream","_rev":"86604","name":"token-stream","description":"Take an array of token and produce a more useful API to give to a parser","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"alubbe","email":"npm@lubbe.org"},{"name":"bloodyowl","email":"mlbli@me.com"},{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},{"name":"jbnicolai","email":"jappelman@xebia.com"},{"name":"timothygu","email":"timothygu99@gmail.com"}],"time":{"modified":"2021-06-03T10:28:07.000Z","created":"2014-11-20T13:28:14.796Z","1.0.0":"2016-06-01T05:34:32.722Z","0.0.1":"2014-11-20T13:28:14.796Z"},"users":{"robinblomberg":true},"author":{"name":"ForbesLindesay"},"repository":{"type":"git","url":"git+https://github.com/pugjs/token-stream.git"},"versions":{"1.0.0":{"name":"token-stream","version":"1.0.0","description":"Take an array of token and produce a more useful API to give to a parser","dependencies":{},"devDependencies":{"istanbul":"*"},"scripts":{"test":"node test && npm run coverage","coverage":"istanbul cover test"},"repository":{"type":"git","url":"git+https://github.com/pugjs/token-stream.git"},"author":{"name":"ForbesLindesay"},"license":"MIT","gitHead":"a0a9100a450c5e0db9ead52cdd4455da376d8ce5","bugs":{"url":"https://github.com/pugjs/token-stream/issues"},"homepage":"https://github.com/pugjs/token-stream#readme","_id":"token-stream@1.0.0","_shasum":"cc200eab2613f4166d27ff9afc7ca56d49df6eb4","_from":".","_npmVersion":"3.8.9","_nodeVersion":"6.2.0","_npmUser":{"name":"timothygu","email":"timothygu99@gmail.com"},"dist":{"shasum":"cc200eab2613f4166d27ff9afc7ca56d49df6eb4","size":2310,"noattachment":false,"key":"/token-stream/-/token-stream-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/token-stream/download/token-stream-1.0.0.tgz"},"maintainers":[{"name":"alubbe","email":"npm@lubbe.org"},{"name":"bloodyowl","email":"mlbli@me.com"},{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},{"name":"jbnicolai","email":"jappelman@xebia.com"},{"name":"timothygu","email":"timothygu99@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/token-stream-1.0.0.tgz_1464759272310_0.31107465783134103"},"directories":{},"publish_time":1464759272722,"_cnpm_publish_time":1464759272722,"_hasShrinkwrap":false},"0.0.1":{"name":"token-stream","version":"0.0.1","description":"Take an array of token and produce a more useful API to give to a parser","dependencies":{},"devDependencies":{"istanbul":"^0.3.2"},"scripts":{"test":"node test && npm run coverage","coverage":"istanbul cover test"},"repository":{"type":"git","url":"https://github.com/jadejs/token-stream.git"},"author":{"name":"ForbesLindesay"},"license":"MIT","gitHead":"f41daf0266e179dd3570f1256ad683ce9cf6a235","bugs":{"url":"https://github.com/jadejs/token-stream/issues"},"homepage":"https://github.com/jadejs/token-stream","_id":"token-stream@0.0.1","_shasum":"ceeefc717a76c4316f126d0b9dbaa55d7e7df01a","_from":".","_npmVersion":"1.5.0-alpha-4","_npmUser":{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},"maintainers":[{"name":"alubbe","email":"npm@lubbe.org"},{"name":"bloodyowl","email":"mlbli@me.com"},{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},{"name":"jbnicolai","email":"jappelman@xebia.com"},{"name":"timothygu","email":"timothygu99@gmail.com"}],"dist":{"shasum":"ceeefc717a76c4316f126d0b9dbaa55d7e7df01a","size":2182,"noattachment":false,"key":"/token-stream/-/token-stream-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/token-stream/download/token-stream-0.0.1.tgz"},"directories":{},"publish_time":1416490094796,"_cnpm_publish_time":1416490094796,"_hasShrinkwrap":false}},"readme":"# token-stream\n\nTake an array of token and produce a more useful API to give to a parser.\n\n[![Build Status](https://img.shields.io/travis/pugjs/token-stream/master.svg)](https://travis-ci.org/pugjs/token-stream)\n[![Dependency Status](https://img.shields.io/david/pugjs/token-stream.svg)](https://david-dm.org/pugjs/token-stream)\n[![NPM version](https://img.shields.io/npm/v/token-stream.svg)](https://www.npmjs.org/package/token-stream)\n\n## Installation\n\n    npm install token-stream\n\n## Usage\n\n```js\nvar TokenStream = require('token-stream');\n\nvar stream = new TokenStream([\n  'a',\n  'b',\n  'c',\n  'd'\n]);\nassert(stream.peek() === 'a');\nassert(stream.lookahead(0) == 'a');\nassert(stream.lookahead(1) == 'b');\n\nassert(stream.advance() === 'a');\nassert(stream.peek() === 'b');\nassert(stream.lookahead(0) == 'b');\nassert(stream.lookahead(1) == 'c');\n\nstream.defer('z');\nassert(stream.peek() === 'z');\nassert(stream.lookahead(0) == 'z');\nassert(stream.lookahead(1) == 'b');\nassert(stream.advance() === 'z');\nassert(stream.advance() === 'b');\nassert(stream.advance() === 'c');\nassert(stream.advance() === 'd');\n\n// an error is thrown if you try and advance beyond the end of the stream\nassert.throws(function () {\n  stream.advance();\n});\n```\n\n## API\n\n### stream.peek()\n\nGets and returns the next item in the stream without advancing the stream's position.\n\n### stream.advance()\n\nReturns the next item in the stream and advances the stream by one item.\n\n### stream.defer(token)\n\nPut a token on the start of the stream (useful if you need to back track after calling advance).\n\n### stream.lookahead(index)\n\nReturn the item at `index` position from the start of the stream, but don't advance the stream.  `stream.lookahead(0)` is equivalent to `stream.peek()`.\n\n## License\n\n  MIT\n","_attachments":{},"homepage":"https://github.com/pugjs/token-stream#readme","bugs":{"url":"https://github.com/pugjs/token-stream/issues"},"license":"MIT"}