提交 6f1e6361 编写于 作者: L liu-ganlin

update buffer doc parameter

Signed-off-by: Nliu-ganlin <liuganlin@huawei.com>
上级 3e90daed
...@@ -108,7 +108,7 @@ buf.fill(0); ...@@ -108,7 +108,7 @@ buf.fill(0);
### byteLength ### byteLength
byteLength(string: string | Buffer | TypeArray | DataView | ArrayBuffer | SharedArrayBuffer, encoding?: BufferEncoding): number byteLength(string: string | Buffer | TypedArray | DataView | ArrayBuffer | SharedArrayBuffer, encoding?: BufferEncoding): number
根据不同的编码方法,返回字符串的字节数。 根据不同的编码方法,返回字符串的字节数。
...@@ -118,7 +118,7 @@ byteLength(string: string | Buffer | TypeArray | DataView | ArrayBuffer | Shared ...@@ -118,7 +118,7 @@ byteLength(string: string | Buffer | TypeArray | DataView | ArrayBuffer | Shared
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| string | string&nbsp;\|&nbsp;Buffer&nbsp;\|&nbsp;TypeArray&nbsp;\|&nbsp;DataView&nbsp;\|&nbsp;ArrayBuffer&nbsp;\|&nbsp;SharedArrayBuffer | 是 | 指定字符串。 | | string | string&nbsp;\|&nbsp;Buffer&nbsp;\|&nbsp;TypedArray&nbsp;\|&nbsp;DataView&nbsp;\|&nbsp;ArrayBuffer&nbsp;\|&nbsp;SharedArrayBuffer | 是 | 指定字符串。 |
| encoding | BufferEncoding | 否 | 编码方式。 默认值: 'utf-8' | | encoding | BufferEncoding | 否 | 编码方式。 默认值: 'utf-8' |
**返回值:** **返回值:**
...@@ -139,7 +139,7 @@ console.log(`${str}: ${str.length} characters, ${buffer.byteLength(str, 'utf-8') ...@@ -139,7 +139,7 @@ console.log(`${str}: ${str.length} characters, ${buffer.byteLength(str, 'utf-8')
### compare ### compare
compare(buf1: Buffer | Uint8Array, buf2: Buffer | Uint8Array): number compare(buf1: Buffer | Uint8Array, buf2: Buffer | Uint8Array): -1 | 0 | 1
返回比较buf1和buf2的结果, 通常用于对Buffer实例的数组进行排序。 返回比较buf1和buf2的结果, 通常用于对Buffer实例的数组进行排序。
...@@ -157,7 +157,7 @@ compare(buf1: Buffer | Uint8Array, buf2: Buffer | Uint8Array): number ...@@ -157,7 +157,7 @@ compare(buf1: Buffer | Uint8Array, buf2: Buffer | Uint8Array): number
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| number | 如果buf1与buf2相同,则返回0<br/>如果排序时buf1位于buf2之后,则返回1<br/>如果排序时buf1位于buf2之前,则返回-1。 | | -1&nbsp;\|&nbsp;0&nbsp;\|&nbsp;1 | 如果buf1与buf2相同,则返回0<br/>如果排序时buf1位于buf2之后,则返回1<br/>如果排序时buf1位于buf2之前,则返回-1。 |
**示例:** **示例:**
...@@ -206,7 +206,7 @@ console.log(buf.toString('hex')); // 3132333461626364 ...@@ -206,7 +206,7 @@ console.log(buf.toString('hex')); // 3132333461626364
### from ### from
from(array: number[]): Buffer from(array: number[]): Buffer;
根据指定数组创建新的Buffer实例。 根据指定数组创建新的Buffer实例。
...@@ -266,9 +266,9 @@ let buf = buffer.from(ab, 0, 2); ...@@ -266,9 +266,9 @@ let buf = buffer.from(ab, 0, 2);
### from ### from
from(data: Buffer | Uint8Array): Buffer from(buffer: Buffer | Uint8Array): Buffer
创建并复制`data`数据到新的Buffer实例并返回。 创建并复制`buffer`数据到新的Buffer实例并返回。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -276,7 +276,7 @@ from(data: Buffer | Uint8Array): Buffer ...@@ -276,7 +276,7 @@ from(data: Buffer | Uint8Array): Buffer
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| data | Buffer&nbsp;\|&nbsp;Uint8Array | 是 | 实例数据。 | | buffer | Buffer&nbsp;\|&nbsp;Uint8Array | 是 | 实例数据。 |
**返回值:** **返回值:**
...@@ -325,7 +325,7 @@ let buf = buffer.from(new String('this is a test')); ...@@ -325,7 +325,7 @@ let buf = buffer.from(new String('this is a test'));
### from ### from
from(string: string, encoding?: BufferEncoding): Buffer from(string: String, encoding?: BufferEncoding): Buffer
根据指定编码格式的字符串,创建新的Buffer实例。 根据指定编码格式的字符串,创建新的Buffer实例。
...@@ -335,7 +335,7 @@ from(string: string, encoding?: BufferEncoding): Buffer ...@@ -335,7 +335,7 @@ from(string: string, encoding?: BufferEncoding): Buffer
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| string | string | 是 | 字符串 | | string | String | 是 | 字符串 |
| encoding | BufferEncoding | 否 | 编码格式。 默认值: 'utf-8'。 | | encoding | BufferEncoding | 否 | 编码格式。 默认值: 'utf-8'。 |
**返回值:** **返回值:**
...@@ -434,7 +434,7 @@ compare(target: Buffer | Uint8Array, targetStart?: number, targetEnd?: number, s ...@@ -434,7 +434,7 @@ compare(target: Buffer | Uint8Array, targetStart?: number, targetEnd?: number, s
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| target | Buffer&nbsp;\|&nbsp;Uint8Array | 是 | 要比较的实例对象。 | | target | Buffer&nbsp;\|&nbsp;Uint8Array | 是 | 要比较的实例对象。 |
| targetStart | number | 否 | `target`实例中开始的偏移量。 默认值: 0。 | | targetStart | number | 否 | `target`实例中开始的偏移量。 默认值: 0。 |
| targetEnd | number | 否 | `target`实例中结束的偏移量(不包括本身)。 默认值: target.lengt。 | | targetEnd | number | 否 | `target`实例中结束的偏移量(不包括本身)。 默认值: target.length。 |
| sourceStart | number | 否 | `this`实例中开始的偏移量。 默认值: 0。 | | sourceStart | number | 否 | `this`实例中开始的偏移量。 默认值: 0。 |
| sourceEnd | number | 否 | `this`实例中结束的偏移量(不包括本身)。 默认值: buf.length。 | | sourceEnd | number | 否 | `this`实例中结束的偏移量(不包括本身)。 默认值: buf.length。 |
...@@ -516,7 +516,7 @@ for (let pair of buf.entries()) { ...@@ -516,7 +516,7 @@ for (let pair of buf.entries()) {
### equals ### equals
equals(otherBuffer: Buffer | Uint8Array): boolean equals(otherBuffer: Uint8Array | Buffer): boolean
比较`this`实例和otherBuffer实例是否相等。 比较`this`实例和otherBuffer实例是否相等。
...@@ -526,7 +526,7 @@ equals(otherBuffer: Buffer | Uint8Array): boolean ...@@ -526,7 +526,7 @@ equals(otherBuffer: Buffer | Uint8Array): boolean
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| otherBuffer | Buffer&nbsp;\|&nbsp;Uint8Array | 是 | 比较的目标对象。 | | otherBuffer | Uint8Array&nbsp;\|&nbsp;Buffer | 是 | 比较的目标对象。 |
**返回值:** **返回值:**
...@@ -705,7 +705,7 @@ console.log(buf.lastIndexOf('buffer').toString()); // 打印: 17 ...@@ -705,7 +705,7 @@ console.log(buf.lastIndexOf('buffer').toString()); // 打印: 17
### readBigInt64BE ### readBigInt64BE
readBigInt64BE(offset: number): bigint readBigInt64BE(offset?: number): bigint
从指定的`offset`处读取有符号的大端序64位整数。 从指定的`offset`处读取有符号的大端序64位整数。
...@@ -715,7 +715,7 @@ readBigInt64BE(offset: number): bigint ...@@ -715,7 +715,7 @@ readBigInt64BE(offset: number): bigint
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| offset | number | | 偏移量。默认值: 0。 | | offset | number | | 偏移量。默认值: 0。 |
**返回值:** **返回值:**
...@@ -735,9 +735,9 @@ console.log(buf.readBigInt64BE(0).toString()); ...@@ -735,9 +735,9 @@ console.log(buf.readBigInt64BE(0).toString());
### readBigInt64LE ### readBigInt64LE
readBigInt64LE(offset: number): bigint readBigInt64LE(offset?: number): bigint
从指定的`offset`处读取符号的小端序64位整数。 从指定的`offset`处读取符号的小端序64位整数。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -745,7 +745,7 @@ readBigInt64LE(offset: number): bigint ...@@ -745,7 +745,7 @@ readBigInt64LE(offset: number): bigint
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| offset | number | | 偏移量。默认值: 0。 | | offset | number | | 偏移量。默认值: 0。 |
**返回值:** **返回值:**
...@@ -765,7 +765,7 @@ console.log(buf.readBigInt64LE(0).toString()); ...@@ -765,7 +765,7 @@ console.log(buf.readBigInt64LE(0).toString());
### readBigUInt64BE ### readBigUInt64BE
readBigUInt64BE(offset: number): bigint readBigUInt64BE(offset?: number): bigint
从指定的`offset`处读取无符号的大端序64位整数。 从指定的`offset`处读取无符号的大端序64位整数。
...@@ -775,7 +775,7 @@ readBigUInt64BE(offset: number): bigint ...@@ -775,7 +775,7 @@ readBigUInt64BE(offset: number): bigint
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| offset | number | | 偏移量。默认值: 0。 | | offset | number | | 偏移量。默认值: 0。 |
**返回值:** **返回值:**
...@@ -795,7 +795,7 @@ console.log(buf.readBigUInt64BE(0).toString()); ...@@ -795,7 +795,7 @@ console.log(buf.readBigUInt64BE(0).toString());
### readBigUInt64LE ### readBigUInt64LE
readBigUInt64LE(offset: number): bigint readBigUInt64LE(offset?: number): bigint
从指定的`offset`处读取无符号的小端序64位整数。 从指定的`offset`处读取无符号的小端序64位整数。
...@@ -805,7 +805,7 @@ readBigUInt64LE(offset: number): bigint ...@@ -805,7 +805,7 @@ readBigUInt64LE(offset: number): bigint
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| offset | number | | 偏移量。默认值: 0。 | | offset | number | | 偏移量。默认值: 0。 |
**返回值:** **返回值:**
...@@ -825,7 +825,7 @@ console.log(buf.readBigUInt64LE(0).toString()); ...@@ -825,7 +825,7 @@ console.log(buf.readBigUInt64LE(0).toString());
### readDoubleBE ### readDoubleBE
readDoubleBE(offset: number): number readDoubleBE(offset?: number): number
从指定`offset`处读取64位大端序双精度值。 从指定`offset`处读取64位大端序双精度值。
...@@ -835,7 +835,7 @@ readDoubleBE(offset: number): number ...@@ -835,7 +835,7 @@ readDoubleBE(offset: number): number
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| offset | number | | 偏移量。默认值: 0。 | | offset | number | | 偏移量。默认值: 0。 |
**返回值:** **返回值:**
...@@ -854,7 +854,7 @@ console.log(buf.readDoubleBE(0).toString()); ...@@ -854,7 +854,7 @@ console.log(buf.readDoubleBE(0).toString());
### readDoubleLE ### readDoubleLE
readDoubleLE(offset: number): number readDoubleLE(offset?: number): number
从指定`offset`处读取64位小端序双精度值。 从指定`offset`处读取64位小端序双精度值。
...@@ -864,7 +864,7 @@ readDoubleLE(offset: number): number ...@@ -864,7 +864,7 @@ readDoubleLE(offset: number): number
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| offset | number | | 偏移量。默认值: 0。 | | offset | number | | 偏移量。默认值: 0。 |
**返回值:** **返回值:**
...@@ -883,7 +883,7 @@ console.log(buf.readDoubleLE(0).toString()); ...@@ -883,7 +883,7 @@ console.log(buf.readDoubleLE(0).toString());
### readFloatBE ### readFloatBE
readFloatBE(offset: number): number readFloatBE(offset?: number): number
从指定`offset`处读取32位大端序浮点数。 从指定`offset`处读取32位大端序浮点数。
...@@ -893,7 +893,7 @@ readFloatBE(offset: number): number ...@@ -893,7 +893,7 @@ readFloatBE(offset: number): number
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| offset | number | | 偏移量。默认值: 0。 | | offset | number | | 偏移量。默认值: 0。 |
**返回值:** **返回值:**
...@@ -912,7 +912,7 @@ console.log(buf.readFloatBE(0).toString()); ...@@ -912,7 +912,7 @@ console.log(buf.readFloatBE(0).toString());
### readFloatLE ### readFloatLE
readFloatLE(offset: number): number readFloatLE(offset?: number): number
从指定`offset`处读取32位小端序浮点数。 从指定`offset`处读取32位小端序浮点数。
...@@ -922,7 +922,7 @@ readFloatLE(offset: number): number ...@@ -922,7 +922,7 @@ readFloatLE(offset: number): number
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| offset | number | | 偏移量。默认值: 0。 | | offset | number | | 偏移量。默认值: 0。 |
**返回值:** **返回值:**
...@@ -941,7 +941,7 @@ console.log(buf.readFloatLE(0).toString()); ...@@ -941,7 +941,7 @@ console.log(buf.readFloatLE(0).toString());
### readInt8 ### readInt8
readInt8(offset: number): number readInt8(offset?: number): number
从指定的`offset`处读取有符号的8位整数。 从指定的`offset`处读取有符号的8位整数。
...@@ -951,7 +951,7 @@ readInt8(offset: number): number ...@@ -951,7 +951,7 @@ readInt8(offset: number): number
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| offset | number | | 偏移量。默认值: 0。 | | offset | number | | 偏移量。默认值: 0。 |
**返回值:** **返回值:**
...@@ -971,7 +971,7 @@ console.log(buf.readInt8(1).toString()); // 打印: 5 ...@@ -971,7 +971,7 @@ console.log(buf.readInt8(1).toString()); // 打印: 5
### readInt16BE ### readInt16BE
readInt16BE(offset: number): number readInt16BE(offset?: number): number
从指定的`offset`处读取有符号的大端序16位整数。 从指定的`offset`处读取有符号的大端序16位整数。
...@@ -981,7 +981,7 @@ readInt16BE(offset: number): number ...@@ -981,7 +981,7 @@ readInt16BE(offset: number): number
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| offset | number | | 偏移量。默认值: 0。 | | offset | number | | 偏移量。默认值: 0。 |
**返回值:** **返回值:**
...@@ -1000,7 +1000,7 @@ console.log(buf.readInt16BE(0).toString()); // 打印: 5 ...@@ -1000,7 +1000,7 @@ console.log(buf.readInt16BE(0).toString()); // 打印: 5
### readInt16LE ### readInt16LE
readInt16LE(offset: number): number readInt16LE(offset?: number): number
从指定的`offset`处读取有符号的小端序16位整数 从指定的`offset`处读取有符号的小端序16位整数
...@@ -1010,7 +1010,7 @@ readInt16LE(offset: number): number ...@@ -1010,7 +1010,7 @@ readInt16LE(offset: number): number
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| offset | number | | 偏移量。默认值: 0。 | | offset | number | | 偏移量。默认值: 0。 |
**返回值:** **返回值:**
...@@ -1029,7 +1029,7 @@ console.log(buf.readInt16LE(0).toString()); // 打印: 1280 ...@@ -1029,7 +1029,7 @@ console.log(buf.readInt16LE(0).toString()); // 打印: 1280
### readInt32BE ### readInt32BE
readInt32BE(offset: number): number readInt32BE(offset?: number): number
从指定的`offset`处读取有符号的大端序32位整数 从指定的`offset`处读取有符号的大端序32位整数
...@@ -1039,7 +1039,7 @@ readInt32BE(offset: number): number ...@@ -1039,7 +1039,7 @@ readInt32BE(offset: number): number
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| offset | number | | 偏移量。默认值: 0。 | | offset | number | | 偏移量。默认值: 0。 |
**返回值:** **返回值:**
...@@ -1058,7 +1058,7 @@ console.log(buf.readInt32BE(0).toString()); // 打印: 5 ...@@ -1058,7 +1058,7 @@ console.log(buf.readInt32BE(0).toString()); // 打印: 5
### readInt32LE ### readInt32LE
readInt32LE(offset: number): number readInt32LE(offset?: number): number
从指定的`offset`处读取有符号的小端序32位整数 从指定的`offset`处读取有符号的小端序32位整数
...@@ -1068,7 +1068,7 @@ readInt32LE(offset: number): number ...@@ -1068,7 +1068,7 @@ readInt32LE(offset: number): number
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| offset | number | | 偏移量。默认值: 0。 | | offset | number | | 偏移量。默认值: 0。 |
**返回值:** **返回值:**
...@@ -1097,8 +1097,8 @@ readIntBE(offset: number, byteLength: number): number ...@@ -1097,8 +1097,8 @@ readIntBE(offset: number, byteLength: number): number
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| offset | number | | 偏移量。 默认值: 0。 | | offset | number | | 偏移量。 默认值: 0。 |
| byteLength | number | | 读取的字节数。 | | byteLength | number | | 读取的字节数。 |
**返回值:** **返回值:**
...@@ -1130,8 +1130,8 @@ readIntLE(offset: number, byteLength: number): number ...@@ -1130,8 +1130,8 @@ readIntLE(offset: number, byteLength: number): number
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| offset | number | | 偏移量。 默认值: 0。 | | offset | number | | 偏移量。 默认值: 0。 |
| byteLength | number | | 读取的字节数。 | | byteLength | number | | 读取的字节数。 |
**返回值:** **返回值:**
...@@ -1151,7 +1151,7 @@ console.log(buf.readIntLE(0, 6).toString(16)); ...@@ -1151,7 +1151,7 @@ console.log(buf.readIntLE(0, 6).toString(16));
### readUInt8 ### readUInt8
readUInt8(offset: number): number readUInt8(offset?: number): number
`offset`处读取8位无符号整型数。 `offset`处读取8位无符号整型数。
...@@ -1182,7 +1182,7 @@ console.log(buf.readUInt8(1).toString()); ...@@ -1182,7 +1182,7 @@ console.log(buf.readUInt8(1).toString());
### readUInt16BE ### readUInt16BE
readUInt16BE(offset: number): number readUInt16BE(offset?: number): number
从指定的`offset`处的buf读取无符号的大端序16位整数。 从指定的`offset`处的buf读取无符号的大端序16位整数。
...@@ -1213,7 +1213,7 @@ console.log(buf.readUInt16BE(1).toString(16)); ...@@ -1213,7 +1213,7 @@ console.log(buf.readUInt16BE(1).toString(16));
### readUInt16LE ### readUInt16LE
readUInt16LE(offset: number): number readUInt16LE(offset?: number): number
从指定的`offset`处的buf读取无符号的小端序16位整数。 从指定的`offset`处的buf读取无符号的小端序16位整数。
...@@ -1244,7 +1244,7 @@ console.log(buf.readUInt16LE(1).toString(16)); ...@@ -1244,7 +1244,7 @@ console.log(buf.readUInt16LE(1).toString(16));
### readUInt32BE ### readUInt32BE
readUInt32BE(offset: number): number readUInt32BE(offset?: number): number
从指定的`offset`处的buf读取无符号的大端序32位整数。 从指定的`offset`处的buf读取无符号的大端序32位整数。
...@@ -1274,7 +1274,7 @@ console.log(buf.readUInt32BE(0).toString(16)); ...@@ -1274,7 +1274,7 @@ console.log(buf.readUInt32BE(0).toString(16));
### readUInt32LE ### readUInt32LE
readUInt32LE(offset: number): number readUInt32LE(offset?: number): number
从指定的`offset`处的buf读取无符号的小端序32位整数。 从指定的`offset`处的buf读取无符号的小端序32位整数。
...@@ -1314,8 +1314,8 @@ readUIntBE(offset: number, byteLength: number): number ...@@ -1314,8 +1314,8 @@ readUIntBE(offset: number, byteLength: number): number
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| offset | number | | 偏移量。 默认值: 0。 | | offset | number | | 偏移量。 默认值: 0。 |
| byteLength | number | | 要读取的字节数。 | | byteLength | number | | 要读取的字节数。 |
**返回值:** **返回值:**
...@@ -1345,8 +1345,8 @@ readUIntLE(offset: number, byteLength: number): number ...@@ -1345,8 +1345,8 @@ readUIntLE(offset: number, byteLength: number): number
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| offset | number | | 偏移量。 默认值: 0。 | | offset | number | | 偏移量。 默认值: 0。 |
| byteLength | number | | 要读取的字节数。 | | byteLength | number | | 要读取的字节数。 |
**返回值:** **返回值:**
...@@ -1581,7 +1581,7 @@ write(str: string, offset?: number, length?: number, encoding?: string): number ...@@ -1581,7 +1581,7 @@ write(str: string, offset?: number, length?: number, encoding?: string): number
| str | string | 是 | 要写入Buffer的字符串。 | | str | string | 是 | 要写入Buffer的字符串。 |
| offset | number | 否 | 偏移量。 默认值: 0。 | | offset | number | 否 | 偏移量。 默认值: 0。 |
| length | number | 否 | 最大字节长度。 默认值: (buf.length - offset)。| | length | number | 否 | 最大字节长度。 默认值: (buf.length - offset)。|
| encoding | BufferEncoding | 否 | 字符编码。 默认值: 'utf8'。 | | encoding | BufferEncoding | 否 | 字符编码。 默认值: 'utf-8'。 |
**返回值:** **返回值:**
...@@ -1597,7 +1597,7 @@ import buffer from '@ohos.buffer'; ...@@ -1597,7 +1597,7 @@ import buffer from '@ohos.buffer';
let buf = buffer.alloc(256); let buf = buffer.alloc(256);
let len = buf.write('\u00bd + \u00bc = \u00be', 0); let len = buf.write('\u00bd + \u00bc = \u00be', 0);
console.log(`${len} bytes: ${buf.toString('utf8', 0, len)}`); console.log(`${len} bytes: ${buf.toString('utf-8', 0, len)}`);
// 打印: 12 bytes: ½ + ¼ = ¾ // 打印: 12 bytes: ½ + ¼ = ¾
let buffer1 = buffer.alloc(10); let buffer1 = buffer.alloc(10);
...@@ -1637,7 +1637,7 @@ buf.writeBigInt64BE(0x0102030405060708n, 0); ...@@ -1637,7 +1637,7 @@ buf.writeBigInt64BE(0x0102030405060708n, 0);
### writeBigInt64LE ### writeBigInt64LE
writeBigInt64LE(value : bigint, offset? : number): number writeBigInt64LE(value: bigint, offset?: number): number
从buf的offset偏移写入小端序的64位BigInt型数据value 从buf的offset偏移写入小端序的64位BigInt型数据value
...@@ -1668,7 +1668,7 @@ buf.writeBigInt64LE(0x0102030405060708n, 0); ...@@ -1668,7 +1668,7 @@ buf.writeBigInt64LE(0x0102030405060708n, 0);
### writeBigUInt64BE ### writeBigUInt64BE
writeBigUInt64BE(value : bigint, offset? : number): number writeBigUInt64BE(value: bigint, offset?: number): number
从buf的offset偏移写入大端序的64位BigUInt型数据value 从buf的offset偏移写入大端序的64位BigUInt型数据value
...@@ -1699,7 +1699,7 @@ buf.writeBigUInt64BE(0xdecafafecacefaden, 0); ...@@ -1699,7 +1699,7 @@ buf.writeBigUInt64BE(0xdecafafecacefaden, 0);
### writeBigUInt64LE ### writeBigUInt64LE
writeBigUInt64LE(value : bigint, offset? : number): number writeBigUInt64LE(value: bigint, offset?: number): number
从buf的offset偏移写入小端序的64位BigUInt型数据value 从buf的offset偏移写入小端序的64位BigUInt型数据value
...@@ -1730,7 +1730,7 @@ buf.writeBigUInt64LE(0xdecafafecacefaden, 0); ...@@ -1730,7 +1730,7 @@ buf.writeBigUInt64LE(0xdecafafecacefaden, 0);
### writeDoubleBE ### writeDoubleBE
writeDoubleBE(value : number, offset? : number): number writeDoubleBE(value: number, offset?: number): number
从buf的offset偏移写入大端序的64位有符号双浮点型数据value 从buf的offset偏移写入大端序的64位有符号双浮点型数据value
...@@ -1761,7 +1761,7 @@ buf.writeDoubleBE(123.456, 0); ...@@ -1761,7 +1761,7 @@ buf.writeDoubleBE(123.456, 0);
### writeDoubleLE ### writeDoubleLE
writeDoubleLE(value : number, offset? : number): number writeDoubleLE(value: number, offset?: number): number
从buf的offset偏移写入小端序的64位有符号双浮点型数据value 从buf的offset偏移写入小端序的64位有符号双浮点型数据value
...@@ -1792,7 +1792,7 @@ buf.writeDoubleLE(123.456, 0); ...@@ -1792,7 +1792,7 @@ buf.writeDoubleLE(123.456, 0);
### writeFloatBE ### writeFloatBE
writeFloatBE(value : number, offset? : number): number writeFloatBE(value: number, offset?: number): number
从buf的offset偏移写入大端序的32位有符号浮点型数据value 从buf的offset偏移写入大端序的32位有符号浮点型数据value
...@@ -1824,7 +1824,7 @@ buf.writeFloatBE(0xcafebabe, 0); ...@@ -1824,7 +1824,7 @@ buf.writeFloatBE(0xcafebabe, 0);
### writeFloatLE ### writeFloatLE
writeFloatLE(value : number, offset? : number): number writeFloatLE(value: number, offset?: number): number
从buf的offset偏移写入小端序的32位有符号浮点型数据value 从buf的offset偏移写入小端序的32位有符号浮点型数据value
...@@ -1855,7 +1855,7 @@ buf.writeFloatLE(0xcafebabe, 0); ...@@ -1855,7 +1855,7 @@ buf.writeFloatLE(0xcafebabe, 0);
### writeInt8 ### writeInt8
writeInt8(value : number, offset? : number): number writeInt8(value: number, offset?: number): number
从buf的offset偏移写入8位有符号整型数据value 从buf的offset偏移写入8位有符号整型数据value
...@@ -1888,7 +1888,7 @@ buf.writeInt8(-2, 1); ...@@ -1888,7 +1888,7 @@ buf.writeInt8(-2, 1);
### writeInt16BE ### writeInt16BE
writeInt16BE(value : number, offset? : number): number writeInt16BE(value: number, offset?: number): number
从buf的offset偏移写入大端序的16位有符号整型数据value 从buf的offset偏移写入大端序的16位有符号整型数据value
...@@ -1920,7 +1920,7 @@ buf.writeInt16BE(0x0102, 0); ...@@ -1920,7 +1920,7 @@ buf.writeInt16BE(0x0102, 0);
### writeInt16LE ### writeInt16LE
writeInt16LE(value : number, offset : number): number writeInt16LE(value: number, offset?: number): number
从buf的offset偏移写入小端序的16位有符号整型数据value 从buf的offset偏移写入小端序的16位有符号整型数据value
...@@ -1951,7 +1951,7 @@ buf.writeInt16LE(0x0304, 0); ...@@ -1951,7 +1951,7 @@ buf.writeInt16LE(0x0304, 0);
### writeInt32BE ### writeInt32BE
writeInt32BE(value : number, offset : number): number writeInt32BE(value: number, offset?: number): number
从buf的offset偏移写入大端序的32位有符号整型数据value 从buf的offset偏移写入大端序的32位有符号整型数据value
...@@ -1983,7 +1983,7 @@ buf.writeInt32BE(0x01020304, 0); ...@@ -1983,7 +1983,7 @@ buf.writeInt32BE(0x01020304, 0);
### writeInt32LE ### writeInt32LE
writeInt32LE(value : number, offset : number): number writeInt32LE(value: number, offset?: number): number
从buf的offset偏移写入小端序的32位有符号整型数据value 从buf的offset偏移写入小端序的32位有符号整型数据value
...@@ -2014,7 +2014,7 @@ buf.writeInt32LE(0x05060708, 0); ...@@ -2014,7 +2014,7 @@ buf.writeInt32LE(0x05060708, 0);
### writeIntBE ### writeIntBE
writeIntBE(value : number, offset : number, byteLength : number): number writeIntBE(value: number, offset: number, byteLength: number): number
从buf的offset偏移写入大端序的有符号value数据,value字节长度为byteLength 从buf的offset偏移写入大端序的有符号value数据,value字节长度为byteLength
...@@ -2025,8 +2025,8 @@ writeIntBE(value : number, offset : number, byteLength : number): number ...@@ -2025,8 +2025,8 @@ writeIntBE(value : number, offset : number, byteLength : number): number
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | number | 是 | 写入 buf 的数字。 | | value | number | 是 | 写入 buf 的数字。 |
| offset | number | | 偏移量。 默认值: 0。 | | offset | number | | 偏移量。 默认值: 0。 |
| byteLength | number | | 要写入的字节数。 | | byteLength | number | | 要写入的字节数。 |
**返回值:** **返回值:**
...@@ -2047,7 +2047,7 @@ buf.writeIntBE(0x1234567890ab, 0, 6); ...@@ -2047,7 +2047,7 @@ buf.writeIntBE(0x1234567890ab, 0, 6);
### writeIntLE ### writeIntLE
writeIntLE(value : number, offset : number, byteLength : number): number writeIntLE(value: number, offset: number, byteLength: number): number
从buf的offset偏移写入小端序的有符号value数据,value字节长度为byteLength 从buf的offset偏移写入小端序的有符号value数据,value字节长度为byteLength
...@@ -2058,8 +2058,8 @@ writeIntLE(value : number, offset : number, byteLength : number): number ...@@ -2058,8 +2058,8 @@ writeIntLE(value : number, offset : number, byteLength : number): number
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | number | 是 | 写入 buf 的数字。 | | value | number | 是 | 写入 buf 的数字。 |
| offset | number | | 偏移量。 默认值: 0。 | | offset | number | | 偏移量。 默认值: 0。 |
| byteLength | number | | 要写入的字节数。 | | byteLength | number | | 要写入的字节数。 |
**返回值:** **返回值:**
...@@ -2079,7 +2079,7 @@ buf.writeIntLE(0x1234567890ab, 0, 6); ...@@ -2079,7 +2079,7 @@ buf.writeIntLE(0x1234567890ab, 0, 6);
### writeUInt8 ### writeUInt8
writeUInt8(value : number, offset : number): number writeUInt8(value: number, offset?: number): number
从buf的offset偏移写入8位无符号整型数据value 从buf的offset偏移写入8位无符号整型数据value
...@@ -2113,7 +2113,7 @@ buf.writeUInt8(0x42, 3); ...@@ -2113,7 +2113,7 @@ buf.writeUInt8(0x42, 3);
### writeUInt16BE ### writeUInt16BE
writeUInt16BE(value : number, offset : number): number writeUInt16BE(value: number, offset?: number): number
从buf的offset偏移写入大端序的16位无符号整型数据value 从buf的offset偏移写入大端序的16位无符号整型数据value
...@@ -2145,7 +2145,7 @@ buf.writeUInt16BE(0xbeef, 2); ...@@ -2145,7 +2145,7 @@ buf.writeUInt16BE(0xbeef, 2);
### writeUInt16LE ### writeUInt16LE
writeUInt16LE(value : number, offset : number): number writeUInt16LE(value: number, offset?: number): number
从buf的offset偏移写入小端序的16位无符号整型数据value 从buf的offset偏移写入小端序的16位无符号整型数据value
...@@ -2177,7 +2177,7 @@ buf.writeUInt16LE(0xbeef, 2); ...@@ -2177,7 +2177,7 @@ buf.writeUInt16LE(0xbeef, 2);
### writeUInt32BE ### writeUInt32BE
writeUInt32BE(value : number, offset : number): number writeUInt32BE(value: number, offset?: number): number
从buf的offset偏移写入大端序的32位无符号整型数据value 从buf的offset偏移写入大端序的32位无符号整型数据value
...@@ -2208,7 +2208,7 @@ buf.writeUInt32BE(0xfeedface, 0); ...@@ -2208,7 +2208,7 @@ buf.writeUInt32BE(0xfeedface, 0);
### writeUInt32LE ### writeUInt32LE
writeUInt32LE(value : number, offset : number): number writeUInt32LE(value: number, offset?: number): number
从buf的offset偏移写入小端序的32位无符号整型数据value 从buf的offset偏移写入小端序的32位无符号整型数据value
...@@ -2239,7 +2239,7 @@ buf.writeUInt32LE(0xfeedface, 0); ...@@ -2239,7 +2239,7 @@ buf.writeUInt32LE(0xfeedface, 0);
### writeUIntBE ### writeUIntBE
writeUIntBE(value : number, offset : number, byteLength : number): number writeUIntBE(value: number, offset: number, byteLength: number): number
从buf的offset偏移写入大端序的无符号value数据,value字节长度为byteLength 从buf的offset偏移写入大端序的无符号value数据,value字节长度为byteLength
...@@ -2250,8 +2250,8 @@ writeUIntBE(value : number, offset : number, byteLength : number): number ...@@ -2250,8 +2250,8 @@ writeUIntBE(value : number, offset : number, byteLength : number): number
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | number | 是 | 写入 buf 的数据。 | | value | number | 是 | 写入 buf 的数据。 |
| offset | number | | 偏移量。 默认值: 0。 | | offset | number | | 偏移量。 默认值: 0。 |
| byteLength | number | | 要写入的字节数。 | | byteLength | number | | 要写入的字节数。 |
**返回值:** **返回值:**
...@@ -2271,7 +2271,7 @@ buf.writeUIntBE(0x1234567890ab, 0, 6); ...@@ -2271,7 +2271,7 @@ buf.writeUIntBE(0x1234567890ab, 0, 6);
### writeUIntLE ### writeUIntLE
writeUIntLE(value : number, offset : number, byteLength : number): number writeUIntLE(value: number, offset: number, byteLength: number): number
从buf的offset偏移写入小端序的无符号value数据,value字节长度为byteLength 从buf的offset偏移写入小端序的无符号value数据,value字节长度为byteLength
...@@ -2282,8 +2282,8 @@ writeUIntLE(value : number, offset : number, byteLength : number): number ...@@ -2282,8 +2282,8 @@ writeUIntLE(value : number, offset : number, byteLength : number): number
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | number | 是 | 写入 buf 的数据。 | | value | number | 是 | 写入 buf 的数据。 |
| offset | number | | 偏移量。 默认值: 0。 | | offset | number | | 偏移量。 默认值: 0。 |
| byteLength | number | | 要写入的字节数。 | | byteLength | number | | 要写入的字节数。 |
**返回值:** **返回值:**
...@@ -2303,7 +2303,7 @@ buf.writeUIntLE(0x1234567890ab, 0, 6); ...@@ -2303,7 +2303,7 @@ buf.writeUIntLE(0x1234567890ab, 0, 6);
### transcode ### transcode
transcode(source : Buffer | Uint8Array, fromEnc : string, toEnc : string): Buffer transcode(source: Buffer | Uint8Array, fromEnc: string, toEnc: string): Buffer
将给定的Buffer或Uint8Array实例从一种字符编码重新编码为另一种 将给定的Buffer或Uint8Array实例从一种字符编码重新编码为另一种
...@@ -2329,7 +2329,7 @@ transcode(source : Buffer | Uint8Array, fromEnc : string, toEnc : string): Buffe ...@@ -2329,7 +2329,7 @@ transcode(source : Buffer | Uint8Array, fromEnc : string, toEnc : string): Buffe
import buffer from '@ohos.buffer'; import buffer from '@ohos.buffer';
let buf = buffer.alloc(50); let buf = buffer.alloc(50);
let newBuf = buffer.transcode(buffer.from(''), 'utf8', 'ascii'); let newBuf = buffer.transcode(buffer.from(''), 'utf-8', 'ascii');
console.log(newBuf.toString('ascii')); console.log(newBuf.toString('ascii'));
``` ```
...@@ -2346,7 +2346,7 @@ console.log(newBuf.toString('ascii')); ...@@ -2346,7 +2346,7 @@ console.log(newBuf.toString('ascii'));
### constructor ### constructor
constructor(sources: string[] | ArrayBuffer[] | TypedArray[] | DataView[] | Blob[] , options: Object) constructor(sources: string[] | ArrayBuffer[] | TypedArray[] | DataView[] | Blob[] , options?: Object)
Blob的构造函数。 Blob的构造函数。
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册