Object Buffer
Binary data cache object for io Data processing for reading and writing
The Buffer object is a global basic class, which can be created directly with new Buffer(...) at any time:
1var buf = new Buffer();
Inheritance
Constructor
Buffer
Cache object constructor
1new Buffer(Array datas);
Call parameters:
- datas: Array, initialize the data array
Cache object constructor
1new Buffer(ArrayBuffer datas);
Call parameters:
- datas: ArrayBuffer, initialize the data array
Cache object constructor
1new Buffer(TypedArray datas);
Call parameters:
- datas: TypedArray, initialize the data array
Cache object constructor
1new Buffer(ArrayBufferView datas);
Call parameters:
- datas: ArrayBufferView, initialize the data array
Cache object constructor
1new Buffer(Buffer buffer);
Call parameters:
- buffer: Buffer, initialize the Buffer object
Cache object constructor
1
2new 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, the allowed value is: "hex", "base64", "utf8", or iconv Character set supported by the module
Cache object constructor
1new Buffer(Integer size = 0);
Call parameters:
- size: Integer, initialize buffer size
Operator
operator[]
Cached objects can directly access binary data using subscripts
1Integer Buffer[];
@iterator
Query the iterator of the current object element
1Iterator Buffer.@iterator();
Return result:
- Iterator, Returns an iterator of current object elements
Object
Buffer
Binary data cache object for io Data processing for reading and writing
1Buffer new Buffer;
Static function
isBuffer
Check whether the given variable is a Buffer object
1static Boolean Buffer.isBuffer(Value v);
Call parameters:
- v: Value, given the variable to be tested
Return result:
- Boolean, Whether the incoming object is a Buffer object
from
Create Buffer objects from other Buffers
1
2
3static Buffer Buffer.from(Buffer buffer,
Integer byteOffset = 0,
Integer length = -1);
Call parameters:
- buffer: Buffer, a given Buffer type variable is used to create a 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
3static Buffer Buffer.from(String str,
Integer byteOffset = 0,
Integer length = -1);
Call parameters:
- str: String, the initialization 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
2static Buffer Buffer.from(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, the allowed value is: "hex", "base64", "utf8", or iconv Character set supported by the module
Return result:
- Buffer, Return Buffer instance
concat
Concatenate data in 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 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
3static 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, the allowed value is: "hex", "base64", "utf8", or iconv Character set supported by the module
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
3static 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, specify the encoding format, the allowed value is: "hex", "base64", "utf8", or iconv Character set supported by the module
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
3static 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, the allowed value is: "hex", "base64", "utf8", or iconv Character set supported by the module
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.
1static 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.
1static 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
2static 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, specify the encoding format, the allowed value is: "hex", "base64", "utf8", or iconv Character set supported by the module
Return result:
- Integer, Returns the actual byte length
Returns the actual byte length of the string
1
2static 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, specify the encoding format, the allowed value is: "hex", "base64", "utf8", or iconv Character set supported by the module
Return result:
- Integer, Returns the actual byte length
Returns the actual byte length of the string
1
2static 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, specify the encoding format, the allowed value is: "hex", "base64", "utf8", or iconv Character set supported by the module
Return result:
- Integer, Returns the actual byte length
Returns the actual byte length of the string
1
2static 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, specify the encoding format, the allowed value is: "hex", "base64", "utf8", or iconv Character set supported by the module
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
2static 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
1static Boolean Buffer.isEncoding(String codec);
Call parameters:
- codec: String, encoding format to be detected
Return result:
- Boolean, Does it support
Member attributes
length
Integer, get the size of the cached object
1readonly Integer Buffer.length;
buffer
ArrayBuffer, return buffered data in ArrayBuffer format
1readonly ArrayBuffer Buffer.buffer;
Member function
resize
Modify the size of the cached object
1Buffer.resize(Integer sz);
Call parameters:
- sz: Integer, specify new size
append
Write a set of binary data at the end of the cache object
1Buffer.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
2Buffer.append(String str,
String codec = "utf8");
Call parameters:
- str: String, the string to be written
- codec: String, specify the encoding format, the allowed value is: "hex", "base64", "utf8", or iconv Character set supported by the module
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
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, write start position
- length: Integer, write length (unit byte, default value -1), if not specified, it is the length of the string to be written
- codec: String, specify the encoding format, the allowed value is: "hex", "base64", "utf8", or iconv Character set supported by the module
Return result:
- Integer, The length of the written data byte
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
3Integer Buffer.write(String str,
Integer offset = 0,
String codec = "utf8");
Call parameters:
- str: String, the string to be written
- offset: Integer, write start position
- codec: String, specify the encoding format, the allowed value is: "hex", "base64", "utf8", or iconv Character set supported by the module
Return result:
- Integer, The length of the written data byte
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
2Integer Buffer.write(String str,
String codec = "utf8");
Call parameters:
- str: String, the string to be written
- codec: String, specify the encoding format, the allowed value is: "hex", "base64", "utf8", or iconv Character set supported by the module
Return result:
- Integer, The length of the written data byte
fill
Fill the Buffer object with the 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, fill start position
- end: Integer, fill end position
Return result:
- Buffer, Return the current Buffer object
Fill the Buffer object with the specified content data
1
2
3Buffer Buffer.fill(Buffer v,
Integer offset = 0,
Integer end = -1);
Call parameters:
- v: Buffer, the data to be filled, if offset and end are not specified, the entire buffer will be filled
- offset: Integer, fill start position
- end: Integer, fill end position
Return result:
- Buffer, Return the current Buffer object
Fill the Buffer object with the specified content data
1
2
3Buffer 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, fill start position
- end: Integer, fill end position
Return result:
- Buffer, Return the current Buffer object
indexOf
Returns the position of the first occurrence of a specified data in the Buffer
1
2Integer 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, Return the location found, return -1 if not found
Returns the position of the first occurrence of a specified data in the Buffer
1
2Integer 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, Return the location found, return -1 if not found
Returns the position of the first occurrence of a specified data in the Buffer
1
2Integer 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, Return the location found, return -1 if not found
compare
Compare the contents of the cache
1Integer 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
4Integer 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 of the target cache object to start copying, 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, 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
2Integer 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
1Integer Buffer.readUInt8(Integer offset = 0);
Call parameters:
- offset: Integer, specify the starting position for reading, the default is 0
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
1Integer Buffer.readUInt16LE(Integer offset = 0);
Call parameters:
- offset: Integer, specify the starting position for reading, the default is 0
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
1Integer Buffer.readUInt16BE(Integer offset = 0);
Call parameters:
- offset: Integer, specify the starting position for reading, the default is 0
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
1Long Buffer.readUInt32LE(Integer offset = 0);
Call parameters:
- offset: Integer, specify the starting position for reading, the default is 0
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
1Long Buffer.readUInt32BE(Integer offset = 0);
Call parameters:
- offset: Integer, specify the starting position for reading, the default is 0
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
2Long Buffer.readUIntLE(Integer offset = 0,
Integer byteLength = 8);
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
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
2Long Buffer.readUIntBE(Integer offset = 0,
Integer byteLength = 8);
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
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
1Long Buffer.readInt64LE(Integer offset = 0);
Call parameters:
- offset: Integer, specify the starting position for reading, the default is 0
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
1Long Buffer.readInt64BE(Integer offset = 0);
Call parameters:
- offset: Integer, specify the starting position for reading, the default is 0
Return result:
- Long, Returns the integer value read
readInt8
Read an 8-bit integer value from the cache object
1Integer Buffer.readInt8(Integer offset = 0);
Call parameters:
- offset: Integer, specify the starting position for reading, the default is 0
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
1Integer Buffer.readInt16LE(Integer offset = 0);
Call parameters:
- offset: Integer, specify the starting position for reading, the default is 0
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
1Integer Buffer.readInt16BE(Integer offset = 0);
Call parameters:
- offset: Integer, specify the starting position for reading, the default is 0
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
1Integer Buffer.readInt32LE(Integer offset = 0);
Call parameters:
- offset: Integer, specify the starting position for reading, the default is 0
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
1Integer Buffer.readInt32BE(Integer offset = 0);
Call parameters:
- offset: Integer, specify the starting position for reading, the default is 0
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
2Long Buffer.readIntLE(Integer offset = 0,
Integer byteLength = 8);
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
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 it in high-endian order
1
2Long Buffer.readIntBE(Integer offset = 0,
Integer byteLength = 8);
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
Return result:
- Long, Returns the integer value read
writeInt64LE
Write a 64-bit integer value to the cache object in low-endian storage
1
2Integer Buffer.writeInt64LE(Long value,
Integer offset = 0);
Call parameters:
- value: Long, specify the value to be written
- offset: Integer, specify the starting position of writing
Return result:
- Integer, offset plus the number of bytes written
writeInt64BE
Write a 64-bit integer value to the cache object and store it in high-endian order
1
2Integer Buffer.writeInt64BE(Long value,
Integer offset = 0);
Call parameters:
- value: Long, specify the value to be written
- offset: Integer, specify the starting position of writing
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
1Number Buffer.readFloatLE(Integer offset = 0);
Call parameters:
- offset: Integer, specify the starting position for reading, the default is 0
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 order
1Number Buffer.readFloatBE(Integer offset = 0);
Call parameters:
- offset: Integer, specify the starting position for reading, the default is 0
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
1Number Buffer.readDoubleLE(Integer offset = 0);
Call parameters:
- offset: Integer, specify the starting position for reading, the default is 0
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
1Number Buffer.readDoubleBE(Integer offset = 0);
Call parameters:
- offset: Integer, specify the starting position for reading, the default is 0
Return result:
- 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, specify the value to be written
- offset: Integer, specify the starting position of writing
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
2Integer Buffer.writeUInt16LE(Integer value,
Integer offset = 0);
Call parameters:
- value: Integer, specify the value to be written
- offset: Integer, specify the starting position of writing
Return result:
- Integer, offset plus the number of bytes written
writeUInt16BE
Write a 16-bit unsigned integer value to the cache object, and store it in high-endian order
1
2Integer Buffer.writeUInt16BE(Integer value,
Integer offset = 0);
Call parameters:
- value: Integer, specify the value to be written
- offset: Integer, specify the starting position of writing
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
2Integer Buffer.writeUInt32LE(Long value,
Integer offset = 0);
Call parameters:
- value: Long, specify the value to be written
- offset: Integer, specify the starting position of writing
Return result:
- Integer, offset plus the number of bytes written
writeUInt32BE
Write a 32-bit unsigned integer value to the cache object, and store it in high-endian order
1
2Integer Buffer.writeUInt32BE(Long value,
Integer offset = 0);
Call parameters:
- value: Long, specify the value to be written
- offset: Integer, specify the starting position of writing
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
3Integer Buffer.writeUIntLE(Long value,
Integer offset = 0,
Integer byteLength = 8);
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
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
3Integer Buffer.writeUIntBE(Long value,
Integer offset = 0,
Integer byteLength = 8);
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
Return result:
- 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, specify the value to be written
- offset: Integer, specify the starting position of writing
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
2Integer Buffer.writeInt16LE(Integer value,
Integer offset = 0);
Call parameters:
- value: Integer, specify the value to be written
- offset: Integer, specify the starting position of writing
Return result:
- Integer, offset plus the number of bytes written
writeInt16BE
Write a 16-bit integer value to the cache object and store it in high-endian order
1
2Integer Buffer.writeInt16BE(Integer value,
Integer offset = 0);
Call parameters:
- value: Integer, specify the value to be written
- offset: Integer, specify the starting position of writing
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
2Integer Buffer.writeInt32LE(Integer value,
Integer offset = 0);
Call parameters:
- value: Integer, specify the value to be written
- offset: Integer, specify the starting position of writing
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
2Integer Buffer.writeInt32BE(Integer value,
Integer offset = 0);
Call parameters:
- value: Integer, specify the value to be written
- offset: Integer, specify the starting position of writing
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
3Integer Buffer.writeIntLE(Long value,
Integer offset = 0,
Integer byteLength = 8);
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
Return result:
- Integer, offset plus the number of bytes written
writeIntBE
Write an integer value to the cache object, with a maximum support of 64 bits, stored in high-endian order
1
2
3Integer Buffer.writeIntBE(Long value,
Integer offset = 0,
Integer byteLength = 8);
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
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
2Integer Buffer.writeFloatLE(Number value,
Integer offset);
Call parameters:
- value: Number, specify the value to be written
- offset: Integer, specify the starting position of writing
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
2Integer Buffer.writeFloatBE(Number value,
Integer offset);
Call parameters:
- value: Number, specify the value to be written
- offset: Integer, specify the starting position of writing
Return result:
- Integer, offset plus the number of bytes written
writeDoubleLE
Write a double-precision floating-point number to the cache object, and store it in low-endian order
1
2Integer Buffer.writeDoubleLE(Number value,
Integer offset);
Call parameters:
- value: Number, specify the value to be written
- offset: Integer, specify the starting position of writing
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
2Integer Buffer.writeDoubleBE(Number value,
Integer offset);
Call parameters:
- value: Number, specify the value to be written
- offset: Integer, specify the starting position of writing
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
1Buffer 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 the new cache 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 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 result:
- Buffer, Return the new cache object
join
Put all the elements in the current object into a string
1String Buffer.join(String separator = ",");
Call parameters:
- separator: String, split character, default is ","
Return result:
- String, Return the generated string
reverse
Return a new cache object, containing the reverse order of the current object data
1Buffer Buffer.reverse();
Return result:
- Buffer, Return the new cache object
equals
Compare whether the current object is equal to the given object
1Boolean Buffer.equals(object expected);
Call parameters:
- expected: object, Develop targets for comparison
Return result:
- Boolean, Return the result of object comparison
hex
Use hexadecimal encoding to cache object content
1String Buffer.hex();
Return result:
- String, Returns the encoded string
base64
use base64 Encoding cache object content
1String Buffer.base64();
Return result:
- String, Returns the encoded string
keys
Returns an array of all binary data
1Iterator Buffer.keys();
Return result:
- Iterator, Returns an iterator containing the data index of the object
values
Returns an array of all binary data
1Iterator Buffer.values();
Return result:
- Iterator, Returns an iterator containing the data values of the object
entries
Returns an iterator containing object data [index, byte] pairs
1Iterator Buffer.entries();
Return result:
- Iterator, [index, byte] iterator of pairs
toArray
Returns an array of all binary data
1Array Buffer.toArray();
Return result:
- Array, Returns an array containing object data
toString
Returns the encoded string of binary data
1
2
3String Buffer.toString(String codec,
Integer offset = 0,
Integer end);
Call parameters:
- codec: String, specify the encoding format, the allowed value is: "hex", "base64", "utf8", or iconv Character set supported by the module
- offset: Integer, read start position
- end: Integer, read end position
Return result:
- String, Returns the string representation of the object
Returns the encoded string of binary data
1
2String Buffer.toString(String codec,
Integer offset = 0);
Call parameters:
- codec: String, specify the encoding format, the allowed value is: "hex", "base64", "utf8", or iconv Character set supported by the module
- offset: Integer, read start position
Return result:
- String, Returns the string representation of the object
Returns the utf8 encoded string of binary data
1String 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
1String 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
1Value Buffer.toJSON(String key = "");
Call parameters:
- key: String, unused
Return result:
- Value, Returns a value containing JSON serializable