Object built-in object

ObjectRangeStream

Range query stream reading object

RangeStream objects are used toSeekableStreamObject data is intercepted. Creation method:

1 2 3 4 5
var stm = new io.RangeStream(stream, '0-10'); stm.end // 11 var stm = new io.RangeStream(stream, 0, 10); stm.end // 10

inheritance relationship

Constructor

RangeStream

RangeStream constructor

1 2
new RangeStream(SeekableStream stm, String range);

Call parameters:

  • stm:SeekableStream, the binary underlying stream object of RangeStream, must beSeekableStream
  • range: String, a string describing the range, in the format of 'begin-[end]', '[begin]-end'

RangeStream constructor

1 2 3
new RangeStream(SeekableStream stm, Long begin, Long end);

Call parameters:

  • stm:SeekableStream, the binary underlying stream object of RangeStream, must beSeekableStream
  • begin: Long, the starting position of the content read from stm
  • end: Long, the end position of the content read from stm

member properties

begin

Long, query the starting value of range

1
readonly Long RangeStream.begin;

end

Long, query range end value

1
readonly Long RangeStream.end;

fd

Integer, queryStreamThe corresponding file descriptor value, implemented by subclasses

1
readonly Integer RangeStream.fd;

member function

seek

Move the current file operation location

1 2
RangeStream.seek(Long offset, Integer whence = fs.SEEK_SET);

Call parameters:

  • offset: Long, specify the new location
  • whence: Integer, specifies the position reference, allowed values ​​are: SEEK_SET, SEEK_CUR, SEEK_END

tell

Query the current position of the stream

1
Long RangeStream.tell();

Return results:

  • Long, returns the current position of the stream

rewind

Move the current position to the beginning of the stream

1
RangeStream.rewind();

size

Query stream size

1
Long RangeStream.size();

Return results:

  • Long, returns the stream size

readAll

Read all remaining data from the stream

1
Buffer RangeStream.readAll() async;

Return results:

  • Buffer, returns the data read from the stream. If there is no data to read or the connection is interrupted, null is returned.

truncate

Modify the file size. If the new size is smaller than the original size, the file will be truncated.

1
RangeStream.truncate(Long bytes) async;

Call parameters:

  • bytes: Long, new file size

eof

Query whether the file reaches the end

1
Boolean RangeStream.eof();

Return results:

  • Boolean, returns True to indicate the end

stat

Query basic information of the current file

1
Stat RangeStream.stat() async;

Return results:

  • Stat, returnStatObject description file information

read

Read data of specified size from the stream

1
Buffer RangeStream.read(Integer bytes = -1) async;

Call parameters:

  • bytes: Integer, specifies the amount of data to be read. The default is to read data blocks of random size. The size of the data read depends on the device.

Return results:

  • Buffer, returns the data read from the stream. If there is no data to read or the connection is interrupted, null is returned.

write

Write the given data to the stream

1
RangeStream.write(Buffer data) async;

Call parameters:

  • data:Buffer, given the data to be written

flush

Write file buffer contents to physical device

1
RangeStream.flush() async;

close

Close the current stream object

1
RangeStream.close() async;

copyTo

Copy stream data to target stream

1 2
Long RangeStream.copyTo(Stream stm, Long bytes = -1) async;

Call parameters:

  • stm:Stream, target stream object
  • bytes: Long, number of bytes copied

Return results:

  • Long, returns the number of bytes copied

toString

Returns the string representation of the object. Generally, "[Native Object]" is returned. The object can be re-implemented according to its own characteristics.

1
String RangeStream.toString();

Return results:

  • String, returns the string representation of the object

toJSON

Returns a JSON format representation of the object, generally returning a collection of readable properties defined by the object.

1
Value RangeStream.toJSON(String key = "");

Call parameters:

  • key: String, not used

Return results:

  • Value, returns a value containing JSON serializable