Stream.d.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * A stream represents an ordered sequence of tokens.
  3. */
  4. export declare class Stream {
  5. tokens: number[];
  6. /**
  7. *
  8. * @constructor
  9. * @param {!(Array.<number>|Uint8Array)} tokens Array of tokens that provide
  10. * the stream.
  11. */
  12. constructor(tokens: number[] | Uint8Array);
  13. /**
  14. * @return {boolean} True if end-of-stream has been hit.
  15. */
  16. endOfStream(): boolean;
  17. /**
  18. * When a token is read from a stream, the first token in the
  19. * stream must be returned and subsequently removed, and
  20. * end-of-stream must be returned otherwise.
  21. *
  22. * @return {number} Get the next token from the stream, or
  23. * end_of_stream.
  24. */
  25. read(): number;
  26. /**
  27. * When one or more tokens are prepended to a stream, those tokens
  28. * must be inserted, in given order, before the first token in the
  29. * stream.
  30. *
  31. * @param {(number|!Array.<number>)} token The token(s) to prepend to the
  32. * stream.
  33. */
  34. prepend(token: (number | Array<number>)): void;
  35. /**
  36. * When one or more tokens are pushed to a stream, those tokens
  37. * must be inserted, in given order, after the last token in the
  38. * stream.
  39. *
  40. * @param {(number|!Array.<number>)} token The tokens(s) to push to the
  41. * stream.
  42. */
  43. push(token: (number | Array<number>)): void;
  44. }