subset method

InputStream subset (
  1. [int position,
  2. int length]

Return a InputStream to read a subset of this stream. It does not move the read position of this stream. position is specified relative to the start of the buffer. If position is not specified, the current read position is used. If length is not specified, the remainder of this stream is used.


InputStream subset([int position, int length]) {
  if (position == null) {
    position = offset;
  } else {
    position += start;

  if (length == null || length < 0) {
    length = _length - (position - start);

  return InputStream(buffer,
      byteOrder: byteOrder, start: position, length: length);