Lines Matching refs:stream

1 # token-stream
5 …s](https://img.shields.io/travis/jadejs/token-stream/master.svg)](https://travis-ci.org/jadejs/tok…
6 …s](https://img.shields.io/gemnasium/jadejs/token-stream.svg)](https://gemnasium.com/jadejs/token-s…
7 …[NPM version](https://img.shields.io/npm/v/token-stream.svg)](https://www.npmjs.org/package/token-
11 npm install token-stream
16 var TokenStream = require('token-stream');
18 var stream = new TokenStream([
24 assert(stream.peek() === 'a');
25 assert(stream.lookahead(0) == 'a');
26 assert(stream.lookahead(1) == 'b');
28 assert(stream.advance() === 'a');
29 assert(stream.peek() === 'b');
30 assert(stream.lookahead(0) == 'b');
31 assert(stream.lookahead(1) == 'c');
33 stream.defer('z');
34 assert(stream.peek() === 'z');
35 assert(stream.lookahead(0) == 'z');
36 assert(stream.lookahead(1) == 'b');
37 assert(stream.advance() === 'z');
38 assert(stream.advance() === 'b');
39 assert(stream.advance() === 'c');
40 assert(stream.advance() === 'd');
42 // an error is thrown if you try and advance beyond the end of the stream
44 stream.adavance();
50 ### stream.peek()
52 Gets and returns the next item in the stream without advancing the stream's position.
54 ### stream.advance()
56 Returns the next item in the stream and advances the stream by one item.
58 ### stream.defer(token)
60 Put a token on the start of the stream (useful if you need to back track after calling advance.
62 ### stream.lookahead(index)
64 …x` position from the start of the stream, but don't advance the stream. `stream.lookahead(0)` is …