Object built-in object

Object Buffer

Binary data cache object, used for data processing of io read and write

The Buffer object is a global basic class, which can be created directly with new Buffer(...) at any time:

1
var buf = new Buffer();

Inheritance

Constructor

Buffer

Cache object constructor

1
new Buffer(Array datas);

Call parameters:

  • datas : Array, initialize the data array

Cache object constructor

1
new Buffer(ArrayBuffer datas);

Call parameters:

  • datas : ArrayBuffer, initialize the data array

Cache object constructor

1
new Buffer(TypedArray datas);

Call parameters:

  • datas : TypedArray, initialized data array

Cache object constructor

1
new Buffer(ArrayBufferView datas);

Call parameters:

  • datas : ArrayBufferView, initialize the data array

Cache object constructor

1
new Buffer(Buffer buffer);

Call parameters:

  • buffer : Buffer, initialize the Buffer object

Cache object constructor

1 2
new Buffer(String str, String codec = "utf8");

Call parameters:

  • str : String, the initialization string, the string will be written in utf-8 format, and an empty object is created by default
  • codec : String, specify the encoding format, allowed values ​​are: " hex ", " base64 ", "utf8", or the character set supported by the system

Cache object constructor

1
new Buffer(Integer size = 0);

Call parameters:

  • size : Integer, initial buffer size

Subscript operation

Cached objects can directly access binary data using subscripts

1
Integer Buffer[];

Static function

isBuffer

Check whether the given variable is a Buffer object

1
static Boolean Buffer.isBuffer(Value v);

Call parameters:

  • v : Value, given the variable to be detected

Return result:

  • Boolean , whether the incoming object is a Buffer object

from

Create Buffer objects from other Buffers

1 2 3
static Buffer Buffer.from(Buffer buffer, Integer byteOffset = 0, Integer length = -1);

Call parameters:

  • buffer : Buffer, given Buffer type variable is used to create Buffer object
  • byteOffset : Integer, specify the starting position of the data, starting at 0
  • length : Integer, specify the data length, the start bit is -1, which means all the remaining data

Return result:

  • Buffer , return Buffer instance

Create a Buffer object from a string

1 2 3
static Buffer Buffer.from(String str, Integer byteOffset = 0, Integer length = -1);

Call parameters:

  • str : String, initialize the string, the string will be written in utf-8 format
  • byteOffset : Integer, specify the starting position of the data, starting at 0
  • length : Integer, specify the data length, the start bit is -1, which means all the remaining data

Return result:

  • Buffer , return Buffer instance

Create a Buffer object from a string

1 2
static Buffer Buffer.from(String str, String codec = "utf8");

Call parameters:

  • str : String, initialization string, the string will be written in utf-8 format, and an empty object is created by default
  • codec : String, specifies the encoding format, allowed values ​​are: " hex ", " base64 ", "utf8", or the character set supported by the system

Return result:

  • Buffer , return Buffer instance

concat

Concatenate data in multiple buffers

1 2
static Buffer Buffer.concat(Array buflist, Integer cutLength = -1);

Call parameters:

  • buflist : Array, Buffer array to be spliced
  • cutLength : Integer, how many Buffer objects to intercept

Return result:

  • Buffer , the new Buffer object generated after splicing

alloc

Allocate a new buffer area of ​​the specified length. If the size is 0, a zero-length buffer area will be created.

1 2 3
static Buffer Buffer.alloc(Integer size, Integer fill = 0, String codec = "utf8");

Call parameters:

  • size : Integer, the required length of the buffer
  • fill : Integer, pre-fill the value of the new buffer, you can use string/buffer/integer value types. Default value: 0
  • codec : String, specify the encoding format, allowed values ​​are: " hex ", " base64 ", "utf8", or the character set supported by the system

Return result:

  • Buffer , filled new Buffer object

Allocate a new buffer area of ​​the specified length. If the size is 0, a zero-length buffer area will be created.

1 2 3
static Buffer Buffer.alloc(Integer size, String fill = "", String codec = "utf8");

Call parameters:

  • size : Integer, the required length of the buffer
  • fill : String, pre-fill the value of the new buffer, you can use string/buffer/integer value types. Default value: 0
  • codec : String, specifies the encoding format, allowed values ​​are: " hex ", " base64 ", "utf8", or the character set supported by the system

Return result:

  • Buffer , the filled new Buffer object

Allocate a new buffer area of ​​the specified length. If the size is 0, a zero-length buffer area will be created.

1 2 3
static Buffer Buffer.alloc(Integer size, Buffer fill, String codec = "utf8");

Call parameters:

  • size : Integer, the required length of the buffer
  • fill : Buffer, pre-fill the value of the new buffer, you can use string/buffer/integer value types. Default value: 0
  • codec : String, specify the encoding format, allowed values ​​are: " hex ", " base64 ", "utf8", or the character set supported by the system

Return result:

  • Buffer , the filled new Buffer object

allocUnsafe

Allocate a new buffer area of ​​the specified length. If the size is 0, a zero-length buffer area will be created.

1
static Buffer Buffer.allocUnsafe(Integer size);

Call parameters:

  • size : Integer, the required length of the buffer

Return result:

  • Buffer , a new Buffer object of the specified size

allocUnsafeSlow

Allocate a new buffer area of ​​the specified length. If the size is 0, a zero-length buffer area will be created.

1
static Buffer Buffer.allocUnsafeSlow(Integer size);

Call parameters:

  • size : Integer, the required length of the buffer

Return result:

  • Buffer , a new Buffer object of the specified size

byteLength

Returns the actual byte length of the string

1 2
static Integer Buffer.byteLength(String str, String codec = "utf8");

Call parameters:

  • str : String, the string of bytes to be fetched, if str is an ArrayBuffer/TypedArray/DataView/Buffer object, return their actual length
  • codec : String, specifies the encoding format, allowed values ​​are: " hex ", " base64 ", "utf8", or the character set supported by the system

Return result:

  • Integer , returns the actual byte length

Returns the actual byte length of the string

1 2
static Integer Buffer.byteLength(ArrayBuffer str, String codec = "utf8");

Call parameters:

  • str : ArrayBuffer, the string of bytes to be fetched, if str is an ArrayBuffer/TypedArray/DataView/Buffer object, return their actual length
  • codec : String, specifies the encoding format, allowed values ​​are: " hex ", " base64 ", "utf8", or the character set supported by the system

Return result:

  • Integer , returns the actual byte length

Returns the actual byte length of the string

1 2
static Integer Buffer.byteLength(ArrayBufferView str, String codec = "utf8");

Call parameters:

  • str : ArrayBufferView, the string of bytes to be fetched, if str is an ArrayBuffer/TypedArray/DataView/Buffer object, return their actual length
  • codec : String, specifies the encoding format, allowed values ​​are: " hex ", " base64 ", "utf8", or the character set supported by the system

Return result:

  • Integer , returns the actual byte length

Returns the actual byte length of the string

1 2
static Integer Buffer.byteLength(Buffer str, String codec = "utf8");

Call parameters:

  • str : Buffer, the string of bytes to be fetched, if str is an ArrayBuffer/TypedArray/DataView/Buffer object, return their actual length
  • codec : String, specifies the encoding format, allowed values ​​are: " hex ", " base64 ", "utf8", or the character set supported by the system

Return result:

  • Integer , returns the actual byte length

compare

Comparing buf1 and buf2 is often used for sorting between Buffer instances. This method is equivalent to buf1.compare(buf2).

1 2
static Integer Buffer.compare(Buffer buf1, Buffer buf2);

Call parameters:

  • buf1 : Buffer, buf to be compared
  • buf2 : Buffer, buf to be compared

Return result:

  • Integer , returns the comparison byte length

isEncoding

Check whether the encoding format is supported

1
static Boolean Buffer.isEncoding(String codec);

Call parameters:

  • codec : String, encoding format to be detected

Return result:

  • Boolean , support

Member attributes

length

Integer, get the size of the cached object

1
readonly Integer Buffer.length;

Member function

resize

Modify cache object size

1
Buffer.resize(Integer sz);

Call parameters:

  • sz : Integer, specify new size

append

Write a set of binary data at the end of the cache object

1
Buffer.append(Buffer data);

Call parameters:

  • data : Buffer, initialize binary data

Write a string at the end of the cache object, the string will be written in utf-8 format

1 2
Buffer.append(String str, String codec = "utf8");

Call parameters:

  • str : String, the string to be written
  • codec : String, specifies the encoding format, allowed values ​​are: " hex ", " base64 ", "utf8", or the character set supported by the system

write

Write the specified string to the cache object, the string defaults to utf-8, and only part of the data is written when the boundary is exceeded

1 2 3 4
Integer Buffer.write(String str, Integer offset = 0, Integer length = -1, String codec = "utf8");

Call parameters:

  • str : String, the string to be written
  • offset : Integer, start position of writing
  • length : Integer, write length (unit byte, default value -1), if not specified, it is the length of the string to be written
  • codec : String, specifies the encoding format, allowed values ​​are: " hex ", " base64 ", "utf8", or the character set supported by the system

Return result:

  • Integer , the byte length of the written data

Write the specified string to the cache object, the string defaults to utf-8, and only part of the data is written when the boundary is exceeded

1 2 3
Integer Buffer.write(String str, Integer offset = 0, String codec = "utf8");

Call parameters:

  • str : String, the string to be written
  • offset : Integer, start position of writing
  • codec : String, specifies the encoding format, allowed values ​​are: " hex ", " base64 ", "utf8", or the character set supported by the system

Return result:

  • Integer , the byte length of the written data

Write the specified string to the cache object, the string defaults to utf-8, and only part of the data is written when the boundary is exceeded

1 2
Integer Buffer.write(String str, String codec = "utf8");

Call parameters:

  • str : String, the string to be written
  • codec : String, specifies the encoding format, allowed values ​​are: " hex ", " base64 ", "utf8", or the character set supported by the system

Return result:

  • Integer , the byte length of the written data

fill

Fill the Buffer object with the specified content data

1 2 3
Buffer Buffer.fill(Integer v, Integer offset = 0, Integer end = -1);

Call parameters:

  • v : Integer, the data to be filled, if offset and end are not specified, the entire buffer will be filled
  • offset : Integer, starting position of filling
  • end : Integer, filling end position

Return result:

  • Buffer , returns the current Buffer object

Fill the Buffer object with the specified content data

1 2 3
Buffer Buffer.fill(Buffer v, Integer offset = 0, Integer end = -1);

Call parameters:

  • v : Buffer, data to be filled, if offset and end are not specified, the entire buffer will be filled
  • offset : Integer, starting position of filling
  • end : Integer, filling end position

Return result:

  • Buffer , returns the current Buffer object

Fill the Buffer object with the specified content data

1 2 3
Buffer Buffer.fill(String v, Integer offset = 0, Integer end = -1);

Call parameters:

  • v : String, the data to be filled, if offset and end are not specified, the entire buffer will be filled
  • offset : Integer, starting position of filling
  • end : Integer, filling end position

Return result:

  • Buffer , returns the current Buffer object

indexOf

Returns the position of the first occurrence of a specified data in the Buffer

1 2
Integer Buffer.indexOf(Integer v, Integer offset = 0);

Call parameters:

  • v : Integer, the data to be searched, if the offset is not specified, the default starts from the start bit
  • offset : Integer, starting search position

Return result:

  • Integer , returns the location found, returns -1 if not found

Returns the position of the first occurrence of a specified data in the Buffer

1 2
Integer Buffer.indexOf(Buffer v, Integer offset = 0);

Call parameters:

  • v : Buffer, the data to be searched, if the offset is not specified, the default starts from the start bit
  • offset : Integer, starting search position

Return result:

  • Integer , returns the location found, returns -1 if not found

Returns the position of the first occurrence of a specified data in the Buffer

1 2
Integer Buffer.indexOf(String v, Integer offset = 0);

Call parameters:

  • v : String, the data to be searched, if the offset is not specified, the default starts from the start bit
  • offset : Integer, starting search position

Return result:

  • Integer , returns the location found, returns -1 if not found

compare

Compare the contents of the cache

1
Integer Buffer.compare(Buffer buf);

Call parameters:

  • buf : Buffer, the buffer object to be compared

Return result:

  • Integer , content comparison result

copy

Copy data from the source cache object area to the target cache object area

1 2 3 4
Integer Buffer.copy(Buffer targetBuffer, Integer targetStart = 0, Integer sourceStart = 0, Integer sourceEnd = -1);

Call parameters:

  • targetBuffer : Buffer, target buffer object
  • targetStart : Integer, the byte position where the target cache object starts copying, the default is 0
  • sourceStart : Integer, the start byte position of the source buffer object, the default is 0
  • sourceEnd : Integer, the end byte position of the source buffer object, the default is -1, which means the length of the source data

Return result:

  • Integer , the length of the copied data byte

set

Copy data from the source cache object area to the target cache object area

1 2
Integer Buffer.set(Buffer src, Integer start);

Call parameters:

  • src : Buffer, target buffer object
  • start : Integer, the starting byte position of the source cache object

Return result:

  • Integer , the length of the copied data byte

readUInt8

Read an 8-bit unsigned integer value from the cache object

1 2
Integer Buffer.readUInt8(Integer offset = 0, Boolean noAssert = false);

Call parameters:

  • offset : Integer, specify the starting position for reading, the default is 0
  • noAssert : Boolean, specifies that no error is thrown when reading out of bounds, the default is flase, throw

Return result:

  • Integer , returns the integer value read

readUInt16LE

Read a 16-bit unsigned integer value from the cache object and store it in low-endian order

1 2
Integer Buffer.readUInt16LE(Integer offset = 0, Boolean noAssert = false);

Call parameters:

  • offset : Integer, specify the starting position for reading, the default is 0
  • noAssert : Boolean, specifies that no error will be thrown when reading out of bounds, the default is flase, throw

Return result:

  • Integer , returns the integer value read

readUInt16BE

Read a 16-bit unsigned integer value from the cache object and store it in high-endian order

1 2
Integer Buffer.readUInt16BE(Integer offset = 0, Boolean noAssert = false);

Call parameters:

  • offset : Integer, specify the starting position for reading, the default is 0
  • noAssert : Boolean, specifies that no error is thrown when reading out of bounds, the default is flase, throw

Return result:

  • Integer , returns the integer value read

readUInt32LE

Read a 32-bit unsigned integer value from the cache object and store it in low-endian order

1 2
Long Buffer.readUInt32LE(Integer offset = 0, Boolean noAssert = false);

Call parameters:

  • offset : Integer, specify the starting position for reading, the default is 0
  • noAssert : Boolean, specifies that no error is thrown when reading out of bounds, the default is flase, throw

Return result:

  • Long , returns the integer value read

readUInt32BE

Read a 32-bit unsigned integer value from the cache object and store it in high-endian order

1 2
Long Buffer.readUInt32BE(Integer offset = 0, Boolean noAssert = false);

Call parameters:

  • offset : Integer, specify the starting position for reading, the default is 0
  • noAssert : Boolean, specifies that no error will be thrown when reading out of bounds, the default is flase, throw

Return result:

  • Long , returns the integer value read

readUIntLE

Read an unsigned integer value from the cache object, with a maximum support of 64 bits, stored in low-endian order

1 2 3
Long Buffer.readUIntLE(Integer offset = 0, Integer byteLength = 8, Boolean noAssert = false);

Call parameters:

  • offset : Integer, specify the starting position for reading, the default is 0
  • byteLength : Integer, specify the number of bytes read, the default is 8 bytes
  • noAssert : Boolean, specifies that no error is thrown when reading out of bounds, the default is flase, throw

Return result:

  • Long , returns the integer value read

readUIntBE

Read an unsigned integer value from the cache object, with a maximum support of 64 bits, stored in high-endian order

1 2 3
Long Buffer.readUIntBE(Integer offset = 0, Integer byteLength = 8, Boolean noAssert = false);

Call parameters:

  • offset : Integer, specify the starting position for reading, the default is 0
  • byteLength : Integer, specify the number of bytes read, the default is 8 bytes
  • noAssert : Boolean, specifies that no error is thrown when reading out of bounds, the default is flase, throw

Return result:

  • Long , returns the integer value read

readInt64LE

Read a 64-bit integer value from the cache object and store it in low-endian order

1 2
Long Buffer.readInt64LE(Integer offset = 0, Boolean noAssert = false);

Call parameters:

  • offset : Integer, specify the starting position for reading, the default is 0
  • noAssert : Boolean, specifies that no error is thrown when reading out of bounds, the default is flase, throw

Return result:

  • Long , returns the integer value read

readInt64BE

Read a 64-bit integer value from the cache object and store it in high-endian order

1 2
Long Buffer.readInt64BE(Integer offset = 0, Boolean noAssert = false);

Call parameters:

  • offset : Integer, specify the starting position for reading, the default is 0
  • noAssert : Boolean, specifies that no error is thrown when reading out of bounds, the default is flase, throw

Return result:

  • Long , returns the integer value read

readInt8

Read an 8-bit integer value from the cache object

1 2
Integer Buffer.readInt8(Integer offset = 0, Boolean noAssert = false);

Call parameters:

  • offset : Integer, specify the starting position for reading, the default is 0
  • noAssert : Boolean, specifies that no error is thrown when reading out of bounds, the default is flase, throw

Return result:

  • Integer , returns the integer value read

readInt16LE

Read a 16-bit integer value from the cache object and store it in low-endian order

1 2
Integer Buffer.readInt16LE(Integer offset = 0, Boolean noAssert = false);

Call parameters:

  • offset : Integer, specify the starting position for reading, the default is 0
  • noAssert : Boolean, specifies that no error will be thrown when reading out of bounds, the default is flase, throw

Return result:

  • Integer , returns the integer value read

readInt16BE

Read a 16-bit integer value from the cache object and store it in high-endian order

1 2
Integer Buffer.readInt16BE(Integer offset = 0, Boolean noAssert = false);

Call parameters:

  • offset : Integer, specify the starting position for reading, the default is 0
  • noAssert : Boolean, specifies that no error is thrown when reading out of bounds, the default is flase, throw

Return result:

  • Integer , returns the integer value read

readInt32LE

Read a 32-bit integer value from the cache object and store it in low-endian order

1 2
Integer Buffer.readInt32LE(Integer offset = 0, Boolean noAssert = false);

Call parameters:

  • offset : Integer, specify the starting position for reading, the default is 0
  • noAssert : Boolean, specifies that no error is thrown when reading out of bounds, the default is flase, throw

Return result:

  • Integer , returns the integer value read

readInt32BE

Read a 32-bit integer value from the cache object and store it in high-endian order

1 2
Integer Buffer.readInt32BE(Integer offset = 0, Boolean noAssert = false);

Call parameters:

  • offset : Integer, specify the starting position for reading, the default is 0
  • noAssert : Boolean, specifies that no error will be thrown when reading out of bounds, the default is flase, throw

Return result:

  • Integer , returns the integer value read

readIntLE

Read an integer value from the cache object, with a maximum support of 64 bits, stored in low-endian order

1 2 3
Long Buffer.readIntLE(Integer offset = 0, Integer byteLength = 8, Boolean noAssert = false);

Call parameters:

  • offset : Integer, specify the starting position for reading, the default is 0
  • byteLength : Integer, specify the number of bytes read, the default is 8 bytes
  • noAssert : Boolean, specifies that no error is thrown when reading out of bounds, the default is flase, throw

Return result:

  • Long , returns the integer value read

readIntBE

Read an integer value from the cache object, with a maximum support of 64 bits, and store in high-endian order

1 2 3
Long Buffer.readIntBE(Integer offset = 0, Integer byteLength = 8, Boolean noAssert = false);

Call parameters:

  • offset : Integer, specify the starting position for reading, the default is 0
  • byteLength : Integer, specify the number of bytes read, the default is 8 bytes
  • noAssert : Boolean, specifies that no error is thrown when reading out of bounds, the default is flase, throw

Return result:

  • Long , returns the integer value read

writeInt64LE

Write a 64-bit integer value to the cache object in low-endian storage

1 2 3
Integer Buffer.writeInt64LE(Long value, Integer offset = 0, Boolean noAssert = false);

Call parameters:

  • value : Long, specify the value to be written
  • offset : Integer, specify the starting position of writing
  • noAssert : Boolean, specify that no error will be thrown when writing out of bounds, the default is flase, throw

Return result:

  • Integer , offset plus the number of bytes written

writeInt64BE

Write a 64-bit integer value to the cache object in high-endian storage

1 2 3
Integer Buffer.writeInt64BE(Long value, Integer offset = 0, Boolean noAssert = false);

Call parameters:

  • value : Long, specify the value to be written
  • offset : Integer, specify the starting position of writing
  • noAssert : Boolean, specify that no error will be thrown when writing out of bounds, the default is flase, throw

Return result:

  • Integer , offset plus the number of bytes written

readFloatLE

Read a floating point number from the cache object and store it in low-endian order

1 2
Number Buffer.readFloatLE(Integer offset = 0, Boolean noAssert = false);

Call parameters:

  • offset : Integer, specify the starting position for reading, the default is 0
  • noAssert : Boolean, specifies that no error will be thrown when reading out of bounds, the default is flase, throw

Return result:

  • Number , returns the floating point number read

readFloatBE

Read a floating point number from the cache object and store it in high-endian

1 2
Number Buffer.readFloatBE(Integer offset = 0, Boolean noAssert = false);

Call parameters:

  • offset : Integer, specify the starting position for reading, the default is 0
  • noAssert : Boolean, specifies that no error is thrown when reading out of bounds, the default is flase, throw

Return result:

  • Number , returns the floating point number read

readDoubleLE

Read a double-precision floating-point number from the cache object and store it in low-endian order

1 2
Number Buffer.readDoubleLE(Integer offset = 0, Boolean noAssert = false);

Call parameters:

  • offset : Integer, specify the starting position for reading, the default is 0
  • noAssert : Boolean, specifies that no error is thrown when reading out of bounds, the default is flase, throw

Return result:

  • Number , returns the double-precision floating-point number read

readDoubleBE

Read a double-precision floating-point number from the cache object and store it in high-endian order

1 2
Number Buffer.readDoubleBE(Integer offset = 0, Boolean noAssert = false);

Call parameters:

  • offset : Integer, specify the starting position for reading, the default is 0
  • noAssert : Boolean, specifies that no error is thrown when reading out of bounds, the default is flase, throw

Return result:

  • Number , returns the double-precision floating-point number read

writeUInt8

Write an 8-bit unsigned integer value to the cache object

1 2 3
Integer Buffer.writeUInt8(Integer value, Integer offset = 0, Boolean noAssert = false);

Call parameters:

  • value : Integer, specify the value to be written
  • offset : Integer, specify the starting position of writing
  • noAssert : Boolean, specify that no error will be thrown when writing out of bounds, the default is flase, throw

Return result:

  • Integer , offset plus the number of bytes written

writeUInt16LE

Write a 16-bit unsigned integer value to the cache object in low-endian storage

1 2 3
Integer Buffer.writeUInt16LE(Integer value, Integer offset = 0, Boolean noAssert = false);

Call parameters:

  • value : Integer, specify the value to be written
  • offset : Integer, specify the starting position of writing
  • noAssert : Boolean, specify that no error will be thrown when writing out of bounds, the default is flase, throw

Return result:

  • Integer , offset plus the number of bytes written

writeUInt16BE

Write a 16-bit unsigned integer value to the cache object in high-endian storage

1 2 3
Integer Buffer.writeUInt16BE(Integer value, Integer offset = 0, Boolean noAssert = false);

Call parameters:

  • value : Integer, specify the value to be written
  • offset : Integer, specify the starting position of writing
  • noAssert : Boolean, specify that no error will be thrown when writing out of bounds, the default is flase, throw

Return result:

  • Integer , offset plus the number of bytes written

writeUInt32LE

Write a 32-bit unsigned integer value to the cache object in low-endian storage

1 2 3
Integer Buffer.writeUInt32LE(Long value, Integer offset = 0, Boolean noAssert = false);

Call parameters:

  • value : Long, specify the value to be written
  • offset : Integer, specify the starting position of writing
  • noAssert : Boolean, specify that no error will be thrown when writing out of bounds, the default is flase, throw

Return result:

  • Integer , offset plus the number of bytes written

writeUInt32BE

Write a 32-bit unsigned integer value to the cache object in high-endian storage

1 2 3
Integer Buffer.writeUInt32BE(Long value, Integer offset = 0, Boolean noAssert = false);

Call parameters:

  • value : Long, specify the value to be written
  • offset : Integer, specify the starting position of writing
  • noAssert : Boolean, specify that no error will be thrown when writing out of bounds, the default is flase, throw

Return result:

  • Integer , offset plus the number of bytes written

writeUIntLE

Write an unsigned integer value to the cache object, with a maximum support of 64 bits, stored in low-endian order

1 2 3 4
Integer Buffer.writeUIntLE(Long value, Integer offset = 0, Integer byteLength = 8, Boolean noAssert = false);

Call parameters:

  • value : Long, specify the value to be written
  • offset : Integer, specify the starting position of writing
  • byteLength : Integer, specify the number of bytes written, the default is 8 bytes
  • noAssert : Boolean, specify that no error will be thrown when writing out of bounds, the default is flase, throw

Return result:

  • Integer , offset plus the number of bytes written

writeUIntBE

Write an unsigned integer value to the cache object, with a maximum support of 64 bits, stored in high-endian order

1 2 3 4
Integer Buffer.writeUIntBE(Long value, Integer offset = 0, Integer byteLength = 8, Boolean noAssert = false);

Call parameters:

  • value : Long, specify the value to be written
  • offset : Integer, specify the starting position of writing
  • byteLength : Integer, specify the number of bytes written, the default is 8 bytes
  • noAssert : Boolean, specify that no error will be thrown when writing out of bounds, the default is flase, throw

Return result:

  • Integer , offset plus the number of bytes written

writeInt8

Write an 8-bit integer value to the cache object

1 2 3
Integer Buffer.writeInt8(Integer value, Integer offset = 0, Boolean noAssert = false);

Call parameters:

  • value : Integer, specify the value to be written
  • offset : Integer, specify the starting position of writing
  • noAssert : Boolean, specify that no error will be thrown when writing out of bounds, the default is flase, throw

Return result:

  • Integer , offset plus the number of bytes written

writeInt16LE

Write a 16-bit integer value to the cache object in low-endian storage

1 2 3
Integer Buffer.writeInt16LE(Integer value, Integer offset = 0, Boolean noAssert = false);

Call parameters:

  • value : Integer, specify the value to be written
  • offset : Integer, specify the starting position of writing
  • noAssert : Boolean, specify that no error will be thrown when writing out of bounds, the default is flase, throw

Return result:

  • Integer , offset plus the number of bytes written

writeInt16BE

Write a 16-bit integer value to the cache object in high-endian storage

1 2 3
Integer Buffer.writeInt16BE(Integer value, Integer offset = 0, Boolean noAssert = false);

Call parameters:

  • value : Integer, specify the value to be written
  • offset : Integer, specify the starting position of writing
  • noAssert : Boolean, specify that no error will be thrown when writing out of bounds, the default is flase, throw

Return result:

  • Integer , offset plus the number of bytes written

writeInt32LE

Write a 32-bit integer value to the cache object in low-endian storage

1 2 3
Integer Buffer.writeInt32LE(Integer value, Integer offset = 0, Boolean noAssert = false);

Call parameters:

  • value : Integer, specify the value to be written
  • offset : Integer, specify the starting position of writing
  • noAssert : Boolean, specify that no error will be thrown when writing out of bounds, the default is flase, throw

Return result:

  • Integer , offset plus the number of bytes written

writeInt32BE

Write a 32-bit integer value to the cache object in high-endian storage

1 2 3
Integer Buffer.writeInt32BE(Integer value, Integer offset = 0, Boolean noAssert = false);

Call parameters:

  • value : Integer, specify the value to be written
  • offset : Integer, specify the starting position of writing
  • noAssert : Boolean, specify that no error will be thrown when writing out of bounds, the default is flase, throw

Return result:

  • Integer , offset plus the number of bytes written

writeIntLE

Write an integer value to the cache object, with a maximum support of 64 bits, stored in low-endian order

1 2 3 4
Integer Buffer.writeIntLE(Long value, Integer offset = 0, Integer byteLength = 8, Boolean noAssert = false);

Call parameters:

  • value : Long, specify the value to be written
  • offset : Integer, specify the starting position of writing
  • byteLength : Integer, specify the number of bytes written, the default is 8 bytes
  • noAssert : Boolean, specify that no error will be thrown when writing out of bounds, the default is flase, throw

Return result:

  • Integer , offset plus the number of bytes written

writeIntBE

Write an integer value to the cache object, the maximum support is 64 bits, in high-endian storage mode

1 2 3 4
Integer Buffer.writeIntBE(Long value, Integer offset = 0, Integer byteLength = 8, Boolean noAssert = false);

Call parameters:

  • value : Long, specify the value to be written
  • offset : Integer, specify the starting position of writing
  • byteLength : Integer, specify the number of bytes written, the default is 8 bytes
  • noAssert : Boolean, specify that no error will be thrown when writing out of bounds, the default is flase, throw

Return result:

  • Integer , offset plus the number of bytes written

writeFloatLE

Write a floating point number to the cache object in low-endian storage

1 2 3
Integer Buffer.writeFloatLE(Number value, Integer offset, Boolean noAssert = false);

Call parameters:

  • value : Number, specify the value to be written
  • offset : Integer, specify the starting position of writing
  • noAssert : Boolean, specify that no error will be thrown when writing out of bounds, the default is flase, throw

Return result:

  • Integer , offset plus the number of bytes written

writeFloatBE

Write a floating point number to the cache object in high-endian storage

1 2 3
Integer Buffer.writeFloatBE(Number value, Integer offset, Boolean noAssert = false);

Call parameters:

  • value : Number, specify the value to be written
  • offset : Integer, specify the starting position of writing
  • noAssert : Boolean, specify that no error will be thrown when writing out of bounds, the default is flase, throw

Return result:

  • Integer , offset plus the number of bytes written

writeDoubleLE

Write a double-precision floating-point number to the cache object in low-endian storage

1 2 3
Integer Buffer.writeDoubleLE(Number value, Integer offset, Boolean noAssert = false);

Call parameters:

  • value : Number, specify the value to be written
  • offset : Integer, specify the starting position of writing
  • noAssert : Boolean, specify that no error will be thrown when writing out of bounds, the default is flase, throw

Return result:

  • Integer , offset plus the number of bytes written

writeDoubleBE

Write a double-precision floating-point number to the cache object in high-endian storage

1 2 3
Integer Buffer.writeDoubleBE(Number value, Integer offset, Boolean noAssert = false);

Call parameters:

  • value : Number, specify the value to be written
  • offset : Integer, specify the starting position of writing
  • noAssert : Boolean, specify that no error will be thrown when writing out of bounds, the default is flase, throw

Return result:

  • Integer , offset plus the number of bytes written

slice

Return a new cache object containing data from the specified start to the end of the cache

1
Buffer Buffer.slice(Integer start = 0);

Call parameters:

  • start : Integer, the start of the specified range, the default starts from the beginning

Return result:

  • Buffer , return a new buffer object

Return a new cache object that contains the data in the specified range. If the range exceeds the cache, only the valid part of the data is returned

1 2
Buffer Buffer.slice(Integer start, Integer end);

Call parameters:

  • start : Integer, the start of the specified range
  • end : Integer, the end of the specified range

Return result:

  • Buffer , return a new buffer object

join

Put all the elements in the current object into a string

1
String Buffer.join(String separator = ",");

Call parameters:

  • separator : String, the separator character, the default is ","

Return result:

  • String , returns the generated string

reverse

Return a new cached object containing the reverse order of the current object data

1
Buffer Buffer.reverse();

Return result:

  • Buffer , return a new buffer object

equals

Compare whether the current object is equal to the given object

1
Boolean Buffer.equals(object expected);

Call parameters:

  • expected : object , the target object to be compared

Return result:

  • Boolean , returns the result of object comparison

hex

Use hexadecimal encoding to cache object content

1
String Buffer.hex();

Return result:

  • String , returns the encoded string

base64

Use base64 encoding to cache object content

1
String Buffer.base64();

Return result:

  • String , returns the encoded string

keys

Returns an array of all binary data

1
Iterator Buffer.keys();

Return result:

  • Iterator , returns an iterator containing the data index of the object

values

Returns an array of all binary data

1
Iterator Buffer.values();

Return result:

  • Iterator , returns an iterator containing object data values

entries

Returns an iterator containing object data [index, byte] pairs

1
Iterator Buffer.entries();

Return result:

  • Iterator , [index, byte] pair of iterators

toArray

Returns an array of all binary data

1
Array Buffer.toArray();

Return result:

  • Array , returns an array containing object data

toString

Returns the encoded string of binary data

1 2 3
String Buffer.toString(String codec, Integer offset = 0, Integer end);

Call parameters:

  • codec : String, specify the encoding format, allowed values ​​are: " hex ", " base64 ", "utf8", or the character set supported by the system
  • offset : Integer, start position of reading
  • end : Integer, read end position

Return result:

  • String , returns the string representation of the object

Returns the encoded string of binary data

1 2
String Buffer.toString(String codec, Integer offset = 0);

Call parameters:

  • codec : String, specifies the encoding format, allowed values ​​are: " hex ", " base64 ", "utf8", or the character set supported by the system
  • offset : Integer, start position of reading

Return result:

  • String , returns the string representation of the object

Returns the utf8 encoded string of binary data

1
String Buffer.toString();

Return result:

  • String , returns the string representation of the object

Returns the string representation of the object, generally returns "[Native Object]", the object can be re-implemented according to its own characteristics

1
String Buffer.toString();

Return result:

  • String , returns the string representation of the object

toJSON

Returns the JSON format representation of the object, generally returns a collection of readable attributes defined by the object

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

Call parameters:

  • key : String, unused

Return result:

  • Value , returns a value containing JSON serializable