diff --git a/api/@ohos.buffer.d.ts b/api/@ohos.buffer.d.ts index e78838f4d50d19ac5ba39ce95ed38652b5313998..5052e2092986a0c1f157fb04036fe7f3b758b45d 100644 --- a/api/@ohos.buffer.d.ts +++ b/api/@ohos.buffer.d.ts @@ -40,7 +40,8 @@ * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ declare namespace buffer { /** @@ -59,13 +60,14 @@ declare namespace buffer { * @since 10 */ /** - * Enumerates the supported encoding formats. + * This parameter specifies the type of a common encoding format. * * @typedef { 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2' | 'base64' | 'base64url' | 'latin1' | 'binary' | 'hex' } * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ type BufferEncoding = | 'ascii' @@ -103,6 +105,27 @@ declare namespace buffer { * @since 11 */ interface TypedArray extends Int8Array {} + /** + * TypedArray features and methods + * + * @typedef { Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + type TypedArray = Int8Array + | Uint8Array + | Uint8ClampedArray + | Int16Array + | Uint16Array + | Int32Array + | Uint32Array + | Float32Array + | Float64Array + | BigInt64Array + | BigUint64Array; /** * Allocates a new Buffer for a fixed size bytes. If fill is undefined, the Buffer will be zero-filled. * @@ -133,11 +156,11 @@ declare namespace buffer { * @since 10 */ /** - * Creates and initializes a Buffer instance of the specified length. + * Allocates a new Buffer for a fixed size bytes. If fill is undefined, the Buffer will be zero-filled. * - * @param { number } size - Size of the Buffer instance to create, in bytes. - * @param { string | Buffer | number } [fill] - Value to be filled in the buffer. The default value is 0. - * @param { BufferEncoding } [encoding] - Encoding format (valid only when fill is a string). The default value is 'utf8'. + * @param { number } size - size size The desired length of the new Buffer + * @param { string | Buffer | number } [fill] - fill [fill=0] A value to pre-fill the new Buffer with + * @param { BufferEncoding } [encoding] - encoding [encoding='utf8'] If `fill` is a string, this is its encoding * @returns { Buffer } Return a new allocated Buffer * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -146,7 +169,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ function alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): Buffer; @@ -176,10 +200,9 @@ declare namespace buffer { * @since 10 */ /** - * Creates a Buffer instance of the specified size from the buffer pool, without initializing it. - * You need to use fill() to initialize the Buffer instance created. + * Allocates a new Buffer for a fixed size bytes. The Buffer will not be initially filled. * - * @param { number } size - Size of the Buffer instance to create, in bytes. + * @param { number } size - size size The desired length of the new Buffer * @returns { Buffer } Return a new allocated Buffer * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -188,7 +211,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ function allocUninitializedFromPool(size: number): Buffer; @@ -218,9 +242,9 @@ declare namespace buffer { * @since 10 */ /** - * Creates a Buffer instance of the specified size, without initializing it. + * Allocates a new un-pooled Buffer for a fixed size bytes. The Buffer will not be initially filled. * - * @param { number } size - Size of the Buffer instance to create, in bytes. + * @param { number } size - size size The desired length of the new Buffer * @returns { Buffer } Return a new allocated Buffer * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -229,7 +253,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ function allocUninitialized(size: number): Buffer; @@ -263,10 +288,12 @@ declare namespace buffer { * @since 10 */ /** - * Obtains the number of bytes of a string based on the encoding format. + * Returns the byte length of a string when encoded using `encoding`. + * This is not the same as [`String.prototype.length`], which does not account + * for the encoding that is used to convert the string into bytes. * - * @param { string | Buffer | TypedArray | DataView | ArrayBuffer | SharedArrayBuffer } string - Target string. - * @param { BufferEncoding } [encoding] - Encoding format of the string. The default value is 'utf8'. + * @param { string | Buffer | TypedArray | DataView | ArrayBuffer | SharedArrayBuffer } string - string string A value to calculate the length of + * @param { BufferEncoding } [encoding] - encoding [encoding='utf8'] If `string` is a string, this is its encoding * @returns { number } The number of bytes contained within `string` * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -281,6 +308,25 @@ declare namespace buffer { encoding?: BufferEncoding ): number; + /** + * Returns the byte length of a string when encoded using `encoding`. + * This is not the same as [`String.prototype.length`], which does not account + * for the encoding that is used to convert the string into bytes. + * + * @param { string | Buffer | TypedArray | DataView | ArrayBuffer } doc - string string A value to calculate the length of + * @param { BufferEncoding } [encoding] - encoding [encoding='utf8'] If `string` is a string, this is its encoding + * @returns { number } The number of bytes contained within `string` + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + function byteLength( + doc: string | Buffer | TypedArray | DataView | ArrayBuffer, + encoding?: BufferEncoding + ): number; + /** * Returns a new `Buffer` which is the result of concatenating all the `Buffer`instances in the `list` together. * @@ -311,10 +357,10 @@ declare namespace buffer { * @since 10 */ /** - * Concatenates an array of Buffer instances of the specified length into a new instance. + * Returns a new `Buffer` which is the result of concatenating all the `Buffer`instances in the `list` together. * - * @param { Buffer[] | Uint8Array[] } list - Array of instances to concatenate. - * @param { number } [totalLength] - Total length of bytes to be copied. The default value is 0. + * @param { Buffer[] | Uint8Array[] } list - list list List of `Buffer` or Uint8Array instances to concatenate + * @param { number } [totalLength] - totalLength totalLength Total length of the `Buffer` instances in `list` when concatenated * @returns { Buffer } Return a new allocated Buffer * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -324,7 +370,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ function concat(list: Buffer[] | Uint8Array[], totalLength?: number): Buffer; @@ -352,9 +399,9 @@ declare namespace buffer { * @since 10 */ /** - * Creates a Buffer instance with the specified array. + * Allocates a new Buffer using an array of bytes in the range 0 – 255. Array entries outside that range will be truncated to fit into it. * - * @param { number[] } array - Array to create a Buffer instance. + * @param { number[] } array - array array an array of bytes in the range 0 – 255 * @returns { Buffer } Return a new allocated Buffer * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -362,7 +409,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ function from(array: number[]): Buffer; @@ -400,11 +448,12 @@ declare namespace buffer { * @since 10 */ /** - * Creates a Buffer instance of the specified length that shares memory with arrayBuffer. + * This creates a view of the ArrayBuffer without copying the underlying memory. * - * @param { ArrayBuffer | SharedArrayBuffer } arrayBuffer - ArrayBuffer or SharedArrayBuffer instance whose memory is to be shared. - * @param { number } [byteOffset] - Byte offset. The default value is 0. - * @param { number } [length] - Length of the Buffer instance to create, in bytes. The default value is arrayBuffer.byteLength minus byteOffset. + * @param { ArrayBuffer | SharedArrayBuffer } arrayBuffer - arrayBuffer arrayBuffer An ArrayBuffer, + * SharedArrayBuffer, for example the .buffer property of a TypedArray. + * @param { number } [byteOffset] - byteOffset [byteOffset = 0] Index of first byte to expose + * @param { number } [length] - length [length = arrayBuffer.byteLength - byteOffset] Number of bytes to expose * @returns { Buffer } Return a view of the ArrayBuffer * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -418,6 +467,23 @@ declare namespace buffer { */ function from(arrayBuffer: ArrayBuffer | SharedArrayBuffer, byteOffset?: number, length?: number): Buffer; + /** + * This creates a view of the ArrayBuffer without copying the underlying memory. + * + * @param { ArrayBuffer } arrayBuffer - arrayBuffer arrayBuffer An ArrayBuffer, + * @param { number } [byteOffset] - byteOffset [byteOffset = 0] Index of first byte to expose + * @param { number } [length] - length [length = arrayBuffer.byteLength - byteOffset] Number of bytes to expose + * @returns { Buffer } Return a view of the ArrayBuffer + * @throws { BusinessError } 10200001 - The value of "[byteOffset/length]" is out of range. + * It must be >= [left range] and <= [right range]. Received value is: [byteOffset/length] + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + function from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer; + /** * Copies the passed buffer data onto a new Buffer instance. * @@ -442,9 +508,9 @@ declare namespace buffer { * @since 10 */ /** - * Copies the data of a passed Buffer instance to create a new Buffer instance and returns the new one. + * Copies the passed buffer data onto a new Buffer instance. * - * @param { Buffer | Uint8Array } buffer - Buffer or Uint8Array instance. + * @param { Buffer | Uint8Array } buffer - buffer buffer An existing Buffer or Uint8Array from which to copy data * @returns { Buffer } Return a new allocated Buffer * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -452,7 +518,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ function from(buffer: Buffer | Uint8Array): Buffer; @@ -486,11 +553,12 @@ declare namespace buffer { * @since 10 */ /** - * Creates a Buffer instance based on the specified object. + * For the object whose value returned by valueof() function is strictly equal to object + * or supports symbol To primitive object, a new buffer instance is created. * - * @param { Object } object - Object that supports Symbol.toPrimitive or valueOf(). - * @param { number | string } offsetOrEncoding - Byte offset or encoding format. - * @param { number } length - Length of the Buffer instance to create, in bytes. + * @param { Object } object - object object An object supporting Symbol.toPrimitive or valueOf() + * @param { number | string } offsetOrEncoding - offsetOrEncoding offsetOrEncoding A byte-offset or encoding + * @param { number } length - length length A length * @returns { Buffer } Return a new allocated Buffer * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -498,7 +566,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ function from(object: Object, offsetOrEncoding: number | string, length: number): Buffer; @@ -530,10 +599,11 @@ declare namespace buffer { * @since 10 */ /** - * Creates a Buffer instance based on a string in the given encoding format. + * Creates a new Buffer containing string. The encoding parameter identifies the character encoding + * to be used when converting string into bytes. * - * @param { String } string - String. - * @param { BufferEncoding } [encoding] - Encoding format of the string. The default value is 'utf8'. + * @param { String } string - string string A string to encode + * @param { BufferEncoding } [encoding] - encoding [encoding='utf8'] The encoding of string * @returns { Buffer } Return a new Buffer containing string * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -541,7 +611,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ function from(string: String, encoding?: BufferEncoding): Buffer; @@ -563,14 +634,15 @@ declare namespace buffer { * @since 10 */ /** - * Checks whether the specified object is a Buffer instance. + * Returns true if obj is a Buffer, false otherwise * - * @param { Object } obj - Object to check. + * @param { Object } obj - obj obj Objects to be judged * @returns { boolean } true or false * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ function isBuffer(obj: Object): boolean; @@ -592,14 +664,15 @@ declare namespace buffer { * @since 10 */ /** - * Checks whether the encoding format is supported. + * Returns true if encoding is the name of a supported character encoding, or false otherwise. * - * @param { string } encoding - Encoding format. + * @param { string } encoding - encoding encoding A character encoding name to check * @returns { boolean } true or false * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ function isEncoding(encoding: string): boolean; @@ -633,10 +706,10 @@ declare namespace buffer { * @since 10 */ /** - * Compares two Buffer instances. This API is used for sorting Buffer instances. + * Compares buf1 to buf2 * - * @param { Buffer | Uint8Array } buf1 - Buffer instance to compare. - * @param { Buffer | Uint8Array } buf2 - Buffer instance to compare. + * @param { Buffer | Uint8Array } buf1 - buf1 buf1 A Buffer or Uint8Array instance. + * @param { Buffer | Uint8Array } buf2 - buf2 buf2 A Buffer or Uint8Array instance. * @returns { -1 | 0 | 1 } 0 is returned if target is the same as buf * 1 is returned if target should come before buf when sorted. * -1 is returned if target should come after buf when sorted. @@ -650,6 +723,22 @@ declare namespace buffer { */ function compare(buf1: Buffer | Uint8Array, buf2: Buffer | Uint8Array): -1 | 0 | 1; + /** + * Compares buf1 to buf2 + * + * @param { Buffer | Uint8Array } buf1 - buf1 buf1 A Buffer or Uint8Array instance. + * @param { Buffer | Uint8Array } buf2 - buf2 buf2 A Buffer or Uint8Array instance. + * @returns { number } 0 is returned if target is the same as buf + * 1 is returned if target should come before buf when sorted. + * -1 is returned if target should come after buf when sorted. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + function compare(buf1: Buffer | Uint8Array, buf2: Buffer | Uint8Array): number; + /** * Re-encodes the given Buffer or Uint8Array instance from one character encoding to another. * @@ -678,11 +767,11 @@ declare namespace buffer { * @since 10 */ /** - * Transcodes the given Buffer or Uint8Array object from one encoding format to another. + * Re-encodes the given Buffer or Uint8Array instance from one character encoding to another. * - * @param { Buffer | Uint8Array } source - Instance to encode. - * @param { string } fromEnc - Current encoding format - * @param { string } toEnc - Target encoding format. + * @param { Buffer | Uint8Array } source - source source A Buffer or Uint8Array instance. + * @param { string } fromEnc - fromEnc fromEnc The current encoding + * @param { string } toEnc - toEnc toEnc To target encoding * @returns { Buffer } Returns a new Buffer instance * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -690,7 +779,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ function transcode(source: Buffer | Uint8Array, fromEnc: string, toEnc: string): Buffer; @@ -714,7 +804,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ class Buffer { /** @@ -746,6 +837,18 @@ declare namespace buffer { */ length: number; + /** + * Gets the element number of the buffer. + * + * @type { number } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get length(): number; + /** * The underlying ArrayBuffer object based on which this Buffer object is created. * @@ -775,6 +878,19 @@ declare namespace buffer { */ buffer: ArrayBuffer; + /** + * The underlying ArrayBuffer object based on which this Buffer object is created. + * + * @type { ArrayBuffer } + * @throws { BusinessError } 10200013 - Buffer cannot be set for the buffer that has only a getter. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get buffer(): ArrayBuffer; + /** * The byteOffset of the Buffers underlying ArrayBuffer object * @@ -804,6 +920,19 @@ declare namespace buffer { */ byteOffset: number; + /** + * The byteOffset of the Buffers underlying ArrayBuffer object + * + * @type { number } + * @throws { BusinessError } 10200013 - ByteOffset cannot be set for the buffer that has only a getter. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get byteOffset(): number; + /** * Fills buf with the specified value. If the offset and end are not given, the entire buf will be filled. * @@ -836,12 +965,12 @@ declare namespace buffer { * @since 10 */ /** - * Fills this Buffer instance at the specified position. By default, data is filled cyclically. + * Fills buf with the specified value. If the offset and end are not given, the entire buf will be filled. * - * @param { string | Buffer | Uint8Array | number } value - Value to fill. - * @param { number } [offset] - Offset to the start position in this Buffer instance where data is filled. The default value is 0. - * @param { number } [end] - Offset to the end position in this Buffer instance (not inclusive). The default value is the length of this Buffer instance. - * @param { BufferEncoding } [encoding] - Encoding format (valid only when value is a string). The default value is 'utf8'. + * @param { string | Buffer | Uint8Array | number } value - value value The value with which to fill buf + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to fill buf + * @param { number } [end] - end [end = buf.length] Where to stop filling buf (not inclusive) + * @param { BufferEncoding } [encoding] - encoding [encoding='utf8'] The encoding for value if value is a string * @returns { Buffer } A reference to buf * @throws { BusinessError } 10200001 - The value of "[offset/end]" is out of range. It must be >= 0 and <= [right range]. Received value is: [offset/end] * @throws { BusinessError } 401 - Parameter error. Possible causes: @@ -850,7 +979,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ fill( value: string | Buffer | Uint8Array | number, @@ -901,15 +1031,14 @@ declare namespace buffer { * @since 10 */ /** - * Compares this Buffer instance with another instance. + * Compares buf with target and returns a number indicating whether buf comes before, after, + * or is the same as target in sort order. Comparison is based on the actual sequence of bytes in each Buffer. * - * @param { Buffer | Uint8Array } target - Target Buffer instance to compare. - * @param { number } [targetStart] - Offset to the start of the data to compare in the target Buffer instance. The default value is 0. - * @param { number } [targetEnd] - Offset to the end of the data to compare in the target Buffer instance (not inclusive). - * The default value is the length of the target Buffer instance. - * @param { number } [sourceStart] - Offset to the start of the data to compare in this Buffer instance. The default value is 0. - * @param { number } [sourceEnd] - Offset to the end of the data to compare in this Buffer instance (not inclusive). - * The default value is the length of this Buffer instance. + * @param { Buffer | Uint8Array } target - target target A Buffer or Uint8Array with which to compare buf + * @param { number } [targetStart] - targetStart [targetStart = 0] The offset within target at which to begin comparison + * @param { number } [targetEnd] - targetEnd [targetEnd = target.length] The offset within target at which to end comparison (not inclusive) + * @param { number } [sourceStart] - sourceStart [sourceStart = 0] The offset within buf at which to begin comparison + * @param { number } [sourceEnd] - sourceEnd [sourceEnd = buf.length] The offset within buf at which to end comparison (not inclusive) * @returns { -1 | 0 | 1 } 0 is returned if target is the same as buf * 1 is returned if target should come before buf when sorted. * -1 is returned if target should come after buf when sorted. @@ -931,6 +1060,35 @@ declare namespace buffer { sourceEnd?: number ): -1 | 0 | 1; + /** + * Compares buf with target and returns a number indicating whether buf comes before, after, + * or is the same as target in sort order. Comparison is based on the actual sequence of bytes in each Buffer. + * + * @param { Buffer | Uint8Array } target - target target A Buffer or Uint8Array with which to compare buf + * @param { number } [targetStart] - targetStart [targetStart = 0] The offset within target at which to begin comparison + * @param { number } [targetEnd] - targetEnd [targetEnd = target.length] The offset within target at which to end comparison (not inclusive) + * @param { number } [sourceStart] - sourceStart [sourceStart = 0] The offset within buf at which to begin comparison + * @param { number } [sourceEnd] - sourceEnd [sourceEnd = buf.length] The offset within buf at which to end comparison (not inclusive) + * @returns { number } number is returned if target is the same as buf + * @throws { BusinessError } 401 - Parameter error. Possible causes: + * 1.Mandatory parameters are left unspecified; + * 2.Incorrect parameter types. + * @throws { BusinessError } 10200001 - The value of "[targetStart/targetEnd/sourceStart/sourceEnd]" is out of range. + * It must be >= 0 and <= [right range]. Received value is: [targetStart/targetEnd/sourceStart/sourceEnd] + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + compare( + target: Buffer | Uint8Array, + targetStart?: number, + targetEnd?: number, + sourceStart?: number, + sourceEnd?: number + ): number; + /** * Copies data from a region of buf to a region in target, even if the target memory region overlaps with buf. * If sourceEnd is greater than the length of the target, the length of the target shall prevail, and the extra part will not be overwritten. @@ -967,13 +1125,13 @@ declare namespace buffer { * @since 10 */ /** - * Copies data at the specified position in this Buffer instance to the specified position in another Buffer instance. + * Copies data from a region of buf to a region in target, even if the target memory region overlaps with buf. + * If sourceEnd is greater than the length of the target, the length of the target shall prevail, and the extra part will not be overwritten. * - * @param { Buffer | Uint8Array } target - Instance to which data is copied. - * @param { number } [targetStart] - Offset to the start position in the target instance where data is copied. The default value is 0. - * @param { number } [sourceStart] - Offset to the start position in this Buffer instance where data is copied. The default value is 0. - * @param { number } [sourceEnd] - Offset to the end position in this Buffer instance (not inclusive). - * The default value is the length of this Buffer instance. + * @param { Buffer | Uint8Array } target - target target A Buffer or Uint8Array to copy into + * @param { number } [targetStart] - targetStart [targetStart = 0] The offset within target at which to begin writing + * @param { number } [sourceStart] - sourceStart [sourceStart = 0] The offset within buf from which to begin copying + * @param { number } [sourceEnd] - sourceEnd [sourceEnd = buf.length] The offset within buf at which to stop copying (not inclusive) * @returns { number } The number of bytes copied * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -983,7 +1141,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ copy(target: Buffer | Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; @@ -1007,15 +1166,16 @@ declare namespace buffer { * @since 10 */ /** - * Checks whether this Buffer instance is the same as another Buffer instance. + * Returns true if both buf and otherBuffer have exactly the same bytes, false otherwise * - * @param { Uint8Array | Buffer } otherBuffer - Buffer instance to compare. + * @param { Uint8Array | Buffer } otherBuffer - otherBuffer otherBuffer A Buffer or Uint8Array with which to compare buf * @returns { boolean } true or false * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ equals(otherBuffer: Uint8Array | Buffer): boolean; @@ -1047,13 +1207,11 @@ declare namespace buffer { * @since 10 */ /** - * Checks whether this Buffer instance contains the specified value. + * Returns true if value was found in buf, false otherwise * - * @param { string | number | Buffer | Uint8Array } value - Value to match. - * @param { number } [byteOffset] - Number of bytes to skip before starting to check data. - * Number of bytes to skip before starting to check data. If the offset is a negative number, - * data is checked from the end of the Buffer instance. The default value is 0. - * @param { BufferEncoding } [encoding] - Encoding format (valid only when value is a string). The default value is 'utf8'. + * @param { string | number | Buffer | Uint8Array } value - value value What to search for + * @param { number } [byteOffset] - byteOffset [byteOffset = 0] Where to begin searching in buf. If negative, then offset is calculated from the end of buf + * @param { BufferEncoding } [encoding] - encoding [encoding='utf8'] If value is a string, this is its encoding * @returns { boolean } true or false * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -1061,7 +1219,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ includes(value: string | number | Buffer | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): boolean; @@ -1095,12 +1254,12 @@ declare namespace buffer { * @since 10 */ /** - * Obtains the index of the first occurrence of the specified value in this Buffer instance. + * The index of the first occurrence of value in buf * - * @param { string | number | Buffer | Uint8Array } value - Value to match. - * @param { number } [byteOffset] - Number of bytes to skip before starting to check data. - * If the offset is a negative number, data is checked from the end of the Buffer instance. The default value is 0. - * @param { BufferEncoding } [encoding] - Encoding format (valid only when value is a string). The default value is 'utf8'. + * @param { string | number | Buffer | Uint8Array } value - value value What to search for + * @param { number } [byteOffset] - byteOffset [byteOffset = 0] Where to begin searching in buf + * @param { BufferEncoding } [encoding] - encoding [encoding='utf8'] If value is a string, + * this is the encoding used to determine the binary representation of the string that will be searched for in buf * @returns { number } The index of the first occurrence of value in buf, or -1 if buf does not contain value * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -1108,7 +1267,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ indexOf(value: string | number | Buffer | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number; @@ -1128,13 +1288,14 @@ declare namespace buffer { * @since 10 */ /** - * Creates and returns an iterator that contains the keys of this Buffer instance. + * Creates and returns an iterator of buf keys (indices). * * @returns { IterableIterator } * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ keys(): IterableIterator; @@ -1154,13 +1315,14 @@ declare namespace buffer { * @since 10 */ /** - * Creates and returns an iterator that contains the values of this Buffer instance. + * Creates and returns an iterator for buf values (bytes). * * @returns { IterableIterator } * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ values(): IterableIterator; @@ -1180,13 +1342,14 @@ declare namespace buffer { * @since 10 */ /** - * Creates and returns an iterator that contains key-value pairs of this Buffer instance. + * Creates and returns an iterator of [index, byte] pairs from the contents of buf. * * @returns { IterableIterator<[number, number]> } * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ entries(): IterableIterator<[number, number]>; @@ -1220,13 +1383,12 @@ declare namespace buffer { * @since 10 */ /** - * Obtains the index of the last occurrence of the specified value in this Buffer instance. + * The index of the last occurrence of value in buf * - * @param { string | number | Buffer | Uint8Array } value - Value to match. - * @param { number } [byteOffset] - Number of bytes to skip before starting to check data. - * If the offset is a negative number, data is checked from the end of the Buffer instance. - * The default value is the length of this Buffer instance. - * @param { BufferEncoding } [encoding] - Encoding format (valid only when value is a string). The default value is 'utf8'. + * @param { string | number | Buffer | Uint8Array } value - value value What to search for + * @param { number } [byteOffset] - byteOffset [byteOffset = 0] Where to begin searching in buf + * @param { BufferEncoding } [encoding] - encoding [encoding='utf8'] If value is a string, + * this is the encoding used to determine the binary representation of the string that will be searched for in buf * @returns { number } The index of the last occurrence of value in buf, or -1 if buf does not contain value * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -1234,7 +1396,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ lastIndexOf(value: string | number | Buffer | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number; @@ -1260,16 +1423,17 @@ declare namespace buffer { * @since 10 */ /** - * Reads a 64-bit, big-endian, signed big integer from this Buffer instance at the specified offset. + * Reads a signed, big-endian 64-bit integer from buf at the specified offset * - * @param { number } [offset] - Number of bytes to skip before starting to read data. The default value is 0. The value range is [0, Buffer.length - 8]. + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - 8 * @returns { bigint } Return a signed, big-endian 64-bit integer * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. * @throws { BusinessError } 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 8. Received value is: [offset] * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ readBigInt64BE(offset?: number): bigint; @@ -1295,16 +1459,17 @@ declare namespace buffer { * @since 10 */ /** - * Reads a 64-bit, little-endian, signed big integer from this Buffer instance at the specified offset. + * Reads a signed, little-endian 64-bit integer from buf at the specified offset * - * @param { number } [offset] - Number of bytes to skip before starting to read data. The default value is 0. The value range is [0, Buffer.length - 8]. + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - 8 * @returns { bigint } Return a signed, little-endian 64-bit integer * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. * @throws { BusinessError } 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 8. Received value is: [offset] * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ readBigInt64LE(offset?: number): bigint; @@ -1330,16 +1495,17 @@ declare namespace buffer { * @since 10 */ /** - * Reads a 64-bit, big-endian, unsigned big integer from this Buffer instance at the specified offset. + * Reads a unsigned, big-endian 64-bit integer from buf at the specified offset * - * @param { number } [offset] - Number of bytes to skip before starting to read data. The default value is 0. The value range is [0, Buffer.length - 8]. + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - 8 * @returns { bigint } Return a unsigned, big-endian 64-bit integer * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. * @throws { BusinessError } 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 8. Received value is: [offset] * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ readBigUInt64BE(offset?: number): bigint; @@ -1365,16 +1531,17 @@ declare namespace buffer { * @since 10 */ /** - * Reads a 64-bit, little-endian, unsigned big integer from this Buffer instance at the specified offset. + * Reads a unsigned, little-endian 64-bit integer from buf at the specified offset * - * @param { number } [offset] - Number of bytes to skip before starting to read data. The default value is 0. The value range is [0, Buffer.length - 8]. + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - 8 * @returns { bigint } Return a unsigned, little-endian 64-bit integer * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. * @throws { BusinessError } 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 8. Received value is: [offset] * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ readBigUInt64LE(offset?: number): bigint; @@ -1400,16 +1567,17 @@ declare namespace buffer { * @since 10 */ /** - * Reads a 64-bit, big-endian, double-precision floating-point number from this Buffer instance at the specified offset. + * Reads a 64-bit, big-endian double from buf at the specified offset * - * @param { number } [offset] - Number of bytes to skip before starting to read data. The default value is 0. The value range is [0, Buffer.length - 8]. + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - 8 * @returns { number } Return a 64-bit, big-endian double * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. * @throws { BusinessError } 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 8. Received value is: [offset] * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ readDoubleBE(offset?: number): number; @@ -1435,16 +1603,17 @@ declare namespace buffer { * @since 10 */ /** - * Reads a 64-bit, little-endian, double-precision floating-point number from this Buffer instance at the specified offset. + * Reads a 64-bit, little-endian double from buf at the specified offset * - * @param { number } [offset] - Number of bytes to skip before starting to read data. The default value is 0. The value range is [0, Buffer.length - 8]. + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - 8 * @returns { number } Return a 64-bit, little-endian double * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. * @throws { BusinessError } 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 8. Received value is: [offset] * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ readDoubleLE(offset?: number): number; @@ -1470,16 +1639,17 @@ declare namespace buffer { * @since 10 */ /** - * Reads a 32-bit, big-endian, single-precision floating-point number from this Buffer instance at the specified offset. + * Reads a 32-bit, big-endian float from buf at the specified offset * - * @param { number } [offset] - Number of bytes to skip before starting to read data. The default value is 0. The value range is [0, Buffer.length - 4]. + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - 4 * @returns { number } Return a 32-bit, big-endian float * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. * @throws { BusinessError } 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 4. Received value is: [offset] * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ readFloatBE(offset?: number): number; @@ -1505,16 +1675,17 @@ declare namespace buffer { * @since 10 */ /** - * Reads a 32-bit, little-endian, single-precision floating-point number from this Buffer instance at the specified offset. + * Reads a 32-bit, little-endian float from buf at the specified offset * - * @param { number } [offset] - Number of bytes to skip before starting to read data. The default value is 0. The value range is [0, Buffer.length - 4]. + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - 4 * @returns { number } Return a 32-bit, little-endian float * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. * @throws { BusinessError } 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 4. Received value is: [offset] * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ readFloatLE(offset?: number): number; @@ -1540,16 +1711,17 @@ declare namespace buffer { * @since 10 */ /** - * Reads an 8-bit signed integer from this Buffer instance at the specified offset. + * Reads a signed 8-bit integer from buf at the specified offset * - * @param { number } [offset] - Number of bytes to skip before starting to read data. The default value is 0. The value range is [0, Buffer.length - 1]. + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - 1 * @returns { number } Return a signed 8-bit integer * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. * @throws { BusinessError } 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 1. Received value is: [offset] * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ readInt8(offset?: number): number; @@ -1575,16 +1747,17 @@ declare namespace buffer { * @since 10 */ /** - * Reads a 16-bit, big-endian, signed integer from this Buffer instance at the specified offset. + * Reads a signed, big-endian 16-bit integer from buf at the specified offset * - * @param { number } [offset] - Number of bytes to skip before starting to read data. The default value is 0. The value range is [0, Buffer.length - 2]. + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - 2 * @returns { number } Return a signed, big-endian 16-bit integer * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. * @throws { BusinessError } 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 2. Received value is: [offset] * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ readInt16BE(offset?: number): number; @@ -1610,16 +1783,17 @@ declare namespace buffer { * @since 10 */ /** - * Reads a 16-bit, little-endian, signed integer from this Buffer instance at the specified offset. + * Reads a signed, little-endian 16-bit integer from buf at the specified offset * - * @param { number } [offset] - Number of bytes to skip before starting to read data. The default value is 0. The value range is [0, Buffer.length - 2]. + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - 2 * @returns { number } Return a signed, little-endian 16-bit integer * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. * @throws { BusinessError } 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 2. Received value is: [offset] * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ readInt16LE(offset?: number): number; @@ -1645,16 +1819,17 @@ declare namespace buffer { * @since 10 */ /** - * Reads a 32-bit, big-endian, signed integer from this Buffer instance at the specified offset. + * Reads a signed, big-endian 32-bit integer from buf at the specified offset * - * @param { number } [offset] - Number of bytes to skip before starting to read data. The default value is 0. The value range is [0, Buffer.length - 4]. + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - 4 * @returns { number } Return a signed, big-endian 32-bit integer * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. * @throws { BusinessError } 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 4. Received value is: [offset] * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ readInt32BE(offset?: number): number; @@ -1680,16 +1855,17 @@ declare namespace buffer { * @since 10 */ /** - * Reads a 32-bit, little-endian, signed integer from this Buffer instance at the specified offset. + * Reads a signed, little-endian 32-bit integer from buf at the specified offset * - * @param { number } [offset] - Number of bytes to skip before starting to read data. The default value is 0. The value range is [0, Buffer.length - 4]. + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - 4 * @returns { number } Return a signed, little-endian 32-bit integer * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. * @throws { BusinessError } 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 4. Received value is: [offset] * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ readInt32LE(offset?: number): number; @@ -1723,11 +1899,11 @@ declare namespace buffer { * @since 10 */ /** - * Reads the specified number of bytes from this Buffer instance at the specified offset, and interprets the result as a big-endian, - * two's complement signed value that supports up to 48 bits of precision. + * Reads byteLength number of bytes from buf at the specified offset and interprets the result as a big-endian, + * two's complement signed value supporting up to 48 bits of accuracy * - * @param { number } offset - Number of bytes to skip before starting to read data. The default value is 0. The value range is [0, Buffer.length - byteLength]. - * @param { number } byteLength - Number of bytes to read. The value range is [1, 6]. + * @param { number } offset - offset offset Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - byteLength + * @param { number } byteLength - byteLength byteLength Number of bytes to read. Must satisfy 0 < byteLength <= 6 * @returns { number } * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -1736,7 +1912,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ readIntBE(offset: number, byteLength: number): number; @@ -1770,11 +1947,11 @@ declare namespace buffer { * @since 10 */ /** - * Reads the specified number of bytes from this Buffer instance at the specified offset and interprets the result as a little-endian, - * two's complement signed value that supports up to 48 bits of precision. + * Reads byteLength number of bytes from buf at the specified offset and interprets the result as a little-endian, + * two's complement signed value supporting up to 48 bits of accuracy. * - * @param { number } offset - Number of bytes to skip before starting to read data. The default value is 0. The value range is [0, Buffer.length - byteLength]. - * @param { number } byteLength - Number of bytes to read. The value range is [1, 6]. + * @param { number } offset - offset offset Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - byteLength + * @param { number } byteLength - byteLength byteLength Number of bytes to read. Must satisfy 0 < byteLength <= 6 * @returns { number } * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -1783,7 +1960,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ readIntLE(offset: number, byteLength: number): number; @@ -1809,16 +1987,17 @@ declare namespace buffer { * @since 10 */ /** - * Reads an 8-bit unsigned integer from this Buffer instance at the specified offset. + * Reads an unsigned 8-bit integer from buf at the specified offset * - * @param { number } [offset] - Number of bytes to skip before starting to read data. The default value is 0. The value range is [0, Buffer.length - 1]. + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to read. Must satisfy 0 <= offset <= buf.length - 1 * @returns { number } Reads an unsigned 8-bit integer * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. * @throws { BusinessError } 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 1. Received value is: [offset] * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ readUInt8(offset?: number): number; @@ -1844,16 +2023,17 @@ declare namespace buffer { * @since 10 */ /** - * Reads a 16-bit, big-endian, unsigned integer from this Buffer instance at the specified offset. + * Reads an unsigned, big-endian 16-bit integer from buf at the specified offset * - * @param { number } [offset] - Number of bytes to skip before starting to read data. The default value is 0. The value range is [0, Buffer.length - 2]. + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to read. Must satisfy 0 <= offset <= buf.length - 2 * @returns { number } Reads an unsigned, big-endian 16-bit integer * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. * @throws { BusinessError } 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 2. Received value is: [offset] * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ readUInt16BE(offset?: number): number; @@ -1879,16 +2059,17 @@ declare namespace buffer { * @since 10 */ /** - * Reads a 16-bit, little-endian, unsigned integer from this Buffer instance at the specified offset. + * Reads an unsigned, little-endian 16-bit integer from buf at the specified offset * - * @param { number } [offset] - Number of bytes to skip before starting to read data. The default value is 0. The value range is [0, Buffer.length - 2]. + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to read. Must satisfy 0 <= offset <= buf.length - 2 * @returns { number } Reads an unsigned, little-endian 16-bit integer * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. * @throws { BusinessError } 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 2. Received value is: [offset] * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ readUInt16LE(offset?: number): number; @@ -1914,16 +2095,17 @@ declare namespace buffer { * @since 10 */ /** - * Reads a 32-bit, big-endian, unsigned integer from this Buffer instance at the specified offset. + * Reads an unsigned, big-endian 32-bit integer from buf at the specified offset * - * @param { number } [offset] - Number of bytes to skip before starting to read data. The default value is 0. The value range is [0, Buffer.length - 4]. + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to read. Must satisfy 0 <= offset <= buf.length - 4 * @returns { number } Reads an unsigned, big-endian 32-bit integer * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. * @throws { BusinessError } 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 4. Received value is: [offset] * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ readUInt32BE(offset?: number): number; @@ -1949,16 +2131,17 @@ declare namespace buffer { * @since 10 */ /** - * Reads a 32-bit, little-endian, unsigned integer from this Buffer instance at the specified offset. + * Reads an unsigned, little-endian 32-bit integer from buf at the specified offset * - * @param { number } [offset] - Number of bytes to skip before starting to read data. The default value is 0. The value range is [0, Buffer.length - 4]. + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to read. Must satisfy 0 <= offset <= buf.length - 4 * @returns { number } Reads an unsigned, little-endian 32-bit integer * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. * @throws { BusinessError } 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 4. Received value is: [offset] * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ readUInt32LE(offset?: number): number; @@ -1992,11 +2175,11 @@ declare namespace buffer { * @since 10 */ /** - * Reads the specified number of bytes from this Buffer instance at the specified offset, and interprets the result as an unsigned, - * big-endian integer that supports up to 48 bits of precision. + * Reads byteLength number of bytes from buf at the specified offset and interprets the result as + * an unsigned big-endian integer supporting up to 48 bits of accuracy. * - * @param { number } offset - Number of bytes to skip before starting to read data. The default value is 0. The value range is [0, Buffer.length - byteLength]. - * @param { number } byteLength - Number of bytes to read. The value range is [1, 6]. + * @param { number } offset - offset offset Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - byteLength + * @param { number } byteLength - byteLength byteLength Number of bytes to read. Must satisfy 0 < byteLength <= 6 * @returns { number } * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -2005,7 +2188,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ readUIntBE(offset: number, byteLength: number): number; @@ -2039,11 +2223,11 @@ declare namespace buffer { * @since 10 */ /** - * Reads the specified number of bytes from this Buffer instance at the specified offset, and interprets the result as an unsigned, - * little-endian integer that supports up to 48 bits of precision. + * Reads byteLength number of bytes from buf at the specified offset and interprets the result as an unsigned, + * little-endian integer supporting up to 48 bits of accuracy. * - * @param { number } offset - Number of bytes to skip before starting to read data. The default value is 0. The value range is [0, Buffer.length - byteLength]. - * @param { number } byteLength - Number of bytes to read. The value range is [1, 6]. + * @param { number } offset - offset offset Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - byteLength + * @param { number } byteLength - byteLength byteLength Number of bytes to read. Must satisfy 0 < byteLength <= 6 * @returns { number } * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -2052,7 +2236,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ readUIntLE(offset: number, byteLength: number): number; @@ -2076,15 +2261,16 @@ declare namespace buffer { * @since 10 */ /** - * Truncates this Buffer instance from the specified position to create a new Buffer instance. + * Returns a new Buffer that references the same memory as the original, but offset and cropped by the start and end indices. * - * @param { number } [start] - Offset to the start position in this Buffer instance where data is truncated. The default value is 0. - * @param { number } [end] - Offset to the end position in this Buffer instance (not inclusive). The default value is the length of this Buffer instance. + * @param { number } [start] - start [start = 0] Where the new Buffer will start + * @param { number } [end] - end [end = buf.length] Where the new Buffer will end (not inclusive) * @returns { Buffer } Returns a new Buffer that references the same memory as the original * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ subarray(start?: number, end?: number): Buffer; @@ -2106,14 +2292,15 @@ declare namespace buffer { * @since 10 */ /** - * Interprets this Buffer instance as an array of unsigned 16-bit integers and swaps the byte order in place. + * Interprets buf as an array of unsigned 16-bit integers and swaps the byte order in-place. * * @returns { Buffer } A reference to buf * @throws { BusinessError } 10200009 - The buffer size must be a multiple of 16-bits * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ swap16(): Buffer; @@ -2135,14 +2322,15 @@ declare namespace buffer { * @since 10 */ /** - * Interprets this Buffer instance as an array of unsigned 32-bit integers and swaps the byte order in place. + * Interprets buf as an array of unsigned 32-bit integers and swaps the byte order in-place. * * @returns { Buffer } A reference to buf * @throws { BusinessError } 10200009 - The buffer size must be a multiple of 32-bits * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ swap32(): Buffer; @@ -2164,14 +2352,15 @@ declare namespace buffer { * @since 10 */ /** - * Interprets this Buffer instance as an array of unsigned 64-bit integers and swaps the byte order in place. + * Interprets buf as an array of unsigned 64-bit integers and swaps the byte order in-place. * * @returns { Buffer } A reference to buf * @throws { BusinessError } 10200009 - The buffer size must be a multiple of 64-bits * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ swap64(): Buffer; @@ -2191,7 +2380,7 @@ declare namespace buffer { * @since 10 */ /** - * Converts this Buffer instance into a JSON object. + * Returns a JSON representation of buf * * @returns { Object } Returns a JSON * @syscap SystemCapability.Utils.Lang @@ -2225,11 +2414,11 @@ declare namespace buffer { * @since 10 */ /** - * Converts the data at the specified position in this Buffer instance into a string in the specified encoding format. + * Decodes buf to a string according to the specified character encoding in encoding * - * @param { string } [encoding] - Encoding format (valid only when value is a string). The default value is 'utf8'. - * @param { number } [start] - Offset to the start position of the data to convert. The default value is 0. - * @param { number } [end] - Offset to the end position of the data to convert. The default value is the length of this Buffer instance. + * @param { string } [encoding] - encoding [encoding='utf8'] The character encoding to use + * @param { number } [start] - start [start = 0] The byte offset to start decoding at + * @param { number } [end] - end [end = buf.length] The byte offset to stop decoding at (not inclusive) * @returns { string } * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types. * @syscap SystemCapability.Utils.Lang @@ -2239,6 +2428,21 @@ declare namespace buffer { */ toString(encoding?: string, start?: number, end?: number): string; + /** + * Decodes buf to a string according to the specified character encoding in encoding + * + * @param { BufferEncoding } [encoding] - encoding [encoding='utf8'] The character encoding to use + * @param { number } [start] - start [start = 0] The byte offset to start decoding at + * @param { number } [end] - end [end = buf.length] The byte offset to stop decoding at (not inclusive) + * @returns { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + toString(encoding?: BufferEncoding, start?: number, end?: number): string; + /** * Writes string to buf at offset according to the character encoding in encoding * @@ -2271,12 +2475,12 @@ declare namespace buffer { * @since 10 */ /** - * Writes a string of the specified length to this Buffer instance at the specified position in the given encoding format. + * Writes string to buf at offset according to the character encoding in encoding * - * @param { string } str - String to write. - * @param { number } [offset] - Number of bytes to skip before starting to write data. The default value is 0. - * @param { number } [length] - Maximum number of bytes to write. The default value is Buffer.length minus offset. - * @param { string } [encoding] - Encoding format of the string. The default value is 'utf8'. + * @param { string } str - str str Writes string to buf at offset according to the character encoding in encoding + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to write string + * @param { number } [length] - length [length = buf.length - offset] Maximum number of bytes to write (written bytes will not exceed buf.length - offset) + * @param { string } [encoding] - encoding [encoding='utf8'] The character encoding of string. * @returns { number } Number of bytes written. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -2285,7 +2489,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ write(str: string, offset?: number, length?: number, encoding?: string): number; @@ -2318,10 +2523,10 @@ declare namespace buffer { * @since 10 */ /** - * Writes a 64-bit, big-endian, signed big integer to this Buffer instance at the specified offset. + * Writes value to buf at the specified offset as big-endian. * - * @param { bigint } value - Data to write. - * @param { number } [offset] - Number of bytes to skip before starting to write data. The default value is 0. The value range is [0, Buffer.length - 8]. + * @param { bigint } value - value value Number to be written to buf + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to write. Must satisfy: 0 <= offset <= buf.length - 8 * @returns { number } offset plus the number of bytes written * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -2331,7 +2536,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ writeBigInt64BE(value: bigint, offset?: number): number; @@ -2365,10 +2571,10 @@ declare namespace buffer { * @since 10 */ /** - * Writes a 64-bit, little-endian, signed big integer to this Buffer instance at the specified offset. + * Writes value to buf at the specified offset as little-endian. * - * @param { bigint } value - Data to write. - * @param { number } [offset] - Number of bytes to skip before starting to write data. The default value is 0. The value range is [0, Buffer.length - 8]. + * @param { bigint } value - value value Number to be written to buf + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to write. Must satisfy: 0 <= offset <= buf.length - 8 * @returns { number } offset plus the number of bytes written * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -2378,7 +2584,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ writeBigInt64LE(value: bigint, offset?: number): number; @@ -2412,10 +2619,10 @@ declare namespace buffer { * @since 10 */ /** - * Writes a 64-bit, big-endian, unsigned big integer to this Buffer instance at the specified offset. + * Writes value to buf at the specified offset as big-endian. * - * @param { bigint } value - Data to write. - * @param { number } [offset] - Number of bytes to skip before starting to write data. The default value is 0. The value range is [0, Buffer.length - 8]. + * @param { bigint } value - value value Number to be written to buf + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to write. Must satisfy: 0 <= offset <= buf.length - 8 * @returns { number } offset plus the number of bytes written * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -2425,7 +2632,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ writeBigUInt64BE(value: bigint, offset?: number): number; @@ -2459,10 +2667,10 @@ declare namespace buffer { * @since 10 */ /** - * Writes a 64-bit, little-endian, unsigned big integer to this Buffer instance at the specified offset. + * Writes value to buf at the specified offset as little-endian. * - * @param { bigint } value - Data to write. - * @param { number } [offset] - Number of bytes to skip before starting to write data. The default value is 0. The value range is [0, Buffer.length - 8]. + * @param { bigint } value - value value Number to be written to buf + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to write. Must satisfy: 0 <= offset <= buf.length - 8 * @returns { number } offset plus the number of bytes written * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -2472,7 +2680,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ writeBigUInt64LE(value: bigint, offset?: number): number; @@ -2504,10 +2713,10 @@ declare namespace buffer { * @since 10 */ /** - * Writes a 64-bit, big-endian, double-precision floating-point number to this Buffer instance at the specified offset. + * Writes value to buf at the specified offset as big-endian. * - * @param { number } value - Data to write. - * @param { number } [offset] - Number of bytes to skip before starting to write data. The default value is 0. The value range is [0, Buffer.length - 8]. + * @param { number } value - value value Number to be written to buf + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to write. Must satisfy: 0 <= offset <= buf.length - 8 * @returns { number } offset plus the number of bytes written * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -2516,7 +2725,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ writeDoubleBE(value: number, offset?: number): number; @@ -2548,10 +2758,10 @@ declare namespace buffer { * @since 10 */ /** - * Writes a 64-bit, little-endian, double-precision floating-point number to this Buffer instance at the specified offset. + * Writes value to buf at the specified offset as little-endian. * - * @param { number } value - Data to write. - * @param { number } [offset] - Number of bytes to skip before starting to write data. The default value is 0. The value range is [0, Buffer.length - 8]. + * @param { number } value - value value Number to be written to buf + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to write. Must satisfy: 0 <= offset <= buf.length - 8 * @returns { number } offset plus the number of bytes written * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -2560,7 +2770,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ writeDoubleLE(value: number, offset?: number): number; @@ -2592,10 +2803,10 @@ declare namespace buffer { * @since 10 */ /** - * Writes a 32-bit, big-endian, single-precision floating-point number to this Buffer instance at the specified offset. + * Writes value to buf at the specified offset as big-endian. * - * @param { number } value - Data to write. - * @param { number } [offset] - Number of bytes to skip before starting to write data. The default value is 0. The value range is [0, Buffer.length - 4]. + * @param { number } value - value value Number to be written to buf + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to write. Must satisfy: 0 <= offset <= buf.length - 4 * @returns { number } offset plus the number of bytes written * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -2604,7 +2815,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ writeFloatBE(value: number, offset?: number): number; @@ -2636,10 +2848,10 @@ declare namespace buffer { * @since 10 */ /** - * Writes a 32-bit, little-endian, single-precision floating-point number to this Buffer instance at the specified offset. + * Writes value to buf at the specified offset as little-endian. * - * @param { number } value - Data to write. - * @param { number } [offset] - Number of bytes to skip before starting to write data. The default value is 0. The value range is [0, Buffer.length - 4]. + * @param { number } value - value value Number to be written to buf + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to write. Must satisfy: 0 <= offset <= buf.length - 4 * @returns { number } offset plus the number of bytes written * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -2648,7 +2860,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ writeFloatLE(value: number, offset?: number): number; @@ -2682,10 +2895,10 @@ declare namespace buffer { * @since 10 */ /** - * Writes an 8-bit signed integer to this Buffer instance at the specified offset. + * Writes value to buf at the specified offset. value must be a valid signed 8-bit integer. * - * @param { number } value - Data to write. - * @param { number } [offset] - Number of bytes to skip before starting to write data. The default value is 0. The value range is [0, Buffer.length - 1]. + * @param { number } value - value value Number to be written to buf + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to write. Must satisfy: 0 <= offset <= buf.length - 1 * @returns { number } offset plus the number of bytes written * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -2695,7 +2908,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ writeInt8(value: number, offset?: number): number; @@ -2729,10 +2943,10 @@ declare namespace buffer { * @since 10 */ /** - * Writes a 16-bit, big-endian, signed integer to this Buffer instance at the specified offset. + * Writes value to buf at the specified offset as big-endian. The value must be a valid signed 16-bit integer * - * @param { number } value - Data to write. - * @param { number } [offset] - Number of bytes to skip before starting to write data. The default value is 0. The value range is [0, Buffer.length - 2]. + * @param { number } value - value value Number to be written to buf + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to write. Must satisfy: 0 <= offset <= buf.length - 2 * @returns { number } offset plus the number of bytes written * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -2742,7 +2956,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ writeInt16BE(value: number, offset?: number): number; @@ -2776,10 +2991,10 @@ declare namespace buffer { * @since 10 */ /** - * Writes a 16-bit, little-endian, signed integer to this Buffer instance at the specified offset. + * Writes value to buf at the specified offset as little-endian. The value must be a valid signed 16-bit integer * - * @param { number } value - Data to write. - * @param { number } [offset] - Number of bytes to skip before starting to write data. The default value is 0. The value range is [0, Buffer.length - 2]. + * @param { number } value - value value Number to be written to buf + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to write. Must satisfy: 0 <= offset <= buf.length - 2 * @returns { number } offset plus the number of bytes written * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -2789,7 +3004,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ writeInt16LE(value: number, offset?: number): number; @@ -2823,10 +3039,10 @@ declare namespace buffer { * @since 10 */ /** - * Writes a 32-bit, big-endian, signed integer to this Buffer instance at the specified offset. + * Writes value to buf at the specified offset as big-endian. The value must be a valid signed 32-bit integer. * - * @param { number } value - Data to write. - * @param { number } [offset] - Number of bytes to skip before starting to write data. The default value is 0. The value range is [0, Buffer.length - 4]. + * @param { number } value - value value Number to be written to buf + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to write. Must satisfy: 0 <= offset <= buf.length - 4 * @returns { number } offset plus the number of bytes written * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -2836,7 +3052,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ writeInt32BE(value: number, offset?: number): number; @@ -2870,10 +3087,10 @@ declare namespace buffer { * @since 10 */ /** - * Writes a 32-bit, little-endian, signed integer to this Buffer instance at the specified offset. + * Writes value to buf at the specified offset as little-endian. The value must be a valid signed 32-bit integer. * - * @param { number } value - Data to write. - * @param { number } [offset] - Number of bytes to skip before starting to write data. The default value is 0. The value range is [0, Buffer.length - 4]. + * @param { number } value - value value Number to be written to buf + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to write. Must satisfy: 0 <= offset <= buf.length - 4 * @returns { number } offset plus the number of bytes written * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -2883,7 +3100,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ writeInt32LE(value: number, offset?: number): number; @@ -2917,11 +3135,11 @@ declare namespace buffer { * @since 10 */ /** - * Writes a big-endian signed value of the specified length to this Buffer instance at the specified offset. + * Writes byteLength bytes of value to buf at the specified offset as big-endian * - * @param { number } value - Data to write. - * @param { number } offset - Number of bytes to skip before starting to write data. The default value is 0. The value range is [0, Buffer.length - byteLength]. - * @param { number } byteLength - Number of bytes to write. + * @param { number } value - value value Number to be written to buf + * @param { number } offset - offset offset Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - byteLength + * @param { number } byteLength - byteLength byteLength Number of bytes to write. Must satisfy 0 < byteLength <= 6 * @returns { number } offset plus the number of bytes written * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -2930,7 +3148,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ writeIntBE(value: number, offset: number, byteLength: number): number; @@ -2964,11 +3183,11 @@ declare namespace buffer { * @since 10 */ /** - * Writes a little-endian signed value of the specified length to this Buffer instance at the specified offset. + * Writes byteLength bytes of value to buf at the specified offset as little-endian * - * @param { number } value - Data to write. - * @param { number } offset - Number of bytes to skip before starting to write data. The default value is 0. The value range is [0, Buffer.length - byteLength]. - * @param { number } byteLength - Number of bytes to write. + * @param { number } value - value value Number to be written to buf + * @param { number } offset - offset offset Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - byteLength + * @param { number } byteLength - byteLength byteLength Number of bytes to write. Must satisfy 0 < byteLength <= 6 * @returns { number } offset plus the number of bytes written * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -2977,7 +3196,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ writeIntLE(value: number, offset: number, byteLength: number): number; @@ -3011,10 +3231,10 @@ declare namespace buffer { * @since 10 */ /** - * Writes an 8-bit unsigned integer to this Buffer instance at the specified offset. + * Writes value to buf at the specified offset. value must be a valid unsigned 8-bit integer * - * @param { number } value - Data to write. - * @param { number } [offset] - Number of bytes to skip before starting to write data. The default value is 0. The value range is [0, Buffer.length - 1]. + * @param { number } value - value value Number to be written to buf + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - 1 * @returns { number } offset plus the number of bytes written * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -3024,7 +3244,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ writeUInt8(value: number, offset?: number): number; @@ -3058,10 +3279,10 @@ declare namespace buffer { * @since 10 */ /** - * Writes a 16-bit, big-endian, unsigned integer to this Buffer instance at the specified offset. + * Writes value to buf at the specified offset as big-endian. The value must be a valid unsigned 16-bit integer. * - * @param { number } value - Data to write. - * @param { number } [offset] - Number of bytes to skip before starting to write data. The default value is 0. The value range is [0, Buffer.length - 2]. + * @param { number } value - value value Number to be written to buf + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - 2 * @returns { number } offset plus the number of bytes written * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -3071,7 +3292,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ writeUInt16BE(value: number, offset?: number): number; @@ -3105,10 +3327,10 @@ declare namespace buffer { * @since 10 */ /** - * Writes a 16-bit, little-endian, unsigned integer to this Buffer instance at the specified offset. + * Writes value to buf at the specified offset as little-endian. The value must be a valid unsigned 16-bit integer. * - * @param { number } value - Data to write. - * @param { number } [offset] - Number of bytes to skip before starting to write data. The default value is 0. The value range is [0, Buffer.length - 2]. + * @param { number } value - value value Number to be written to buf + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - 2 * @returns { number } offset plus the number of bytes written * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -3118,7 +3340,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ writeUInt16LE(value: number, offset?: number): number; @@ -3152,10 +3375,10 @@ declare namespace buffer { * @since 10 */ /** - * Writes a 32-bit, big-endian, unsigned integer to this Buffer instance at the specified offset. + * Writes value to buf at the specified offset as big-endian. The value must be a valid unsigned 32-bit integer. * - * @param { number } value - Data to write. - * @param { number } [offset] - Number of bytes to skip before starting to write data. The default value is 0. The value range is [0, Buffer.length - 4]. + * @param { number } value - value value Number to be written to buf + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - 4 * @returns { number } offset plus the number of bytes written * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -3165,7 +3388,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ writeUInt32BE(value: number, offset?: number): number; @@ -3199,10 +3423,10 @@ declare namespace buffer { * @since 10 */ /** - * Writes a 32-bit, little-endian, unsigned integer to this Buffer instance at the specified offset. + * Writes value to buf at the specified offset as little-endian. The value must be a valid unsigned 32-bit integer. * - * @param { number } value - Data to write. - * @param { number } [offset] - Number of bytes to skip before starting to write data. The default value is 0. The value range is [0, Buffer.length - 4]. + * @param { number } value - value value Number to be written to buf + * @param { number } [offset] - offset [offset = 0] Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - 4 * @returns { number } offset plus the number of bytes written * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -3212,7 +3436,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ writeUInt32LE(value: number, offset?: number): number; @@ -3246,11 +3471,11 @@ declare namespace buffer { * @since 10 */ /** - * Writes an unsigned big-endian value of the specified length to this Buffer instance at the specified offset. + * Writes byteLength bytes of value to buf at the specified offset as big-endian * - * @param { number } value - Data to write. - * @param { number } offset - Number of bytes to skip before starting to write data. The default value is 0. The value range is [0, Buffer.length - byteLength]. - * @param { number } byteLength - Number of bytes to write. + * @param { number } value - value value Number to be written to buf + * @param { number } offset - offset offset Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - byteLength + * @param { number } byteLength - byteLength byteLength Number of bytes to write. Must satisfy 0 < byteLength <= 6 * @returns { number } offset plus the number of bytes written * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -3259,7 +3484,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ writeUIntBE(value: number, offset: number, byteLength: number): number; @@ -3293,11 +3519,11 @@ declare namespace buffer { * @since 10 */ /** - * Writes an unsigned little-endian value of the specified length to this Buffer instance at the specified offset. + * Writes byteLength bytes of value to buf at the specified offset as little-endian * - * @param { number } value - Data to write. - * @param { number } offset - Number of bytes to skip before starting to write data. The default value is 0. The value range is [0, Buffer.length - byteLength]. - * @param { number } byteLength - Number of bytes to write. + * @param { number } value - value value Number to be written to buf + * @param { number } offset - offset offset Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - byteLength + * @param { number } byteLength - byteLength byteLength Number of bytes to write. Must satisfy 0 < byteLength <= 6 * @returns { number } offset plus the number of bytes written * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -3306,9 +3532,70 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ writeUIntLE(value: number, offset: number, byteLength: number): number; + + /** + * Returns the byte at the specified index. + * + * @param { number } index - byte index to read + * @returns { number | undefined } Returns the byte value at `index` + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + $_get(index: number): number | undefined; + + /** + * Sets the byte at the specified index. + * + * @param { number } index – byte index to write + * @param { number } value – byte value (0–255) + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + $_set(index: number, value: number): void; + } + + /** + * Defines the Blob related options parameters. + * + * @interface BlobOptions + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + interface BlobOptions { + /** + * Blob content type. The default parameter is' '. + * @type { ?string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + type?: string; + + /** + * How to output a string ending with '\ n' as' transparent or native . The default value is transparent. + * @type { ?string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + endings?: string; } /** @@ -3330,7 +3617,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ class Blob { /** @@ -3363,15 +3651,13 @@ declare namespace buffer { * @since 10 */ /** - * A constructor used to create a Blob instance. + * Creates a new Blob object containing a concatenation of the given sources. * - * @param { string[] | ArrayBuffer[] | TypedArray[] | DataView[] | Blob[] } sources - Data sources of the Blob instance. - * @param { Object } options: - * - endings: specifies how the terminator '\n' is output. The value can be 'native' or 'transparent'. 'native' - * means that the terminator follows the system. 'transparent' means that the terminator stored in the Blob - * instance remains unchanged. The default value is 'transparent'. - * - type: type of the data in the Blob instance. This type represents the MIME type of the data. However, - * it is not used for type format validation. The default value is ''. + * @param { string[] | ArrayBuffer[] | TypedArray[] | DataView[] | Blob[] } sources - sources sources An array of string, , + * , , or objects, or any mix of such objects, that will be stored within the Blob + * @param { Object } [options] - options options {endings: string, type: string} + * endings: One of either 'transparent' or 'native'. + * type: The Blob content-type * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; * 2.Incorrect parameter types. @@ -3382,6 +3668,25 @@ declare namespace buffer { */ constructor(sources: string[] | ArrayBuffer[] | TypedArray[] | DataView[] | Blob[], options?: Object); + /** + * Creates a new Blob object containing a concatenation of the given sources. + * + * @param { Array | Array | Array | Array | Array } sources - sources sources An array of string, , + * , , or objects, or any mix of such objects, that will be stored within the Blob + * @param { BlobOptions } [options] - options options {endings: string, type: string} + * endings: One of either 'transparent' or 'native'. + * type: The Blob content-type + * @throws { BusinessError } 401 - Parameter error. Possible causes: + * 1.Mandatory parameters are left unspecified; + * 2.Incorrect parameter types. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + constructor(sources: Array | Array | Array | Array | Array, options?: BlobOptions); + /** * The total size of the Blob in bytes * @@ -3398,13 +3703,14 @@ declare namespace buffer { * @since 10 */ /** - * Total size of the Blob instance, in bytes. + * The total size of the Blob in bytes * * @type { number } * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ size: number; @@ -3424,13 +3730,14 @@ declare namespace buffer { * @since 10 */ /** - * Type of the data in the Blob instance. + * The content-type of the Blob * * @type { string } * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ type: string; @@ -3450,13 +3757,14 @@ declare namespace buffer { * @since 10 */ /** - * Puts the Blob data into an ArrayBuffer instance. This API uses a promise to return the result. + * Returns a promise that fulfills with an containing a copy of the Blob data. * * @returns { Promise } * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ arrayBuffer(): Promise; @@ -3482,16 +3790,17 @@ declare namespace buffer { * @since 10 */ /** - * Creates a Blob instance by copying specified data from this Blob instance. + * Creates and returns a new Blob containing a subset of this Blob objects data. The original Blob is not altered * - * @param { number } [start] - Offset to the start position of the data to copy. The default value is 0. - * @param { number } [end] - Offset to the end position of the data to copy. The default value is the data length in the original Blob instance. - * @param { string } [type] - Type of the data in the new Blob instance. The default value is ''. + * @param { number } [start] - start start The starting index + * @param { number } [end] - end end The ending index + * @param { string } [type] - type type The content-type for the new Blob * @returns { Blob } * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ slice(start?: number, end?: number, type?: string): Blob; @@ -3511,13 +3820,14 @@ declare namespace buffer { * @since 10 */ /** - * Returns text in UTF-8 format. This API uses a promise to return the result. + * Returns a promise that fulfills with the contents of the Blob decoded as a UTF-8 string. * * @returns { Promise } * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ text(): Promise; } diff --git a/api/@ohos.uri.d.ts b/api/@ohos.uri.d.ts index d2de4cbfa03140478cc3d3aa6eb13c1ce6da5f0e..4073c286715ed75b9d68608a4c580dcca9bfac04 100644 --- a/api/@ohos.uri.d.ts +++ b/api/@ohos.uri.d.ts @@ -34,15 +34,14 @@ * @since 10 */ /** - * The uri module provides APIs for parsing URI strings that comply with the RFC3986 standard. - * This standard defines how to encode and parse the identifiers used to locate network resources. - * The module does not support parsing of URIs in non-standard scenarios. + * The uri module provides utilities for URI resolution and parsing. * * @namespace uri * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ declare namespace uri { /** @@ -66,7 +65,8 @@ declare namespace uri { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 * @name URI */ class URI { @@ -98,9 +98,10 @@ declare namespace uri { * @since 10 */ /** - * A constructor used to create a URI instance. + * URI constructor, which is used to instantiate a URI object. + * uri: Constructs a URI by parsing a given string. * - * @param { string } uri - Input object. + * @param { string } uri - uri uri * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; * 2.Incorrect parameter types; @@ -109,7 +110,8 @@ declare namespace uri { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ constructor(uri: string); /** @@ -128,13 +130,14 @@ declare namespace uri { * @since 10 */ /** - * Converts this URI into an encoded string. + * Returns the serialized URI as a string. * - * @returns { string } URI in a serialized string. + * @returns { string } Returns the serialized URI as a string. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ toString(): string; @@ -174,9 +177,9 @@ declare namespace uri { * @since 10 */ /** - * Checks whether this URI is the same as another URI object. + * Check whether this URI is equivalent to other URI objects. * - * @param { URI } other - URI object to compare. + * @param { URI } other - other other URI object to be compared * @returns { boolean } boolean Tests whether this URI is equivalent to other URI objects. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -184,7 +187,8 @@ declare namespace uri { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ equalsTo(other: URI): boolean; @@ -204,13 +208,14 @@ declare namespace uri { * @since 10 */ /** - * Checks whether this URI is an absolute URI (whether the scheme component is defined). + * Indicates whether this URI is an absolute URI. * * @returns { boolean } boolean Indicates whether the URI is an absolute URI (whether the scheme component is defined). * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ checkIsAbsolute(): boolean; @@ -230,18 +235,18 @@ declare namespace uri { * @since 10 */ /** - * Normalizes the path of this URI. + * Normalize the path of this URI, It is not safe to call the normalize interface with URI. * * @returns { URI } URI Used to normalize the path of this URI and return a URI object whose path has been normalized. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ normalize(): URI; /** - * Obtains the first value of a given key from the query component of this URI. If the query component contains encoded content, - * this API decodes the key before obtaining the value. + * Searches the query string for the first value with the given key. * * @param { string } key - Given the first value of the key. * @returns { string } Return decoded value. @@ -255,10 +260,25 @@ declare namespace uri { */ getQueryValue(key: string): string; /** - * Adds a query parameter to this URI to create a new URI, while keeping the existing URI unchanged. + * Searches the query string for the first value with the given key. + * + * @param { string } key - Given the first value of the key. + * @returns { string | null } Return decoded value, If no corresponding value is found return a null object. + * @throws { BusinessError } 401 - Parameter error. Possible causes: + * 1.Mandatory parameters are left unspecified; + * 2.Incorrect parameter types. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + getQueryValue(key: string): string | null; + /** + * Encodes the key and value and then appends the result to the query string. * - * @param { string } [key] - Key of the query parameter. - * @param { string } [value] - Value of the query parameter. + * @param { string } [key] - The key it will be encoded with. + * @param { string } [value] - The value it will be encoded with. * @returns { URI } Return URI object. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -266,11 +286,12 @@ declare namespace uri { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ addQueryValue(key: string, value: string): URI; /** - * Obtains all non-repeated keys in the query component of this URI. + * Returns a set of the unique names of all query parameters. * * @returns { string[] } Return a set of decoded names. * @syscap SystemCapability.Utils.Lang @@ -280,9 +301,20 @@ declare namespace uri { */ getQueryNames(): string[]; /** - * Obtains the values of a given key from the query component of this URI. + * Returns a set of the unique names of all query parameters. * - * @param { string } key - Key of the URI query parameter. + * @returns { Array } Return a set of decoded names. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + getQueryNames(): Array; + /** + * Searches the query string for parameter values with the given key. + * + * @param { string } key - The key it will be encoded with. * @returns { string[] } Return a set of decoded values. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -293,8 +325,21 @@ declare namespace uri { * @since 12 */ getQueryValues(key: string): string[]; + /** - * Obtains the value of the Boolean type of a query parameter in this URI. + * Searches the query string for parameter values with the given key. + * + * @param { string } key - The key it will be encoded with. + * @returns { Array } Return a set of decoded values. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + getQueryValues(key: string): Array; + /** + * Searches the query string for the first value with the given key and interprets it as a boolean value. * * @param { string } key - Indicates the key value to be queried. * @param { boolean } defaultValue - The default value returned when the key has no query parameters. @@ -305,31 +350,34 @@ declare namespace uri { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ getBooleanQueryValue(key: string, defaultValue: boolean): boolean; /** - * Clears the query component of this URI to create a new URI, while keeping the existing URI object unchanged. + * Clears the the previously set query. * * @returns { URI } After clearing, return the URI object. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ clearQuery(): URI; /** - * Obtains the last segment of this URI. + * Gets the decoded last path segment. * * @returns { string } Returns the last decoded segment, or null if the path is empty. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ getLastSegment(): string; /** - * Obtains all segments of this URI. + * Gets the decoded path segments. * * @returns { string[] } Return decoded path segments, each without a leading or trailing "/". * @syscap SystemCapability.Utils.Lang @@ -339,8 +387,18 @@ declare namespace uri { */ getSegment(): string[]; /** - * Encodes a given field, appends it to the path component of this URI to create a new URI, and returns the new URI, - * while keeping the existing URI unchanged. + * Gets the decoded path segments. + * + * @returns { Array } Return decoded path segments, each without a leading or trailing "/". + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + getSegment(): Array; + /** + * Encodes the given path segment and appends it to the path. * * @param { string } [pathSegment] - path segment to be added. * @returns { URI } After adding, return the URI object. @@ -350,12 +408,12 @@ declare namespace uri { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ addSegment(pathSegment: string): URI; /** - * Appends an encoded field to the path component of this URI to create a new URI and returns the new URI, - * while keeping the existing URI unchanged. + * Creates a new Uri by appending an already-encoded path segment to a base Uri. * * @param { string } pathSegment - Encoding path segment to be added. * @returns { URI } After adding, return the URI object. @@ -365,42 +423,45 @@ declare namespace uri { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ addEncodedSegment(pathSegment: string): URI; /** - * Checks whether this URI is a hierarchical URI. The URI that starts with a slash (/) in scheme-specific-part is a - * hierarchical URI. Relative URIs are also hierarchical. + * Determine whether URI is hierarchical. * * @returns { boolean } Return true as Hierarchical, otherwise return false. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ checkHierarchical(): boolean; /** - * Checks whether this URI is an opaque URI. The URI that does not start with a slash (/) is an opaque URI. + * Determine whether URI is Opaque. * * @returns { boolean } Return true as Opaque, otherwise return false. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ checkOpaque(): boolean; /** - * Checks whether this URI is a relative URI. A relative URI does not contain the scheme component. + * Determine whether URI is Relative. * * @returns { boolean } Return true as Relative, otherwise return false. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ checkRelative(): boolean; /** - * Creates a URI based on the provided scheme, scheme-specific-part, and fragment components. + * Creates an opaque Uri from the given components. * * @param { string } scheme - of the URI. * @param { string } ssp -scheme-specific-part, everything between the scheme separator (':') and the fragment @@ -413,7 +474,8 @@ declare namespace uri { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ static createFromParts(scheme: string, ssp: string, fragment: string): URI; /** @@ -773,6 +835,334 @@ declare namespace uri { * @since 12 */ encodedSSP: string; + /** + * Gets the protocol part of the URI. + * + * @type { string | null } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get scheme(): string | null; + + /** + * Sets the protocol part of the URI. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + set scheme(input: string | null); + + /** + * Gets Obtains the user information part of the URI. + * + * @type { string | null } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get userInfo(): string | null; + + /** + * Sets Obtains the user information part of the URI. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + set userInfo(input: string | null); + + /** + * Gets the hostname portion of the URI without a port. + * + * @type { string | null } + * @syscap SystemCapability.Utils.Lang + * @since 20 + * @arkts 1.2 + */ + get host(): string | null; + + /** + * Gets the port portion of the URI. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @since 20 + * @arkts 1.2 + */ + get port(): string; + + /** + * Gets the path portion of the URI. + * + * @type { string | null } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get path(): string | null; + + /** + * Sets the path portion of the URI. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + set path(input: string | null); + + /** + * Gets the query portion of the URI + * + * @type { string | null } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get query(): string | null; + + /** + * Sets the query portion of the URI + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + set query(input: string | null); + + /** + * Gets the fragment part of the URI. + * + * @type { string | null } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get fragment(): string | null; + + /** + * Sets the fragment part of the URI. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + set fragment(input: string | null); + + /** + * Gets the decoding permission component part of this URI. + * + * @type { string | null } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get authority(): string | null; + + /** + * Sets the decoding permission component part of this URI. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + set authority(input: string | null); + + /** + * Gets the decoding scheme-specific part of the URI. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get ssp(): string; + + /** + * Sets the decoding scheme-specific part of the URI. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + set ssp(input: string | null); + + /** + * Gets Obtains the encoded user information part of the URI. + * + * @type { string | null } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get encodedUserInfo(): string | null; + /** + * Sets Obtains the encoded user information part of the URI. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + set encodedUserInfo(input: string | null); + + /** + * Gets the encoded path portion of the URI. + * + * @type { string | null } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get encodedPath(): string | null; + /** + * Sets the encoded path portion of the URI. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + set encodedPath(input: string | null); + + /** + * Gets the encoded query component from this URI. + * + * @type { string | null } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get encodedQuery(): string | null; + /** + * Sets the encoded query component from this URI. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + set encodedQuery(input: string | null); + + /** + * Gets the encoded fragment part of this URI, everything after the '#'. + * + * @type { string | null } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get encodedFragment(): string | null; + /** + * Sets the encoded fragment part of this URI, everything after the '#'. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + set encodedFragment(input: string | null); + + /** + * Gets the encoded authority part of this URI. + * + * @type { string | null } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get encodedAuthority(): string | null; + /** + * Sets the encoded authority part of this URI. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + set encodedAuthority(input: string | null); + + /** + * Gets the scheme-specific part of this URI, i.e. everything between the scheme separator ':' and + * the fragment separator '#'. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get encodedSSP(): string; + + /** + * Sets the scheme-specific part of this URI, i.e. everything between the scheme separator ':' and + * the fragment separator '#'. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + set encodedSSP(input: string | null) } } export default uri; diff --git a/api/@ohos.url.d.ts b/api/@ohos.url.d.ts index ad5a9b4df0ee25884f019ea1852e6c6b841734a0..6045d1ad259105e45196b4837f2fae8564c69ce5 100644 --- a/api/@ohos.url.d.ts +++ b/api/@ohos.url.d.ts @@ -34,13 +34,14 @@ * @since 10 */ /** - * The url module provides APIs for parsing URL strings and constructing URL instances to process URL strings. + * The url module provides utilities for URL resolution and parsing. * * @namespace url * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ declare namespace url { /** @@ -244,7 +245,8 @@ declare namespace url { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 * @name URLParams */ class URLParams { @@ -276,14 +278,14 @@ declare namespace url { * @since 10 */ /** - * A constructor used to create a URLParams instance. + * A parameterized constructor used to create an URLParams instance. + * As the input parameter of the constructor function, init supports four types. + * The input parameter is a character string two-dimensional array. + * The input parameter is the object list. + * The input parameter is a character string. + * The input parameter is the URLParams object. * - * @param { string[][] | Record | string | URLParams } [init] - Input parameter objects, which include the following: - * - string[][]: two-dimensional string array. - * - Record: list of objects. - * - string: string. - * - URLParams: object. - * The default value is null. + * @param { string[][] | Record | string | URLParams } [init] - init init * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed. * @syscap SystemCapability.Utils.Lang * @crossplatform @@ -292,6 +294,23 @@ declare namespace url { */ constructor(init?: string[][] | Record | string | URLParams); + /** + * A parameterized constructor used to create an URLParams instance. + * As the input parameter of the constructor function, init supports four types. + * The input parameter is a character string two-dimensional array. + * The input parameter is the object list. + * The input parameter is a character string. + * The input parameter is the URLParams object. + * + * @param { [string, string][] | Record | string | URLParams } [init] - init init + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + constructor(init?: [string, string][] | Record | string | URLParams); + /** * Appends a specified key/value pair as a new search parameter. * @@ -318,10 +337,10 @@ declare namespace url { * @since 10 */ /** - * Appends a key-value pair into the query string. + * Appends a specified key/value pair as a new search parameter. * - * @param { string } name - Key of the key-value pair to append. - * @param { string } value - Value of the key-value pair to append. + * @param { string } name - name name Key name of the search parameter to be inserted. + * @param { string } value - value value Values of search parameters to be inserted. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; * 2.Incorrect parameter types; @@ -329,7 +348,8 @@ declare namespace url { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ append(name: string, value: string): void; @@ -357,9 +377,9 @@ declare namespace url { * @since 10 */ /** - * Deletes key-value pairs of the specified key. + * Deletes the given search parameter and its associated value,from the list of all search parameters. * - * @param { string } name - Key of the key-value pairs to delete. + * @param { string } name - name name Name of the key-value pair to be deleted. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; * 2.Incorrect parameter types; @@ -367,7 +387,8 @@ declare namespace url { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ delete(name: string): void; @@ -397,9 +418,9 @@ declare namespace url { * @since 10 */ /** - * Obtains all the values based on the specified key. + * Returns all key-value pairs associated with a given search parameter as an array. * - * @param { string } name - Target key. + * @param { string } name - name name Specifies the name of a key value. * @returns { string[] } string[] Returns all key-value pairs with the specified name. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -412,6 +433,19 @@ declare namespace url { */ getAll(name: string): string[]; + /** + * Returns all key-value pairs associated with a given search parameter as an array. + * + * @param { string } name - name name Specifies the name of a key value. + * @returns { Array } Array Returns all key-value pairs with the specified name. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + getAll(name: string): Array; + /** * Returns an ES6 iterator. Each item of the iterator is a JavaScript Array. * The first item of Array is name, and the second item of Array is value. @@ -430,14 +464,15 @@ declare namespace url { * @since 10 */ /** - * Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and the first and second fields of - * each array are the key and value respectively. + * Returns an ES6 iterator. Each item of the iterator is a JavaScript Array. + * The first item of Array is name, and the second item of Array is value. * * @returns { IterableIterator<[string, string]> } Returns an iterator for ES6. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ entries(): IterableIterator<[string, string]>; @@ -469,10 +504,11 @@ declare namespace url { * @since 10 */ /** - * Traverses the key-value pairs in the URLSearchParams instance by using a callback. + * Callback functions are used to traverse key-value pairs on the URLParams instance object. * - * @param { function } callbackFn - Callback invoked to traverse the key-value pairs in the URLSearchParams instance. - * @param { Object } [thisArg] - Value of this to use when callbackFn is invoked. The default value is this object. + * @param { function } callbackFn - callbackFn value Current traversal key value, + * key Indicates the name of the key that is traversed. + * @param { Object } [thisArg] - thisArg thisArg to be used as this value for when callbackFn is called * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; * 2.Incorrect parameter types; @@ -484,6 +520,18 @@ declare namespace url { */ forEach(callbackFn: (value: string, key: string, searchParams: URLParams) => void, thisArg?: Object): void; + /** + * Iterates over a collection (e.g., URLs) and executes a callback function for each element. + * + * @param { UrlCbFn } callbackFn - A callback function to execute for each element. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + forEach(callbackFn: UrlCbFn): void; + /** * Returns the first value associated to the given search parameter. * @@ -510,9 +558,9 @@ declare namespace url { * @since 10 */ /** - * Obtains the value of the first key-value pair based on the specified key. + * Returns the first value associated to the given search parameter. * - * @param { string } name - Key specified to obtain the value. + * @param { string } name - name name Specifies the name of a key-value pair. * @returns { string | null } Returns the first value found by name. If no value is found, null is returned. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -525,6 +573,20 @@ declare namespace url { */ get(name: string): string | null; + /** + * Returns the first value associated to the given search parameter. + * + * @param { string } name - name name Specifies the name of a key-value pair. + * @returns { string | undefined } Returns the first value found by name. + * If no value is found, undefined is returned. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get(name: string): string | undefined; + /** * Returns a Boolean that indicates whether a parameter with the specified name exists. * @@ -549,9 +611,9 @@ declare namespace url { * @since 10 */ /** - * Checks whether a key has a value. + * Returns a Boolean that indicates whether a parameter with the specified name exists. * - * @param { string } name - Key specified to search for its value. + * @param { string } name - name name Specifies the name of a key-value pair. * @returns { boolean } Returns a Boolean value that indicates whether a found * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -559,7 +621,8 @@ declare namespace url { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ has(name: string): boolean; @@ -595,12 +658,13 @@ declare namespace url { * @since 10 */ /** - * Sets the value for a key. If key-value pairs matching the specified key exist, the value of the first key-value - * pair will be set to the specified value and other key-value pairs will be deleted. Otherwise, the key-value pair - * will be appended to the query string. + * Sets the value associated with a given search parameter to the + * given value. If there were several matching values, this method + * deletes the others. If the search parameter doesn't exist, this + * method creates it. * - * @param { string } name - Key of the value to set. - * @param { string } value - Value to set. + * @param { string } name - name name Key name of the parameter to be set. + * @param { string } value - value value Indicates the parameter value to be set. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; * 2.Incorrect parameter types; @@ -608,7 +672,8 @@ declare namespace url { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ set(name: string, value: string): void; @@ -626,14 +691,13 @@ declare namespace url { * @since 10 */ /** - * Sorts all key-value pairs contained in this object based on the Unicode code points of the keys and returns - * undefined. This method uses a stable sorting algorithm, that is, the relative order between key-value pairs - * with equal keys is retained. + * Sort all key/value pairs contained in this object in place and return undefined. * * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ sort(): void; @@ -653,13 +717,14 @@ declare namespace url { * @since 10 */ /** - * Obtains an ES6 iterator that contains the keys of all the key-value pairs. + * Returns an iterator allowing to go through all keys contained in this object. * * @returns { IterableIterator } Returns an ES6 Iterator over the names of each name-value pair. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ keys(): IterableIterator; @@ -679,13 +744,14 @@ declare namespace url { * @since 10 */ /** - * Obtains an ES6 iterator that contains the values of all the key-value pairs. + * Returns an iterator allowing to go through all values contained in this object. * * @returns { IterableIterator } Returns an ES6 Iterator over the values of each name-value pair. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ values(): IterableIterator; @@ -709,8 +775,8 @@ declare namespace url { * @since 10 */ /** - * Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and the first and second fields ofeach array are - * the key and value respectively. + * Returns an iterator allowing to go through all key/value + * pairs contained in this object. * * @returns { IterableIterator<[string, string]> } Returns an ES6 iterator. Each item of the iterator is a JavaScript Array. * The first item of Array is name, and the second item of Array is value. @@ -721,6 +787,21 @@ declare namespace url { */ [Symbol.iterator](): IterableIterator<[string, string]>; + /** + * Returns an iterator allowing to go through all key/value + * pairs contained in this object. + * + * @returns { IterableIterator<[string, string]> } Returns an ES6 iterator. + * Each item of the iterator is a JavaScript Array. + * The first item of Array is name, and the second item of Array is value. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + $_iterator(): IterableIterator<[string, string]>; + /** * Returns a query string suitable for use in a URL. * @@ -737,13 +818,14 @@ declare namespace url { * @since 10 */ /** - * Obtains search parameters that are serialized as a string and, if necessary, percent-encodes the characters in the string. + * Returns a query string suitable for use in a URL. * * @returns { string } Returns a search parameter serialized as a string, percent-encoded if necessary. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ toString(): string; } @@ -769,7 +851,8 @@ declare namespace url { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 * @name URL */ class URL { @@ -802,13 +885,13 @@ declare namespace url { * @since 10 */ /** - * A no-argument constructor used to create a URL. It returns a URL object after parseURL is called. - * It is not used independently. + * URL constructor, which is used to instantiate a URL object. * * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ constructor(); @@ -844,16 +927,11 @@ declare namespace url { * @since 10 */ /** - * Parses a URL. + * Replaces the original constructor to process arguments and return a url object. * - * @param { string } url - A string representing an absolute or a relative URL. - * In the case of a relative URL, you must specify base to parse the final URL. - * In the case of an absolute URL, the passed base will be ignored. + * @param { string } url - url url Absolute or relative input URL to resolve. Base is required if input is relative. * If input is an absolute value, base ignores the value. - * @param { string | URL } [base] - Either a string or an object. The default value is undefined. - * - string: string. - * - URL: URL object. - * This parameter is used when url is a relative URL. + * @param { string | URL } [base] - base base Base URL to parse if input is not absolute. * @returns { URL } * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -863,7 +941,8 @@ declare namespace url { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ static parseURL(url: string, base?: string | URL): URL; @@ -883,13 +962,14 @@ declare namespace url { * @since 10 */ /** - * Converts the parsed URL into a string. + * Returns the serialized URL as a string. * * @returns { string } Returns the serialized URL as a string. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ toString(): string; @@ -909,13 +989,14 @@ declare namespace url { * @since 10 */ /** - * Converts the parsed URL into a JSON string. + * Returns the serialized URL as a string. * * @returns { string } Returns the serialized URL as a string. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ toJSON(): string; @@ -1179,6 +1260,271 @@ declare namespace url { * @since 11 */ search: string; + + /** + * Gets and sets the fragment portion of the URL. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get hash(): string; + + /** + * Gets and sets the fragment portion of the URL. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + set hash(hash: string); + + /** + * Gets and sets the host portion of the URL. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get host(): string; + + /** + * Gets and sets the host portion of the URL. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + set host(host: string); + + /** + * Gets and sets the host name portion of the URL,not include the port. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get hostname(): string; + + /** + * Gets and sets the host name portion of the URL,not include the port. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + set hostname(hostname: string); + + /** + * Gets and sets the serialized URL. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get href(): string; + + /** + * Gets and sets the serialized URL. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + set href(href: string); + + /** + * Gets the read-only serialization of the URL's origin. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get origin(): string; + + /** + * Gets and sets the password portion of the URL. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get password(): string; + + /** + * Gets and sets the password portion of the URL. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + set password(password: string); + + /** + * Gets and sets the path portion of the URL. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get pathname(): string; + + /** + * Gets and sets the path portion of the URL. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + set pathname(pathname: string); + + /** + * Gets and sets the port portion of the URL. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get port(): string; + + /** + * Gets and sets the port portion of the URL. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + set port(port: string); + + /** + * Gets and sets the protocol portion of the URL. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get protocol(): string; + + /** + * Gets and sets the protocol portion of the URL. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + set protocol(protocol: string); + + /** + * Gets and sets the serialized query portion of the URL. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get search(): string; + + /** + * Gets and sets the serialized query portion of the URL. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + set search(search: string); + /** + * Gets the URLParams object that represents the URL query parameter. + * This property is read-only, but URLParams provides an object that can be used to change + * the URL instance. To replace the entire query parameter for a URL, use url.searchsetter. + * + * @type { URLParams } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get params(): URLParams; + + /** + * Gets and sets the username portion of the URL. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get username(): string; + + /** + * Gets and sets the username portion of the URL. + * + * @type { string } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + set username(username: string); /** * Gets the URLSearchParams object that represents the URL query parameter. @@ -1251,5 +1597,20 @@ declare namespace url { */ username: string; } + + /** + * The type of URL callback function. + * + * @typedef { function } UrlCbFn + * @param { string } value - The value of the URL parameter. + * @param { string } key - The key of the URL parameter. + * @param { URLParams } searchParams - The URLParams object containing all parameters. + * @returns { void } This callback does not return a value. + * @syscap SystemCapability.Utils.Lang + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + type UrlCbFn = (value: string, key: string, searchParams: URLParams) => void; } export default url; diff --git a/api/@ohos.util.ArrayList.d.ts b/api/@ohos.util.ArrayList.d.ts index 284a6b70236b17af70f23b249eb7f3535af5cd4c..ae103a8bfc06d97b7157565bb4ca518854e74340 100644 --- a/api/@ohos.util.ArrayList.d.ts +++ b/api/@ohos.util.ArrayList.d.ts @@ -40,7 +40,8 @@ * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ declare class ArrayList { /** @@ -59,13 +60,14 @@ declare class ArrayList { * @since 10 */ /** - * A constructor used to create an ArrayList instance. + * A constructor used to create a ArrayList object. * * @throws { BusinessError } 10200012 - The ArrayList's constructor cannot be directly invoked. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ constructor(); /** @@ -84,7 +86,7 @@ declare class ArrayList { * @since 10 */ /** - * Number of elements in an array list. + * Gets the element number of the ArrayList.This is a number one higher than the highest index in the arraylist. * * @type { number } * @syscap SystemCapability.Utils.Lang @@ -93,6 +95,17 @@ declare class ArrayList { * @since 12 */ length: number; + /** + * Gets the element number of the ArrayList. + * + * @type { number } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get length(): number; /** * Appends the specified element to the end of this arraylist. * @@ -113,15 +126,16 @@ declare class ArrayList { * @since 10 */ /** - * Adds an element at the end of this container. + * Appends the specified element to the end of this arraylist. * - * @param { T } element - Target element. + * @param { T } element - element element to be appended to this arraylist * @returns { boolean } the boolean type, returns true if the addition is successful, and returns false if it fails. * @throws { BusinessError } 10200011 - The add method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ add(element: T): boolean; /** @@ -158,10 +172,12 @@ declare class ArrayList { * @since 10 */ /** - * Inserts an element at the specified position in this container. + * Inserts the specified element at the specified position in this + * arraylist. Shifts the element currently at that position (if any) and + * any subsequent elements to the right (adds one to their index). * - * @param { T } element - Target element. - * @param { number } index - Index of the position where the element is to be inserted. + * @param { T } element - element element element to be inserted + * @param { number } index - index index at which the specified element is to be inserted * @throws { BusinessError } 10200001 - The value of index is out of range. * @throws { BusinessError } 10200011 - The insert method cannot be bound. * @throws { BusinessError } 401 - Parameter error. Possible causes: @@ -171,7 +187,8 @@ declare class ArrayList { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ insert(element: T, index: number): void; /** @@ -194,15 +211,16 @@ declare class ArrayList { * @since 10 */ /** - * Checks whether this container has the specified element. + * Check if arraylist contains the specified element * - * @param { T } element - Target element. + * @param { T } element - element element element to be contained * @returns { boolean } the boolean type,if arraylist contains the specified element,return true,else return false * @throws { BusinessError } 10200011 - The has method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ has(element: T): boolean; /** @@ -227,15 +245,17 @@ declare class ArrayList { * @since 10 */ /** - * Obtains the index of the first occurrence of the specified element in this container. + * Returns the index of the first occurrence of the specified element + * in this arraylist, or -1 if this arraylist does not contain the element. * - * @param { T } element - Target element. + * @param { T } element - element element element to be contained * @returns { number } the number type ,returns the lowest index such that or -1 if there is no such index. * @throws { BusinessError } 10200011 - The getIndexOf method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ getIndexOf(element: T): number; /** @@ -270,11 +290,12 @@ declare class ArrayList { * @since 10 */ /** - * Removes an element with the specified position from this container. + * Find the corresponding element according to the index, + * delete the element, and move the index of all elements to the right of the element forward by one. * - * @param { number } index - Position index of the target element. - * @returns { T } Element removed. - * @throws { BusinessError } 10200001 - The value of index is out of range. + * @param { number } index - index index the index in the arraylist + * @returns { T } the T type ,returns undefined if arraylist is empty,If the index is + * @throws { BusinessError } 10200001 - The value of "index" is out of range. * @throws { BusinessError } 10200011 - The removeByIndex method cannot be bound. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -283,7 +304,8 @@ declare class ArrayList { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ removeByIndex(index: number): T; /** @@ -310,15 +332,18 @@ declare class ArrayList { * @since 10 */ /** - * Removes the first occurrence of the specified element from this container. + * Removes the first occurrence of the specified element from this arraylist, + * if it is present. If the arraylist does not contain the element, it is + * unchanged. More formally, removes the element with the lowest index * - * @param { T } element - Target element. + * @param { T } element - element element element to remove * @returns { boolean } the boolean type ,If there is no such element, return false * @throws { BusinessError } 10200011 - The remove method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ remove(element: T): boolean; /** @@ -343,15 +368,17 @@ declare class ArrayList { * @since 10 */ /** - * Obtains the index of the last occurrence of the specified element in this container. + * Returns in the index of the last occurrence of the specified element in this arraylist , + * or -1 if the arraylist does not contain the element. * - * @param { T } element - Target element. + * @param { T } element - element element element to find * @returns { number } the number type * @throws { BusinessError } 10200011 - The getLastIndexOf method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ getLastIndexOf(element: T): number; /** @@ -384,11 +411,10 @@ declare class ArrayList { * @since 10 */ /** - * Removes from this container all of the elements within a range, including the element at the start position but - * not that at the end position. + * Removes from this arraylist all of the elements whose index is between fromIndex,inclusive,and toIndex ,exclusive. * - * @param { number } fromIndex - Index of the start position. - * @param { number } toIndex - Index of the end position. + * @param { number } fromIndex - fromIndex fromIndex The starting position of the index, containing the value at that index position + * @param { number } toIndex - toIndex toIndex the end of the index, excluding the value at that index * @throws { BusinessError } 10200001 - The value of fromIndex or toIndex is out of range. * @throws { BusinessError } 10200011 - The removeByRange method cannot be bound. * @throws { BusinessError } 401 - Parameter error. Possible causes: @@ -398,7 +424,8 @@ declare class ArrayList { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ removeByRange(fromIndex: number, toIndex: number): void; /** @@ -435,10 +462,14 @@ declare class ArrayList { * @since 10 */ /** - * Replaces all elements in this container with new elements, and returns the new ones. + * Replaces each element of this arraylist with the result of applying the operator to that element. * - * @param { function } callbackFn - Callback invoked for the replacement. - * @param { Object } [thisArg] - Value of this to use when callbackFn is invoked. The default value is this instance. + * @param { function } callbackFn - callbackFn + * callbackFn (required) A function that accepts up to three arguments. + * The function to be called for each element. + * @param { Object } [thisArg] - thisArg + * thisArg (Optional) The value to be used as this value for when callbackFn is called. + * If thisArg is omitted, undefined is used as the this value. * @throws { BusinessError } 10200011 - The replaceAllElements method cannot be bound. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -449,6 +480,19 @@ declare class ArrayList { * @since 12 */ replaceAllElements(callbackFn: (value: T, index?: number, arrlist?: ArrayList) => T, thisArg?: Object): void; + + /** + * Replaces each element of this arrayList with the result of applying the operator to that element. + * + * @param { ArrayListCbFn1 } callbackFn - A callback function to execute for each element. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + replaceAllElements(callbackFn: ArrayListCbFn1): void; + /** * Executes a provided function once for each value in the arraylist object. * @@ -483,10 +527,14 @@ declare class ArrayList { * @since 10 */ /** - * Uses a callback to traverse the elements in this container and obtain their position indexes. + * Executes a provided function once for each value in the arraylist object. * - * @param { function } callbackFn - Callback invoked for the replacement. - * @param { Object } [thisArg] - Value of this to use when callbackFn is invoked. The default value is this instance. + * @param { function } callbackFn - callbackFn + * callbackFn (required) A function that accepts up to three arguments. + * The function to be called for each element. + * @param { Object } [thisArg] - thisArg + * thisArg (Optional) The value to be used as this value for when callbackFn is called. + * If thisArg is omitted, undefined is used as the this value. * @throws { BusinessError } 10200011 - The forEach method cannot be bound. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -497,6 +545,19 @@ declare class ArrayList { * @since 12 */ forEach(callbackFn: (value: T, index?: number, arrlist?: ArrayList) => void, thisArg?: Object): void; + + /** + * Iterates over elements in a generic ArrayList and executes a callback function for each element. + * + * @param { ArrayListCbFn } callbackFn - A callback function to execute for each element. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + forEach(callbackFn: ArrayListCbFn): void; + /** * Sorts this arraylist according to the order induced by the specified comparator,without comparator this parameter, * it will default to ASCII sorting @@ -531,10 +592,14 @@ declare class ArrayList { * @since 10 */ /** - * Sorts elements in this container. + * Sorts this arraylist according to the order induced by the specified comparator,without comparator this parameter, + * it will default to ASCII sorting * - * @param { function } [comparator] - Callback invoked for sorting. The default value is the callback function for - * sorting elements in ascending order. + * @param { function } [comparator] - comparator + * comparator (Optional) A function that accepts up to two arguments.Specifies the sort order. + * Must be a function,return number type,If it returns firstValue minus secondValue, it returns an arraylist + * sorted in ascending order;If it returns secondValue minus firstValue, it returns an arraylist sorted in descending order; + * If this parameter is empty, it will default to ASCII sorting * @throws { BusinessError } 10200011 - The sort method cannot be bound. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Incorrect parameter types; @@ -542,7 +607,8 @@ declare class ArrayList { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ sort(comparator?: (firstValue: T, secondValue: T) => number): void; /** @@ -577,12 +643,11 @@ declare class ArrayList { * @since 10 */ /** - * Obtains elements within a range in this container, including the element at the start position but not that at the - * end position, and returns these elements as a new ArrayList instance. + * Returns a view of the portion of this arraylist between the specified fromIndex,inclusive,and toIndex,exclusive * - * @param { number } fromIndex - Index of the start position. - * @param { number } toIndex - Index of the end position. - * @returns { ArrayList } New ArrayList instance obtained. + * @param { number } fromIndex - fromIndex fromIndex The starting position of the index, containing the value at that index position + * @param { number } toIndex - toIndex toIndex the end of the index, excluding the value at that index + * @returns { ArrayList } * @throws { BusinessError } 10200001 - The value of fromIndex or toIndex is out of range. * @throws { BusinessError } 10200011 - The subArrayList method cannot be bound. * @throws { BusinessError } 401 - Parameter error. Possible causes: @@ -592,7 +657,8 @@ declare class ArrayList { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ subArrayList(fromIndex: number, toIndex: number): ArrayList; /** @@ -613,13 +679,15 @@ declare class ArrayList { * @since 10 */ /** - * Clears this container and sets its length to 0. + * Removes all of the elements from this arraylist.The arraylist will + * be empty after this call returns.length becomes 0 * * @throws { BusinessError } 10200011 - The clear method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ clear(): void; /** @@ -640,14 +708,15 @@ declare class ArrayList { * @since 10 */ /** - * Clones this container and returns a copy. The modification to the copy does not affect the original instance. + * Returns a shallow copy of this instance. (The elements themselves are not copied.) * * @returns { ArrayList } this arraylist instance * @throws { BusinessError } 10200011 - The clone method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ clone(): ArrayList; /** @@ -668,14 +737,15 @@ declare class ArrayList { * @since 10 */ /** - * Obtains the capacity of this container. + * returns the capacity of this arraylist * * @returns { number } the number type * @throws { BusinessError } 10200011 - The getCapacity method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ getCapacity(): number; /** @@ -696,14 +766,15 @@ declare class ArrayList { * @since 10 */ /** - * Converts this container into an array. + * convert arraylist to array * * @returns { Array } the Array type * @throws { BusinessError } 10200011 - The convertToArray method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ convertToArray(): Array; /** @@ -724,20 +795,22 @@ declare class ArrayList { * @since 10 */ /** - * Checks whether this container is empty (contains no element). + * Determine whether arraylist is empty and whether there is an element * * @returns { boolean } Returns true if the container is empty; returns false otherwise. * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ isEmpty(): boolean; /** - * Returns the element at the given index. + * Returns the item at that index. * - * @param { number } index - Index. The value must be less than or equal to int32_max, that is, 2147483647. + * @param { number } index - The zero-based index of the desired code unit. + * Throws error if index < 0 or index >= arraylist.length. * @returns { T } The element in the arraylist matching the given index. * @throws { BusinessError } 401 - Parameter error. * @throws { BusinessError } 10200001 - The value of index is out of range. @@ -746,6 +819,33 @@ declare class ArrayList { * @since 12 */ [index: number]: T; + + /** + * Returns the item at that index. + * + * @param { number } index - The zero-based index of the desired code unit. + * @returns { T } The element in the arrayList matching the given index. + * @throws { BusinessError } 10200001 - The value of index is out of range. + * @syscap SystemCapability.Utils.Lang + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + $_get(index: number): T; + + /** + * Set the value of item at that index. + * + * @param { number } index - The index of the element to set. + * @param { T } value - The value to set at the specified index. + * @throws { BusinessError } 10200001 - The value of index is out of range. + * @syscap SystemCapability.Utils.Lang + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + $_set(index: number, value: T): void; + /** * If the newCapacity provided by the user is greater than or equal to length, * change the capacity of the arraylist to newCapacity, otherwise the capacity will not be changed @@ -772,9 +872,10 @@ declare class ArrayList { * @since 10 */ /** - * Increases the capacity of this container. + * If the newCapacity provided by the user is greater than or equal to length, + * change the capacity of the arraylist to newCapacity, otherwise the capacity will not be changed * - * @param { number } newCapacity - New capacity. + * @param { number } newCapacity - newCapacity newCapacity * @throws { BusinessError } 10200011 - The increaseCapacityTo method cannot be bound. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -782,7 +883,8 @@ declare class ArrayList { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ increaseCapacityTo(newCapacity: number): void; /** @@ -801,14 +903,14 @@ declare class ArrayList { * @since 10 */ /** - * Releases the reserved space in this container by adjusting the container capacity to the actual number of elements - * in this container. + * Limit the capacity to the current length * * @throws { BusinessError } 10200011 - The trimToCurrentLength method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ trimToCurrentLength(): void; /** @@ -829,7 +931,7 @@ declare class ArrayList { * @since 10 */ /** - * Obtains an iterator, each item of which is a JavaScript object. + * returns an iterator.Each item of the iterator is a Javascript Object * * @returns { IterableIterator } * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. @@ -839,6 +941,48 @@ declare class ArrayList { * @since 12 */ [Symbol.iterator](): IterableIterator; + + /** + * Returns an iterator. Each item of the iterator is a ArkTS Object + * + * @returns { IterableIterator } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + $_iterator(): IterableIterator; } + /** + * The type of ArrayList callback function. + * + * @typedef { function } ArrayListCbFn + * @param { T } value - The current element being processed + * @param { number } index - The index of the current element + * @param { ArrayList } arrlist - The ArrayList instance being traversed + * @returns { void } This callback does not return a value + * @syscap SystemCapability.Utils.Lang + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + type ArrayListCbFn = (value: T, index: number, arrlist: ArrayList) => void; + + /** + * The type of ArrayList callback function. + * + * @typedef { function } ArrayListCbFn + * @param { T } value - The current element being processed + * @param { number } index - The index of the current element + * @param { ArrayList } arrlist - The ArrayList instance being traversed + * @returns { T } This callback does not return a value + * @syscap SystemCapability.Utils.Lang + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + type ArrayListCbFn1 = (value: T, index?: number, arrlist?: ArrayList) => T; + export default ArrayList; diff --git a/api/@ohos.util.Deque.d.ts b/api/@ohos.util.Deque.d.ts index 9eb396a3fc85896bb907aa2bf6f33b1a5236128a..8e4758b126ebe044d827f4c34ffd5d1fa807989f 100644 --- a/api/@ohos.util.Deque.d.ts +++ b/api/@ohos.util.Deque.d.ts @@ -43,7 +43,8 @@ * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ declare class Deque { /** @@ -68,7 +69,8 @@ declare class Deque { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ constructor(); /** @@ -96,6 +98,17 @@ declare class Deque { * @since 12 */ length: number; + /** + * Gets the element number of the Deque. + * + * @type { number } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get length(): number; /** * Inserts an element into the deque header. * @@ -121,7 +134,8 @@ declare class Deque { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ insertFront(element: T): void; /** @@ -149,7 +163,8 @@ declare class Deque { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ insertEnd(element: T): void; /** @@ -180,7 +195,8 @@ declare class Deque { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ has(element: T): boolean; /** @@ -211,6 +227,19 @@ declare class Deque { * @since 12 */ getFirst(): T; + + /** + * Obtains the header element of a deque. + * + * @returns { T | undefined } the first element of the deque if it exists, otherwise returns undefined. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + getFirst(): T | undefined; + /** * Obtains the end element of a deque. * @@ -239,6 +268,19 @@ declare class Deque { * @since 12 */ getLast(): T; + + /** + * Obtains the end element of a deque. + * + * @returns { T | undefined } the last element of the deque if it exists, otherwise returns undefined. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + getLast(): T | undefined; + /** * Obtains the header element of a deque and delete the element. * @@ -267,6 +309,19 @@ declare class Deque { * @since 12 */ popFirst(): T; + + /** + * Obtains the header element of a deque and delete the element. + * + * @returns { T | undefined } the deleted element of the deque if it exists, otherwise returns undefined. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + popFirst(): T | undefined; + /** * Obtains the end element of a deque and delete the element. * @@ -295,6 +350,19 @@ declare class Deque { * @since 12 */ popLast(): T; + + /** + * Obtains the end element of a deque and delete the element. + * + * @returns { T | undefined } the deleted element of the deque if it exists, otherwise returns undefined. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + popLast(): T | undefined; + /** * Executes a provided function once for each value in the deque object. * @@ -347,6 +415,44 @@ declare class Deque { * @since 12 */ forEach(callbackFn: (value: T, index?: number, deque?: Deque) => void, thisArg?: Object): void; + + /** + * Iterates over elements in a generic Deque (double-ended queue) and executes a callback function for each element. + * + * @param { DequeCbFnforEach } callbackFn - A callback function to execute for each element. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + forEach(callbackFn: DequeCbFnforEach): void; + /** + * Returns the byte at the specified index. + * + * @param { number } index - The zero-based index of the desired code unit. + * @returns { T } The element in the deque matching the given index. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + $_get(index: number): T; + + /** + * Sets the byte at the specified index. + * + * @param { number } index – The index of the element to set. + * @param { T } value – The value to set at the specified index. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + $_set(index: number, value: T): void; + /** * returns an iterator.Each item of the iterator is a Javascript Object * @@ -375,6 +481,33 @@ declare class Deque { * @since 12 */ [Symbol.iterator](): IterableIterator; + + /** + * Returns an iterator. Each item of the iterator is a ArkTS Object + * + * @returns { IterableIterator } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + $_iterator(): IterableIterator; } + /** + * The type of Deque forEach callback function. + * + * @typedef { function } DequeCbFnforEach + * @param { T } value - The current element being processed + * @param { number } index - The index of the current element + * @param { Deque } deque - The Deque instance being traversed + * @returns { void } This callback does not return a value + * @syscap SystemCapability.Utils.Lang + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + type DequeCbFnforEach = (value: T, index: number, deque: Deque) => void; + export default Deque; diff --git a/api/@ohos.util.HashMap.d.ts b/api/@ohos.util.HashMap.d.ts index d15b1bd7a0b4a37cacf6e11c56949979ae13d990..7ade3272fd8cad35b3691c6bc958b37f44454bb1 100644 --- a/api/@ohos.util.HashMap.d.ts +++ b/api/@ohos.util.HashMap.d.ts @@ -40,7 +40,8 @@ * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ declare class HashMap { /** @@ -59,13 +60,14 @@ declare class HashMap { * @since 10 */ /** - * A constructor used to create a HashMap instance. + * A constructor used to create a HashMap object. * * @throws { BusinessError } 10200012 - The HashMap's constructor cannot be directly invoked. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ constructor(); /** @@ -84,7 +86,7 @@ declare class HashMap { * @since 10 */ /** - * Number of elements in a hash map. + * Gets the element number of the hashmap. * * @type { number } * @syscap SystemCapability.Utils.Lang @@ -93,6 +95,17 @@ declare class HashMap { * @since 12 */ length: number; + /** + * Gets the element number of the HashMap. + * + * @type { number } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get length(): number; /** * Returns whether the Map object contains elements * @@ -111,14 +124,15 @@ declare class HashMap { * @since 10 */ /** - * Checks whether this container is empty (contains no element). + * Returns whether the Map object contains elements * * @returns { boolean } the boolean type * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ isEmpty(): boolean; /** @@ -141,15 +155,16 @@ declare class HashMap { * @since 10 */ /** - * Checks whether this container contains the specified key. + * Returns whether a key is contained in this map * - * @param { K } key - Target key. + * @param { K } key - key key need to determine whether to include the key * @returns { boolean } the boolean type * @throws { BusinessError } 10200011 - The hasKey method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ hasKey(key: K): boolean; /** @@ -172,15 +187,16 @@ declare class HashMap { * @since 10 */ /** - * Checks whether this container contains the specified value. + * Returns whether a value is contained in this map * - * @param { V } value - Target value. + * @param { V } value - value value need to determine whether to include the value * @returns { boolean } the boolean type * @throws { BusinessError } 10200011 - The hasValue method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ hasValue(value: V): boolean; /** @@ -203,9 +219,9 @@ declare class HashMap { * @since 10 */ /** - * Obtains the value of the specified key in this container. If nothing is obtained, undefined is returned. + * Returns a specified element in a Map object, or undefined if there is no corresponding element * - * @param { K } key - Target key. + * @param { K } key - key key the index in HashMap * @returns { V } value or undefined * @throws { BusinessError } 10200011 - The get method cannot be bound. * @syscap SystemCapability.Utils.Lang @@ -214,6 +230,20 @@ declare class HashMap { * @since 12 */ get(key: K): V; + + /** + * Returns a specified element in a Map object, or undefined if there is no corresponding element + * + * @param { K } key - key key the index in HashMap + * @returns { V | undefined } value or undefined + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get(key: K): V | undefined; + /** * Adds all element groups in one map to another map * @@ -238,9 +268,9 @@ declare class HashMap { * @since 10 */ /** - * Adds all elements in a HashMap instance to this container. + * Adds all element groups in one map to another map * - * @param { HashMap } map - HashMap instance whose elements are to be added to the current container. + * @param { HashMap } map - map map the Map object to add members * @throws { BusinessError } 10200011 - The setAll method cannot be bound. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -248,7 +278,8 @@ declare class HashMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ setAll(map: HashMap): void; /** @@ -277,10 +308,10 @@ declare class HashMap { * @since 10 */ /** - * Adds or updates an element in this container. + * Adds or updates a(new) key-value pair with a key and value specified for the Map object * - * @param { K } key - Key of the target element. - * @param { V } value - Value of the target element. + * @param { K } key - key key Added or updated targets + * @param { V } value - value value Added or updated value * @returns { Object } the map object after set * @throws { BusinessError } 10200011 - The set method cannot be bound. * @throws { BusinessError } 401 - Parameter error. Possible causes: @@ -288,7 +319,8 @@ declare class HashMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ set(key: K, value: V): Object; /** @@ -311,9 +343,9 @@ declare class HashMap { * @since 10 */ /** - * Removes an element with the specified key from this container. + * Remove a specified element from a Map object * - * @param { K } key - Key of the target element. + * @param { K } key - key key Target to be deleted * @returns { V } Target mapped value * @throws { BusinessError } 10200011 - The remove method cannot be bound. * @syscap SystemCapability.Utils.Lang @@ -322,6 +354,20 @@ declare class HashMap { * @since 12 */ remove(key: K): V; + + /** + * Remove a specified element from a Map object + * + * @param { K } key - key key Target to be deleted + * @returns { V | undefined } Tthe value associated with the key if it was removed, undefined otherwise + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + remove(key: K): V | undefined; + /** * Clear all element groups in the map * @@ -338,13 +384,14 @@ declare class HashMap { * @since 10 */ /** - * Clears this container and sets its length to 0. + * Clear all element groups in the map * * @throws { BusinessError } 10200011 - The clear method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ clear(): void; /** @@ -365,14 +412,15 @@ declare class HashMap { * @since 10 */ /** - * Obtains an iterator that contains all the keys in this container. + * Returns a new Iterator object that contains the keys contained in this map * * @returns { IterableIterator } * @throws { BusinessError } 10200011 - The keys method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ keys(): IterableIterator; /** @@ -393,14 +441,15 @@ declare class HashMap { * @since 10 */ /** - * Obtains an iterator that contains all the values in this container. + * Returns a new Iterator object that contains the values contained in this map * * @returns { IterableIterator } * @throws { BusinessError } 10200011 - The values method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ values(): IterableIterator; /** @@ -425,16 +474,17 @@ declare class HashMap { * @since 10 */ /** - * Replaces an element in this container. + * Replace the old value by new value corresponding to the specified key * - * @param { K } key - Key of the target element. - * @param { V } newValue - New value of the element. + * @param { K } key - key key Updated targets + * @param { V } newValue - newValue newValue Updated the target mapped value * @returns { boolean } the boolean type(Is there a target pointed to by the key) * @throws { BusinessError } 10200011 - The replace method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ replace(key: K, newValue: V): boolean; /** @@ -473,10 +523,15 @@ declare class HashMap { * @since 10 */ /** - * Uses a callback to traverse the elements in this container and obtain their position indexes. + * Executes the given callback function once for each real key in the map. + * It does not perform functions on deleted keys * - * @param { function } callbackFn - Callback invoked to traverse the elements in the container. - * @param { Object } [thisArg] - Value of this to use when callbackFn is invoked. The default value is this instance. + * @param { function } callbackFn - callbackFn + * callbackFn (required) A function that accepts up to three arguments. + * The function to be called for each element. + * @param { Object } [thisArg] - thisArg + * thisArg (Optional) The value to be used as this value for when callbackFn is called. + * If thisArg is omitted, undefined is used as the this value. * @throws { BusinessError } 10200011 - The forEach method cannot be bound. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -487,6 +542,19 @@ declare class HashMap { * @since 12 */ forEach(callbackFn: (value?: V, key?: K, map?: HashMap) => void, thisArg?: Object): void; + + /** + * Iterates over all key-value pairs in the HashMap and executes a callback function for each entry. + * + * @param { HashMapCbFn } callbackFn - A callback function to execute for each key-value pair. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + forEach(callbackFn: HashMapCbFn): void; + /** * Returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order * @@ -505,14 +573,15 @@ declare class HashMap { * @since 10 */ /** - * Obtains an iterator that contains all the elements in this container. + * Returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order * * @returns { IterableIterator<[K, V]> } * @throws { BusinessError } 10200011 - The entries method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ entries(): IterableIterator<[K, V]>; /** @@ -533,7 +602,7 @@ declare class HashMap { * @since 10 */ /** - * Obtains an iterator, each item of which is a JavaScript object. + * returns an iterator.Each item of the iterator is a Javascript Object * * @returns { IterableIterator<[K, V]> } * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. @@ -543,6 +612,33 @@ declare class HashMap { * @since 12 */ [Symbol.iterator](): IterableIterator<[K, V]>; + + /** + * returns an iterator.Each item of the iterator is a Javascript Object + * + * @returns { IterableIterator<[K, V]> } an iterator for the HashMap + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + $_iterator(): IterableIterator<[K, V]>; } + /** + * The type of HashMap callback function. + * + * @typedef { function } HashMapCbFn + * @param { V } value - The value of the current entry + * @param { K } key - The key of the current entry + * @param { HashMap } map - The HashMap instance being traversed + * @returns { void } This callback does not return a value + * @syscap SystemCapability.Utils.Lang + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + type HashMapCbFn = (value: V, key: K, map: HashMap) => void; + export default HashMap; diff --git a/api/@ohos.util.HashSet.d.ts b/api/@ohos.util.HashSet.d.ts index 7d86579d11838cf3a6b489d0dc1ed2520d33bdbb..654a6e7c8f42d6b1915096ee33811be6f1711005 100644 --- a/api/@ohos.util.HashSet.d.ts +++ b/api/@ohos.util.HashSet.d.ts @@ -37,7 +37,8 @@ * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ declare class HashSet { /** @@ -62,7 +63,8 @@ declare class HashSet { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ constructor(); /** @@ -90,6 +92,17 @@ declare class HashSet { * @since 12 */ length: number; + /** + * Gets the element number of the HashSet. + * + * @type { number } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get length(): number; /** * Returns whether the Set object contains elements * @@ -115,7 +128,8 @@ declare class HashSet { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ isEmpty(): boolean; /** @@ -158,7 +172,8 @@ declare class HashSet { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ has(value: T): boolean; /** @@ -201,7 +216,8 @@ declare class HashSet { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ add(value: T): boolean; /** @@ -244,7 +260,8 @@ declare class HashSet { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ remove(value: T): boolean; /** @@ -269,7 +286,8 @@ declare class HashSet { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ clear(): void; /** @@ -324,6 +342,19 @@ declare class HashSet { * @since 12 */ forEach(callbackFn: (value?: T, key?: T, set?: HashSet) => void, thisArg?: Object): void; + + /** + * Iterates over all elements in the HashSet and executes a callback function for each element. + * + * @param { HashSetCbFn } callbackFn - A callback function to execute for each element. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + forEach(callbackFn: HashSetCbFn): void; + /** * Returns a new Iterator object that contains the values contained in this set * @@ -349,7 +380,8 @@ declare class HashSet { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ values(): IterableIterator; /** @@ -377,7 +409,8 @@ declare class HashSet { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ entries(): IterableIterator<[T, T]>; /** @@ -408,6 +441,33 @@ declare class HashSet { * @since 12 */ [Symbol.iterator](): IterableIterator; + + /** + * returns an iterator.Each item of the iterator is a Javascript Object + * + * @returns { IterableIterator } an iterator for the HashSet + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + $_iterator(): IterableIterator; } +/** + * The type of HashSet callback function. + * + * @typedef { function } HashSetCbFn + * @param { T } value - The current element being processed + * @param { T } key - [Deprecated] HashSet does not use key-value pairs, this parameter exists only for API compatibility + * @param { HashSet } set - The HashSet instance being traversed + * @returns { void } This callback does not return a value + * @syscap SystemCapability.Utils.Lang + * @atomicservice + * @since 20 + * @arkts 1.2 + */ +type HashSetCbFn = (value: T, key: T, set: HashSet) => void; + export default HashSet; diff --git a/api/@ohos.util.LightWeightMap.d.ts b/api/@ohos.util.LightWeightMap.d.ts index 64c50f29dfb32de8482c9a3d443ba75c54b864d4..20cca18d68b8ae32852ddcd646a68a083cce6314 100644 --- a/api/@ohos.util.LightWeightMap.d.ts +++ b/api/@ohos.util.LightWeightMap.d.ts @@ -37,7 +37,8 @@ * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ declare class LightWeightMap { /** @@ -62,7 +63,8 @@ declare class LightWeightMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ constructor(); /** @@ -90,6 +92,17 @@ declare class LightWeightMap { * @since 12 */ length: number; + /** + * Gets the element number of the LightWeightMap. + * + * @type { number } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get length(): number; /** * Returns whether this map has all the object in a specified map * @@ -127,7 +140,8 @@ declare class LightWeightMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ hasAll(map: LightWeightMap): boolean; /** @@ -158,7 +172,8 @@ declare class LightWeightMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ hasKey(key: K): boolean; /** @@ -189,7 +204,8 @@ declare class LightWeightMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ hasValue(value: V): boolean; /** @@ -229,7 +245,8 @@ declare class LightWeightMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ increaseCapacityTo(minimumCapacity: number): void; /** @@ -257,7 +274,8 @@ declare class LightWeightMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ entries(): IterableIterator<[K, V]>; /** @@ -291,6 +309,20 @@ declare class LightWeightMap { * @since 12 */ get(key: K): V; + + /** + * Returns the value to which the specified key is mapped, or undefined if this map contains no mapping for the key + * + * @param { K } key - key key the index in LightWeightMap + * @returns { V | undefined } value if associated with key presents, undefined otherwise + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get(key: K): V | undefined; + /** * Obtains the index of the key equal to a specified key in an LightWeightMap container * @@ -319,7 +351,8 @@ declare class LightWeightMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ getIndexOfKey(key: K): number; /** @@ -350,7 +383,8 @@ declare class LightWeightMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ getIndexOfValue(value: V): number; /** @@ -378,7 +412,8 @@ declare class LightWeightMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ isEmpty(): boolean; /** @@ -424,7 +459,8 @@ declare class LightWeightMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ getKeyAt(index: number): K; /** @@ -452,7 +488,8 @@ declare class LightWeightMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ keys(): IterableIterator; /** @@ -489,7 +526,8 @@ declare class LightWeightMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ setAll(map: LightWeightMap): void; /** @@ -523,7 +561,8 @@ declare class LightWeightMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ set(key: K, value: V): Object; /** @@ -557,6 +596,20 @@ declare class LightWeightMap { * @since 12 */ remove(key: K): V; + + /** + * Remove the mapping for this key from this map if present + * + * @param { K } key - key key Target to be deleted + * @returns { V | undefined } the value associated with the key if it was removed, undefined otherwise + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + remove(key: K): V | undefined; + /** * Deletes a key-value pair at the location identified by index from an LightWeightMap container * @@ -594,7 +647,8 @@ declare class LightWeightMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ removeAt(index: number): boolean; /** @@ -622,7 +676,8 @@ declare class LightWeightMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ clear(): void; /** @@ -671,7 +726,8 @@ declare class LightWeightMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ setValueAt(index: number, newValue: V): boolean; /** @@ -729,6 +785,19 @@ declare class LightWeightMap { * @since 12 */ forEach(callbackFn: (value?: V, key?: K, map?: LightWeightMap) => void, thisArg?: Object): void; + + /** + * Iterates over all key-value pairs in the LightWeightMap and executes a callback function for each entry. + * + * @param { LightWeightMapCbFn } callbackFn - A callback function that will be executed for each key-value pair. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + forEach(callbackFn: LightWeightMapCbFn): void; + /** * returns an ES6 iterator.Each item of the iterator is a Javascript Object * @@ -757,6 +826,19 @@ declare class LightWeightMap { * @since 12 */ [Symbol.iterator](): IterableIterator<[K, V]>; + + /** + * returns an ES6 iterator.Each item of the iterator is a Javascript Object + * + * @returns { IterableIterator<[K, V]> } an iterator for the LightWeightMap + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + $_iterator(): IterableIterator<[K, V]>; + /** * Obtains a string that contains all the keys and values in an LightWeightMap container * @@ -782,7 +864,8 @@ declare class LightWeightMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ toString(): String; /** @@ -828,7 +911,8 @@ declare class LightWeightMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ getValueAt(index: number): V; /** @@ -856,9 +940,25 @@ declare class LightWeightMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ values(): IterableIterator; } + /** + * The type of LightWeightMap callback function. + * + * @typedef { function } LightWeightMapCbFn + * @param { V } value - The value of the current entry + * @param { K } key - The key of the current entry + * @param { LightWeightMap } map - The LightWeightMap instance being traversed + * @returns { void } This callback does not return a value + * @syscap SystemCapability.Utils.Lang + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + type LightWeightMapCbFn = (value: V, key: K, map: LightWeightMap) => void; + export default LightWeightMap; diff --git a/api/@ohos.util.LightWeightSet.d.ts b/api/@ohos.util.LightWeightSet.d.ts index ffde49ae6751e5cf33a5430d7a2ebc83a4983da1..612b677db1d98cfa7662c04846177a593ce3bf91 100644 --- a/api/@ohos.util.LightWeightSet.d.ts +++ b/api/@ohos.util.LightWeightSet.d.ts @@ -37,7 +37,8 @@ * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ declare class LightWeightSet { /** @@ -62,7 +63,8 @@ declare class LightWeightSet { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ constructor(); /** @@ -90,6 +92,19 @@ declare class LightWeightSet { * @since 12 */ length: number; + + /** + * Gets the element number of the LightWeightSet. + * + * @type { number } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get length(): number; + /** * If the set does not contain the element, the specified element is added * @@ -118,7 +133,8 @@ declare class LightWeightSet { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ add(obj: T): boolean; /** @@ -158,7 +174,8 @@ declare class LightWeightSet { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ addAll(set: LightWeightSet): boolean; /** @@ -198,7 +215,8 @@ declare class LightWeightSet { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ hasAll(set: LightWeightSet): boolean; /** @@ -229,7 +247,8 @@ declare class LightWeightSet { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ has(key: T): boolean; /** @@ -296,7 +315,8 @@ declare class LightWeightSet { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ increaseCapacityTo(minimumCapacity: number): void; /** @@ -327,7 +347,8 @@ declare class LightWeightSet { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ getIndexOf(key: T): number; /** @@ -361,6 +382,20 @@ declare class LightWeightSet { * @since 12 */ remove(key: T): T; + + /** + * Deletes an object of a specified Object type from an LightWeightSet container + * + * @param { T } key - key key Target to be deleted + * @returns { T | undefined } the removed value if it was present, undefined otherwise + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + remove(key: T): T | undefined; + /** * Deletes an object at the location identified by index from an LightWeightSet container * @@ -398,7 +433,8 @@ declare class LightWeightSet { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ removeAt(index: number): boolean; /** @@ -426,7 +462,8 @@ declare class LightWeightSet { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ clear(): void; /** @@ -484,6 +521,20 @@ declare class LightWeightSet { * @since 12 */ forEach(callbackFn: (value?: T, key?: T, set?: LightWeightSet) => void, thisArg?: Object): void; + + /** + * Executes the given callback function once for each real key in the map. + * It does not perform functions on deleted keys. + * + * @param { LightWeightSetForEachCb } callbackFn - A callback function to execute for each element. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + forEach(callbackFn: LightWeightSetForEachCb): void; + /** * returns an ES6 iterator.Each item of the iterator is a Javascript Object * @@ -512,6 +563,19 @@ declare class LightWeightSet { * @since 12 */ [Symbol.iterator](): IterableIterator; + + /** + * returns an ES6 iterator.Each item of the iterator is a Javascript Object + * + * @returns { IterableIterator } an iterator for the LightWeightSet + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + $_iterator(): IterableIterator; + /** * Obtains a string that contains all the keys and values in an LightWeightSet container * @@ -534,7 +598,8 @@ declare class LightWeightSet { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ toString(): String; /** @@ -562,7 +627,8 @@ declare class LightWeightSet { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ toArray(): Array; /** @@ -605,6 +671,20 @@ declare class LightWeightSet { * @since 12 */ getValueAt(index: number): T; + + /** + * Obtains the object at the location identified by index in an LightWeightSet container + * + * @param { number } index - index index Target subscript for search + * @returns { T | undefined } the value at the specified index, or undefined if the index out of range + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + getValueAt(index: number): T | undefined; + /** * Returns a ES6 iterator of the values contained in this Set * @@ -630,7 +710,8 @@ declare class LightWeightSet { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ values(): IterableIterator; /** @@ -658,7 +739,8 @@ declare class LightWeightSet { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ entries(): IterableIterator<[T, T]>; /** @@ -686,9 +768,25 @@ declare class LightWeightSet { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ isEmpty(): boolean; } +/** + * The type of LightWeightSet callback function. + * + * @typedef { function } LightWeightSetForEachCb + * @param { T } value - The value of current element + * @param { T } key - The key of current element(same as value) + * @param { LightWeightSet } set - The LightWeightSet instance being traversed + * @returns { void } This callback does not return a value + * @syscap SystemCapability.Utils.Lang + * @atomicservice + * @since 20 + * @arkts 1.2 + */ +type LightWeightSetForEachCb = (value: T, key: T, set: LightWeightSet) => void + export default LightWeightSet; diff --git a/api/@ohos.util.LinkedList.d.ts b/api/@ohos.util.LinkedList.d.ts index 3cb01b1dde057175c95c66f1759e022b4ffc826f..73ab126b6d1a40c7c0e6357ae99120d304a490c2 100644 --- a/api/@ohos.util.LinkedList.d.ts +++ b/api/@ohos.util.LinkedList.d.ts @@ -38,13 +38,13 @@ /** * LinkedList is implemented based on the doubly linked list. Each node of the doubly linked list has * references pointing to the previous element and the next element. When querying an element, - * the system traverses the list from the beginning or end. LinkedList offers efficient insertion and - * removal operations but supports low query efficiency. LinkedList allows null elements. + * the system traverses the list from the beginning or end. * * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ declare class LinkedList { /** @@ -63,13 +63,14 @@ declare class LinkedList { * @since 10 */ /** - * A constructor used to create a LinkedList instance. + * A constructor used to create a LinkedList object. * * @throws { BusinessError } 10200012 - The LinkedList's constructor cannot be directly invoked. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ constructor(); /** @@ -88,7 +89,7 @@ declare class LinkedList { * @since 10 */ /** - * Number of elements in a linked list. + * Gets the element number of the LinkedList. This is a number one higher than the highest index in the linkedlist. * * @type { number } * @syscap SystemCapability.Utils.Lang @@ -97,6 +98,19 @@ declare class LinkedList { * @since 12 */ length: number; + + /** + * Gets the element number of the LinkedList. + * + * @type { number } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get length(): number; + /** * Appends the specified element to the end of this linkedlist. * @@ -117,15 +131,16 @@ declare class LinkedList { * @since 10 */ /** - * Adds an element at the end of this container. + * Appends the specified element to the end of this linkedlist. * - * @param { T } element - Target element. + * @param { T } element - element element to be appended to this linkedlist * @returns { boolean } the boolean type, returns true if the addition is successful, and returns false if it fails. * @throws { BusinessError } 10200011 - The add method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ add(element: T): boolean; /** @@ -158,10 +173,10 @@ declare class LinkedList { * @since 10 */ /** - * Inserts an element at the specified position in this container. + * Inserts the specified element at the specified position in this linkedlist. * - * @param { number } index - Index of the position where the element is to be inserted. - * @param { T } element - Target element. + * @param { number } index - index index index at which the specified element is to be inserted + * @param { T } element - element element element to be inserted * @throws { BusinessError } 10200011 - The insert method cannot be bound. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -171,7 +186,8 @@ declare class LinkedList { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ insert(index: number, element: T): void; /** @@ -202,9 +218,10 @@ declare class LinkedList { * @since 10 */ /** - * Obtains an element at the specified position in this container. + * Returns the element at the specified position in this linkedlist, + * or returns undefined if this linkedlist is empty * - * @param { number } index - Position index of the target element. + * @param { number } index - index index specified position * @returns { T } the T type * @throws { BusinessError } 10200011 - The get method cannot be bound. * @throws { BusinessError } 401 - Parameter error. Possible causes: @@ -216,6 +233,21 @@ declare class LinkedList { * @since 12 */ get(index: number): T; + + /** + * Returns the element at the specified position in this linkedList, + * or returns undefined if this linkedList is empty + * + * @param { number } index - specified position + * @returns { T | undefined} the element at the specified index, or undefined if the index is out of range. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get(index: number): T | undefined; + /** * Inserts the specified element at the beginning of this LinkedList. * @@ -234,14 +266,15 @@ declare class LinkedList { * @since 10 */ /** - * Adds an element at the top of this container. + * Inserts the specified element at the beginning of this LinkedList. * - * @param { T } element - Target element. + * @param { T } element - element element the element to add * @throws { BusinessError } 10200011 - The addFirst method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ addFirst(element: T): void; /** @@ -264,7 +297,7 @@ declare class LinkedList { * @since 10 */ /** - * Removes the first element from this container. + * Retrieves and removes the head (first element) of this linkedlist. * * @returns { T } Element removed. * @throws { BusinessError } 10200011 - The removeFirst method cannot be bound. @@ -275,6 +308,20 @@ declare class LinkedList { * @since 12 */ removeFirst(): T; + + /** + * Retrieves and removes the head (first element) of this linkedList. + * + * @returns { T | undefined } the head of this list + * @throws { BusinessError } 10200010 - Container is empty. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + removeFirst(): T | undefined; + /** * Removes and returns the last element from this linkedlist. * @@ -295,7 +342,7 @@ declare class LinkedList { * @since 10 */ /** - * Removes the last element from this container. + * Removes and returns the last element from this linkedlist. * * @returns { T } Element removed. * @throws { BusinessError } 10200011 - The removeLast method cannot be bound. @@ -306,6 +353,20 @@ declare class LinkedList { * @since 12 */ removeLast(): T; + + /** + * Removes and returns the last element from this linkedList. + * + * @returns { T | undefined } the head of this list + * @throws { BusinessError } 10200010 - Container is empty. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + removeLast(): T | undefined; + /** * Check if linkedlist contains the specified element * @@ -326,15 +387,16 @@ declare class LinkedList { * @since 10 */ /** - * Checks whether this container has the specified element. + * Check if linkedlist contains the specified element * - * @param { T } element - Target element. + * @param { T } element - element element element to be contained * @returns { boolean } the boolean type,if linkedList contains the specified element,return true,else return false * @throws { BusinessError } 10200011 - The has method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ has(element: T): boolean; /** @@ -359,15 +421,17 @@ declare class LinkedList { * @since 10 */ /** - * Obtains the index of the first occurrence of the specified element in this container. + * Returns the index of the first occurrence of the specified element + * in this linkedlist, or -1 if this linkedlist does not contain the element. * - * @param { T } element - Target element. + * @param { T } element - element element element to be contained * @returns { number } the number type ,returns the lowest index such that or -1 if there is no such index. * @throws { BusinessError } 10200011 - The getIndexOf method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ getIndexOf(element: T): number; /** @@ -402,9 +466,9 @@ declare class LinkedList { * @since 10 */ /** - * Searches for an element based on its index and then removes it. + * Find the corresponding element according to the index. * - * @param { number } index - Position index of the target element. + * @param { number } index - index index the index in the linkedlist * @returns { T } the T type ,returns undefined if linkedlist is empty,If the index is * out of bounds (greater than or equal to length or less than 0), throw an exception * @throws { BusinessError } 10200011 - The removeByIndex method cannot be bound. @@ -419,6 +483,23 @@ declare class LinkedList { * @since 12 */ removeByIndex(index: number): T; + + /** + * Find the corresponding element according to the index. + * + * @param { number } index - the index in the linkedList + * @returns { T | undefined } the T type, if the index is + * out of bounds (greater than or equal to length or less than 0), throw an exception + * @throws { BusinessError } 10200001 - The value of "index" is out of range. It must be >= 0 && <= ${length}. + * Received value is: ${index} + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + removeByIndex(index: number): T | undefined; + /** * Removes the first occurrence of the specified element from this linkedlist, * if it is present. If the linkedlist does not contain the element, it is @@ -443,15 +524,18 @@ declare class LinkedList { * @since 10 */ /** - * Removes the first occurrence of the specified element from this container. + * Removes the first occurrence of the specified element from this linkedlist, + * if it is present. If the linkedlist does not contain the element, it is + * unchanged. More formally, removes the element with the lowest index * - * @param { T } element - Target element. + * @param { T } element - element element element to remove * @returns { boolean } the boolean type ,If there is no such element, return false * @throws { BusinessError } 10200011 - The remove method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ remove(element: T): boolean; /** @@ -482,9 +566,11 @@ declare class LinkedList { * @since 10 */ /** - * Removes the first occurrence of the specified element from this container. + * Removes the first occurrence of the specified element from this linkedlist, + * if it is present. If the linkedlist does not contain the element, it is + * unchanged. More formally, removes the element with the lowest index * - * @param { T } element - Target element. + * @param { T } element - element element element to remove * @returns { boolean } the boolean type ,If there is no such element, return false * @throws { BusinessError } 10200011 - The removeFirstFound method cannot be bound. * @throws { BusinessError } 10200010 - Container is empty. @@ -492,7 +578,8 @@ declare class LinkedList { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ removeFirstFound(element: T): boolean; /** @@ -523,9 +610,11 @@ declare class LinkedList { * @since 10 */ /** - * Removes the last occurrence of the specified element from this container. + * Removes the last occurrence of the specified element from this linkedlist, + * if it is present. If the linkedlist does not contain the element, it is + * unchanged. More formally, removes the element with the lowest index * - * @param { T } element - Target element. + * @param { T } element - element element element to remove * @returns { boolean } the boolean type ,If there is no such element, return false * @throws { BusinessError } 10200011 - The removeLastFound method cannot be bound. * @throws { BusinessError } 10200010 - Container is empty. @@ -533,7 +622,8 @@ declare class LinkedList { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ removeLastFound(element: T): boolean; /** @@ -558,15 +648,17 @@ declare class LinkedList { * @since 10 */ /** - * Obtains the index of the last occurrence of the specified element in this container. + * Returns in the index of the last occurrence of the specified element in this linkedlist , + * or -1 if the linkedlist does not contain the element. * - * @param { T } element - Target element. + * @param { T } element - element element element to find * @returns { number } the number type * @throws { BusinessError } 10200011 - The getLastIndexOf method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ getLastIndexOf(element: T): number; /** @@ -589,7 +681,8 @@ declare class LinkedList { * @since 10 */ /** - * Obtains the first element in this container. + * Returns the first element (the item at index 0) of this linkedlist. + * or returns undefined if linkedlist is empty * * @returns { T } the T type ,returns undefined if linkedList is empty * @throws { BusinessError } 10200011 - The getFirst method cannot be bound. @@ -599,6 +692,20 @@ declare class LinkedList { * @since 12 */ getFirst(): T; + + /** + * Returns the first element (the item at index 0) of this linkedList. + * or returns undefined if linkedList is empty + * + * @returns { T | undefined } the T type, returns undefined if linkedList is empty + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + getFirst(): T | undefined; + /** * Returns the Last element (the item at index length-1) of this linkedlist. * or returns undefined if linkedlist is empty @@ -619,7 +726,8 @@ declare class LinkedList { * @since 10 */ /** - * Obtains the last element in this container. + * Returns the Last element (the item at index length-1) of this linkedlist. + * or returns undefined if linkedlist is empty * * @returns { T } the T type ,returns undefined if linkedList is empty * @throws { BusinessError } 10200011 - The getLast method cannot be bound. @@ -629,6 +737,20 @@ declare class LinkedList { * @since 12 */ getLast(): T; + + /** + * Returns the Last element (the item at index length - 1) of this linkedList. + * or returns undefined if linkedList is empty + * + * @returns { T | undefined } the T type, returns undefined if linkedList is empty + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + getLast(): T | undefined; + /** * Replaces the element at the specified position in this Vector with the specified element * @@ -661,10 +783,10 @@ declare class LinkedList { * @since 10 */ /** - * Replaces an element at the specified position in this container with a given element. + * Replaces the element at the specified position in this Vector with the specified element * - * @param { number } index - Position index of the target element. - * @param { T } element - Element to be used for replacement. + * @param { number } index - index index index to find + * @param { T } element - element element replaced element * @returns { T } the T type ,returns undefined if linkedList is empty * @throws { BusinessError } 10200011 - The set method cannot be bound. * @throws { BusinessError } 10200001 - The value of index is out of range. @@ -678,6 +800,25 @@ declare class LinkedList { * @since 12 */ set(index: number, element: T): T; + + /** + * Replaces the element at the specified position in this Vector with the specified element + * + * @param { number } index - index index index to find + * @param { T } element - element element replaced element + * @returns { T | undefined } the T type ,returns undefined if linkedList is empty + * @throws { BusinessError } 10200001 - The value of index is out of range. + * 1.Mandatory parameters are left unspecified; + * 2.Incorrect parameter types; + * 3.Parameter verification failed. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + set(index: number, element: T): T | undefined; + /** * Replaces each element of this linkedlist with the result of applying the operator to that element. * @@ -718,10 +859,17 @@ declare class LinkedList { * @since 10 */ /** - * Uses a callback to traverse the elements in this container and obtain their position indexes. + * Replaces each element of this linkedlist with the result of applying the operator to that element. * - * @param { function } callbackFn - Callback invoked to traverse the elements in the container. - * @param { Object } [thisArg] - Value of this to use when callbackFn is invoked. The default value is this instance. + * @param { function } callbackFn - callbackFn + * callbackFn (required) A function that accepts up to three arguments. + * The function to be called for each element. + * Value (required) current element + * Index (Optional) The index value of the current element. + * LinkedList (Optional) The linkedlist object to which the current element belongs. + * @param { Object } [thisArg] - thisArg + * thisArg (Optional) The value to be used as this value for when callbackFn is called. + * If thisArg is omitted, undefined is used as the this value. * @throws { BusinessError } 10200011 - The forEach method cannot be bound. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -732,6 +880,19 @@ declare class LinkedList { * @since 12 */ forEach(callbackFn: (value: T, index?: number, LinkedList?: LinkedList) => void, thisArg?: Object): void; + + /** + * Replaces each element of this linkedList with the result of applying the operator to that element. + * + * @param { LinkedListForEachCb } callbackFn - callbackFn + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + forEach(callbackfn: LinkedListForEachCb): void; + /** * Removes all of the elements from this linkedlist.The linkedlist will * be empty after this call returns.length becomes 0 @@ -750,13 +911,15 @@ declare class LinkedList { * @since 10 */ /** - * Clears this container and sets its length to 0. + * Removes all of the elements from this linkedlist.The linkedlist will + * be empty after this call returns.length becomes 0 * * @throws { BusinessError } 10200011 - The clear method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ clear(): void; /** @@ -777,14 +940,15 @@ declare class LinkedList { * @since 10 */ /** - * Clones this container and returns a copy. The modification to the copy does not affect the original instance. + * Returns a shallow copy of this instance. (The elements themselves are not copied.) * * @returns { LinkedList } this linkedlist instance * @throws { BusinessError } 10200011 - The clone method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ clone(): LinkedList; /** @@ -805,14 +969,15 @@ declare class LinkedList { * @since 10 */ /** - * Converts this container into an array. + * convert linkedlist to array * * @returns { Array } the Array type * @throws { BusinessError } 10200011 - The convertToArray method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ convertToArray(): Array; /** @@ -833,7 +998,7 @@ declare class LinkedList { * @since 10 */ /** - * Obtains an iterator, each item of which is a JavaScript object. + * returns an iterator.Each item of the iterator is a Javascript Object * * @returns { IterableIterator } * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. @@ -843,6 +1008,34 @@ declare class LinkedList { * @since 12 */ [Symbol.iterator](): IterableIterator; + + /** + * returns an iterator. Each item of the iterator is a ArkTS Object + * + * @returns { IterableIterator } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + $_iterator(): IterableIterator; + } +/** + * The type of LinkedList callback function. + * + * @typedef { function } LinkedListForEachCb + * @param { T } value - The value of current element + * @param { number } index - The index of current element + * @param { LinkedList } linkedList - The LinkedList instance being traversed + * @returns { void } This callback does not return a value + * @syscap SystemCapability.Utils.Lang + * @atomicservice + * @since 20 + * @arkts 1.2 + */ +type LinkedListForEachCb = (value: T, index: number, linkedList: LinkedList) => void + export default LinkedList; diff --git a/api/@ohos.util.List.d.ts b/api/@ohos.util.List.d.ts index 1834ca5678d8f5e9817d95c94b762d091bba9cf3..5967f7ce6c9db96aee26e5a8ab2ef4f2c6437873 100644 --- a/api/@ohos.util.List.d.ts +++ b/api/@ohos.util.List.d.ts @@ -35,13 +35,13 @@ */ /** * List is implemented based on the singly linked list. Each node has a reference pointing to the next element. - * When querying an element, the system traverses the list from the beginning. List offers efficient insertion - * and removal operations but supports low query efficiency. List allows null elements. + * When querying an element, the system traverses the list from the beginning. * * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ declare class List { /** @@ -60,13 +60,14 @@ declare class List { * @since 10 */ /** - *A constructor used to create a List instance. + * A constructor used to create a List object. * * @throws { BusinessError } 10200012 - The List's constructor cannot be directly invoked. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ constructor(); /** @@ -85,7 +86,7 @@ declare class List { * @since 10 */ /** - * Number of elements in a list. + * Gets the element number of the List. This is a number one higher than the highest index in the list. * * @type { number } * @syscap SystemCapability.Utils.Lang @@ -94,6 +95,19 @@ declare class List { * @since 12 */ length: number; + + /** + * Gets the element number of the List. + * + * @type { number } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get length(): number; + /** * Appends the specified element to the end of this list. * @@ -114,15 +128,16 @@ declare class List { * @since 10 */ /** - * Adds an element at the end of this container. + * Appends the specified element to the end of this list. * - * @param { T } element - Target element. + * @param { T } element - element element to be appended to this list * @returns { boolean } the boolean type, returns true if the addition is successful, and returns false if it fails. * @throws { BusinessError } 10200011 - The add method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ add(element: T): boolean; /** @@ -155,10 +170,10 @@ declare class List { * @since 10 */ /** - * Inserts an element at the specified position in this container. + * Inserts the specified element at the specified position in this list. * - * @param { T } element - Target element. - * @param { number } index - Index of the position where the element is to be inserted. + * @param { T } element - element element element to be inserted + * @param { number } index - index index index at which the specified element is to be inserted * @throws { BusinessError } 10200011 - The insert method cannot be bound. * @throws { BusinessError } 10200001 - The value of index is out of range. * @throws { BusinessError } 401 - Parameter error. Possible causes: @@ -168,7 +183,8 @@ declare class List { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ insert(element: T, index: number): void; /** @@ -199,9 +215,10 @@ declare class List { * @since 10 */ /** - * Obtains the element at the specified position in this container. + * Returns the element at the specified position in this list, + * or returns undefined if this list is empty * - * @param { number } index - Position index of the target element. + * @param { number } index - index index specified position * @returns { T } the T type * @throws { BusinessError } 10200011 - The get method cannot be bound. * @throws { BusinessError } 401 - Parameter error. Possible causes: @@ -213,6 +230,21 @@ declare class List { * @since 12 */ get(index: number): T; + + /** + * Returns the element at the specified position in this list, + * or returns undefined if this list is empty + * + * @param { number } index - specified position + * @returns { T | undefined} the element at the specified index, or undefined if the index is out of range. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get(index: number): T | undefined; + /** * Check if list contains the specified element * @@ -233,15 +265,16 @@ declare class List { * @since 10 */ /** - * Checks whether this container has the specified element. + * Check if list contains the specified element * - * @param { T } element - Target element. + * @param { T } element - element element element to be contained * @returns { boolean } the boolean type,if list contains the specified element,return true,else return false * @throws { BusinessError } 10200011 - The has method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ has(element: T): boolean; /** @@ -266,15 +299,17 @@ declare class List { * @since 10 */ /** - * Obtains the index of the first occurrence of the specified element in this container. + * Returns the index of the first occurrence of the specified element + * in this list, or -1 if this list does not contain the element. * - * @param { T } element - Target element. + * @param { T } element - element element element to be contained * @returns { number } the number type ,returns the lowest index such that or -1 if there is no such index. * @throws { BusinessError } 10200011 - The getIndexOf method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ getIndexOf(element: T): number; /** @@ -307,9 +342,9 @@ declare class List { * @since 10 */ /** - * Searches for an element based on its index and then removes it. + * Find the corresponding element according to the index. * - * @param { number } index - Position index of the target element. + * @param { number } index - index index the index in the list * @returns { T } the T type ,returns undefined if list is empty,If the index is * out of bounds (greater than or equal to length or less than 0), throw an exception * @throws { BusinessError } 10200011 - The removeByIndex method cannot be bound. @@ -323,6 +358,23 @@ declare class List { * @since 12 */ removeByIndex(index: number): T; + + /** + * Find the corresponding element according to the index. + * + * @param { number } index - the index in the linkedList + * @returns { T | undefined } the T type, if the index is + * out of bounds (greater than or equal to length or less than 0), throw an exception + * @throws { BusinessError } 10200001 - The value of "index" is out of range. It must be >= 0 && <= ${length - 1}. + * Received value is: ${index} + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + removeByIndex(index: number): T | undefined; + /** * Removes the first occurrence of the specified element from this list, * if it is present. If the list does not contain the element, it is @@ -347,15 +399,18 @@ declare class List { * @since 10 */ /** - * Removes the first occurrence of the specified element from this container. + * Removes the first occurrence of the specified element from this list, + * if it is present. If the list does not contain the element, it is + * unchanged. More formally, removes the element with the lowest index * - * @param { T } element - Target element. + * @param { T } element - element element element to remove * @returns { boolean } the boolean type ,If there is no such element, return false * @throws { BusinessError } 10200011 - The remove method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ remove(element: T): boolean; /** @@ -380,15 +435,17 @@ declare class List { * @since 10 */ /** - * Obtains the index of the last occurrence of the specified element in this container. + * Returns in the index of the last occurrence of the specified element in this list , + * or -1 if the list does not contain the element. * - * @param { T } element - Target element. + * @param { T } element - element element element to find * @returns { number } the number type * @throws { BusinessError } 10200011 - The getLastIndexOf method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ getLastIndexOf(element: T): number; /** @@ -411,7 +468,8 @@ declare class List { * @since 10 */ /** - * Obtains the first element in this container. + * Returns the first element (the item at index 0) of this list. + * or returns undefined if list is empty * * @returns { T } the T type ,returns undefined if list is empty * @throws { BusinessError } 10200011 - The getFirst method cannot be bound. @@ -441,7 +499,8 @@ declare class List { * @since 10 */ /** - * Obtains the last element in this container. + * Returns the Last element (the item at index length-1) of this list. + * or returns undefined if list is empty * * @returns { T } the T type ,returns undefined if list is empty * @throws { BusinessError } 10200011 - The getLast method cannot be bound. @@ -451,6 +510,33 @@ declare class List { * @since 12 */ getLast(): T; + + /** + * Returns the first element (the item at index 0) of this list. + * or returns undefined if list is empty + * + * @returns { T | undefined } the T type, returns undefined if list is empty + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + getFirst(): T | undefined; + + /** + * Returns the Last element (the item at index length-1) of this list. + * or returns undefined if list is empty + * + * @returns { T | undefined } the T type, returns undefined if list is empty + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + getLast(): T | undefined; + /** * Replaces the element at the specified position in this List with the specified element * @@ -481,10 +567,10 @@ declare class List { * @since 10 */ /** - * Replaces an element at the specified position in this container with a given element. + * Replaces the element at the specified position in this List with the specified element * - * @param { number } index - Position index of the target element. - * @param { T } element - Element to be used for replacement. + * @param { number } index - index index index to find + * @param { T } element - element element replaced element * @returns { T } the T type * @throws { BusinessError } 10200011 - The set method cannot be bound. * @throws { BusinessError } 10200001 - The value of index is out of range. @@ -497,6 +583,21 @@ declare class List { * @since 12 */ set(index: number, element: T): T; + /** + * Replaces the element at the specified position in this List with the specified element + * + * @param { number } index - index to find + * @param { T } element - replaced element + * @returns { T | undefined } the T type, returns undefined if linkedList is empty + * @throws { BusinessError } 10200001 - The value of "index" is out of range. It must be >= 0 && <= ${length - 1}. + * Received value is: ${index} + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + set(index: number, element: T): T | undefined; /** * Compares the specified object with this list for equality.if the object are the same as this list * return true, otherwise return false. @@ -519,15 +620,17 @@ declare class List { * @since 10 */ /** - * Compares whether a specified object is equal to this container. + * Compares the specified object with this list for equality.if the object are the same as this list + * return true, otherwise return false. * - * @param { Object } obj - Object used for comparison. + * @param { Object } obj - obj obj Compare objects * @returns { boolean } the boolean type * @throws { BusinessError } 10200011 - The equal method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ equal(obj: Object): boolean; /** @@ -564,10 +667,14 @@ declare class List { * @since 10 */ /** - * Uses a callback to traverse the elements in this container and obtain their position indexes. + * Replaces each element of this list with the result of applying the operator to that element. * - * @param { function } callbackFn - Callback invoked for the replacement. - * @param { Object } [thisArg] - Value of this to use when callbackFn is invoked. The default value is this instance. + * @param { function } callbackFn - callbackFn + * callbackFn (required) A function that accepts up to three arguments. + * The function to be called for each element. + * @param { Object } [thisArg] - thisArg + * thisArg (Optional) The value to be used as this value for when callbackFn is called. + * If thisArg is omitted, undefined is used as the this value. * @throws { BusinessError } 10200011 - The forEach method cannot be bound. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -578,6 +685,19 @@ declare class List { * @since 12 */ forEach(callbackFn: (value: T, index?: number, List?: List) => void, thisArg?: Object): void; + + /** + * Replaces each element of this list with the result of applying the operator to that element. + * + * @param { ListForEachCb } callbackFn - callbackFn + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + forEach(callbackfn: ListForEachCb): void; + /** * Sorts this list according to the order induced by the specified comparator * @@ -610,9 +730,13 @@ declare class List { * @since 10 */ /** - * Sorts elements in this container. + * Sorts this list according to the order induced by the specified comparator * - * @param { function } comparator - Callback invoked for sorting. + * @param { function } comparator - comparator + * comparator (required) A function that accepts up to two arguments. + * Specifies the sort order. Must be a function,return number type,If it returns firstValue + * minus secondValue, it returns an list sorted in ascending order;If it returns secondValue + * minus firstValue, it returns an list sorted in descending order; * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; * 2.Incorrect parameter types. @@ -620,7 +744,8 @@ declare class List { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ sort(comparator: (firstValue: T, secondValue: T) => number): void; /** @@ -641,13 +766,15 @@ declare class List { * @since 10 */ /** - * Clears this container and sets its length to 0. + * Removes all of the elements from this list.The list will + * be empty after this call returns.length becomes 0 * * @throws { BusinessError } 10200011 - The clear method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ clear(): void; /** @@ -680,11 +807,10 @@ declare class List { * @since 10 */ /** - * Obtains elements within a range in this container, including the element at the start position but not that at the - * end position, and returns these elements as a new List instance. + * Returns a view of the portion of this list between the specified fromIndex,inclusive,and toIndex,exclusive * - * @param { number } fromIndex - Index of the start position. - * @param { number } toIndex - Index of the end position. + * @param { number } fromIndex - fromIndex fromIndex The starting position of the index, containing the value at that index position + * @param { number } toIndex - toIndex toIndex the end of the index, excluding the value at that index * @returns { List } * @throws { BusinessError } 10200011 - The getSubList method cannot be bound. * @throws { BusinessError } 10200001 - The value of fromIndex or toIndex is out of range. @@ -694,7 +820,8 @@ declare class List { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ getSubList(fromIndex: number, toIndex: number): List; /** @@ -731,10 +858,14 @@ declare class List { * @since 10 */ /** - * Replaces all elements in this container with new elements, and returns the new ones. + * Replaces each element of this list with the result of applying the operator to that element. * - * @param { function } callbackFn - Callback invoked for the replacement. - * @param { Object } [thisArg] - Value of this to use when callbackFn is invoked. The default value is this instance. + * @param { function } callbackFn - callbackFn + * callbackFn (required) A function that accepts up to three arguments. + * The function to be called for each element. + * @param { Object } [thisArg] - thisArg + * thisArg (Optional) The value to be used as this value for when callbackFn is called. + * If thisArg is omitted, undefined is used as the this value. * @throws { BusinessError } 10200011 - The replaceAllElements method cannot be bound. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -745,6 +876,19 @@ declare class List { * @since 12 */ replaceAllElements(callbackFn: (value: T, index?: number, list?: List) => T, thisArg?: Object): void; + + /** + * Replaces each element of this list with the result of applying the operator to that element. + * + * @param { ListReplaceCb } callbackFn - callbackFn + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + replaceAllElements(callbackfn: ListReplaceCb): void; + /** * convert list to array * @@ -763,14 +907,15 @@ declare class List { * @since 10 */ /** - * Converts this container into an array. + * convert list to array * * @returns { Array } the Array type * @throws { BusinessError } 10200011 - The convertToArray method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ convertToArray(): Array; /** @@ -791,16 +936,43 @@ declare class List { * @since 10 */ /** - * Checks whether this container is empty (contains no element). + * Determine whether list is empty and whether there is an element * * @returns { boolean } the boolean type * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ isEmpty(): boolean; + /** + * Returns the item at that index + * + * @param { number } index - the zero-based index of the desired code unit. + * @returns { T | undefined } the element in the list matching the given index, + * or undefined if the index is out of range. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + $_get(index: number): T | undefined; + + /** + * Set the value of item at that index. + * + * @param { number } index – the index of the element to set. + * @param { T } value – the value to set at the specified index + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + $_set(index: number, value: T): void; /** * returns an iterator.Each item of the iterator is a Javascript Object * @@ -819,7 +991,7 @@ declare class List { * @since 10 */ /** - * Obtains an iterator, each item of which is a JavaScript object. + * returns an iterator.Each item of the iterator is a Javascript Object * * @returns { IterableIterator } * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. @@ -829,6 +1001,49 @@ declare class List { * @since 12 */ [Symbol.iterator](): IterableIterator; + + /** + * returns an iterator. Each item of the iterator is a ArkTS Object + * + * @returns { IterableIterator } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + $_iterator(): IterableIterator; + } +/** + * The type of List callback function. + * + * @typedef { function } ListForEachCb + * @param { T } value - The value of current element + * @param { number } index - The index of current element + * @param { List } list - The List instance being traversed + * @returns { void } This callback does not return a value + * @syscap SystemCapability.Utils.Lang + * @atomicservice + * @since 20 + * @arkts 1.2 + */ +type ListForEachCb = (value: T, index: number, list: List) => void + +/** + * The type of List callback function. + * + * @typedef { function } LinkedListForEachCb + * @param { T } value - The old value of current element + * @param { number } index - The index of current element + * @param { List } list - The List instance being traversed + * @returns { T } - The new value of current element + * @syscap SystemCapability.Utils.Lang + * @atomicservice + * @since 20 + * @arkts 1.2 + */ +type ListReplaceCb = (value: T, index: number, list: List) => T + export default List; diff --git a/api/@ohos.util.PlainArray.d.ts b/api/@ohos.util.PlainArray.d.ts index 4da484961b12ef65706d2666804b786cd9a629c6..6b28d6ba1121cdb78e75016f0395d057e5a114e0 100644 --- a/api/@ohos.util.PlainArray.d.ts +++ b/api/@ohos.util.PlainArray.d.ts @@ -40,7 +40,8 @@ * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ declare class PlainArray { /** @@ -65,7 +66,8 @@ declare class PlainArray { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ constructor(); /** @@ -93,6 +95,19 @@ declare class PlainArray { * @since 12 */ length: number; + + /** + * Gets the element number of the PlainArray. + * + * @type { number } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get length(): number; + /** * Appends a key-value pair to PlainArray * @@ -130,7 +145,8 @@ declare class PlainArray { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ add(key: number, value: T): void; /** @@ -155,7 +171,8 @@ declare class PlainArray { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ clear(): void; /** @@ -183,7 +200,8 @@ declare class PlainArray { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ clone(): PlainArray; /** @@ -223,7 +241,8 @@ declare class PlainArray { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ has(key: number): boolean; /** @@ -266,6 +285,21 @@ declare class PlainArray { * @since 12 */ get(key: number): T; + + /** + * Queries the value associated with the specified key + * + * @param { number } key - looking for goals + * @returns { T | undefined } the value of key-value pairs + * @throws { BusinessError } 10200001 - The value of index is out of range. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get(key: number): T | undefined; + /** * Queries the index for a specified key * @@ -303,7 +337,8 @@ declare class PlainArray { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ getIndexOfKey(key: number): number; /** @@ -334,7 +369,8 @@ declare class PlainArray { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ getIndexOfValue(value: T): number; /** @@ -362,7 +398,8 @@ declare class PlainArray { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ isEmpty(): boolean; /** @@ -402,7 +439,8 @@ declare class PlainArray { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ getKeyAt(index: number): number; /** @@ -445,6 +483,21 @@ declare class PlainArray { * @since 12 */ remove(key: number): T; + + /** + * Remove the key-value pair based on a specified key if it exists and return the value + * + * @param { number } key - target to be deleted + * @returns { T | undefined } target mapped value, or undefined if key is not exist + * @throws { BusinessError } 10200001 - The value of index is out of range. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + remove(key: number): T | undefined; + /** * Remove the key-value pair at a specified index if it exists and return the value * @@ -485,6 +538,21 @@ declare class PlainArray { * @since 12 */ removeAt(index: number): T; + + /** + * Remove the key-value pair at a specified index if it exists and return the value + * + * @param { number } index - target subscript for search + * @returns { T | undefined } the T type, or undefined if container is empty + * @throws { BusinessError } 10200001 - The value of index is out of range. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + removeAt(index: number): T | undefined; + /** * Remove a group of key-value pairs from a specified index * @@ -528,7 +596,8 @@ declare class PlainArray { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ removeRangeFrom(index: number, size: number): number; /** @@ -571,7 +640,8 @@ declare class PlainArray { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ setValueAt(index: number, value: T): void; /** @@ -599,7 +669,8 @@ declare class PlainArray { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ toString(): String; /** @@ -642,7 +713,8 @@ declare class PlainArray { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ getValueAt(index: number): T; /** @@ -697,6 +769,19 @@ declare class PlainArray { * @since 12 */ forEach(callbackFn: (value: T, index?: number, PlainArray?: PlainArray) => void, thisArg?: Object): void; + + /** + * Executes a provided function once for each value in the PlainArray object. + * + * @param { PlainArrayForEachCb } callbackFn - callbackFn + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + forEach(callbackFn: PlainArrayForEachCb): void; + /** * returns an iterator.Each item of the iterator is a Javascript Object * @@ -725,6 +810,34 @@ declare class PlainArray { * @since 12 */ [Symbol.iterator](): IterableIterator<[number, T]>; + + /** + * returns an iterator. Each item of the iterator is a ArkTS Object + * + * @returns { IterableIterator<[number, T]> } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + $_iterator(): IterableIterator<[number, T]>; + } +/** + * The type of PlainArray callback function. + * + * @typedef { function } PlainArrayForEachCb + * @param { T } value - The value of current element + * @param { number } key - The key of current element + * @param { PlainArray } PlainArray - The PlainArray instance being traversed + * @returns { void } This callback does not return a value + * @syscap SystemCapability.Utils.Lang + * @atomicservice + * @since 20 + * @arkts 1.2 + */ +type PlainArrayForEachCb = (value: T, key: number, PlainArray: PlainArray) => void + export default PlainArray; diff --git a/api/@ohos.util.Queue.d.ts b/api/@ohos.util.Queue.d.ts index f4764226358cd4eda07f6533e894d71958f38cc1..abdba11d474fc39a97a03e70145a74614aaade00 100644 --- a/api/@ohos.util.Queue.d.ts +++ b/api/@ohos.util.Queue.d.ts @@ -43,7 +43,8 @@ * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ declare class Queue { /** @@ -68,7 +69,8 @@ declare class Queue { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ constructor(); /** @@ -96,6 +98,19 @@ declare class Queue { * @since 12 */ length: number; + + /** + * Gets the element number of the Queue. + * + * @type { number } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get length(): number; + /** * Inserting specified element at the end of a queue if it is possible to do * so immediately without violating capacity restrictions. @@ -127,7 +142,8 @@ declare class Queue { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ add(element: T): boolean; /** @@ -158,6 +174,19 @@ declare class Queue { * @since 12 */ getFirst(): T; + + /** + * Obtains the header element of a queue. + * + * @returns { T | undefined } the first element of the queue if it exists, otherwise returns undefined. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + getFirst(): T | undefined; + /** * Retrieves and removes the head of this queue * @@ -186,6 +215,19 @@ declare class Queue { * @since 12 */ pop(): T; + + /** + * Retrieves and removes the head of this queue + * + * @returns { T | undefined } the deleted element of the deque if it exists, otherwise returns undefined. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + pop(): T | undefined; + /** * Executes a provided function once for each value in the queue object. * @@ -238,6 +280,19 @@ declare class Queue { * @since 12 */ forEach(callbackFn: (value: T, index?: number, Queue?: Queue) => void, thisArg?: Object): void; + + /** + * Executes a provided function once for each value in the queue object. + * + * @param { QueueForEachCb } callbackFn - callbackFn + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + forEach(callbackfn: QueueForEachCb): void; + /** * returns an iterator.Each item of the iterator is a Javascript Object * @@ -266,6 +321,34 @@ declare class Queue { * @since 12 */ [Symbol.iterator](): IterableIterator; + + /** + * returns an iterator. Each item of the iterator is a ArkTS Object + * + * @returns { IterableIterator } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + $_iterator(): IterableIterator; + } +/** + * The type of Queue callback function. + * + * @typedef { function } QueueForEachCb + * @param { T } value - The value of current element + * @param { number } index - The key of current element + * @param { Queue } queue - The Queue instance being traversed + * @returns { void } This callback does not return a value + * @syscap SystemCapability.Utils.Lang + * @atomicservice + * @since 20 + * @arkts 1.2 + */ +type QueueForEachCb = (value: T, index: number, queue: Queue) => void + export default Queue; diff --git a/api/@ohos.util.Stack.d.ts b/api/@ohos.util.Stack.d.ts index fe9713d5eacb814f207898542f6fde7b377baceb..340ed2c85f60351be061718902de490facbc13ff 100644 --- a/api/@ohos.util.Stack.d.ts +++ b/api/@ohos.util.Stack.d.ts @@ -40,7 +40,8 @@ * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ declare class Stack { /** @@ -65,7 +66,8 @@ declare class Stack { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ constructor(); /** @@ -93,6 +95,19 @@ declare class Stack { * @since 12 */ length: number; + + /** + * Gets the element number of the Stack. + * + * @type { number } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get length(): number; + /** * Tests if this stack is empty * @@ -118,7 +133,8 @@ declare class Stack { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ isEmpty(): boolean; /** @@ -152,6 +168,20 @@ declare class Stack { * @since 12 */ peek(): T; + + /** + * Looks at the object at the top of this stack without removing it from the stack + * Return undefined if this stack is empty + * + * @returns { T | undefined } the top value, or undefined if container is empty + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + peek(): T | undefined; + /** * Removes the object at the top of this stack and returns that object as the value of this function * an exception if the stack is empty @@ -183,6 +213,20 @@ declare class Stack { * @since 12 */ pop(): T; + + /** + * Removes the object at the top of this stack and returns that object as the value of this function + * an exception if the stack is empty + * + * @returns { T | undefined } Stack top value, or undefined if container is empty + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + pop(): T | undefined; + /** * Pushes an item onto the top of this stack * @@ -211,7 +255,8 @@ declare class Stack { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ push(item: T): T; /** @@ -242,7 +287,8 @@ declare class Stack { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ locate(element: T): number; /** @@ -297,6 +343,19 @@ declare class Stack { * @since 12 */ forEach(callbackFn: (value: T, index?: number, stack?: Stack) => void, thisArg?: Object): void; + + /** + * Executes a provided function once for each value in the Stack object. + * + * @param { StackForEachCb } callbackFn - callbackFn + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + forEach(callbackfn: StackForEachCb): void; + /** * returns an ES6 iterator.Each item of the iterator is a Javascript Object * @@ -325,6 +384,34 @@ declare class Stack { * @since 12 */ [Symbol.iterator](): IterableIterator; + + /** + * returns an iterator. Each item of the iterator is a ArkTS Object + * + * @returns { IterableIterator } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + $_iterator(): IterableIterator; + } +/** + * The type of Stack callback function. + * + * @typedef { function } StackForEachCb + * @param { T } value - The value of current element + * @param { number } index - The key of current element + * @param { Stack } stack - The Stack instance being traversed + * @returns { void } This callback does not return a value + * @syscap SystemCapability.Utils.Lang + * @atomicservice + * @since 20 + * @arkts 1.2 + */ +type StackForEachCb = (value: T, index: number, stack: Stack) => void + export default Stack; diff --git a/api/@ohos.util.TreeMap.d.ts b/api/@ohos.util.TreeMap.d.ts index 3aee29d8471e0ba7e48b72f670013c7336b4540a..ad93707e33003ce173ca9e234f8e95482e7fc10e 100644 --- a/api/@ohos.util.TreeMap.d.ts +++ b/api/@ohos.util.TreeMap.d.ts @@ -43,7 +43,8 @@ * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ declare class TreeMap { /** @@ -92,6 +93,20 @@ declare class TreeMap { * @since 12 */ constructor(comparator?: (firstValue: K, secondValue: K) => boolean); + + /** + * A constructor used to create a TreeMap object. + * + * @param { TreeMapComparator } [comparator] - comparator + * comparator (Optional) User-defined comparison functions. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + constructor(comparator?: TreeMapComparator); + /** * Gets the element number of the hashmap. * @@ -117,6 +132,19 @@ declare class TreeMap { * @since 12 */ length: number; + + /** + * Gets the element number of the TreeMap. + * + * @type { number } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get length(): number; + /** * Returns whether the Map object contains elements * @@ -142,7 +170,8 @@ declare class TreeMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ isEmpty(): boolean; /** @@ -173,7 +202,8 @@ declare class TreeMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ hasKey(key: K): boolean; /** @@ -204,7 +234,8 @@ declare class TreeMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ hasValue(value: V): boolean; /** @@ -300,6 +331,46 @@ declare class TreeMap { * @since 12 */ getLastKey(): K; + + /** + * Returns a specified element in a Map object, or undefined if there is no corresponding element + * + * @param { K } key - key key the index in TreeMap + * @returns { V | undefined } value if associated with key presents, undefined otherwise + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get(key: K): V | undefined; + + /** + * Obtains the first sorted key in the treemap. + * Or returns undefined if tree map is empty + * + * @returns { K | undefined } the key of the first element if exists, undefined otherwise + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + getFirstKey(): K | undefined; + + /** + * Obtains the last sorted key in the treemap. + * Or returns undefined if tree map is empty + * + * @returns { K | undefined } the key of the last element if exists, undefined otherwise + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + getLastKey(): K | undefined; + /** * Adds all element groups in one map to another map * @@ -334,7 +405,8 @@ declare class TreeMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ setAll(map: TreeMap): void; /** @@ -380,7 +452,8 @@ declare class TreeMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ set(key: K, value: V): Object; /** @@ -414,6 +487,20 @@ declare class TreeMap { * @since 12 */ remove(key: K): V; + + /** + * Remove a specified element from a Map object + * + * @param { K } key - key key Target to be deleted + * @returns { V | undefined } the value of the removed element, undefined otherwise + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + remove(key: K): V | undefined; + /** * Clear all element groups in the map * @@ -436,7 +523,8 @@ declare class TreeMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ clear(): void; /** @@ -507,6 +595,35 @@ declare class TreeMap { * @since 12 */ getHigherKey(key: K): K; + + /** + * Returns the greatest element smaller than or equal to the specified key + * if the key does not exist, undefined is returned + * + * @param { K } key - key key Objective of comparison + * @returns { K | undefined } the lower key of the given key's element if exists, undefined otherwise + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + getLowerKey(key: K): K | undefined; + + /** + * Returns the least element greater than or equal to the specified key + * if the key does not exist, undefined is returned + * + * @param { K } key - key key Objective of comparison + * @returns { K | undefined } the higher key of the given key's element if exists, undefined otherwise + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + getHigherKey(key: K): K | undefined; + /** * Returns a new Iterator object that contains the keys contained in this map * @@ -532,7 +649,8 @@ declare class TreeMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ keys(): IterableIterator; /** @@ -560,7 +678,8 @@ declare class TreeMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ values(): IterableIterator; /** @@ -594,7 +713,8 @@ declare class TreeMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ replace(key: K, newValue: V): boolean; /** @@ -652,6 +772,20 @@ declare class TreeMap { * @since 12 */ forEach(callbackFn: (value?: V, key?: K, map?: TreeMap) => void, thisArg?: Object): void; + + /** + * Executes the given callback function once for each real key in the map. + * It does not perform functions on deleted keys + * + * @param { TreeMapForEachCb } callbackFn - callbackFn + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + forEach(callbackFn: TreeMapForEachCb): void; + /** * Returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order * @@ -677,7 +811,8 @@ declare class TreeMap { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ entries(): IterableIterator<[K, V]>; /** @@ -708,6 +843,48 @@ declare class TreeMap { * @since 12 */ [Symbol.iterator](): IterableIterator<[K, V]>; + + /** + * returns an ES6 iterator.Each item of the iterator is a Javascript Object + * + * @returns { IterableIterator<[K, V]> } an iterator for the TreeMap + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + $_iterator(): IterableIterator<[K, V]>; + } +/** + * The type of TreeMap callback function. + * + * @typedef { function } TreeMapForEachCb + * @param { V } value - The value of current element + * @param { K } key - The key of current element + * @param { TreeMap } map - The TreeMap instance being traversed + * @returns { void } This callback does not return a value + * @syscap SystemCapability.Utils.Lang + * @atomicservice + * @since 20 + * @arkts 1.2 + */ +type TreeMapForEachCb = (value: V, key: K, map: TreeMap) => void + +/** + * The type of TreeMap comparator. + * + * @typedef { function } TreeMapComparator + * @param { K } firstValue - The first value compared + * @param { K } secondValue - The second value compared + * @returns { number } - Comparison results + * @syscap SystemCapability.Utils.Lang + * @atomicservice + * @since 20 + * @arkts 1.2 + */ +type TreeMapComparator = (firstValue: K, secondValue: K) => number + export default TreeMap; diff --git a/api/@ohos.util.TreeSet.d.ts b/api/@ohos.util.TreeSet.d.ts index db14019651213cf385e2d0e5c832280c1ec70369..d09e7b054817a150bab30931d0ab7b62618138db 100644 --- a/api/@ohos.util.TreeSet.d.ts +++ b/api/@ohos.util.TreeSet.d.ts @@ -40,7 +40,8 @@ * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ declare class TreeSet { /** @@ -89,6 +90,20 @@ declare class TreeSet { * @since 12 */ constructor(comparator?: (firstValue: T, secondValue: T) => boolean); + + /** + * A constructor used to create a TreeSet object. + * + * @param { TreeSetComparator } [comparator] - comparator + * comparator (Optional) User-defined comparison functions. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + constructor(comparator?: TreeSetComparator); + /** * Gets the element number of the TreeSet. * @@ -114,6 +129,19 @@ declare class TreeSet { * @since 12 */ length: number; + + /** + * Gets the element number of the TreeSet. + * + * @type { number } + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + get length(): number; + /** * Returns whether the Set object contains elements * @@ -139,7 +167,8 @@ declare class TreeSet { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ isEmpty(): boolean; /** @@ -170,7 +199,8 @@ declare class TreeSet { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ has(value: T): boolean; /** @@ -213,7 +243,8 @@ declare class TreeSet { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ add(value: T): boolean; /** @@ -244,7 +275,8 @@ declare class TreeSet { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ remove(value: T): boolean; /** @@ -269,7 +301,8 @@ declare class TreeSet { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ clear(): void; /** @@ -476,6 +509,83 @@ declare class TreeSet { * @since 12 */ popLast(): T; + + /** + * Gets the first elements in a set + * + * @returns { T | undefined } the value of the first element if exists, undefined otherwise + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + getFirstValue(): T | undefined; + + /** + * Gets the last elements in a set + * + * @returns { T | undefined } the value of the last element if exists, undefined otherwise + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + getLastValue(): T | undefined; + + /** + * Returns the greatest element smaller than or equal to the specified key + * if the key does not exist, undefined is returned + * + * @param { T } key - key key Objective of comparison + * @returns { T | undefined } the lower value of the given key's element if exists, undefined otherwise + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + getLowerValue(key: T): T | undefined; + + /** + * Returns the least element greater than or equal to the specified key + * if the key does not exist, undefined is returned + * + * @param { T } key - key key Objective of comparison + * @returns { T | undefined } the higher value of the given key's element if exists, undefined otherwise + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + getHigherValue(key: T): T | undefined; + + /** + * Return and delete the first element, returns undefined if tree set is empty + * + * @returns { T | undefined} the value of the first element in the TreeSet if exists, undefined otherwise + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + popFirst(): T | undefined; + + /** + * Return and delete the last element, returns undefined if tree set is empty + * + * @returns { T | undefined } the value of the last element in the TreeSet if exists, undefined otherwise + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + popLast(): T | undefined; + /** * Executes a provided function once for each value in the Set object. * @@ -528,6 +638,19 @@ declare class TreeSet { * @since 12 */ forEach(callbackFn: (value?: T, key?: T, set?: TreeSet) => void, thisArg?: Object): void; + + /** + * Executes a provided function once for each value in the Set object. + * + * @param { TreeSetForEachCb } callbackFn - callbackFn + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + forEach(callbackFn: TreeSetForEachCb): void; + /** * Returns a new Iterator object that contains the values contained in this set * @@ -553,7 +676,8 @@ declare class TreeSet { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ values(): IterableIterator; /** @@ -581,7 +705,8 @@ declare class TreeSet { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ entries(): IterableIterator<[T, T]>; /** @@ -612,6 +737,48 @@ declare class TreeSet { * @since 12 */ [Symbol.iterator](): IterableIterator; + + /** + * returns an ES6 iterator.Each item of the iterator is a Javascript Object + * + * @returns { IterableIterator } an iterator for the TreeSet + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + $_iterator(): IterableIterator; + } +/** + * The type of TreeSet callback function. + * + * @typedef { function } TreeSetForEachCb + * @param { T } value - The value of current element + * @param { T } key - The key of current element(same as value) + * @param { TreeSet } set - The TreeSet instance being traversed + * @returns { void } This callback does not return a value + * @syscap SystemCapability.Utils.Lang + * @atomicservice + * @since 20 + * @arkts 1.2 + */ +type TreeSetForEachCb = (value: T, key: T, set: TreeSet) => void + +/** + * The type of TreeSet comparator. + * + * @typedef { function } TreeSetComparator + * @param { T } firstValue - The first value compared + * @param { T } secondValue - The second value compared + * @returns { number } - Comparison results + * @syscap SystemCapability.Utils.Lang + * @atomicservice + * @since 20 + * @arkts 1.2 + */ +type TreeSetComparator = (firstValue: T, secondValue: T) => number + export default TreeSet; diff --git a/api/@ohos.util.json.d.ts b/api/@ohos.util.json.d.ts index 21e92b6c843aa59d506a8abb82fa9472ddb40b79..927eb0db21ddb0866502b95d979605409a0a0a9a 100644 --- a/api/@ohos.util.json.d.ts +++ b/api/@ohos.util.json.d.ts @@ -25,7 +25,8 @@ * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ declare namespace json { /** @@ -35,25 +36,24 @@ declare namespace json { * @param { Object } this - The object to which the parsed key value pair belongs. * @param { string } key - Attribute name. * @param { Object } value - The value of the parsed key value pair. + * @returns { Object | undefined | null } Return an Object, undefined or null value * @syscap SystemCapability.Utils.Lang * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ type Transformer = (this: Object, key: string, value: Object) => Object | undefined | null; /** - * Parses a JSON string into an ArkTS object or null. + * Converts a JavaScript Object Notation (JSON) string into an Object or null. * - * @param { string } text - Valid JSON string. - * @param { Transformer } [reviver] - Conversion function. This parameter can be used to modify the value generated - * after parsing. The default value is undefined. - * @param {ParseOptions} options - Parsing options. This parameter is used to control the type of the parsing result. - * The default value is undefined. + * @param { string } text - A valid JSON string. + * @param { Transformer } [reviver] - A function that transforms the results. + * @param {ParseOptions} options - The config of parse. * @returns { Object | null } Return an Object, array, string, number, boolean, or null value corresponding to JSON text. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; - * 2.Incorrect parameter types; - * 3.Parameter verification failed. + * 2.Incorrect parameter types; 3.Parameter verification failed. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice @@ -62,18 +62,28 @@ declare namespace json { function parse(text: string, reviver?: Transformer, options?: ParseOptions): Object | null; /** - * Converts an ArkTS object or array into a JSON string. In the case of a container, linear containers are supported, - * but non-linear containers are not. + * Converts a JavaScript Object Notation (JSON) string into an Object or null. * - * @param { Object } value - ArkTS object or array. In the case of a container, linear containers are supported, but - * non-linear containers are not. - * @param { (number | string)[] | null } [replacer] - If an array is passed in, only the keys in the array are - * serialized to the final JSON string. If null is passed in, all keys of the object are serialized. The default - * value is undefined. - * @param { string | number } [space] - Indentation, white space, or line break characters inserted into the output - * JSON string for readability purposes. If a number is passed in, it indicates the number of space characters to be - * used as indentation. If a string is passed in, the string is inserted before the output JSON string. If null is - * passed in, no white space is used. The default value is an empty string. + * @param { string } text - A valid JSON string. + * @param { Type } type - A constructor or class representing the expected type of the parsed result. + * @param { Transformer } [reviver] - A function that transforms the results. + * @param {ParseOptions} options - The config of parse. + * @returns { T | null | undefined } Return an Object, array, string, number, boolean, undefined, or null value corresponding to JSON text. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + function parse(text: string, type: Type, reviver?: Transformer, options?: ParseOptions): T | null | undefined; + + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * + * @param { Object } value - A JavaScript value, usually an Object or array. + * @param { (number | string)[] | null } [replacer] - An array of strings and numbers that acts as an approved list + * for selecting the object properties that will be stringify. + * @param { string | number } [space] - Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. * @returns { string } Return a JSON text. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -87,17 +97,27 @@ declare namespace json { function stringify(value: Object, replacer?: (number | string)[] | null, space?: string | number): string; /** - * Converts an ArkTS object or array into a JSON string. In the case of a container, linear containers are supported, - * but non-linear containers are not. + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * + * @param { NullishType } value - A JavaScript value, usually an NullishType or array. + * @param { Transformer | ((number | string)[]) | null } [replacer] - An array of strings and numbers that acts as an approved list + * for selecting the object properties that will be stringify. + * @param { string | number } [space] - Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + * @returns { string } Return a JSON text. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + function stringify(value: NullishType, replacer?: Transformer | ((number | string)[]) | null, space?: string | number): string; + + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. * - * @param { Object } value - ArkTS object or array. In the case of a container, linear containers are supported, but - * non-linear containers are not. - * @param { Transformer } [replacer] - During serialization, each key of the serialized value is converted and - * processed by this function. The default value is undefined. - * @param { string | number } [space] - Indentation, white space, or line break characters inserted into the output - * JSON string for readability purposes. If a number is passed in, it indicates the number of space characters to be - * used as indentation. If a string is passed in, the string is inserted before the output JSON string. If null is - * passed in, no white space is used. The default value is an empty string. + * @param { Object } value - A JavaScript value, usually an Object or array. + * @param { Transformer } [replacer] - A function that transforms the results. + * @param { string | number } [space] - Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. * @returns { string } Return a JSON text. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; @@ -111,8 +131,8 @@ declare namespace json { function stringify(value: Object, replacer?: Transformer, space?: string | number): string; /** - * Checks whether an ArkTS object contains a key. - * + * Checks whether the object parsed from a JSON string contains the property. + * * @param { object } obj - The object parsed from a JSON string. * @param { string } property - Determine whether the object contains the property. * @returns { boolean } Return true if the key is in the object, otherwise return false. @@ -120,12 +140,13 @@ declare namespace json { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ function has(obj: object, property: string): boolean; /** - * Removes a key from an ArkTS object. + * Removes a property from the object parsed from a JSON string. * * @param { object } obj - The object parsed from a JSON string. * @param { string } property - The property to be removed. @@ -144,7 +165,8 @@ declare namespace json { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ const enum BigIntMode { /** @@ -153,7 +175,8 @@ declare namespace json { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ DEFAULT = 0, /** @@ -162,7 +185,8 @@ declare namespace json { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ PARSE_AS_BIGINT = 1, /** @@ -171,7 +195,8 @@ declare namespace json { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ ALWAYS_PARSE_AS_BIGINT = 2, } @@ -183,7 +208,8 @@ declare namespace json { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ interface ParseOptions { /** @@ -192,7 +218,8 @@ declare namespace json { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ bigIntMode: BigIntMode; } diff --git a/api/@ohos.util.stream.d.ts b/api/@ohos.util.stream.d.ts index 072128b1f71e20d2b12a64c66514a83e350f5984..0903242cb7a427fb580c3f0080d8b9b6514573ba 100644 --- a/api/@ohos.util.stream.d.ts +++ b/api/@ohos.util.stream.d.ts @@ -31,16 +31,29 @@ * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ declare namespace stream { + /** + * The type of stream callback function. + * + * @typedef { function } StreamCb + * @returns { void } - The function return void + * @syscap SystemCapability.Utils.Lang + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + type StreamCb = () => void; /** * Streams to which data can be written. * * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ class Writable { /** @@ -49,7 +62,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ constructor(); /** @@ -74,8 +88,30 @@ declare namespace stream { * @crossplatform * @atomicservice * @since 12 - */ + */ write(chunk?: string | Uint8Array, encoding?: string, callback?: Function): boolean; + + /** + * writes a chunk to Writable and invokes callback when the chunk is flushed. The return value indicates + * whether the internal buffer of the Writable reaches the hightWaterMark. If true is returned, the buffer + * does not reach the hightWaterMark. If false is returned, the buffer has been reached. The write function + * should be called after the drain event is triggered. If the write function is called continuously, + * the chunk is still added to the buffer until the memory overflows + * + * @param { string | Uint8Array } [chunk] - Data to be written. + * @param { string } [encoding] - Encoding type. + * @param { StreamCb } [callback] - Callback after writing. + * @returns { boolean } Write success returns true, write failure returns false. + * @throws { BusinessError } 10200035 - The doWrite method has not been implemented. + * @throws { BusinessError } 10200036 - The stream has been ended. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + write(chunk?: string | Uint8Array, encoding?: string, callback?: StreamCb): boolean; + /** * Write the last chunk to Writable. * @@ -94,6 +130,23 @@ declare namespace stream { * @since 12 */ end(chunk?: string | Uint8Array, encoding?: string, callback?: Function): Writable; + + /** + * Write the last chunk to Writable. + * + * @param { string | Uint8Array } [chunk] - Data to be written. + * @param { string } [encoding] - Encoding type. + * @param { StreamCb } [callback] - Callback after writing. + * @returns { Writable } Returns the Writable object. + * @throws { BusinessError } 10200035 - The doWrite method has not been implemented. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + end(chunk?: string | Uint8Array, encoding?: string, callback?: StreamCb): Writable; + /** * Set the default encoding mode. * @@ -106,8 +159,9 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 - */ + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 + */ setDefaultEncoding(encoding?: string): boolean; /** * After the call, all Write operations will be forced to write to the buffer instead of being flushed. @@ -116,7 +170,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ cork(): boolean; /** @@ -126,7 +181,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ uncork(): boolean; /** @@ -141,7 +197,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ on(event: string, callback: Callback): void; /** @@ -155,7 +212,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ off(event: string, callback?: Callback): void; /** @@ -172,6 +230,20 @@ declare namespace stream { * @since 12 */ doInitialize(callback: Function): void; + + /** + * This method is invoked by the Writable method during initialization and must not be invoked directly. + * After the resource is initialized in the doInitialize method, the callback () method is invoked. + * + * @param { StreamCb } callback - Callback when the stream has completed the initial. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + doInitialize(callback: StreamCb): void; + /** * Implemented by subclass inheritance. The implementation logic of flushing chunks in the buffer must not be * directly called. The call is controlled by Writable.write. @@ -189,6 +261,20 @@ declare namespace stream { * @since 12 */ doWrite(chunk: string | Uint8Array, encoding: string, callback: Function): void; + /** + * Implemented by subclass inheritance. The implementation logic of flushing chunks in the buffer must not be + * directly called. The call is controlled by Writable.write. + * + * @param { string | Uint8Array } [chunk] - Data to be written. + * @param { string } [encoding] - Encoding type. + * @param { StreamCb } [callback] - Callback after writing. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + doWrite(chunk: string | Uint8Array, encoding: string, callback: StreamCb): void; /** * The implementation logic of flushing chunks in the buffer in batches should not be actively called. * The call is controlled by Writable.write. @@ -205,6 +291,20 @@ declare namespace stream { * @since 12 */ doWritev(chunks: string[] | Uint8Array[], callback: Function): void; + /** + * The implementation logic of flushing chunks in the buffer in batches should not be actively called. + * The call is controlled by Writable.write. + * + * @param { string[] | Uint8Array[] } [chunks] - Data to be written. + * @param { StreamCb } [callback] - Callback after writing. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + doWritev(chunks: string[] | Uint8Array[], callback: StreamCb): void; + /** * Returns boolean indicating whether it is in ObjectMode. * @@ -213,7 +313,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ readonly writableObjectMode: boolean; /** @@ -224,7 +325,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ readonly writableHighWatermark: number; /** @@ -235,7 +337,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ readonly writable: boolean; /** @@ -246,7 +349,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ readonly writableLength: number; /** @@ -257,7 +361,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ readonly writableCorked: number; /** @@ -268,7 +373,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ readonly writableEnded: boolean; /** @@ -279,7 +385,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ readonly writableFinished: boolean; } @@ -291,7 +398,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ class Transform extends Duplex { /** @@ -300,7 +408,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ constructor(); /** @@ -321,6 +430,23 @@ declare namespace stream { * @since 12 */ doTransform(chunk: string, encoding: string, callback: Function): void; + + /** + * Convert the input data. After the conversion, Transform.push can be called to send the input to the read stream. + * Transform.push should not be called Transform.write to call. + * + * @param { string } chunk - Input data to be converted. + * @param { string } encoding - If the chunk is a string, then this is the encoding type. If chunk is a buffer, + * then this is the special value 'buffer'. Ignore it in that case. + * @param { StreamCb } callback - Callback after conversion. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + doTransform(chunk: string, encoding: string, callback: StreamCb): void; + /** * After all data is flushed to the write stream, you can use the Transform.doFlush writes some extra data, must * not be called directly, only called by Writable after flushing all data. @@ -336,6 +462,20 @@ declare namespace stream { * @since 12 */ doFlush(callback: Function): void; + + /** + * After all data is flushed to the write stream, you can use the Transform.doFlush writes some extra data, must + * not be called directly, only called by Writable after flushing all data. + * + * @param { StreamCb } callback - Callback after flush completion. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + doFlush(callback: StreamCb): void; + } /** @@ -345,7 +485,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ interface ReadableOptions { /** @@ -362,7 +503,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ encoding?: string; } @@ -373,7 +515,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ class Readable { /** @@ -382,7 +525,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ constructor(); /** @@ -396,7 +540,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ constructor(options: ReadableOptions); /** @@ -413,7 +558,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ read(size?: number): string | null; /** @@ -423,7 +569,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ resume(): Readable; /** @@ -433,7 +580,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ pause(): Readable; /** @@ -447,7 +595,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ setEncoding(encoding?: string): boolean; /** @@ -457,7 +606,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ isPaused(): boolean; /** @@ -473,7 +623,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ pipe(destination: Writable, options?: Object): Writable; /** @@ -488,7 +639,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ unpipe(destination?: Writable): Readable; /** @@ -502,7 +654,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ on(event: string, callback: Callback): void; /** @@ -516,7 +669,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ off(event: string, callback?: Callback): void; /** @@ -534,6 +688,20 @@ declare namespace stream { * @since 12 */ doInitialize(callback: Function): void; + + /** + * It may be implemented by child classes, and if so, will be called by the Readable class methods only. + * It must not be called directly. + * + * @param { StreamCb } callback - Callback when the stream has completed the initial. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + doInitialize(callback: StreamCb): void; + /** * The specific implementation of data production. It must not be actively called. * After data production, Readable.push should be called to push the produced data into the buffer. @@ -547,7 +715,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ doRead(size: number): void; /** @@ -564,7 +733,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ push(chunk: Uint8Array | string | null, encoding?: string): boolean; /** @@ -575,7 +745,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ readonly readableObjectMode: boolean; /** @@ -587,7 +758,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ readonly readable: boolean; /** @@ -598,7 +770,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ readonly readableHighWatermark: number; /** @@ -609,7 +782,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ readonly readableFlowing: boolean | null; /** @@ -620,7 +794,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ readonly readableLength: number; /** @@ -632,7 +807,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ readonly readableEncoding: string | null; /** @@ -643,7 +819,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ readonly readableEnded: boolean; } @@ -654,7 +831,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ class Duplex extends Readable { /** @@ -663,7 +841,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ constructor(); /** @@ -690,6 +869,29 @@ declare namespace stream { * @since 12 */ write(chunk?: string | Uint8Array, encoding?: string, callback?: Function): boolean; + + /** + * writes a chunk to Writable and invokes callback when the chunk is flushed. The return value indicates + * whether the internal buffer of the Writable reaches the hightWaterMark. If true is returned, the buffer + * does not reach the hightWaterMark. If false is returned, the buffer has been reached. The write function + * should be called after the drain event is triggered. If the write function is called continuously, + * the chunk is still added to the buffer until the memory overflows + * + * @param { string | Uint8Array } [chunk] - Data to be written. + * @param { string } [encoding] - Encoding type. + * @param { StreamCb } [callback] - Callback after writing. + * @returns { boolean } Write success returns true, write failure returns false. + * @throws { BusinessError } 10200036 - The stream has been ended. + * @throws { BusinessError } 10200037 - The callback is invoked multiple times consecutively. + * @throws { BusinessError } 10200039 - The doTransform method has not been implemented for a class that inherits from Transform. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + write(chunk?: string | Uint8Array, encoding?: string, callback?: StreamCb): boolean; + /** * Write the last chunk to Writable. * @@ -708,6 +910,23 @@ declare namespace stream { * @since 12 */ end(chunk?: string | Uint8Array, encoding?: string, callback?: Function): Writable; + + /** + * Write the last chunk to Writable. + * + * @param { string | Uint8Array } [chunk] - Data to be written. + * @param { string } [encoding] - Encoding type. + * @param { StreamCb } [callback] - Callback after writing. + * @returns { Writable } Returns the Writable object. + * @throws { BusinessError } 10200039 - The doTransform method has not been implemented for a class that inherits from Transform. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + end(chunk?: string | Uint8Array, encoding?: string, callback?: StreamCb): Writable; + /** * Set the default encoding mode. * @@ -720,7 +939,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ setDefaultEncoding(encoding?: string): boolean; /** @@ -730,7 +950,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ cork(): boolean; /** @@ -740,7 +961,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ uncork(): boolean; /** @@ -760,6 +982,22 @@ declare namespace stream { * @since 12 */ doWrite(chunk: string | Uint8Array, encoding: string, callback: Function): void; + + /** + * Implemented by subclass inheritance. The implementation logic of flushing chunks in the buffer must not be + * directly called. The call is controlled by Writable.write. + * + * @param { string | Uint8Array } [chunk] - Data to be written. + * @param { string } [encoding] - Encoding type. + * @param { StreamCb } [callback] - Callback after writing. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + doWrite(chunk: string | Uint8Array, encoding: string, callback: StreamCb): void; + /** * The implementation logic of flushing chunks in the buffer in batches should not be actively called. * The call is controlled by Writable.write. @@ -776,6 +1014,21 @@ declare namespace stream { * @since 12 */ doWritev(chunks: string[] | Uint8Array[], callback: Function): void; + + /** + * The implementation logic of flushing chunks in the buffer in batches should not be actively called. + * The call is controlled by Writable.write. + * + * @param { string[] | Uint8Array[] } [chunks] - Data to be written. + * @param { StreamCb } [callback] - Callback after writing. + * @syscap SystemCapability.Utils.Lang + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + doWritev(chunks: string[] | Uint8Array[], callback: StreamCb): void; + /** * Returns boolean indicating whether it is in ObjectMode. * @@ -784,7 +1037,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ readonly writableObjectMode: boolean; /** @@ -795,7 +1049,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ readonly writableHighWatermark: number; /** @@ -806,7 +1061,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ readonly writable: boolean; /** @@ -817,7 +1073,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ readonly writableLength: number; /** @@ -828,7 +1085,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ readonly writableCorked: number; /** @@ -839,7 +1097,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ readonly writableEnded: boolean; /** @@ -850,7 +1109,8 @@ declare namespace stream { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ readonly writableFinished: boolean; } diff --git a/api/@ohos.xml.d.ts b/api/@ohos.xml.d.ts index 97251381492d0dcf8e0859f8810bde6fc5241796..028a850f9391bdb2d12f420165ca455f2914c1a5 100644 --- a/api/@ohos.xml.d.ts +++ b/api/@ohos.xml.d.ts @@ -40,16 +40,18 @@ * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ declare namespace xml { - /** + /** * The XmlDynamicSerializer interface is used to dynamically generate an xml file. * * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 20 + * @since arkts {'1.1':'20', '1.2':'20'} + * @arkts 1.1&1.2 * @name XmlDynamicSerializer */ class XmlDynamicSerializer { @@ -62,7 +64,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 20 + * @since arkts {'1.1':'20', '1.2':'20'} + * @arkts 1.1&1.2 */ constructor(encoding?: string); @@ -77,7 +80,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 20 + * @since arkts {'1.1':'20', '1.2':'20'} + * @arkts 1.1&1.2 */ setAttributes(name: string, value: string): void; @@ -90,7 +94,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 20 + * @since arkts {'1.1':'20', '1.2':'20'} + * @arkts 1.1&1.2 */ addEmptyElement(name: string): void; @@ -101,7 +106,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 20 + * @since arkts {'1.1':'20', '1.2':'20'} + * @arkts 1.1&1.2 */ setDeclaration(): void; @@ -114,7 +120,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 20 + * @since arkts {'1.1':'20', '1.2':'20'} + * @arkts 1.1&1.2 */ startElement(name: string): void; @@ -126,7 +133,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 20 + * @since arkts {'1.1':'20', '1.2':'20'} + * @arkts 1.1&1.2 */ endElement(): void; @@ -140,7 +148,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 20 + * @since arkts {'1.1':'20', '1.2':'20'} + * @arkts 1.1&1.2 */ setNamespace(prefix: string, namespace: string): void; @@ -153,7 +162,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 20 + * @since arkts {'1.1':'20', '1.2':'20'} + * @arkts 1.1&1.2 */ setComment(text: string): void; @@ -166,7 +176,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 20 + * @since arkts {'1.1':'20', '1.2':'20'} + * @arkts 1.1&1.2 */ setCdata(text: string): void; @@ -179,7 +190,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 20 + * @since arkts {'1.1':'20', '1.2':'20'} + * @arkts 1.1&1.2 */ setText(text: string): void; @@ -192,21 +204,23 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 20 + * @since arkts {'1.1':'20', '1.2':'20'} + * @arkts 1.1&1.2 */ setDocType(text: string): void; /** * Get an ArrayBuffer from a XmlDynamicSerializer instance. * - * @returns { ArrayBuffer } - Returns ArrayBuffer result from a XmlDynamicSerializer instance. Empty ArrayBuffer would return if internal error happens. + * @returns { ArrayBuffer } - Returns ArrayBuffer result from a XmlDynamicSerializer instance. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 20 + * @since arkts {'1.1':'20', '1.2':'20'} + * @arkts 1.1&1.2 */ getOutput(): ArrayBuffer; -} + } /** * The XmlSerializer interface is used to generate an xml file. * @@ -228,7 +242,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 * @name XmlSerializer */ class XmlSerializer { @@ -266,10 +281,14 @@ declare namespace xml { * @since 10 */ /** - * A constructor used to create an XmlSerializer instance. + * A parameterized constructor used to create a new XmlSerializer instance. + * As the input parameter of the constructor function, init supports three types. + * The input parameter is an Arrarybuffer. + * The input parameter is a DataView. + * The input parameter is an encoding format of string type. * - * @param { ArrayBuffer | DataView } buffer - ArrayBuffer or DataView for storing the XML information to set. - * @param { string } [encoding] - Encoding format. The default value is 'utf-8' (the only format currently supported). + * @param { ArrayBuffer | DataView } buffer - A instance, the new XmlPullParser with. + * @param { string } [encoding] - [encoding='utf8'] this is its encoding. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; * 2.Incorrect parameter types; @@ -277,7 +296,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ constructor(buffer: ArrayBuffer | DataView, encoding?: string); @@ -307,17 +327,18 @@ declare namespace xml { * @since 10 */ /** - * Sets an attribute. + * Write an attribute. * - * @param { string } name - Key of the attribute. - * @param { string } value - Value of the attribute. + * @param { string } name - Key name of the attribute. + * @param { string } value - Values of attribute. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; * 2.Incorrect parameter types; 3.Parameter verification failed. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ setAttributes(name: string, value: string): void; @@ -345,9 +366,9 @@ declare namespace xml { * @since 10 */ /** - * Adds an empty element. + * Add an empty element. * - * @param { string } name - Name of the empty element to add. + * @param { string } name - Key name of the attribute. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; * 2.Incorrect parameter types; @@ -355,7 +376,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ addEmptyElement(name: string): void; @@ -373,12 +395,13 @@ declare namespace xml { * @since 10 */ /** - * Sets a file declaration with encoding. + * Writes xml declaration with encoding. For example: . * * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ setDeclaration(): void; @@ -406,7 +429,7 @@ declare namespace xml { * @since 10 */ /** - * Writes the start tag based on the given element name. + * Writes a element start tag with the given name. * * @param { string } name - Name of the element. * @throws { BusinessError } 401 - Parameter error. Possible causes: @@ -416,7 +439,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ startElement(name: string): void; @@ -434,12 +458,13 @@ declare namespace xml { * @since 10 */ /** - * Writes the end tag of the element. + * Writes end tag of the element. * * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ endElement(): void; @@ -469,10 +494,10 @@ declare namespace xml { * @since 10 */ /** - * Sets the namespace for an element tag. + * Writes the namespace of the current element tag. * - * @param { string } prefix - Prefix of the element and its child elements. - * @param { string } namespace - Namespace to set. + * @param { string } prefix - Values name of the prefix. + * @param { string } namespace - Values of namespace. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; * 2.Incorrect parameter types; @@ -480,7 +505,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ setNamespace(prefix: string, namespace: string): void; @@ -508,9 +534,9 @@ declare namespace xml { * @since 10 */ /** - * Sets a comment. + * Writes the comment. * - * @param { string } text - Comment to set. + * @param { string } text - Values of comment. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; * 2.Incorrect parameter types; @@ -518,7 +544,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ setComment(text: string): void; @@ -546,9 +573,9 @@ declare namespace xml { * @since 10 */ /** - * Adds data to the CDATA tag. The structure of the generated CDATA tag is "". + * Writes the CDATA. * - * @param { string } text - CDATA data to set. + * @param { string } text - Values of CDATA. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; * 2.Incorrect parameter types; @@ -556,7 +583,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ setCDATA(text: string): void; @@ -584,9 +612,9 @@ declare namespace xml { * @since 10 */ /** - * Sets a tag value. + * Writes the text. * - * @param { string } text - Tag value to set, which is the content of the text attribute. + * @param { string } text - Values of text. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; * 2.Incorrect parameter types; @@ -594,7 +622,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ setText(text: string): void; @@ -622,9 +651,9 @@ declare namespace xml { * @since 10 */ /** - * Sets a document type. + * Writes the DOCTYPE. * - * @param { string } text - Content of DocType to set. + * @param { string } text - Values of docType. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; * 2.Incorrect parameter types; @@ -632,7 +661,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ setDocType(text: string): void; } @@ -659,7 +689,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ enum EventType { /** @@ -681,7 +712,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ START_DOCUMENT, /** @@ -703,7 +735,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ END_DOCUMENT, /** @@ -725,7 +758,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ START_TAG, /** @@ -747,7 +781,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ END_TAG, /** @@ -769,7 +804,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ TEXT, /** @@ -791,7 +827,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ CDSECT, /** @@ -813,7 +850,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ COMMENT, /** @@ -835,7 +873,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ DOCDECL, /** @@ -857,7 +896,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ INSTRUCTION, /** @@ -879,7 +919,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ ENTITY_REFERENCE, /** @@ -901,7 +942,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ WHITESPACE } @@ -928,7 +970,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ interface ParseInfo { /** @@ -947,13 +990,14 @@ declare namespace xml { * @since 10 */ /** - * Obtains the current column number, starting from 1. + * The current column number, starting from 1. * * @returns { number } * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ getColumnNumber(): number; /** @@ -972,13 +1016,14 @@ declare namespace xml { * @since 10 */ /** - * Obtains the depth of this element. + * The current depth of the element. * * @returns { number } * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ getDepth(): number; /** @@ -997,13 +1042,14 @@ declare namespace xml { * @since 10 */ /** - * Obtains the current line number, starting from 1. + * The current line number, starting from 1. * * @returns { number } * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ getLineNumber(): number; /** @@ -1022,13 +1068,14 @@ declare namespace xml { * @since 10 */ /** - * Obtains the name of this element. + * The current element's name. * * @returns { string } * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ getName(): string; /** @@ -1047,13 +1094,14 @@ declare namespace xml { * @since 10 */ /** - * Obtains the namespace of this element. + * The current element's namespace. * * @returns { string } * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ getNamespace(): string; /** @@ -1072,13 +1120,14 @@ declare namespace xml { * @since 10 */ /** - * Obtains the prefix of this element. + * The current element's prefix. * * @returns { string } * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ getPrefix(): string; /** @@ -1097,13 +1146,14 @@ declare namespace xml { * @since 10 */ /** - * Obtains the text of the current event. + * The text content of the current event as String. * * @returns { string } * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ getText(): string; /** @@ -1122,13 +1172,14 @@ declare namespace xml { * @since 10 */ /** - * Checks whether the current element is empty. + * Returns true if the current element is empty. * * @returns { boolean } * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ isEmptyElementTag(): boolean; /** @@ -1147,13 +1198,14 @@ declare namespace xml { * @since 10 */ /** - * Checks whether the current event contains only whitespace characters. + * Checks whether the current TEXT event contains only whitespace characters. * * @returns { boolean } * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ isWhitespace(): boolean; /** @@ -1172,13 +1224,14 @@ declare namespace xml { * @since 10 */ /** - * Obtains the number of attributes for the current start tag. + * Returns the number of attributes of the current start tag. * * @returns { number } * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ getAttributeCount(): number; } @@ -1205,7 +1258,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ interface ParseOptions { /** @@ -1230,7 +1284,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ supportDoctype?: boolean; @@ -1256,7 +1311,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ ignoreNameSpace?: boolean; @@ -1282,7 +1338,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ tagValueCallbackFunction?: (name: string, value: string) => boolean; @@ -1308,7 +1365,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ attributeValueCallbackFunction?: (name: string, value: string) => boolean; @@ -1334,7 +1392,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ tokenValueCallbackFunction?: (eventType: EventType, value: ParseInfo) => boolean; } @@ -1360,7 +1419,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 * @name XmlPullParser */ class XmlPullParser { @@ -1390,7 +1450,7 @@ declare namespace xml { * @since 10 */ /** - * Creates and returns an XmlPullParser object. + * A constructor used to create a new XmlPullParser instance. * * @param { ArrayBuffer | DataView } buffer - A instance, the new XmlPullParser with. * @param { string } [encoding] - [encoding='utf8'] this is its encoding. @@ -1401,7 +1461,8 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ constructor(buffer: ArrayBuffer | DataView, encoding?: string); @@ -1459,16 +1520,18 @@ declare namespace xml { parse(option: ParseOptions): void; /** - * Parses XML information. + * Parse the XML file from XmlPullParser. * - * @param { ParseOptions } option - XML parsing options. + * @param { ParseOptions } option - Parse options for XmlPullParser, the interface including + * two Boolean variables and three callback functions. * @throws { BusinessError } 401 - Parameter error. Possible causes: * 1.Mandatory parameters are left unspecified; * 2.Incorrect parameter types. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice - * @since 14 + * @since arkts {'1.1':'14', '1.2':'20'} + * @arkts 1.1&1.2 */ parseXml(option: ParseOptions): void; }