A **Buffer** object represents a byte sequence of a fixed length. It is used to store binary data.
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
A **Buffer** object represents a fixed-length sequence of bytes. It is used to store binary data.
You can use the APIs provided by the Buffer module to process images and a large amount of binary data, and receive or upload files.
You can use the APIs provided by the **Buffer** module to process images and a large amount of binary data, and receive or upload files.
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
## Modules to Import
...
@@ -21,55 +22,23 @@ Enumerates the supported encoding formats of strings.
...
@@ -21,55 +22,23 @@ Enumerates the supported encoding formats of strings.
| Encoding Format | Description |
| Encoding Format | Description |
| ------- | -------------------- |
| ------- | -------------------- |
| ascii | ASCII format. |
| 'ascii' | ASCII format, which is case insensitive.|
| utf8 | UTF-8 |
| 'utf8' | UTF-8 format, which is case insensitive.|
| utf-8 | UTF-8 format.|
| 'utf-8' | UTF-8 format, which is case insensitive.|
| utf16le | UTF-16LE format.|
| 'utf16le' | UTF-16 little-endian format, which is case insensitive.|
| ucs2 | UTF-16LE format.|
| 'ucs2' | UTF-16 little-endian format, which is case insensitive.|
| ucs-2 | UTF-16LE format.|
| 'ucs-2' | UTF-16 little-endian format, which is case insensitive.|
| base64 | Base64 format.|
| 'base64' | Base64 format, which is case insensitive.|
| base64url | Base64 format.|
| 'base64url' | Base64 format, which is case insensitive.|
| latin1 | ASCII format.|
| 'latin1' | ASCII format, which is case insensitive.|
| binary | Binary format.|
| 'binary' | Binary format, which is case insensitive.|
| hex | Hexadecimal format.|
| 'hex' | Hexadecimal format, which is case insensitive.|
@@ -507,7 +541,15 @@ Compares this **Buffer** instance with another instance.
...
@@ -507,7 +541,15 @@ Compares this **Buffer** instance with another instance.
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| number | Returns **0** if the two **Buffer** instances are the same.<br>Returns **1** if this instance comes after the target instance when sorted.<br>Returns **-1** if this instance comes before the target instance when sorted. |
| number | Returns **0** if the two **Buffer** instances are the same.<br>Returns **1** if this instance comes after the target instance when sorted. <br>Returns **-1** if this instance comes before the target instance when sorted.|
**Error codes**
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
| 10200001 | The value of "[targetStart/targetEnd/sourceStart/sourceEnd]" is out of range. |
**Example**
**Example**
...
@@ -547,7 +589,7 @@ Copies data at the specified position in this **Buffer** instance to the specifi
...
@@ -547,7 +589,7 @@ Copies data at the specified position in this **Buffer** instance to the specifi
**Error codes**
**Error codes**
For details about the error codes, see [Buffer Error Codes](../errorcodes/errorcode-buffer.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| ID| Error Message|
| -------- | -------- |
| -------- | -------- |
...
@@ -578,6 +620,13 @@ Creates and returns an iterator that contains key-value pairs of this **Buffer**
...
@@ -578,6 +620,13 @@ Creates and returns an iterator that contains key-value pairs of this **Buffer**