ObjectBuffer
Binary data cache object forioRead and write data processing
The Buffer object is a global base class and can be created directly with new Buffer(...) at any time:
1var buf = new Buffer();
inheritance relationship
Constructor
Buffer
Cache object constructor
1new Buffer(Array datas);
Call parameters:
- datas: Array, initialize data array
Cache object constructor
1
2
3new Buffer(ArrayBuffer datas,
Integer byteOffset = 0,
Integer length = -1);
Call parameters:
- datas: ArrayBuffer, initialize data array
- byteOffset: Integer, specifies the starting position of the data, starting from 0
- length: Integer, specifies the data length, starting bit -1, indicating all remaining data
Cache object constructor
1
2
3new Buffer(Uint8Array datas,
Integer byteOffset = 0,
Integer length = -1);
Call parameters:
- datas: Uint8Array, initialize data array
- byteOffset: Integer, specifies the starting position of the data, starting from 0
- length: Integer, specifies the data length, starting bit -1, indicating all remaining data
Cache object constructor
1
2new Buffer(String str,
String codec = "utf8");
Call parameters:
- str: String, initialize the string. The string will be written in utf-8 format. By default, an empty object will be created.
- codec: String, specifies the encoding format, allowed values are: "hex", "base32", "base58", "base64", "utf8", oriconvCharacter sets supported by the module
Cache object constructor
1new Buffer(Integer size = 0);
Call parameters:
- size: Integer, initialization buffer size
object
Binary data cache object forioRead and write data processing
1Buffer new Buffer;
static function
alloc
Allocate a new buffer area of the specified length. If size is 0, a zero-length buffer will be created.
1
2static Buffer Buffer.alloc(Integer size,
Integer fill = 0);
Call parameters:
- size: Integer, the desired length of the buffer
- fill: Integer, pre-fill the value of the new buffer, you can use string/buffer/integer value type. Default value: 0
Return results:
- Buffer, the filled new Buffer object
Allocate a new buffer area of the specified length. If size is 0, a zero-length buffer will be created.
1
2
3static Buffer Buffer.alloc(Integer size,
String fill = "",
String codec = "utf8");
Call parameters:
- size: Integer, the desired length of the buffer
- fill: String, the value to pre-fill the new buffer, string/buffer/integer value types can be used. Default value: 0
- codec: String, specifies the encoding format, allowed values are: "hex", "base32", "base58", "base64", "utf8", oriconvCharacter sets supported by the module
Return results:
- Buffer, the filled new Buffer object
Allocate a new buffer area of the specified length. If size is 0, a zero-length buffer will be created.
1
2static Buffer Buffer.alloc(Integer size,
Buffer fill);
Call parameters:
- size: Integer, the desired length of the buffer
- fill: Buffer, pre-fill the value of the new buffer, you can use string/buffer/integer value type. Default value: 0
Return results:
- Buffer, the filled new Buffer object
allocUnsafe
Allocate a new buffer area of the specified length. If size is 0, a zero-length buffer will be created.
1static Buffer Buffer.allocUnsafe(Integer size);
Call parameters:
- size: Integer, the desired length of the buffer
Return results:
- Buffer, a new Buffer object of specified size
allocUnsafeSlow
Allocate a new buffer area of the specified length. If size is 0, a zero-length buffer will be created.
1static Buffer Buffer.allocUnsafeSlow(Integer size);
Call parameters:
- size: Integer, the desired length of the buffer
Return results:
- Buffer, a new Buffer object of specified size
from
Creates a Buffer object from the given array
1static Buffer Buffer.from(Array datas);
Call parameters:
- datas: Array, initialize data array
Return results:
- Buffer, returns the Buffer instance
Create Buffer objects from other Buffers
1
2
3static Buffer Buffer.from(Buffer buffer,
Integer byteOffset = 0,
Integer length = -1);
Call parameters:
- buffer: Buffer, the given Buffer type variable is used to create a Buffer object
- byteOffset: Integer, specifies the starting position of the data, starting from 0
- length: Integer, specifies the data length, starting bit -1, indicating all remaining data
Return results:
- Buffer, returns the Buffer instance
Create Buffer objects from other Buffers
1
2
3static Buffer Buffer.from(ArrayBuffer datas,
Integer byteOffset = 0,
Integer length = -1);
Call parameters:
- datas: ArrayBuffer, initialize data array
- byteOffset: Integer, specifies the starting position of the data, starting from 0
- length: Integer, specifies the data length, starting bit -1, indicating all remaining data
Return results:
- Buffer, returns the Buffer instance
Create Buffer objects from other Buffers
1
2
3static Buffer Buffer.from(Uint8Array datas,
Integer byteOffset = 0,
Integer length = -1);
Call parameters:
- datas: Uint8Array, initialize data array
- byteOffset: Integer, specifies the starting position of the data, starting from 0
- length: Integer, specifies the data length, starting bit -1, indicating all remaining data
Return results:
- Buffer, returns the Buffer instance
Create Buffer object from string
1
2static Buffer Buffer.from(String str,
String codec = "utf8");
Call parameters:
- str: String, initialize the string. The string will be written in utf-8 format. By default, an empty object will be created.
- codec: String, specifies the encoding format, allowed values are: "hex", "base32", "base58", "base64", "utf8", oriconvCharacter sets supported by the module
Return results:
- Buffer, returns the Buffer instance
concat
Splice data from multiple buffers
1
2static 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 results:
- Buffer, the new Buffer object generated after splicing
isBuffer
Checks whether the given variable is a Buffer object
1static Boolean Buffer.isBuffer(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, whether the incoming object is a Buffer object
isEncoding
Check whether the encoding format is supported
1static Boolean Buffer.isEncoding(String codec);
Call parameters:
- codec: String, the encoding format to be detected
Return results:
- Boolean, does it support
byteLength
Returns the actual byte length of the string
1
2static Integer Buffer.byteLength(String str,
String codec = "utf8");
Call parameters:
- str: String, the string of bytes to be retrieved. If str is an ArrayBuffer/TypedArray/DataView/Buffer object, return their actual length.
- codec: String, specifies the encoding format, allowed values are: "hex", "base32", "base58", "base64", "utf8", oriconvCharacter sets supported by the module
Return results:
- Integer, returns the actual byte length
Returns the actual byte length of the string
1static Integer Buffer.byteLength(ArrayBuffer str);
Call parameters:
- str: ArrayBuffer, the string of bytes to be retrieved. If str is an ArrayBuffer/TypedArray/DataView/Buffer object, return their actual length.
Return results:
- Integer, returns the actual byte length
Returns the actual byte length of the string
1static Integer Buffer.byteLength(Uint8Array str);
Call parameters:
- str: Uint8Array, the string of bytes to be retrieved. If str is an ArrayBuffer/TypedArray/DataView/Buffer object, return their actual length.
Return results:
- Integer, returns the actual byte length
Returns the actual byte length of the string
1static Integer Buffer.byteLength(Buffer str);
Call parameters:
- str: Buffer, the string of bytes to be retrieved. If str is an ArrayBuffer/TypedArray/DataView/Buffer object, return their actual length.
Return results:
- 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
2static Integer Buffer.compare(Buffer buf1,
Buffer buf2);
Call parameters:
- buf1: Buffer, buf to be compared
- buf2: Buffer, buf to be compared
Return results:
- Integer, returns the comparison byte length
member properties
length
Integer, gets the size of the cache object
1readonly Integer Buffer.length;
member function
write
Write the specified string to the cache object. The string defaults to utf-8. When out of bounds, only part of the data is written.
1
2
3
4Integer Buffer.write(String str,
Integer offset = 0,
Integer length = -1,
String codec = "utf8");
Call parameters:
- str: String, the string to be written
- offset: Integer, writing starting position
- length: Integer, writing 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", "base32", "base58", "base64", "utf8", oriconvCharacter sets supported by the module
Return results:
- Integer, length of data written in bytes
Write the specified string to the cache object. The string defaults to utf-8. When out of bounds, only part of the data is written.
1
2
3Integer Buffer.write(String str,
Integer offset = 0,
String codec = "utf8");
Call parameters:
- str: String, the string to be written
- offset: Integer, writing starting position
- codec: String, specifies the encoding format, allowed values are: "hex", "base32", "base58", "base64", "utf8", oriconvCharacter sets supported by the module
Return results:
- Integer, length of data written in bytes
Write the specified string to the cache object. The string defaults to utf-8. When out of bounds, only part of the data is written.
1
2Integer 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", "base32", "base58", "base64", "utf8", oriconvCharacter sets supported by the module
Return results:
- Integer, length of data written in bytes
fill
Fill the Buffer object with specified content data
1
2
3Buffer 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, filling starting position
- end: Integer, fill end position
Return results:
- Buffer, returns the current Buffer object
Fill the Buffer object with specified content data
1
2
3Buffer Buffer.fill(Buffer v,
Integer offset = 0,
Integer end = -1);
Call parameters:
- v: Buffer, the data that needs to be filled. If offset and end are not specified, the entire buffer will be filled.
- offset: Integer, filling starting position
- end: Integer, fill end position
Return results:
- Buffer, returns the current Buffer object
Fill the Buffer object with specified content data
1
2
3
4Buffer Buffer.fill(String v,
Integer offset = 0,
Integer end = -1,
String codec = "utf8");
Call parameters:
- v: String, the data to be filled. If offset and end are not specified, the entire buffer will be filled.
- offset: Integer, filling starting position
- end: Integer, fill end position
- codec: String, specifies the encoding format, allowed values are: "hex", "base32", "base58", "base64", "utf8", oriconvCharacter sets supported by the module
Return results:
- Buffer, returns the current Buffer object
Fill the Buffer object with specified content data
1
2
3Buffer Buffer.fill(String v,
Integer offset,
String codec);
Call parameters:
- v: String, the data to be filled. If offset and end are not specified, the entire buffer will be filled.
- offset: Integer, filling starting position
- codec: String, specifies the encoding format, allowed values are: "hex", "base32", "base58", "base64", "utf8", oriconvCharacter sets supported by the module
Return results:
- Buffer, returns the current Buffer object
Fill the Buffer object with specified content data
1
2Buffer Buffer.fill(String v,
String codec);
Call parameters:
- v: String, the data to be filled. If offset and end are not specified, the entire buffer will be filled.
- codec: String, specifies the encoding format, allowed values are: "hex", "base32", "base58", "base64", "utf8", oriconvCharacter sets supported by the module
Return results:
- Buffer, returns the current Buffer object
copy
Copy data from the source cache object area to the target cache object area
1
2
3
4Integer Buffer.copy(Buffer targetBuffer,
Integer targetStart = 0,
Integer sourceStart = 0,
Integer sourceEnd = -1);
Call parameters:
- targetBuffer: Buffer, target cache object
- targetStart: Integer, the starting byte position of the target cache object to copy, the default is 0
- sourceStart: Integer, the starting byte position of the source cache object, the default is 0
- sourceEnd: Integer, the end byte position of the source cache object, the default is -1, indicating the source data length
Return results:
- Integer, length of copied data bytes
set
Copy data from the source cache object area to the target cache object area
1
2Integer Buffer.set(Buffer src,
Integer start);
Call parameters:
- src: Buffer, target cache object
- start: Integer, the starting byte position of the source cache object
Return results:
- Integer, length of copied data bytes
readUInt8
Read an 8-bit unsigned integer value from the cache object
1Integer Buffer.readUInt8(Integer offset = 0);
Call parameters:
- offset: Integer, specifies the starting position of reading, the default is 0
Return results:
- Integer, returns the read integer value
readUInt16LE
Read a 16-bit unsigned integer value from the cache object, stored in little-endian order
1Integer Buffer.readUInt16LE(Integer offset = 0);
Call parameters:
- offset: Integer, specifies the starting position of reading, the default is 0
Return results:
- Integer, returns the read integer value
readUInt16BE
Read a 16-bit unsigned integer value from the cache object, stored in big endian order
1Integer Buffer.readUInt16BE(Integer offset = 0);
Call parameters:
- offset: Integer, specifies the starting position of reading, the default is 0
Return results:
- Integer, returns the read integer value
readUInt32LE
Read a 32-bit unsigned integer value from the cache object, stored in little-endian order
1Number Buffer.readUInt32LE(Integer offset = 0);
Call parameters:
- offset: Integer, specifies the starting position of reading, the default is 0
Return results:
- Number, returns the read integer value
readUInt32BE
Read a 32-bit unsigned integer value from the cache object, stored in big endian order
1Number Buffer.readUInt32BE(Integer offset = 0);
Call parameters:
- offset: Integer, specifies the starting position of reading, the default is 0
Return results:
- Number, returns the read integer value
readUIntLE
Read an unsigned integer value from the cache object, which supports up to 48 bits and is stored in little-endian order.
1
2Number Buffer.readUIntLE(Integer offset = 0,
Integer byteLength = 6);
Call parameters:
- offset: Integer, specifies the starting position of reading, the default is 0
- byteLength: Integer, specifies the number of bytes to read, the default is 6 bytes
Return results:
- Number, returns the read integer value
readUIntBE
Read an unsigned integer value from the cache object, which supports up to 48 bits and is stored in big endian order.
1
2Number Buffer.readUIntBE(Integer offset = 0,
Integer byteLength = 6);
Call parameters:
- offset: Integer, specifies the starting position of reading, the default is 0
- byteLength: Integer, specifies the number of bytes to read, the default is 6 bytes
Return results:
- Number, returns the read integer value
readInt64LE
Read a 64-bit integer value from the cache object, stored in little-endian order
1Long Buffer.readInt64LE(Integer offset = 0);
Call parameters:
- offset: Integer, specifies the starting position of reading, the default is 0
Return results:
- Long, returns the read integer value
readInt64BE
Read a 64-bit integer value from the cache object, stored in big endian order
1Long Buffer.readInt64BE(Integer offset = 0);
Call parameters:
- offset: Integer, specifies the starting position of reading, the default is 0
Return results:
- Long, returns the read integer value
readInt8
Read an 8-bit integer value from the cache object
1Integer Buffer.readInt8(Integer offset = 0);
Call parameters:
- offset: Integer, specifies the starting position of reading, the default is 0
Return results:
- Integer, returns the read integer value
readInt16LE
Read a 16-bit integer value from the cache object, stored in little-endian order
1Integer Buffer.readInt16LE(Integer offset = 0);
Call parameters:
- offset: Integer, specifies the starting position of reading, the default is 0
Return results:
- Integer, returns the read integer value
readInt16BE
Read a 16-bit integer value from the cache object, stored in big endian order
1Integer Buffer.readInt16BE(Integer offset = 0);
Call parameters:
- offset: Integer, specifies the starting position of reading, the default is 0
Return results:
- Integer, returns the read integer value
readInt32LE
Read a 32-bit integer value from the cache object, stored in little-endian order
1Integer Buffer.readInt32LE(Integer offset = 0);
Call parameters:
- offset: Integer, specifies the starting position of reading, the default is 0
Return results:
- Integer, returns the read integer value
readInt32BE
Read a 32-bit integer value from the cache object, stored in big endian order
1Integer Buffer.readInt32BE(Integer offset = 0);
Call parameters:
- offset: Integer, specifies the starting position of reading, the default is 0
Return results:
- Integer, returns the read integer value
readIntLE
Read an integer value from the cache object, which supports up to 48 bits and is stored in little-endian order.
1
2Number Buffer.readIntLE(Integer offset = 0,
Integer byteLength = 6);
Call parameters:
- offset: Integer, specifies the starting position of reading, the default is 0
- byteLength: Integer, specifies the number of bytes to read, the default is 6 bytes
Return results:
- Number, returns the read integer value
readIntBE
Read an integer value from the cache object, which supports up to 48 bits and is stored in big endian order.
1
2Number Buffer.readIntBE(Integer offset = 0,
Integer byteLength = 6);
Call parameters:
- offset: Integer, specifies the starting position of reading, the default is 0
- byteLength: Integer, specifies the number of bytes to read, the default is 6 bytes
Return results:
- Number, returns the read integer value
readFloatLE
Read a floating point number from the cache object, stored in little-endian order
1Number Buffer.readFloatLE(Integer offset = 0);
Call parameters:
- offset: Integer, specifies the starting position of reading, the default is 0
Return results:
- Number, returns the floating point number read
readFloatBE
Read a floating point number from the cache object, stored in big endian order
1Number Buffer.readFloatBE(Integer offset = 0);
Call parameters:
- offset: Integer, specifies the starting position of reading, the default is 0
Return results:
- Number, returns the floating point number read
readDoubleLE
Reads a double-precision floating point number from the cache object, stored in little-endian order
1Number Buffer.readDoubleLE(Integer offset = 0);
Call parameters:
- offset: Integer, specifies the starting position of reading, the default is 0
Return results:
- Number, returns the double precision floating point number read
readDoubleBE
Reads a double-precision floating point number from the cache object, stored in big-endian order
1Number Buffer.readDoubleBE(Integer offset = 0);
Call parameters:
- offset: Integer, specifies the starting position of reading, the default is 0
Return results:
- Number, returns the double precision floating point number read
writeUInt8
Write an 8-bit unsigned integer value to the cache object
1
2Integer Buffer.writeUInt8(Integer value,
Integer offset = 0);
Call parameters:
- value: Integer, specifies the value to be written
- offset: Integer, specifies the starting position of writing
Return results:
- Integer, offset plus the number of bytes written
writeUInt16LE
Write a 16-bit unsigned integer value to the cache object, stored in little-endian order
1
2Integer Buffer.writeUInt16LE(Integer value,
Integer offset = 0);
Call parameters:
- value: Integer, specifies the value to be written
- offset: Integer, specifies the starting position of writing
Return results:
- Integer, offset plus the number of bytes written
writeUInt16BE
Write a 16-bit unsigned integer value to the cache object, stored in big endian order
1
2Integer Buffer.writeUInt16BE(Integer value,
Integer offset = 0);
Call parameters:
- value: Integer, specifies the value to be written
- offset: Integer, specifies the starting position of writing
Return results:
- Integer, offset plus the number of bytes written
writeUInt32LE
Write a 32-bit unsigned integer value to the cache object, stored in little-endian order
1
2Integer Buffer.writeUInt32LE(Long value,
Integer offset = 0);
Call parameters:
- value: Long, specifies the value to be written
- offset: Integer, specifies the starting position of writing
Return results:
- Integer, offset plus the number of bytes written
writeUInt32BE
Write a 32-bit unsigned integer value to the cache object, stored in big endian order
1
2Integer Buffer.writeUInt32BE(Long value,
Integer offset = 0);
Call parameters:
- value: Long, specifies the value to be written
- offset: Integer, specifies the starting position of writing
Return results:
- Integer, offset plus the number of bytes written
writeUIntLE
Write an unsigned integer value to the cache object, which supports up to 48 bits and is stored in little-endian order.
1
2
3Integer Buffer.writeUIntLE(Long value,
Integer offset = 0,
Integer byteLength = 6);
Call parameters:
- value: Long, specifies the value to be written
- offset: Integer, specifies the starting position of writing
- byteLength: Integer, specifies the number of bytes to write, the default is 6 bytes
Return results:
- Integer, offset plus the number of bytes written
writeUIntBE
Write an unsigned integer value to the cache object, which supports up to 48 bits and is stored in big endian order.
1
2
3Integer Buffer.writeUIntBE(Long value,
Integer offset = 0,
Integer byteLength = 6);
Call parameters:
- value: Long, specifies the value to be written
- offset: Integer, specifies the starting position of writing
- byteLength: Integer, specifies the number of bytes to write, the default is 6 bytes
Return results:
- Integer, offset plus the number of bytes written
writeInt8
Write an 8-bit integer value to the cache object
1
2Integer Buffer.writeInt8(Integer value,
Integer offset = 0);
Call parameters:
- value: Integer, specifies the value to be written
- offset: Integer, specifies the starting position of writing
Return results:
- Integer, offset plus the number of bytes written
writeInt16LE
Write a 16-bit integer value to the cache object, stored in little-endian order
1
2Integer Buffer.writeInt16LE(Integer value,
Integer offset = 0);
Call parameters:
- value: Integer, specifies the value to be written
- offset: Integer, specifies the starting position of writing
Return results:
- Integer, offset plus the number of bytes written
writeInt16BE
Write a 16-bit integer value to the cache object, stored in big endian order
1
2Integer Buffer.writeInt16BE(Integer value,
Integer offset = 0);
Call parameters:
- value: Integer, specifies the value to be written
- offset: Integer, specifies the starting position of writing
Return results:
- Integer, offset plus the number of bytes written
writeInt32LE
Write a 32-bit integer value to the cache object, stored in little-endian order
1
2Integer Buffer.writeInt32LE(Integer value,
Integer offset = 0);
Call parameters:
- value: Integer, specifies the value to be written
- offset: Integer, specifies the starting position of writing
Return results:
- Integer, offset plus the number of bytes written
writeInt32BE
Write a 32-bit integer value to the cache object, stored in big endian order
1
2Integer Buffer.writeInt32BE(Integer value,
Integer offset = 0);
Call parameters:
- value: Integer, specifies the value to be written
- offset: Integer, specifies the starting position of writing
Return results:
- Integer, offset plus the number of bytes written
writeInt64LE
Write a 64-bit integer value to the cache object, stored in little-endian order
1
2Integer Buffer.writeInt64LE(Long value,
Integer offset = 0);
Call parameters:
- value: Long, specifies the value to be written
- offset: Integer, specifies the starting position of writing
Return results:
- Integer, offset plus the number of bytes written
writeInt64BE
Write a 64-bit integer value to the cache object, stored in big-endian order
1
2Integer Buffer.writeInt64BE(Long value,
Integer offset = 0);
Call parameters:
- value: Long, specifies the value to be written
- offset: Integer, specifies the starting position of writing
Return results:
- Integer, offset plus the number of bytes written
writeIntLE
Write an integer value to the cache object, which supports up to 48 bits and is stored in little-endian order.
1
2
3Integer Buffer.writeIntLE(Long value,
Integer offset = 0,
Integer byteLength = 6);
Call parameters:
- value: Long, specifies the value to be written
- offset: Integer, specifies the starting position of writing
- byteLength: Integer, specifies the number of bytes to write, the default is 6 bytes
Return results:
- Integer, offset plus the number of bytes written
writeIntBE
Write an integer value to the cache object, which supports up to 48 bits and is stored in big endian order.
1
2
3Integer Buffer.writeIntBE(Long value,
Integer offset = 0,
Integer byteLength = 6);
Call parameters:
- value: Long, specifies the value to be written
- offset: Integer, specifies the starting position of writing
- byteLength: Integer, specifies the number of bytes to write, the default is 6 bytes
Return results:
- Integer, offset plus the number of bytes written
writeFloatLE
Write a floating point number to the cache object, stored in little-endian order
1
2Integer Buffer.writeFloatLE(Number value,
Integer offset);
Call parameters:
- value: Number, specifies the value to be written
- offset: Integer, specifies the starting position of writing
Return results:
- Integer, offset plus the number of bytes written
writeFloatBE
Write a floating point number to the cache object, stored in big endian order
1
2Integer Buffer.writeFloatBE(Number value,
Integer offset);
Call parameters:
- value: Number, specifies the value to be written
- offset: Integer, specifies the starting position of writing
Return results:
- Integer, offset plus the number of bytes written
writeDoubleLE
Writes a double-precision floating point number to the cache object, stored in little-endian order.
1
2Integer Buffer.writeDoubleLE(Number value,
Integer offset);
Call parameters:
- value: Number, specifies the value to be written
- offset: Integer, specifies the starting position of writing
Return results:
- Integer, offset plus the number of bytes written
writeDoubleBE
Writes a double-precision floating-point number to the cache object, stored in big-endian order.
1
2Integer Buffer.writeDoubleBE(Number value,
Integer offset);
Call parameters:
- value: Number, specifies the value to be written
- offset: Integer, specifies the starting position of writing
Return results:
- Integer, offset plus the number of bytes written
indexOf
Returns the position where a specified data first appears in the Buffer
1
2Integer Buffer.indexOf(Integer v,
Integer offset = 0);
Call parameters:
- v: Integer, the data to be searched. If offset is not specified, it defaults to starting from the starting position.
- offset: Integer, starting search position
Return results:
- Integer, returns the found location, returns -1 if not found.
Returns the position where a specified data first appears in the Buffer
1
2Integer Buffer.indexOf(Buffer v,
Integer offset = 0);
Call parameters:
- v: Buffer, the data to be searched for. If offset is not specified, it defaults to starting from the starting position.
- offset: Integer, starting search position
Return results:
- Integer, returns the found location, returns -1 if not found.
Returns the position where a specified data first appears in the Buffer
1
2Integer Buffer.indexOf(String v,
Integer offset = 0);
Call parameters:
- v: String, the data to be searched. If offset is not specified, it defaults to starting from the starting position.
- offset: Integer, starting search position
Return results:
- Integer, returns the found location, returns -1 if not found.
slice
Returns a new cache object containing data from the specified start to the end of the cache
1Buffer Buffer.slice(Integer start = 0);
Call parameters:
- start: Integer, specifies the start of the range, defaults to starting from the beginning
Return results:
- Buffer, returns the new cache object
Returns a new cache object containing the specified range of data. If the range exceeds the cache, only the valid part of the data will be returned.
1
2Buffer Buffer.slice(Integer start,
Integer end);
Call parameters:
- start: Integer, the beginning of the specified range
- end: Integer, the end of the specified range
Return results:
- Buffer, returns the new cache object
equals
Compares the current object to the given object for equality
1Boolean Buffer.equals(object expected);
Call parameters:
- expected:object, formulate target objects for comparison
Return results:
- Boolean, returns the result of object comparison
compare
Compare cache contents
1Integer Buffer.compare(Buffer buf);
Call parameters:
- buf: Buffer, cache object to be compared
Return results:
- Integer, content comparison results
toString
Returns an encoded string of binary data
1
2
3String Buffer.toString(String codec,
Integer offset = 0,
Integer end);
Call parameters:
- codec: String, specifies the encoding format, allowed values are: "hex", "base32", "base58", "base64", "utf8", oriconvCharacter sets supported by the module
- offset: Integer, reading starting position
- end: Integer, reading end position
Return results:
- String, returns the string representation of the object
Returns an encoded string of binary data
1
2String Buffer.toString(String codec,
Integer offset = 0);
Call parameters:
- codec: String, specifies the encoding format, allowed values are: "hex", "base32", "base58", "base64", "utf8", oriconvCharacter sets supported by the module
- offset: Integer, reading starting position
Return results:
- String, returns the string representation of the object
Returns a UTF8 encoded string of binary data
1String Buffer.toString();
Return results:
- String, returns the string representation of the object
toArray
Returns an array of all binary data
1Array Buffer.toArray();
Return results:
- Array, returns an array containing object data
hex
Cache object content using hexadecimal encoding
1String Buffer.hex();
Return results:
- String, returns the encoded string
base32
usebase32Encoding cache object content
1String Buffer.base32();
Return results:
- String, returns the encoded string
base58
usebase58Encoding cache object content
1String Buffer.base58();
Return results:
- String, returns the encoded string
base64
usebase64Encoding cache object content
1String Buffer.base64();
Return results:
- String, returns the encoded string
toString
Returns the string representation of the object. Generally, "[Native Object]" is returned. The object can be re-implemented according to its own characteristics.
1String Buffer.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.
1Value Buffer.toJSON(String key = "");
Call parameters:
- key: String, not used
Return results:
- Value, returns a value containing JSON serializable