未验证 提交 b99c6141 编写于 作者: O openharmony_ci 提交者: Gitee

!12685 翻译完成:11828+12023+12047+12260 js-apis-util.md

Merge pull request !12685 from wusongqing/TR11828
# util # @ohos.util
This module provides common utility functions, such as **TextEncoder** and **TextDecoder** for string encoding and decoding, **RationalNumber** for rational number operations, **LruBuffer** for buffer management, **Scope** for range determination, **Base64** for Base64 encoding and decoding, and **Types** for checks of built-in object types.
> **NOTE** > **NOTE**
> >
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
This module provides common utility functions, such as **TextEncoder** and **TextDecoder** for string encoding and decoding, **RationalNumber** for rational number operations, **LruBuffer** for buffer management, **Scope** for range determination, **Base64** for Base64 encoding and decoding, and **Types** for checks of built-in object types.
## Modules to Import ## Modules to Import
``` ```js
import util from '@ohos.util'; import util from '@ohos.util';
``` ```
...@@ -45,14 +43,14 @@ console.log(res); ...@@ -45,14 +43,14 @@ console.log(res);
## util.printf<sup>(deprecated)</sup> ## util.printf<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [util.format9+](#utilformat9) instead.
printf(format: string, ...args: Object[]): string printf(format: string, ...args: Object[]): string
Formats the specified values and inserts them into the string by replacing the wildcard in the string. Formats the specified values and inserts them into the string by replacing the wildcard in the string.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [util.format<sup>9+</sup>](#utilformat9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -60,7 +58,7 @@ Formats the specified values and inserts them into the string by replacing the w ...@@ -60,7 +58,7 @@ Formats the specified values and inserts them into the string by replacing the w
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| format | string | Yes| String.| | format | string | Yes| String.|
| ...args | Object[] | No| Values to format. The formatted values will be replaced the wildcard in the string. | | ...args | Object[] | No| Values to format. The formatted values will be replaced the wildcard in the string.|
**Return value** **Return value**
...@@ -69,6 +67,7 @@ Formats the specified values and inserts them into the string by replacing the w ...@@ -69,6 +67,7 @@ Formats the specified values and inserts them into the string by replacing the w
| string | String containing the formatted values.| | string | String containing the formatted values.|
**Example** **Example**
```js ```js
let res = util.printf("%s", "hello world!"); let res = util.printf("%s", "hello world!");
console.log(res); console.log(res);
...@@ -96,22 +95,22 @@ Obtains detailed information about a system error code. ...@@ -96,22 +95,22 @@ Obtains detailed information about a system error code.
**Example** **Example**
```js ```js
let errnum = 10; // 10 is a system error code. let errnum = 10; // 10 is a system error code.
let result = util.errnoToString(errnum); let result = util.errnoToString(errnum);
console.log("result = " + result); console.log("result = " + result);
``` ```
## util.getErrorString<sup>(deprecated)</sup> ## util.getErrorString<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [util.errnoToString9+](#utilerrnotostring9) instead.
getErrorString(errno: number): string getErrorString(errno: number): string
Obtains detailed information about a system error code. Obtains detailed information about a system error code.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [util.errnoToString<sup>9+</sup>](#utilerrnotostring9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -127,6 +126,7 @@ Obtains detailed information about a system error code. ...@@ -127,6 +126,7 @@ Obtains detailed information about a system error code.
| string | Detailed information about the error code.| | string | Detailed information about the error code.|
**Example** **Example**
```js ```js
let errnum = 10; // 10 is a system error code. let errnum = 10; // 10 is a system error code.
let result = util.getErrorString(errnum); let result = util.getErrorString(errnum);
...@@ -154,6 +154,7 @@ Calls back an asynchronous function. In the callback, the first parameter indica ...@@ -154,6 +154,7 @@ Calls back an asynchronous function. In the callback, the first parameter indica
| Function | Callback, in which the first parameter indicates the cause of the rejection (the value is **null** if the promise has been resolved) and the second parameter indicates the resolved value.| | Function | Callback, in which the first parameter indicates the cause of the rejection (the value is **null** if the promise has been resolved) and the second parameter indicates the resolved value.|
**Example** **Example**
```js ```js
async function promiseFn() { async function promiseFn() {
return Promise.reject('value'); return Promise.reject('value');
...@@ -187,6 +188,7 @@ Processes an asynchronous function and returns a promise. ...@@ -187,6 +188,7 @@ Processes an asynchronous function and returns a promise.
| Function | Function in the error-first style (that is, **(err, value) =>...** is called as the last parameter) and the promise.| | Function | Function in the error-first style (that is, **(err, value) =>...** is called as the last parameter) and the promise.|
**Example** **Example**
```js ```js
function aysnFun(str1, str2) { function aysnFun(str1, str2) {
if (typeof str1 === 'object' && typeof str2 === 'object') { if (typeof str1 === 'object' && typeof str2 === 'object') {
...@@ -205,11 +207,11 @@ Processes an asynchronous function and returns a promise. ...@@ -205,11 +207,11 @@ Processes an asynchronous function and returns a promise.
promiseWrapper(original: (err: Object, value: Object) =&gt; void): Object promiseWrapper(original: (err: Object, value: Object) =&gt; void): Object
Processes an asynchronous function and returns a promise.
> **NOTE** > **NOTE**
> >
> This API is deprecated since API version 9. You are advised to use **[util.promisify9+](#utilpromisify9)** instead. > This API is unavailable. You are advised to use [util.promisify<sup>9+</sup>](#utilpromisify9) instead.
Processes an asynchronous function and returns a promise.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -246,6 +248,7 @@ Uses a secure random number generator to generate a random universally unique id ...@@ -246,6 +248,7 @@ Uses a secure random number generator to generate a random universally unique id
| string | A string representing the UUID generated.| | string | A string representing the UUID generated.|
**Example** **Example**
```js ```js
let uuid = util.randomUUID(true); let uuid = util.randomUUID(true);
console.log("RFC 4122 Version 4 UUID:" + uuid); console.log("RFC 4122 Version 4 UUID:" + uuid);
...@@ -274,6 +277,7 @@ Uses a secure random number generator to generate a random binary UUID of RFC 41 ...@@ -274,6 +277,7 @@ Uses a secure random number generator to generate a random binary UUID of RFC 41
| Uint8Array | A Uint8Array value representing the UUID generated.| | Uint8Array | A Uint8Array value representing the UUID generated.|
**Example** **Example**
```js ```js
let uuid = util.randomBinaryUUID(true); let uuid = util.randomBinaryUUID(true);
console.log(JSON.stringify(uuid)); console.log(JSON.stringify(uuid));
...@@ -302,6 +306,7 @@ Parses a UUID from a string, as described in RFC 4122 version 4. ...@@ -302,6 +306,7 @@ Parses a UUID from a string, as described in RFC 4122 version 4.
| Uint8Array | A Uint8Array value representing the UUID parsed. If the parsing fails, **SyntaxError** is thrown.| | Uint8Array | A Uint8Array value representing the UUID parsed. If the parsing fails, **SyntaxError** is thrown.|
**Example** **Example**
```js ```js
let uuid = util.parseUUID("84bdf796-66cc-4655-9b89-d6218d100f9c"); let uuid = util.parseUUID("84bdf796-66cc-4655-9b89-d6218d100f9c");
console.log(JSON.stringify(uuid)); console.log(JSON.stringify(uuid));
...@@ -335,6 +340,8 @@ create(encoding?: string,options?: { fatal?: boolean; ignoreBOM?: boolean },): T ...@@ -335,6 +340,8 @@ create(encoding?: string,options?: { fatal?: boolean; ignoreBOM?: boolean },): T
Creates a **TextDecoder** object. It provides the same function as the deprecated argument constructor. Creates a **TextDecoder** object. It provides the same function as the deprecated argument constructor.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
...@@ -342,7 +349,7 @@ Creates a **TextDecoder** object. It provides the same function as the deprecate ...@@ -342,7 +349,7 @@ Creates a **TextDecoder** object. It provides the same function as the deprecate
| encoding | string | No | Encoding format. | | encoding | string | No | Encoding format. |
| options | Object | No | Encoding-related options, which include **fatal** and **ignoreBOM**.| | options | Object | No | Encoding-related options, which include **fatal** and **ignoreBOM**.|
**Table 1.1** options **Table 1.1** options
| Name | Type| Mandatory| Description | | Name | Type| Mandatory| Description |
| --------- | -------- | ---- | ------------------ | | --------- | -------- | ---- | ------------------ |
...@@ -351,21 +358,21 @@ Creates a **TextDecoder** object. It provides the same function as the deprecate ...@@ -351,21 +358,21 @@ Creates a **TextDecoder** object. It provides the same function as the deprecate
**Example** **Example**
```js ```js
let textDecoder = new util.TextDecoder() let textDecoder = new util.TextDecoder()
textDecoder.create('utf-8', { ignoreBOM : true }); textDecoder.create('utf-8', { ignoreBOM : true });
``` ```
### constructor<sup>(deprecated)</sup> ### constructor<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [constructor9+](#constructor9) instead.
constructor(encoding?: string, options?: { fatal?: boolean; ignoreBOM?: boolean },) constructor(encoding?: string, options?: { fatal?: boolean; ignoreBOM?: boolean },)
A constructor used to create a **TextDecoder** object. A constructor used to create a **TextDecoder** object.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [constructor<sup>9+</sup>](#constructor9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -383,6 +390,7 @@ A constructor used to create a **TextDecoder** object. ...@@ -383,6 +390,7 @@ A constructor used to create a **TextDecoder** object.
| ignoreBOM | boolean | No| Whether to ignore the BOM.| | ignoreBOM | boolean | No| Whether to ignore the BOM.|
**Example** **Example**
```js ```js
let textDecoder = new util.TextDecoder("utf-8",{ignoreBOM: true}); let textDecoder = new util.TextDecoder("utf-8",{ignoreBOM: true});
``` ```
...@@ -402,7 +410,7 @@ Decodes the input content. ...@@ -402,7 +410,7 @@ Decodes the input content.
| input | Uint8Array | Yes| Uint8Array to decode.| | input | Uint8Array | Yes| Uint8Array to decode.|
| options | Object | No| Options related to decoding.| | options | Object | No| Options related to decoding.|
**Table 2** options **Table 2** options
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -415,6 +423,7 @@ Decodes the input content. ...@@ -415,6 +423,7 @@ Decodes the input content.
| string | Data decoded.| | string | Data decoded.|
**Example** **Example**
```js ```js
let textDecoder = new util.TextDecoder("utf-8",{ignoreBOM: true}); let textDecoder = new util.TextDecoder("utf-8",{ignoreBOM: true});
let result = new Uint8Array(6); let result = new Uint8Array(6);
...@@ -445,7 +454,7 @@ Decodes the input content. ...@@ -445,7 +454,7 @@ Decodes the input content.
| input | Uint8Array | Yes| Uint8Array to decode.| | input | Uint8Array | Yes| Uint8Array to decode.|
| options | Object | No| Options related to decoding.| | options | Object | No| Options related to decoding.|
**Table 2** options **Table 2** options
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -458,6 +467,7 @@ Decodes the input content. ...@@ -458,6 +467,7 @@ Decodes the input content.
| string | Data decoded.| | string | Data decoded.|
**Example** **Example**
```js ```js
let textDecoder = new util.TextDecoder("utf-8",{ignoreBOM: true}); let textDecoder = new util.TextDecoder("utf-8",{ignoreBOM: true});
let result = new Uint8Array(6); let result = new Uint8Array(6);
...@@ -493,6 +503,7 @@ A constructor used to create a **TextEncoder** object. ...@@ -493,6 +503,7 @@ A constructor used to create a **TextEncoder** object.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Example** **Example**
```js ```js
let textEncoder = new util.TextEncoder(); let textEncoder = new util.TextEncoder();
``` ```
...@@ -509,7 +520,7 @@ Encodes the input content. ...@@ -509,7 +520,7 @@ Encodes the input content.
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------ | | ------ | ------ | ---- | ------------------ |
| input | string | Yes | String to encode.| | input | string | No | String to encode.|
**Return value** **Return value**
...@@ -528,21 +539,21 @@ result = textEncoder.encodeInto("\uD800¥¥"); ...@@ -528,21 +539,21 @@ result = textEncoder.encodeInto("\uD800¥¥");
### encode<sup>(deprecated)</sup> ### encode<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [encodeInto9+](#encodeinto9) instead.
encode(input?: string): Uint8Array encode(input?: string): Uint8Array
Encodes the input content. Encodes the input content.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [encodeInto<sup>9+</sup>](#encodeinto9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| input | string | Yes| String to encode.| | input | string | No| String to encode.|
**Return value** **Return value**
...@@ -591,14 +602,14 @@ result = that.encodeInto('abcd', dest) ...@@ -591,14 +602,14 @@ result = that.encodeInto('abcd', dest)
### encodeInto<sup>(deprecated)</sup> ### encodeInto<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [encodeIntoUint8Array9+](#encodeintouint8array9) instead.
encodeInto(input: string, dest: Uint8Array, ): { read: number; written: number } encodeInto(input: string, dest: Uint8Array, ): { read: number; written: number }
Stores the UTF-8 encoded text. Stores the UTF-8 encoded text.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [encodeIntoUint8Array<sup>9+</sup>](#encodeintouint8array9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -635,13 +646,13 @@ A constructor used to create a **RationalNumber** object. ...@@ -635,13 +646,13 @@ A constructor used to create a **RationalNumber** object.
**Example** **Example**
```js ```js
let rationalNumber = new util.RationalNumber(); let rationalNumber = new util.RationalNumber();
``` ```
### parseRationalNumber<sup>9+</sup> ### parseRationalNumber<sup>9+</sup>
parseRationalNumber(numerator: number,denominator: number) parseRationalNumber(numerator: number,denominator: number): RationalNumber
Parses a rational number. Previously, this processing is an internal action of the deprecated constructor. Parses a rational number. Previously, this processing is an internal action of the deprecated constructor.
...@@ -656,21 +667,20 @@ Parses a rational number. Previously, this processing is an internal action of t ...@@ -656,21 +667,20 @@ Parses a rational number. Previously, this processing is an internal action of t
**Example** **Example**
```js ```js
let rationalNumber = new util.RationalNumber(); let rationalNumber = util.RationalNumber.parseRationalNumber(1,2)
rationalNumber.parseRationalNumber(1,2) ```
```
### constructor<sup>(deprecated)</sup> ### constructor<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [constructor9+](#constructor9) instead.
constructor(numerator: number,denominator: number) constructor(numerator: number,denominator: number)
A constructor used to create a **RationalNumber** object. A constructor used to create a **RationalNumber** object.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [constructor<sup>9+</sup>](#constructor9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -682,9 +692,9 @@ A constructor used to create a **RationalNumber** object. ...@@ -682,9 +692,9 @@ A constructor used to create a **RationalNumber** object.
**Example** **Example**
```js ```js
let rationalNumber = new util.RationalNumber(1,2); let rationalNumber = new util.RationalNumber(1,2);
``` ```
### createRationalFromString<sup>8+</sup> ### createRationalFromString<sup>8+</sup>
...@@ -707,10 +717,11 @@ Creates a **RationalNumber** object based on the given string. ...@@ -707,10 +717,11 @@ Creates a **RationalNumber** object based on the given string.
| object | **RationalNumber** object created.| | object | **RationalNumber** object created.|
**Example** **Example**
```js
let rationalNumber = new util.RationalNumber(1,2); ```js
let rational = util.RationalNumber.createRationalFromString("3/4"); let rationalNumber = new util.RationalNumber(1,2);
``` let rational = util.RationalNumber.createRationalFromString("3/4");
```
### compare<sup>9+</sup> ### compare<sup>9+</sup>
...@@ -740,16 +751,16 @@ let rational = util.RationalNumber.createRationalFromString("3/4"); ...@@ -740,16 +751,16 @@ let rational = util.RationalNumber.createRationalFromString("3/4");
let result = rationalNumber.compare(rational); let result = rationalNumber.compare(rational);
``` ```
### compareTo<sup>8+</sup><sup>(deprecated)</sup> ### compareTo<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [compare9+](#compare9) instead.
compareTo​(another: RationalNumber): number​ compareTo​(another: RationalNumber): number​
Compares this **RationalNumber** object with a given object. Compares this **RationalNumber** object with a given object.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [compare<sup>9+</sup>](#compare9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -765,11 +776,12 @@ Compares this **RationalNumber** object with a given object. ...@@ -765,11 +776,12 @@ Compares this **RationalNumber** object with a given object.
| number | Returns **0** if the two objects are equal; returns **1** if the given object is less than this object; return **-1** if the given object is greater than this object.| | number | Returns **0** if the two objects are equal; returns **1** if the given object is less than this object; return **-1** if the given object is greater than this object.|
**Example** **Example**
```js
let rationalNumber = new util.RationalNumber(1,2); ```js
let rational = util.RationalNumber.createRationalFromString("3/4"); let rationalNumber = new util.RationalNumber(1,2);
let result = rationalNumber.compareTo(rational); let rational = util.RationalNumber.createRationalFromString("3/4");
``` let result = rationalNumber.compareTo(rational);
```
### valueOf<sup>8+</sup> ### valueOf<sup>8+</sup>
...@@ -786,10 +798,11 @@ Obtains the value of this **RationalNumber** object as an integer or a floating- ...@@ -786,10 +798,11 @@ Obtains the value of this **RationalNumber** object as an integer or a floating-
| number | An integer or a floating-point number.| | number | An integer or a floating-point number.|
**Example** **Example**
```js
let rationalNumber = new util.RationalNumber(1,2); ```js
let result = rationalNumber.valueOf(); let rationalNumber = new util.RationalNumber(1,2);
``` let result = rationalNumber.valueOf();
```
### equals<sup>8+</sup> ### equals<sup>8+</sup>
...@@ -812,11 +825,12 @@ Checks whether this **RationalNumber** object equals the given object. ...@@ -812,11 +825,12 @@ Checks whether this **RationalNumber** object equals the given object.
| boolean | Returns **true** if the two objects are equal; returns **false** otherwise.| | boolean | Returns **true** if the two objects are equal; returns **false** otherwise.|
**Example** **Example**
```js
let rationalNumber = new util.RationalNumber(1,2); ```js
let rational = util.RationalNumber.createRationalFromString("3/4"); let rationalNumber = new util.RationalNumber(1,2);
let result = rationalNumber.equals(rational); let rational = util.RationalNumber.createRationalFromString("3/4");
``` let result = rationalNumber.equals(rational);
```
### getCommonFactor<sup>9+</sup> ### getCommonFactor<sup>9+</sup>
...@@ -841,20 +855,21 @@ Obtains the greatest common divisor of two specified integers. ...@@ -841,20 +855,21 @@ Obtains the greatest common divisor of two specified integers.
**Example** **Example**
```js ```js
let rationalNumber = new util.RationalNumber(1,2); let rationalNumber = new util.RationalNumber(1,2);
let result = util.RationalNumber.getCommonFactor(4,6); let result = util.RationalNumber.getCommonFactor(4,6);
``` ```
### getCommonDivisor<sup>(deprecated)</sup> ### getCommonDivisor<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [getCommonFactor9+](#getcommonfactor9) instead.
static getCommonDivisor​(number1: number,number2: number): number static getCommonDivisor​(number1: number,number2: number): number
Obtains the greatest common divisor of two specified integers. Obtains the greatest common divisor of two specified integers.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getCommonFactor<sup>9+</sup>](#getcommonfactor9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -871,10 +886,11 @@ Obtains the greatest common divisor of two specified integers. ...@@ -871,10 +886,11 @@ Obtains the greatest common divisor of two specified integers.
| number | Greatest common divisor obtained.| | number | Greatest common divisor obtained.|
**Example** **Example**
```js
let rationalNumber = new util.RationalNumber(1,2); ```js
let result = util.RationalNumber.getCommonDivisor(4,6); let rationalNumber = new util.RationalNumber(1,2);
``` let result = util.RationalNumber.getCommonDivisor(4,6);
```
### getNumerator<sup>8+</sup> ### getNumerator<sup>8+</sup>
...@@ -891,10 +907,11 @@ Obtains the numerator of this **RationalNumber** object. ...@@ -891,10 +907,11 @@ Obtains the numerator of this **RationalNumber** object.
| number | Numerator of this **RationalNumber** object.| | number | Numerator of this **RationalNumber** object.|
**Example** **Example**
```js
let rationalNumber = new util.RationalNumber(1,2); ```js
let result = rationalNumber.getNumerator(); let rationalNumber = new util.RationalNumber(1,2);
``` let result = rationalNumber.getNumerator();
```
### getDenominator<sup>8+</sup> ### getDenominator<sup>8+</sup>
...@@ -911,10 +928,11 @@ Obtains the denominator of this **RationalNumber** object. ...@@ -911,10 +928,11 @@ Obtains the denominator of this **RationalNumber** object.
| number | Denominator of this **RationalNumber** object.| | number | Denominator of this **RationalNumber** object.|
**Example** **Example**
```js
let rationalNumber = new util.RationalNumber(1,2); ```js
let result = rationalNumber.getDenominator(); let rationalNumber = new util.RationalNumber(1,2);
``` let result = rationalNumber.getDenominator();
```
### isZero<sup>8+</sup> ### isZero<sup>8+</sup>
...@@ -931,10 +949,11 @@ Checks whether this **RationalNumber** object is **0**. ...@@ -931,10 +949,11 @@ Checks whether this **RationalNumber** object is **0**.
| boolean | Returns **true** if the value of this **RationalNumber** object is **0**; returns **false** otherwise.| | boolean | Returns **true** if the value of this **RationalNumber** object is **0**; returns **false** otherwise.|
**Example** **Example**
```js
let rationalNumber = new util.RationalNumber(1,2); ```js
let result = rationalNumber.isZero(); let rationalNumber = new util.RationalNumber(1,2);
``` let result = rationalNumber.isZero();
```
### isNaN<sup>8+</sup> ### isNaN<sup>8+</sup>
...@@ -951,10 +970,11 @@ Checks whether this **RationalNumber** object is a Not a Number (NaN). ...@@ -951,10 +970,11 @@ Checks whether this **RationalNumber** object is a Not a Number (NaN).
| boolean | Returns **true** if this **RationalNumber** object is a NaN (the denominator and numerator are both **0**); returns **false** otherwise.| | boolean | Returns **true** if this **RationalNumber** object is a NaN (the denominator and numerator are both **0**); returns **false** otherwise.|
**Example** **Example**
```js
let rationalNumber = new util.RationalNumber(1,2); ```js
let result = rationalNumber.isNaN(); let rationalNumber = new util.RationalNumber(1,2);
``` let result = rationalNumber.isNaN();
```
### isFinite<sup>8+</sup> ### isFinite<sup>8+</sup>
...@@ -971,10 +991,11 @@ Checks whether this **RationalNumber** object represents a finite value. ...@@ -971,10 +991,11 @@ Checks whether this **RationalNumber** object represents a finite value.
| boolean | Returns **true** if this **RationalNumber** object represents a finite value (the denominator is not **0**); returns **false** otherwise.| | boolean | Returns **true** if this **RationalNumber** object represents a finite value (the denominator is not **0**); returns **false** otherwise.|
**Example** **Example**
```js
let rationalNumber = new util.RationalNumber(1,2); ```js
let result = rationalNumber.isFinite(); let rationalNumber = new util.RationalNumber(1,2);
``` let result = rationalNumber.isFinite();
```
### toString<sup>8+</sup> ### toString<sup>8+</sup>
...@@ -991,10 +1012,11 @@ Obtains the string representation of this **RationalNumber** object. ...@@ -991,10 +1012,11 @@ Obtains the string representation of this **RationalNumber** object.
| string | Returns **NaN** if the numerator and denominator of this object are both **0**; returns a string in Numerator/Denominator format otherwise, for example, **3/5**.| | string | Returns **NaN** if the numerator and denominator of this object are both **0**; returns a string in Numerator/Denominator format otherwise, for example, **3/5**.|
**Example** **Example**
```js
let rationalNumber = new util.RationalNumber(1,2); ```js
let result = rationalNumber.toString(); let rationalNumber = new util.RationalNumber(1,2);
``` let result = rationalNumber.toString();
```
## LRUCache<sup>9+</sup> ## LRUCache<sup>9+</sup>
...@@ -1005,22 +1027,22 @@ Obtains the string representation of this **RationalNumber** object. ...@@ -1005,22 +1027,22 @@ Obtains the string representation of this **RationalNumber** object.
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| ------ | ------ | ---- | ---- | ---------------------- | | ------ | ------ | ---- | ---- | ---------------------- |
| length | number | Yes | No | Total number of values in this buffer. | | length | number | Yes | No | Total number of values in this cache.|
**Example** **Example**
```js ```js
let pro = new util.LRUCache(); let pro = new util.LRUCache();
pro.put(2,10); pro.put(2,10);
pro.put(1,8); pro.put(1,8);
let result = pro.length; let result = pro.length;
``` ```
### constructor<sup>9+</sup> ### constructor<sup>9+</sup>
constructor(capacity?: number) constructor(capacity?: number)
A constructor used to create a **LruBuffer** instance. The default capacity of the buffer is 64. A constructor used to create a **LruCache** instance. The default capacity of the cache is 64.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -1028,20 +1050,20 @@ A constructor used to create a **LruBuffer** instance. The default capacity of t ...@@ -1028,20 +1050,20 @@ A constructor used to create a **LruBuffer** instance. The default capacity of t
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ---------------------------- | | -------- | ------ | ---- | ---------------------------- |
| capacity | number | No | Capacity of the **LruBuffer** to create.| | capacity | number | No | Capacity of the **LruCache** to create.|
**Example** **Example**
```js ```js
let lrubuffer= new util.LRUCache(); let lrubuffer= new util.LRUCache();
``` ```
### updateCapacity<sup>9+</sup> ### updateCapacity<sup>9+</sup>
updateCapacity(newCapacity: number): void updateCapacity(newCapacity: number): void
Changes the **LruBuffer** capacity. If the new capacity is less than or equal to **0**, an exception will be thrown. Changes the **LruCache** capacity. If the new capacity is less than or equal to **0**, an exception will be thrown.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -1049,21 +1071,21 @@ Changes the **LruBuffer** capacity. If the new capacity is less than or equal to ...@@ -1049,21 +1071,21 @@ Changes the **LruBuffer** capacity. If the new capacity is less than or equal to
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | ------ | ---- | ---------------------------- | | ----------- | ------ | ---- | ---------------------------- |
| newCapacity | number | Yes | New capacity of the **LruBuffer**.| | newCapacity | number | Yes | New capacity of the **LruCache**.|
**Example** **Example**
```js ```js
let pro = new util.LRUCache(); let pro = new util.LRUCache();
let result = pro.updateCapacity(100); let result = pro.updateCapacity(100);
``` ```
### toString<sup>9+</sup> ### toString<sup>9+</sup>
toString(): string toString(): string
Obtains the string representation of this **LruBuffer** object. Obtains the string representation of this **LruCache** object.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -1071,24 +1093,24 @@ Obtains the string representation of this **LruBuffer** object. ...@@ -1071,24 +1093,24 @@ Obtains the string representation of this **LruBuffer** object.
| Type | Description | | Type | Description |
| ------ | -------------------------- | | ------ | -------------------------- |
| string | String representation of this **LruBuffer** object.| | string | String representation of this **LruCache** object.|
**Example** **Example**
```js ```js
let pro = new util.LRUCache(); let pro = new util.LRUCache();
pro.put(2,10); pro.put(2,10);
pro.get(2); pro.get(2);
pro.remove(20); pro.remove(20);
let result = pro.toString(); let result = pro.toString();
``` ```
### getCapacity<sup>9+</sup> ### getCapacity<sup>9+</sup>
getCapacity(): number getCapacity(): number
Obtains the capacity of this buffer. Obtains the capacity of this cache.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -1096,7 +1118,7 @@ Obtains the capacity of this buffer. ...@@ -1096,7 +1118,7 @@ Obtains the capacity of this buffer.
| Type | Description | | Type | Description |
| ------ | ---------------------- | | ------ | ---------------------- |
| number | Capacity of this buffer.| | number | Capacity of this cache.|
**Example** **Example**
...@@ -1110,7 +1132,7 @@ let result = pro.getCapacity(); ...@@ -1110,7 +1132,7 @@ let result = pro.getCapacity();
clear(): void clear(): void
Clears key-value pairs from this buffer. The **afterRemoval()** method will be called to perform subsequent operations. Clears key-value pairs from this cache. The **afterRemoval()** method will be called to perform subsequent operations.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -1175,7 +1197,7 @@ let result = pro.getMissCount(); ...@@ -1175,7 +1197,7 @@ let result = pro.getMissCount();
getRemovalCount(): number getRemovalCount(): number
Obtains the number of removals from this buffer. Obtains the number of removals from this cache.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -1183,7 +1205,7 @@ Obtains the number of removals from this buffer. ...@@ -1183,7 +1205,7 @@ Obtains the number of removals from this buffer.
| Type | Description | | Type | Description |
| ------ | -------------------------- | | ------ | -------------------------- |
| number | Number of removals from the buffer.| | number | Number of removals from the cache.|
**Example** **Example**
...@@ -1224,7 +1246,7 @@ let result = pro.getMatchCount(); ...@@ -1224,7 +1246,7 @@ let result = pro.getMatchCount();
getPutCount(): number getPutCount(): number
Obtains the number of additions to this buffer. Obtains the number of additions to this cache.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -1232,7 +1254,7 @@ Obtains the number of additions to this buffer. ...@@ -1232,7 +1254,7 @@ Obtains the number of additions to this buffer.
| Type | Description | | Type | Description |
| ------ | ---------------------------- | | ------ | ---------------------------- |
| number | Number of additions to the buffer.| | number | Number of additions to the cache.|
**Example** **Example**
...@@ -1247,7 +1269,7 @@ let result = pro.getPutCount(); ...@@ -1247,7 +1269,7 @@ let result = pro.getPutCount();
isEmpty(): boolean isEmpty(): boolean
Checks whether this buffer is empty. Checks whether this cache is empty.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -1255,7 +1277,7 @@ Checks whether this buffer is empty. ...@@ -1255,7 +1277,7 @@ Checks whether this buffer is empty.
| Type | Description | | Type | Description |
| ------- | ---------------------------------------- | | ------- | ---------------------------------------- |
| boolean | Returns **true** if the buffer does not contain any value.| | boolean | Returns **true** if the cache does not contain any value.|
**Example** **Example**
...@@ -1284,7 +1306,7 @@ Obtains the value of the specified key. ...@@ -1284,7 +1306,7 @@ Obtains the value of the specified key.
| Type | Description | | Type | Description |
| ------------------------ | ------------------------------------------------------------ | | ------------------------ | ------------------------------------------------------------ |
| V&nbsp;\|&nbsp;undefined | Returns the value of the key if a match is found in the buffer; returns **undefined** otherwise.| | V \| undefined | Returns the value of the key if a match is found in the cache; returns **undefined** otherwise.|
**Example** **Example**
...@@ -1299,7 +1321,7 @@ let result = pro.get(2); ...@@ -1299,7 +1321,7 @@ let result = pro.get(2);
put(key: K,value: V): V put(key: K,value: V): V
Adds a key-value pair to this buffer. Adds a key-value pair to this cache.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -1327,7 +1349,7 @@ let result = pro.put(2,10); ...@@ -1327,7 +1349,7 @@ let result = pro.put(2,10);
values(): V[] values(): V[]
Obtains all values in this buffer, listed from the most to the least recently accessed. Obtains all values in this cache, listed from the most to the least recently accessed.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -1335,7 +1357,7 @@ Obtains all values in this buffer, listed from the most to the least recently ac ...@@ -1335,7 +1357,7 @@ Obtains all values in this buffer, listed from the most to the least recently ac
| Type | Description | | Type | Description |
| --------- | ------------------------------------------------------------ | | --------- | ------------------------------------------------------------ |
| V&nbsp;[] | All values in the buffer, listed from the most to the least recently accessed.| | V&nbsp;[] | All values in the cache, listed from the most to the least recently accessed.|
**Example** **Example**
...@@ -1352,7 +1374,7 @@ let result = pro.values(); ...@@ -1352,7 +1374,7 @@ let result = pro.values();
keys(): K[] keys(): K[]
Obtains all keys in this buffer, listed from the most to the least recently accessed. Obtains all keys in this cache, listed from the most to the least recently accessed.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -1360,7 +1382,7 @@ Obtains all keys in this buffer, listed from the most to the least recently acce ...@@ -1360,7 +1382,7 @@ Obtains all keys in this buffer, listed from the most to the least recently acce
| Type | Description | | Type | Description |
| --------- | ------------------------------------------------------------ | | --------- | ------------------------------------------------------------ |
| K&nbsp;[] | All keys in the buffer, listed from the most to the least recently accessed.| | K&nbsp;[] | All keys in the cache, listed from the most to the least recently accessed.|
**Example** **Example**
...@@ -1375,7 +1397,7 @@ let result = pro.keys(); ...@@ -1375,7 +1397,7 @@ let result = pro.keys();
remove(key: K): V | undefined remove(key: K): V | undefined
Removes the specified key and its value from this buffer. Removes the specified key and its value from this cache.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -1389,7 +1411,7 @@ Removes the specified key and its value from this buffer. ...@@ -1389,7 +1411,7 @@ Removes the specified key and its value from this buffer.
| Type | Description | | Type | Description |
| ------------------------ | ------------------------------------------------------------ | | ------------------------ | ------------------------------------------------------------ |
| V&nbsp;\|&nbsp;undefined | Returns an **Optional** object containing the removed key-value pair if the key exists in the buffer; returns an empty **Optional** object otherwise. If the key is null, an exception will be thrown.| | V&nbsp;\|&nbsp;undefined | Returns an **Optional** object containing the removed key-value pair if the key exists in the cache; returns an empty **Optional** object otherwise. If the key is null, an exception will be thrown.|
**Example** **Example**
...@@ -1412,10 +1434,10 @@ Performs subsequent operations after a value is removed. ...@@ -1412,10 +1434,10 @@ Performs subsequent operations after a value is removed.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------- | ---- | ------------------------------------------------------------ | | -------- | ------- | ---- | ------------------------------------------------------------ |
| isEvict | boolean | No | Whether the buffer capacity is insufficient. If the value is **true**, this method is called due to insufficient capacity. | | isEvict | boolean | Yes | Whether the cache capacity is insufficient. If the value is **true**, this method is called due to insufficient capacity. |
| key | K | Yes | Key removed. | | key | K | Yes | Key removed. |
| value | V | Yes | Value removed. | | value | V | Yes | Value removed. |
| newValue | V | No | New value for the key if the **put()** method is called and the key to be added already exists. In other cases, this parameter is left blank.| | newValue | V | Yes | New value for the key if the **put()** method is called and the key to be added already exists. In other cases, this parameter is left blank.|
**Example** **Example**
...@@ -1442,30 +1464,31 @@ lru.afterRemoval(false,10,30,null); ...@@ -1442,30 +1464,31 @@ lru.afterRemoval(false,10,30,null);
### contains<sup>9+</sup> ### contains<sup>9+</sup>
contains(key: K): boolean contains(key: object): boolean
Checks whether this buffer contains the specified key. Checks whether this cache contains the specified key.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ---- | ---- | ---------------- | | ------ | ------ | ---- | ---------------- |
| key | K | Yes | Key to check.| | key | object | Yes | Key to check.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ------------------------------------------ | | ------- | ------------------------------------------ |
| boolean | Returns **true** if the buffer contains the specified key; returns **false** otherwise.| | boolean | Returns **true** if the cache contains the specified key; returns **false** otherwise.|
**Example** **Example**
```js ```js
let pro = new util.LRUCache(); let pro = new util.LRUCache();
pro.put(2,10); pro.put(2,10);
let result = pro.contains(20); let obj = {1:"key"};
let result = pro.contains(obj);
``` ```
...@@ -1545,7 +1568,7 @@ let result = pro[Symbol.iterator](); ...@@ -1545,7 +1568,7 @@ let result = pro[Symbol.iterator]();
> **NOTE** > **NOTE**
> >
> This API is deprecated since API version 9. You are advised to use [LRUCache9+](#lrucache9) instead. > This API is supported since API version 8 and deprecated since API version 9. You are advised to use [LRUCache<sup>9+</sup>](#lrucache9) instead.
### Attributes ### Attributes
...@@ -1556,6 +1579,7 @@ let result = pro[Symbol.iterator](); ...@@ -1556,6 +1579,7 @@ let result = pro[Symbol.iterator]();
| length | number | Yes| No| Total number of values in this buffer.| | length | number | Yes| No| Total number of values in this buffer.|
**Example** **Example**
```js ```js
let pro = new util.LruBuffer(); let pro = new util.LruBuffer();
pro.put(2,10); pro.put(2,10);
...@@ -1565,14 +1589,14 @@ let result = pro[Symbol.iterator](); ...@@ -1565,14 +1589,14 @@ let result = pro[Symbol.iterator]();
### constructor<sup>(deprecated)</sup> ### constructor<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [constructor9+](#constructor9) instead.
constructor(capacity?: number) constructor(capacity?: number)
A constructor used to create a **LruBuffer** instance. The default capacity of the buffer is 64. A constructor used to create a **LruBuffer** instance. The default capacity of the buffer is 64.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [constructor<sup>9+</sup>](#constructor9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -1582,20 +1606,21 @@ A constructor used to create a **LruBuffer** instance. The default capacity of t ...@@ -1582,20 +1606,21 @@ A constructor used to create a **LruBuffer** instance. The default capacity of t
| capacity | number | No| Capacity of the **LruBuffer** to create.| | capacity | number | No| Capacity of the **LruBuffer** to create.|
**Example** **Example**
```js ```js
let lrubuffer= new util.LruBuffer(); let lrubuffer= new util.LruBuffer();
``` ```
### updateCapacity<sup>(deprecated)</sup> ### updateCapacity<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [updateCapacity9+](#updatecapacity9) instead.
updateCapacity(newCapacity: number): void updateCapacity(newCapacity: number): void
Changes the **LruBuffer** capacity. If the new capacity is less than or equal to **0**, an exception will be thrown. Changes the **LruBuffer** capacity. If the new capacity is less than or equal to **0**, an exception will be thrown.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [updateCapacity<sup>9+</sup>](#updatecapacity9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -1605,6 +1630,7 @@ Changes the **LruBuffer** capacity. If the new capacity is less than or equal to ...@@ -1605,6 +1630,7 @@ Changes the **LruBuffer** capacity. If the new capacity is less than or equal to
| newCapacity | number | Yes| New capacity of the **LruBuffer**.| | newCapacity | number | Yes| New capacity of the **LruBuffer**.|
**Example** **Example**
```js ```js
let pro = new util.LruBuffer(); let pro = new util.LruBuffer();
let result = pro.updateCapacity(100); let result = pro.updateCapacity(100);
...@@ -1612,14 +1638,14 @@ Changes the **LruBuffer** capacity. If the new capacity is less than or equal to ...@@ -1612,14 +1638,14 @@ Changes the **LruBuffer** capacity. If the new capacity is less than or equal to
### toString<sup>(deprecated)</sup> ### toString<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [toString9+](#tostring9) instead.
toString(): string toString(): string
Obtains the string representation of this **LruBuffer** object. Obtains the string representation of this **LruBuffer** object.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [toString<sup>9+</sup>](#tostring9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
...@@ -1629,6 +1655,7 @@ Obtains the string representation of this **LruBuffer** object. ...@@ -1629,6 +1655,7 @@ Obtains the string representation of this **LruBuffer** object.
| string | String representation of this **LruBuffer** object.| | string | String representation of this **LruBuffer** object.|
**Example** **Example**
```js ```js
let pro = new util.LruBuffer(); let pro = new util.LruBuffer();
pro.put(2,10); pro.put(2,10);
...@@ -1639,14 +1666,14 @@ Obtains the string representation of this **LruBuffer** object. ...@@ -1639,14 +1666,14 @@ Obtains the string representation of this **LruBuffer** object.
### getCapacity<sup>(deprecated)</sup> ### getCapacity<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [getCapacity9+](#getcapacity9) instead.
getCapacity(): number getCapacity(): number
Obtains the capacity of this buffer. Obtains the capacity of this buffer.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getCapacity<sup>9+</sup>](#getcapacity9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
...@@ -1663,17 +1690,18 @@ Obtains the capacity of this buffer. ...@@ -1663,17 +1690,18 @@ Obtains the capacity of this buffer.
### clear<sup>(deprecated)</sup> ### clear<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [clear9+](#clear9) instead.
clear(): void clear(): void
Clears key-value pairs from this buffer. The **afterRemoval()** method will be called to perform subsequent operations. Clears key-value pairs from this buffer. The **afterRemoval()** method will be called to perform subsequent operations.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [clear<sup>9+</sup>](#clear9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Example** **Example**
```js ```js
let pro = new util.LruBuffer(); let pro = new util.LruBuffer();
pro.put(2,10); pro.put(2,10);
...@@ -1683,14 +1711,14 @@ Clears key-value pairs from this buffer. The **afterRemoval()** method will be c ...@@ -1683,14 +1711,14 @@ Clears key-value pairs from this buffer. The **afterRemoval()** method will be c
### getCreateCount<sup>(deprecated)</sup> ### getCreateCount<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [getCreateCount9+](#getcreatecount9) instead.
getCreateCount(): number getCreateCount(): number
Obtains the number of return values for **createDefault()**. Obtains the number of return values for **createDefault()**.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getCreateCount<sup>9+</sup>](#getcreatecount9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
...@@ -1700,6 +1728,7 @@ Obtains the number of return values for **createDefault()**. ...@@ -1700,6 +1728,7 @@ Obtains the number of return values for **createDefault()**.
| number | Number of return values for **createDefault()**.| | number | Number of return values for **createDefault()**.|
**Example** **Example**
```js ```js
let pro = new util.LruBuffer(); let pro = new util.LruBuffer();
pro.put(1,8); pro.put(1,8);
...@@ -1708,14 +1737,14 @@ Obtains the number of return values for **createDefault()**. ...@@ -1708,14 +1737,14 @@ Obtains the number of return values for **createDefault()**.
### getMissCount<sup>(deprecated)</sup> ### getMissCount<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [getMissCount9+](#getmisscount9) instead.
getMissCount(): number getMissCount(): number
Obtains the number of times that the queried values are mismatched. Obtains the number of times that the queried values are mismatched.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getMissCount<sup>9+</sup>](#getmisscount9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
...@@ -1725,6 +1754,7 @@ Obtains the number of times that the queried values are mismatched. ...@@ -1725,6 +1754,7 @@ Obtains the number of times that the queried values are mismatched.
| number | Number of times that the queried values are mismatched.| | number | Number of times that the queried values are mismatched.|
**Example** **Example**
```js ```js
let pro = new util.LruBuffer(); let pro = new util.LruBuffer();
pro.put(2,10); pro.put(2,10);
...@@ -1734,14 +1764,14 @@ Obtains the number of times that the queried values are mismatched. ...@@ -1734,14 +1764,14 @@ Obtains the number of times that the queried values are mismatched.
### getRemovalCount<sup>(deprecated)</sup> ### getRemovalCount<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [getRemovalCount9+](#getremovalcount9) instead.
getRemovalCount(): number getRemovalCount(): number
Obtains the number of removals from this buffer. Obtains the number of removals from this buffer.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getRemovalCount<sup>9+</sup>](#getremovalcount9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
...@@ -1751,6 +1781,7 @@ Obtains the number of removals from this buffer. ...@@ -1751,6 +1781,7 @@ Obtains the number of removals from this buffer.
| number | Number of removals from the buffer.| | number | Number of removals from the buffer.|
**Example** **Example**
```js ```js
let pro = new util.LruBuffer(); let pro = new util.LruBuffer();
pro.put(2,10); pro.put(2,10);
...@@ -1761,14 +1792,14 @@ Obtains the number of removals from this buffer. ...@@ -1761,14 +1792,14 @@ Obtains the number of removals from this buffer.
### getMatchCount<sup>(deprecated)</sup> ### getMatchCount<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [getMatchCount9+](#getmatchcount9) instead.
getMatchCount(): number getMatchCount(): number
Obtains the number of times that the queried values are matched. Obtains the number of times that the queried values are matched.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getMatchCount<sup>9+</sup>](#getmatchcount9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
...@@ -1778,6 +1809,7 @@ Obtains the number of times that the queried values are matched. ...@@ -1778,6 +1809,7 @@ Obtains the number of times that the queried values are matched.
| number | Number of times that the queried values are matched.| | number | Number of times that the queried values are matched.|
**Example** **Example**
```js ```js
let pro = new util.LruBuffer(); let pro = new util.LruBuffer();
pro.put(2,10); pro.put(2,10);
...@@ -1787,14 +1819,14 @@ Obtains the number of times that the queried values are matched. ...@@ -1787,14 +1819,14 @@ Obtains the number of times that the queried values are matched.
### getPutCount<sup>(deprecated)</sup> ### getPutCount<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [getPutCount9+](#getputcount9) instead.
getPutCount(): number getPutCount(): number
Obtains the number of additions to this buffer. Obtains the number of additions to this buffer.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getPutCount<sup>9+</sup>](#getputcount9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
...@@ -1804,6 +1836,7 @@ Obtains the number of additions to this buffer. ...@@ -1804,6 +1836,7 @@ Obtains the number of additions to this buffer.
| number | Number of additions to the buffer.| | number | Number of additions to the buffer.|
**Example** **Example**
```js ```js
let pro = new util.LruBuffer(); let pro = new util.LruBuffer();
pro.put(2,10); pro.put(2,10);
...@@ -1812,14 +1845,14 @@ Obtains the number of additions to this buffer. ...@@ -1812,14 +1845,14 @@ Obtains the number of additions to this buffer.
### isEmpty<sup>(deprecated)</sup> ### isEmpty<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [isEmpty9+](#isempty9) instead.
isEmpty(): boolean isEmpty(): boolean
Checks whether this buffer is empty. Checks whether this buffer is empty.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [isEmpty<sup>9+</sup>](#isempty9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
...@@ -1829,6 +1862,7 @@ Checks whether this buffer is empty. ...@@ -1829,6 +1862,7 @@ Checks whether this buffer is empty.
| boolean | Returns **true** if the buffer does not contain any value.| | boolean | Returns **true** if the buffer does not contain any value.|
**Example** **Example**
```js ```js
let pro = new util.LruBuffer(); let pro = new util.LruBuffer();
pro.put(2,10); pro.put(2,10);
...@@ -1837,14 +1871,14 @@ Checks whether this buffer is empty. ...@@ -1837,14 +1871,14 @@ Checks whether this buffer is empty.
### get<sup>(deprecated)</sup> ### get<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [get9+](#get9) instead.
get(key: K): V | undefined get(key: K): V | undefined
Obtains the value of the specified key. Obtains the value of the specified key.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [get<sup>9+</sup>](#get9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -1860,6 +1894,7 @@ Obtains the value of the specified key. ...@@ -1860,6 +1894,7 @@ Obtains the value of the specified key.
| V&nbsp;\|&nbsp;undefined | Returns the value of the key if a match is found in the buffer; returns **undefined** otherwise.| | V&nbsp;\|&nbsp;undefined | Returns the value of the key if a match is found in the buffer; returns **undefined** otherwise.|
**Example** **Example**
```js ```js
let pro = new util.LruBuffer(); let pro = new util.LruBuffer();
pro.put(2,10); pro.put(2,10);
...@@ -1868,14 +1903,14 @@ Obtains the value of the specified key. ...@@ -1868,14 +1903,14 @@ Obtains the value of the specified key.
### put<sup>(deprecated)</sup> ### put<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [put9+](#put9) instead.
put(key: K,value: V): V put(key: K,value: V): V
Adds a key-value pair to this buffer. Adds a key-value pair to this buffer.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [put<sup>9+</sup>](#put9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -1892,6 +1927,7 @@ Adds a key-value pair to this buffer. ...@@ -1892,6 +1927,7 @@ Adds a key-value pair to this buffer.
| V | Returns the existing value if the key already exists; returns the value added otherwise. If the key or value is null, an exception will be thrown. | | V | Returns the existing value if the key already exists; returns the value added otherwise. If the key or value is null, an exception will be thrown. |
**Example** **Example**
```js ```js
let pro = new util.LruBuffer(); let pro = new util.LruBuffer();
let result = pro.put(2,10); let result = pro.put(2,10);
...@@ -1899,14 +1935,14 @@ Adds a key-value pair to this buffer. ...@@ -1899,14 +1935,14 @@ Adds a key-value pair to this buffer.
### values<sup>(deprecated)</sup> ### values<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [values9+](#values9) instead.
values(): V[] values(): V[]
Obtains all values in this buffer, listed from the most to the least recently accessed. Obtains all values in this buffer, listed from the most to the least recently accessed.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [values<sup>9+</sup>](#values9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
...@@ -1916,6 +1952,7 @@ Obtains all values in this buffer, listed from the most to the least recently ac ...@@ -1916,6 +1952,7 @@ Obtains all values in this buffer, listed from the most to the least recently ac
| V&nbsp;[] | All values in the buffer, listed from the most to the least recently accessed.| | V&nbsp;[] | All values in the buffer, listed from the most to the least recently accessed.|
**Example** **Example**
```js ```js
let pro = new util.LruBuffer(); let pro = new util.LruBuffer();
pro.put(2,10); pro.put(2,10);
...@@ -1926,14 +1963,14 @@ Obtains all values in this buffer, listed from the most to the least recently ac ...@@ -1926,14 +1963,14 @@ Obtains all values in this buffer, listed from the most to the least recently ac
### keys<sup>(deprecated)</sup> ### keys<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [keys9+](#keys9) instead.
keys(): K[] keys(): K[]
Obtains all keys in this buffer, listed from the most to the least recently accessed. Obtains all keys in this buffer, listed from the most to the least recently accessed.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [keys<sup>9+</sup>](#keys9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
...@@ -1951,14 +1988,14 @@ Obtains all keys in this buffer, listed from the most to the least recently acce ...@@ -1951,14 +1988,14 @@ Obtains all keys in this buffer, listed from the most to the least recently acce
### remove<sup>(deprecated)</sup> ### remove<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [remove9+](#remove9) instead.
remove(key: K): V | undefined remove(key: K): V | undefined
Removes the specified key and its value from this buffer. Removes the specified key and its value from this buffer.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [remove<sup>9+</sup>](#remove9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -1982,26 +2019,27 @@ Removes the specified key and its value from this buffer. ...@@ -1982,26 +2019,27 @@ Removes the specified key and its value from this buffer.
### afterRemoval<sup>(deprecated)</sup> ### afterRemoval<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [afterRemoval9+](#afterremoval9) instead.
afterRemoval(isEvict: boolean,key: K,value: V,newValue: V): void afterRemoval(isEvict: boolean,key: K,value: V,newValue: V): void
Performs subsequent operations after a value is removed. Performs subsequent operations after a value is removed.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [afterRemoval<sup>9+</sup>](#afterremoval9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| isEvict | boolean | No| Whether the buffer capacity is insufficient. If the value is **true**, this method is called due to insufficient capacity.| | isEvict | boolean | Yes| Whether the buffer capacity is insufficient. If the value is **true**, this method is called due to insufficient capacity.|
| key | K | Yes| Key removed.| | key | K | Yes| Key removed.|
| value | V | Yes| Value removed.| | value | V | Yes| Value removed.|
| newValue | V | No| New value for the key if the **put()** method is called and the key to be added already exists. In other cases, this parameter is left blank.| | newValue | V | Yes| New value for the key if the **put()** method is called and the key to be added already exists. In other cases, this parameter is left blank.|
**Example** **Example**
```js ```js
let arr = []; let arr = [];
class ChildLruBuffer<K, V> extends util.LruBuffer<K, V> class ChildLruBuffer<K, V> extends util.LruBuffer<K, V>
...@@ -2024,14 +2062,15 @@ Performs subsequent operations after a value is removed. ...@@ -2024,14 +2062,15 @@ Performs subsequent operations after a value is removed.
### contains<sup>(deprecated)</sup> ### contains<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [contains9+](#contains9) instead.
contains(key: K): boolean contains(key: K): boolean
Checks whether this buffer contains the specified key. Checks whether this buffer contains the specified key.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [contains<sup>9+</sup>](#contains9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -2047,6 +2086,7 @@ Checks whether this buffer contains the specified key. ...@@ -2047,6 +2086,7 @@ Checks whether this buffer contains the specified key.
| boolean | Returns **true** if the buffer contains the specified key; returns **false** otherwise.| | boolean | Returns **true** if the buffer contains the specified key; returns **false** otherwise.|
**Example** **Example**
```js ```js
let pro = new util.LruBuffer(); let pro = new util.LruBuffer();
pro.put(2,10); pro.put(2,10);
...@@ -2055,14 +2095,14 @@ Checks whether this buffer contains the specified key. ...@@ -2055,14 +2095,14 @@ Checks whether this buffer contains the specified key.
### createDefault<sup>(deprecated)</sup> ### createDefault<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [createDefault9+](#createdefault9) instead.
createDefault(key: K): V createDefault(key: K): V
Creates a value if the value of the specified key is not available. Creates a value if the value of the specified key is not available.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [createDefault<sup>9+</sup>](#createdefault9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -2078,6 +2118,7 @@ Creates a value if the value of the specified key is not available. ...@@ -2078,6 +2118,7 @@ Creates a value if the value of the specified key is not available.
| V | Value of the key.| | V | Value of the key.|
**Example** **Example**
```js ```js
let pro = new util.LruBuffer(); let pro = new util.LruBuffer();
let result = pro.createDefault(50); let result = pro.createDefault(50);
...@@ -2085,14 +2126,14 @@ Creates a value if the value of the specified key is not available. ...@@ -2085,14 +2126,14 @@ Creates a value if the value of the specified key is not available.
### entries<sup>(deprecated)</sup> ### entries<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [entries9+](#entries9) instead.
entries(): IterableIterator&lt;[K,V]&gt; entries(): IterableIterator&lt;[K,V]&gt;
Obtains a new iterator object that contains all key-value pairs in this object. Obtains a new iterator object that contains all key-value pairs in this object.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [entries<sup>9+</sup>](#entries9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
...@@ -2102,6 +2143,7 @@ Obtains a new iterator object that contains all key-value pairs in this object. ...@@ -2102,6 +2143,7 @@ Obtains a new iterator object that contains all key-value pairs in this object.
| [K,&nbsp;V] | Iterable array.| | [K,&nbsp;V] | Iterable array.|
**Example** **Example**
```js ```js
let pro = new util.LruBuffer(); let pro = new util.LruBuffer();
pro.put(2,10); pro.put(2,10);
...@@ -2110,14 +2152,14 @@ Obtains a new iterator object that contains all key-value pairs in this object. ...@@ -2110,14 +2152,14 @@ Obtains a new iterator object that contains all key-value pairs in this object.
### [Symbol.iterator]<sup>(deprecated)</sup> ### [Symbol.iterator]<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [Symbol.iterator<sup>9+</sup>](#symboliterator9) instead.
[Symbol.iterator]\(): IterableIterator&lt;[K, V]&gt; [Symbol.iterator]\(): IterableIterator&lt;[K, V]&gt;
Obtains a two-dimensional array in key-value pairs. Obtains a two-dimensional array in key-value pairs.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [Symbol.iterator<sup>9+</sup>](#symboliterator9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
...@@ -2127,6 +2169,7 @@ Obtains a two-dimensional array in key-value pairs. ...@@ -2127,6 +2169,7 @@ Obtains a two-dimensional array in key-value pairs.
| [K,&nbsp;V] | Two-dimensional array in key-value pairs.| | [K,&nbsp;V] | Two-dimensional array in key-value pairs.|
**Example** **Example**
```js ```js
let pro = new util.LruBuffer(); let pro = new util.LruBuffer();
pro.put(2,10); pro.put(2,10);
...@@ -2138,6 +2181,7 @@ Obtains a two-dimensional array in key-value pairs. ...@@ -2138,6 +2181,7 @@ Obtains a two-dimensional array in key-value pairs.
Defines the type of values in a **Scope** object. The value type can be **ScopeComparable** or **number**. Defines the type of values in a **Scope** object. The value type can be **ScopeComparable** or **number**.
The values of the **ScopeComparable** type are used to implement the **compareTo** method. Therefore, ensure that the input parameters are comparable. The values of the **ScopeComparable** type are used to implement the **compareTo** method. Therefore, ensure that the input parameters are comparable.
```js ```js
interface ScopeComparable{ interface ScopeComparable{
compareTo(other: ScopeComparable): boolean; compareTo(other: ScopeComparable): boolean;
...@@ -2230,8 +2274,8 @@ Obtains the intersection of this **Scope** and the given **Scope**. ...@@ -2230,8 +2274,8 @@ Obtains the intersection of this **Scope** and the given **Scope**.
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------------------------------ | ---- | ------------------ | | ------ | ---------------------------- | ---- | ------------------ |
| range | [ScopeHelper9+](#scopehelper9) | Yes | **Scope** specified.| | range | [ScopeHelper](#scopehelper9) | Yes | **Scope** specified.|
**Return value** **Return value**
...@@ -2270,8 +2314,8 @@ Obtains the intersection of this **Scope** and the given lower and upper limits. ...@@ -2270,8 +2314,8 @@ Obtains the intersection of this **Scope** and the given lower and upper limits.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------------------ | ---------------------------------------- | | ---------------------------- | ---------------------------------------- |
| [ScopeHelper9+](#scopehelper9) | Intersection of this **Scope** and the given lower and upper limits.| | [ScopeHelper](#scopehelper9) | Intersection of this **Scope** and the given lower and upper limits.|
**Example** **Example**
...@@ -2351,8 +2395,8 @@ Obtains the union set of this **Scope** and the given lower and upper limits. ...@@ -2351,8 +2395,8 @@ Obtains the union set of this **Scope** and the given lower and upper limits.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------------------ | ------------------------------------ | | ---------------------------- | ------------------------------------ |
| [ScopeHelper9+](#scopehelper9) | Union set of this **Scope** and the given lower and upper limits.| | [ScopeHelper](#scopehelper9) | Union set of this **Scope** and the given lower and upper limits.|
**Example** **Example**
...@@ -2377,14 +2421,14 @@ Obtains the union set of this **Scope** and the given **Scope**. ...@@ -2377,14 +2421,14 @@ Obtains the union set of this **Scope** and the given **Scope**.
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------------------------------ | ---- | ------------------ | | ------ | ---------------------------- | ---- | ------------------ |
| range | [ScopeHelper9+](#scopehelper9) | Yes | **Scope** specified.| | range | [ScopeHelper](#scopehelper9) | Yes | **Scope** specified.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------------------ | ---------------------------------- | | ---------------------------- | ---------------------------------- |
| [ScopeHelper9+](#scopehelper9) | Union set of this **Scope** and the given **Scope**.| | [ScopeHelper](#scopehelper9) | Union set of this **Scope** and the given **Scope**.|
**Example** **Example**
...@@ -2416,8 +2460,8 @@ Obtains the union set of this **Scope** and the given value. ...@@ -2416,8 +2460,8 @@ Obtains the union set of this **Scope** and the given value.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------------------ | -------------------------------- | | ---------------------------- | -------------------------------- |
| [ScopeHelper9+](#scopehelper9) | Union set of this **Scope** and the given value.| | [ScopeHelper](#scopehelper9) | Union set of this **Scope** and the given value.|
**Example** **Example**
...@@ -2472,8 +2516,8 @@ Checks whether a range is within this **Scope**. ...@@ -2472,8 +2516,8 @@ Checks whether a range is within this **Scope**.
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------------------------------ | ---- | ------------------ | | ------ | ---------------------------- | ---- | ------------------ |
| range | [ScopeHelper9+](#scopehelper9) | Yes | **Scope** specified.| | range | [ScopeHelper](#scopehelper9) | Yes | **Scope** specified.|
**Return value** **Return value**
...@@ -2528,18 +2572,19 @@ let result = range.clamp(tempMiDF); ...@@ -2528,18 +2572,19 @@ let result = range.clamp(tempMiDF);
> **NOTE** > **NOTE**
> >
> This class is deprecated since API version 9. You are advised to use [ScopeHelper9+](#scopehelper9) instead. > This API is supported since API version 8 and deprecated since API version 9. You are advised to use [ScopeHelper<sup>9+</sup>](#scopehelper9) instead.
### constructor<sup>(deprecated)</sup> ### constructor<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [constructor9+](#constructor9) instead.
constructor(lowerObj: ScopeType, upperObj: ScopeType) constructor(lowerObj: ScopeType, upperObj: ScopeType)
A constructor used to create a **Scope** object with the specified upper and lower limits. A constructor used to create a **Scope** object with the specified upper and lower limits.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [constructor<sup>9+</sup>](#constructor9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -2558,14 +2603,14 @@ A constructor used to create a **Scope** object with the specified upper and low ...@@ -2558,14 +2603,14 @@ A constructor used to create a **Scope** object with the specified upper and low
### toString<sup>(deprecated)</sup> ### toString<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [toString9+](#tostring9) instead.
toString(): string toString(): string
Obtains a string representation that contains this **Scope**. Obtains a string representation that contains this **Scope**.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [toString<sup>9+</sup>](#tostring9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
...@@ -2575,6 +2620,7 @@ Obtains a string representation that contains this **Scope**. ...@@ -2575,6 +2620,7 @@ Obtains a string representation that contains this **Scope**.
| string | String representation containing the **Scope**.| | string | String representation containing the **Scope**.|
**Example** **Example**
```js ```js
let tempLower = new Temperature(30); let tempLower = new Temperature(30);
let tempUpper = new Temperature(40); let tempUpper = new Temperature(40);
...@@ -2584,14 +2630,14 @@ Obtains a string representation that contains this **Scope**. ...@@ -2584,14 +2630,14 @@ Obtains a string representation that contains this **Scope**.
### intersect<sup>(deprecated)</sup> ### intersect<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [intersect9+](#intersect9) instead.
intersect(range: Scope): Scope intersect(range: Scope): Scope
Obtains the intersection of this **Scope** and the given **Scope**. Obtains the intersection of this **Scope** and the given **Scope**.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [intersect<sup>9+</sup>](#intersect9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -2620,14 +2666,14 @@ Obtains the intersection of this **Scope** and the given **Scope**. ...@@ -2620,14 +2666,14 @@ Obtains the intersection of this **Scope** and the given **Scope**.
### intersect<sup>(deprecated)</sup> ### intersect<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [intersect9+](#intersect9) instead.
intersect(lowerObj:ScopeType,upperObj:ScopeType):Scope intersect(lowerObj:ScopeType,upperObj:ScopeType):Scope
Obtains the intersection of this **Scope** and the given lower and upper limits. Obtains the intersection of this **Scope** and the given lower and upper limits.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [intersect<sup>9+</sup>](#intersect9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -2644,6 +2690,7 @@ Obtains the intersection of this **Scope** and the given lower and upper limits. ...@@ -2644,6 +2690,7 @@ Obtains the intersection of this **Scope** and the given lower and upper limits.
| [Scope](#scopedeprecated) | Intersection of this **Scope** and the given lower and upper limits.| | [Scope](#scopedeprecated) | Intersection of this **Scope** and the given lower and upper limits.|
**Example** **Example**
```js ```js
let tempLower = new Temperature(30); let tempLower = new Temperature(30);
let tempUpper = new Temperature(40); let tempUpper = new Temperature(40);
...@@ -2655,14 +2702,14 @@ Obtains the intersection of this **Scope** and the given lower and upper limits. ...@@ -2655,14 +2702,14 @@ Obtains the intersection of this **Scope** and the given lower and upper limits.
### getUpper<sup>(deprecated)</sup> ### getUpper<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [getUpper9+](#getupper9) instead.
getUpper(): ScopeType getUpper(): ScopeType
Obtains the upper limit of this **Scope**. Obtains the upper limit of this **Scope**.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getUpper<sup>9+</sup>](#getupper9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
...@@ -2672,6 +2719,7 @@ Obtains the upper limit of this **Scope**. ...@@ -2672,6 +2719,7 @@ Obtains the upper limit of this **Scope**.
| [ScopeType](#scopetype8) | Upper limit of this **Scope**.| | [ScopeType](#scopetype8) | Upper limit of this **Scope**.|
**Example** **Example**
```js ```js
let tempLower = new Temperature(30); let tempLower = new Temperature(30);
let tempUpper = new Temperature(40); let tempUpper = new Temperature(40);
...@@ -2681,14 +2729,14 @@ Obtains the upper limit of this **Scope**. ...@@ -2681,14 +2729,14 @@ Obtains the upper limit of this **Scope**.
### getLower<sup>(deprecated)</sup> ### getLower<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [getLower9+](#getlower9) instead.
getLower(): ScopeType getLower(): ScopeType
Obtains the lower limit of this **Scope**. Obtains the lower limit of this **Scope**.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getLower<sup>9+</sup>](#getlower9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
...@@ -2698,6 +2746,7 @@ Obtains the lower limit of this **Scope**. ...@@ -2698,6 +2746,7 @@ Obtains the lower limit of this **Scope**.
| [ScopeType](#scopetype8) | Lower limit of this **Scope**.| | [ScopeType](#scopetype8) | Lower limit of this **Scope**.|
**Example** **Example**
```js ```js
let tempLower = new Temperature(30); let tempLower = new Temperature(30);
let tempUpper = new Temperature(40); let tempUpper = new Temperature(40);
...@@ -2707,14 +2756,14 @@ Obtains the lower limit of this **Scope**. ...@@ -2707,14 +2756,14 @@ Obtains the lower limit of this **Scope**.
### expand<sup>(deprecated)</sup> ### expand<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [expand9+](#expand9) instead.
expand(lowerObj: ScopeType,upperObj: ScopeType): Scope expand(lowerObj: ScopeType,upperObj: ScopeType): Scope
Obtains the union set of this **Scope** and the given lower and upper limits. Obtains the union set of this **Scope** and the given lower and upper limits.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [expand<sup>9+</sup>](#expand9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -2743,14 +2792,14 @@ Obtains the union set of this **Scope** and the given lower and upper limits. ...@@ -2743,14 +2792,14 @@ Obtains the union set of this **Scope** and the given lower and upper limits.
### expand<sup>(deprecated)</sup> ### expand<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [expand9+](#expand9) instead.
expand(range: Scope): Scope expand(range: Scope): Scope
Obtains the union set of this **Scope** and the given **Scope**. Obtains the union set of this **Scope** and the given **Scope**.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [expand<sup>9+</sup>](#expand9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -2766,6 +2815,7 @@ Obtains the union set of this **Scope** and the given **Scope**. ...@@ -2766,6 +2815,7 @@ Obtains the union set of this **Scope** and the given **Scope**.
| [Scope](#scopedeprecated) | Union set of this **Scope** and the given **Scope**.| | [Scope](#scopedeprecated) | Union set of this **Scope** and the given **Scope**.|
**Example** **Example**
```js ```js
let tempLower = new Temperature(30); let tempLower = new Temperature(30);
let tempUpper = new Temperature(40); let tempUpper = new Temperature(40);
...@@ -2778,14 +2828,14 @@ Obtains the union set of this **Scope** and the given **Scope**. ...@@ -2778,14 +2828,14 @@ Obtains the union set of this **Scope** and the given **Scope**.
### expand<sup>(deprecated)</sup> ### expand<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [expand9+](#expand9) instead.
expand(value: ScopeType): Scope expand(value: ScopeType): Scope
Obtains the union set of this **Scope** and the given value. Obtains the union set of this **Scope** and the given value.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [expand<sup>9+</sup>](#expand9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -2801,6 +2851,7 @@ Obtains the union set of this **Scope** and the given value. ...@@ -2801,6 +2851,7 @@ Obtains the union set of this **Scope** and the given value.
| [Scope](#scopedeprecated) | Union set of this **Scope** and the given value.| | [Scope](#scopedeprecated) | Union set of this **Scope** and the given value.|
**Example** **Example**
```js ```js
let tempLower = new Temperature(30); let tempLower = new Temperature(30);
let tempUpper = new Temperature(40); let tempUpper = new Temperature(40);
...@@ -2811,14 +2862,14 @@ Obtains the union set of this **Scope** and the given value. ...@@ -2811,14 +2862,14 @@ Obtains the union set of this **Scope** and the given value.
### contains<sup>(deprecated)</sup> ### contains<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [contains9+](#contains9) instead.
contains(value: ScopeType): boolean contains(value: ScopeType): boolean
Checks whether a value is within this **Scope**. Checks whether a value is within this **Scope**.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [contains<sup>9+</sup>](#contains9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -2834,6 +2885,7 @@ Checks whether a value is within this **Scope**. ...@@ -2834,6 +2885,7 @@ Checks whether a value is within this **Scope**.
| boolean | Returns **true** if the value is within this **Scope**; returns **false** otherwise.| | boolean | Returns **true** if the value is within this **Scope**; returns **false** otherwise.|
**Example** **Example**
```js ```js
let tempLower = new Temperature(30); let tempLower = new Temperature(30);
let tempUpper = new Temperature(40); let tempUpper = new Temperature(40);
...@@ -2844,14 +2896,14 @@ Checks whether a value is within this **Scope**. ...@@ -2844,14 +2896,14 @@ Checks whether a value is within this **Scope**.
### contains<sup>(deprecated)</sup> ### contains<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [contains9+](#contains9) instead.
contains(range: Scope): boolean contains(range: Scope): boolean
Checks whether a range is within this **Scope**. Checks whether a range is within this **Scope**.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [contains<sup>9+</sup>](#contains9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -2880,14 +2932,15 @@ Checks whether a range is within this **Scope**. ...@@ -2880,14 +2932,15 @@ Checks whether a range is within this **Scope**.
### clamp<sup>(deprecated)</sup> ### clamp<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [clamp9+](#clamp9) instead.
clamp(value: ScopeType): ScopeType clamp(value: ScopeType): ScopeType
Limits a value to this **Scope**. Limits a value to this **Scope**.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [clamp<sup>9+</sup>](#clamp9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -2903,6 +2956,7 @@ Limits a value to this **Scope**. ...@@ -2903,6 +2956,7 @@ Limits a value to this **Scope**.
| [ScopeType](#scopetype8) | Returns **lowerObj** if the specified value is less than the lower limit; returns **upperObj** if the specified value is greater than the upper limit; returns the specified value if it is within this **Scope**.| | [ScopeType](#scopetype8) | Returns **lowerObj** if the specified value is less than the lower limit; returns **upperObj** if the specified value is greater than the upper limit; returns the specified value if it is within this **Scope**.|
**Example** **Example**
```js ```js
let tempLower = new Temperature(30); let tempLower = new Temperature(30);
let tempUpper = new Temperature(40); let tempUpper = new Temperature(40);
...@@ -3117,35 +3171,36 @@ that.decode(array).then(val=>{ ...@@ -3117,35 +3171,36 @@ that.decode(array).then(val=>{
> **NOTE** > **NOTE**
> >
> This class is deprecated since API version 9. You are advised to use [Base64Helper9+](#base64helper9) instead. > This API is supported since API version 8 and deprecated since API version 9. You are advised to use [Base64Helper<sup>9+</sup>](#base64helper9) instead.
### constructor<sup>(deprecated)</sup> ### constructor<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [constructor9+](#constructor9) instead.
constructor() constructor()
A constructor used to create a **Base64** object. A constructor used to create a **Base64** object.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [constructor<sup>9+</sup>](#constructor9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Example** **Example**
```js ```js
let base64 = new util.Base64(); let base64 = new util.Base64();
``` ```
### encodeSync<sup>(deprecated)</sup> ### encodeSync<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [encodeSync9+](#encodesync9) instead.
encodeSync(src: Uint8Array): Uint8Array encodeSync(src: Uint8Array): Uint8Array
Encodes the input content. Encodes the input content.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [encodeSync<sup>9+</sup>](#encodesync9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -3170,14 +3225,14 @@ Encodes the input content. ...@@ -3170,14 +3225,14 @@ Encodes the input content.
### encodeToStringSync<sup>(deprecated)</sup> ### encodeToStringSync<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [encodeToStringSync9+](#encodetostringsync9) instead.
encodeToStringSync(src: Uint8Array): string encodeToStringSync(src: Uint8Array): string
Encodes the input content. Encodes the input content.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [encodeToStringSync<sup>9+</sup>](#encodetostringsync9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -3193,6 +3248,7 @@ Encodes the input content. ...@@ -3193,6 +3248,7 @@ Encodes the input content.
| string | String encoded from the Uint8Array.| | string | String encoded from the Uint8Array.|
**Example** **Example**
```js ```js
let that = new util.Base64(); let that = new util.Base64();
let array = new Uint8Array([115,49,51]); let array = new Uint8Array([115,49,51]);
...@@ -3201,14 +3257,14 @@ Encodes the input content. ...@@ -3201,14 +3257,14 @@ Encodes the input content.
### decodeSync<sup>(deprecated)</sup> ### decodeSync<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [decodeSync9+](#decodesync9) instead.
decodeSync(src: Uint8Array | string): Uint8Array decodeSync(src: Uint8Array | string): Uint8Array
Decodes the input content. Decodes the input content.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [decodeSync<sup>9+</sup>](#decodesync9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -3224,6 +3280,7 @@ Decodes the input content. ...@@ -3224,6 +3280,7 @@ Decodes the input content.
| Uint8Array | Uint8Array decoded.| | Uint8Array | Uint8Array decoded.|
**Example** **Example**
```js ```js
let that = new util.Base64(); let that = new util.Base64();
let buff = 'czEz'; let buff = 'czEz';
...@@ -3232,14 +3289,14 @@ Decodes the input content. ...@@ -3232,14 +3289,14 @@ Decodes the input content.
### encode<sup>(deprecated)</sup> ### encode<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [encode9+](#encode9) instead.
encode(src: Uint8Array): Promise&lt;Uint8Array&gt; encode(src: Uint8Array): Promise&lt;Uint8Array&gt;
Encodes the input content asynchronously. Encodes the input content asynchronously.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [encode<sup>9+</sup>](#encode9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -3255,6 +3312,7 @@ Encodes the input content asynchronously. ...@@ -3255,6 +3312,7 @@ Encodes the input content asynchronously.
| Promise&lt;Uint8Array&gt; | Uint8Array obtained after asynchronous encoding.| | Promise&lt;Uint8Array&gt; | Uint8Array obtained after asynchronous encoding.|
**Example** **Example**
```js ```js
let that = new util.Base64(); let that = new util.Base64();
let array = new Uint8Array([115,49,51]); let array = new Uint8Array([115,49,51]);
...@@ -3268,14 +3326,14 @@ Encodes the input content asynchronously. ...@@ -3268,14 +3326,14 @@ Encodes the input content asynchronously.
### encodeToString<sup>(deprecated)</sup> ### encodeToString<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [encodeToString9+](#encodetostring9) instead.
encodeToString(src: Uint8Array): Promise&lt;string&gt; encodeToString(src: Uint8Array): Promise&lt;string&gt;
Encodes the input content asynchronously. Encodes the input content asynchronously.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [encodeToString<sup>9+</sup>](#encodetostring9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -3291,6 +3349,7 @@ Encodes the input content asynchronously. ...@@ -3291,6 +3349,7 @@ Encodes the input content asynchronously.
| Promise&lt;string&gt; | String obtained after asynchronous encoding.| | Promise&lt;string&gt; | String obtained after asynchronous encoding.|
**Example** **Example**
```js ```js
let that = new util.Base64(); let that = new util.Base64();
let array = new Uint8Array([115,49,51]); let array = new Uint8Array([115,49,51]);
...@@ -3301,14 +3360,15 @@ Encodes the input content asynchronously. ...@@ -3301,14 +3360,15 @@ Encodes the input content asynchronously.
### decode<sup>(deprecated)</sup> ### decode<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [decode9+](#decode9) instead.
decode(src: Uint8Array | string): Promise&lt;Uint8Array&gt; decode(src: Uint8Array | string): Promise&lt;Uint8Array&gt;
Decodes the input content asynchronously. Decodes the input content asynchronously.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [decode<sup>9+</sup>](#decode9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
...@@ -3324,6 +3384,7 @@ Decodes the input content asynchronously. ...@@ -3324,6 +3384,7 @@ Decodes the input content asynchronously.
| Promise&lt;Uint8Array&gt; | Uint8Array obtained after asynchronous decoding.| | Promise&lt;Uint8Array&gt; | Uint8Array obtained after asynchronous decoding.|
**Example** **Example**
```js ```js
let that = new util.Base64(); let that = new util.Base64();
let array = new Uint8Array([99,122,69,122]); let array = new Uint8Array([99,122,69,122]);
...@@ -3347,6 +3408,7 @@ A constructor used to create a **Types** object. ...@@ -3347,6 +3408,7 @@ A constructor used to create a **Types** object.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Example** **Example**
```js ```js
let type = new util.types(); let type = new util.types();
``` ```
...@@ -3373,6 +3435,7 @@ Checks whether the input value is of the **ArrayBuffer** type. ...@@ -3373,6 +3435,7 @@ Checks whether the input value is of the **ArrayBuffer** type.
| boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isAnyArrayBuffer(new ArrayBuffer(0)); let result = that.isAnyArrayBuffer(new ArrayBuffer(0));
...@@ -3402,6 +3465,7 @@ Checks whether the input value is of the **ArrayBufferView** type. ...@@ -3402,6 +3465,7 @@ Checks whether the input value is of the **ArrayBufferView** type.
| boolean | Returns **true** if the input value is of the **ArrayBufferView** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **ArrayBufferView** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isArrayBufferView(new Int8Array([])); let result = that.isArrayBufferView(new Int8Array([]));
...@@ -3429,6 +3493,7 @@ Checks whether the input value is of the **arguments** type. ...@@ -3429,6 +3493,7 @@ Checks whether the input value is of the **arguments** type.
| boolean | Returns **true** if the input value is of the **arguments** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **arguments** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
function foo() { function foo() {
...@@ -3459,6 +3524,7 @@ Checks whether the input value is of the **ArrayBuffer** type. ...@@ -3459,6 +3524,7 @@ Checks whether the input value is of the **ArrayBuffer** type.
| boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isArrayBuffer(new ArrayBuffer(0)); let result = that.isArrayBuffer(new ArrayBuffer(0));
...@@ -3486,6 +3552,7 @@ Checks whether the input value is an asynchronous function. ...@@ -3486,6 +3552,7 @@ Checks whether the input value is an asynchronous function.
| boolean | Returns **true** if the input value is an asynchronous function; returns **false** otherwise.| | boolean | Returns **true** if the input value is an asynchronous function; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isAsyncFunction(async function foo() {}); let result = that.isAsyncFunction(async function foo() {});
...@@ -3513,6 +3580,7 @@ Checks whether the input value is of the **Boolean** type. ...@@ -3513,6 +3580,7 @@ Checks whether the input value is of the **Boolean** type.
| boolean | Returns **true** if the input value is of the **Boolean** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **Boolean** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isBooleanObject(new Boolean(true)); let result = that.isBooleanObject(new Boolean(true));
...@@ -3540,6 +3608,7 @@ Checks whether the input value is of the **Boolean**, **Number**, **String**, or ...@@ -3540,6 +3608,7 @@ Checks whether the input value is of the **Boolean**, **Number**, **String**, or
| boolean | Returns **true** if the input value is of the **Boolean**, **Number**, **String**, or **Symbol** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **Boolean**, **Number**, **String**, or **Symbol** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isBoxedPrimitive(new Boolean(false)); let result = that.isBoxedPrimitive(new Boolean(false));
...@@ -3567,6 +3636,7 @@ Checks whether the input value is of the **DataView** type. ...@@ -3567,6 +3636,7 @@ Checks whether the input value is of the **DataView** type.
| boolean | Returns **true** if the input value is of the **DataView** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **DataView** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
const ab = new ArrayBuffer(20); const ab = new ArrayBuffer(20);
...@@ -3595,6 +3665,7 @@ Checks whether the input value is of the **Date** type. ...@@ -3595,6 +3665,7 @@ Checks whether the input value is of the **Date** type.
| boolean | Returns **true** if the input value is of the **Date** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **Date** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isDate(new Date()); let result = that.isDate(new Date());
...@@ -3622,6 +3693,7 @@ Checks whether the input value is of the **native external** type. ...@@ -3622,6 +3693,7 @@ Checks whether the input value is of the **native external** type.
| boolean | Returns **true** if the input value is of the **native external** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **native external** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isExternal(true); let result = that.isExternal(true);
...@@ -3649,6 +3721,7 @@ Checks whether the input value is of the **Float32Array** type. ...@@ -3649,6 +3721,7 @@ Checks whether the input value is of the **Float32Array** type.
| boolean | Returns **true** if the input value is of the **Float32Array** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **Float32Array** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isFloat32Array(new Float32Array()); let result = that.isFloat32Array(new Float32Array());
...@@ -3676,6 +3749,7 @@ Checks whether the input value is of the **Float64Array** type. ...@@ -3676,6 +3749,7 @@ Checks whether the input value is of the **Float64Array** type.
| boolean | Returns **true** if the input value is of the **Float64Array** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **Float64Array** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isFloat64Array(new Float64Array()); let result = that.isFloat64Array(new Float64Array());
...@@ -3703,6 +3777,7 @@ Checks whether the input value is a generator function. ...@@ -3703,6 +3777,7 @@ Checks whether the input value is a generator function.
| boolean | Returns **true** if the input value is a generator function; returns **false** otherwise.| | boolean | Returns **true** if the input value is a generator function; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isGeneratorFunction(function* foo() {}); let result = that.isGeneratorFunction(function* foo() {});
...@@ -3730,6 +3805,7 @@ Checks whether the input value is a generator object. ...@@ -3730,6 +3805,7 @@ Checks whether the input value is a generator object.
| boolean | Returns **true** if the input value is a generator object; returns **false** otherwise.| | boolean | Returns **true** if the input value is a generator object; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
function* foo() {} function* foo() {}
...@@ -3759,6 +3835,7 @@ Checks whether the input value is of the **Int8Array** type. ...@@ -3759,6 +3835,7 @@ Checks whether the input value is of the **Int8Array** type.
| boolean | Returns **true** if the input value is of the **Int8Array** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **Int8Array** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isInt8Array(new Int8Array([])); let result = that.isInt8Array(new Int8Array([]));
...@@ -3786,6 +3863,7 @@ Checks whether the input value is of the **Int16Array** type. ...@@ -3786,6 +3863,7 @@ Checks whether the input value is of the **Int16Array** type.
| boolean | Returns **true** if the input value is of the **Int16Array** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **Int16Array** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isInt16Array(new Int16Array([])); let result = that.isInt16Array(new Int16Array([]));
...@@ -3813,6 +3891,7 @@ Checks whether the input value is of the **Int32Array** type. ...@@ -3813,6 +3891,7 @@ Checks whether the input value is of the **Int32Array** type.
| boolean | Returns **true** if the input value is of the **Int32Array** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **Int32Array** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isInt32Array(new Int32Array([])); let result = that.isInt32Array(new Int32Array([]));
...@@ -3840,6 +3919,7 @@ Checks whether the input value is of the **Map** type. ...@@ -3840,6 +3919,7 @@ Checks whether the input value is of the **Map** type.
| boolean | Returns **true** if the input value is of the **Map** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **Map** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isMap(new Map()); let result = that.isMap(new Map());
...@@ -3856,6 +3936,7 @@ Checks whether the input value is of the **MapIterator** type. ...@@ -3856,6 +3936,7 @@ Checks whether the input value is of the **MapIterator** type.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.| | value | Object | Yes| Object to check.|
...@@ -3867,6 +3948,7 @@ Checks whether the input value is of the **MapIterator** type. ...@@ -3867,6 +3948,7 @@ Checks whether the input value is of the **MapIterator** type.
| boolean | Returns **true** if the input value is of the **MapIterator** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **MapIterator** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
const map = new Map(); const map = new Map();
...@@ -3895,6 +3977,7 @@ Checks whether the input value is of the **Error** type. ...@@ -3895,6 +3977,7 @@ Checks whether the input value is of the **Error** type.
| boolean | Returns **true** if the input value is of the **Error** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **Error** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isNativeError(new TypeError()); let result = that.isNativeError(new TypeError());
...@@ -3922,6 +4005,7 @@ Checks whether the input value is a number object. ...@@ -3922,6 +4005,7 @@ Checks whether the input value is a number object.
| boolean | Returns **true** if the input value is a number object; returns **false** otherwise.| | boolean | Returns **true** if the input value is a number object; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isNumberObject(new Number(0)); let result = that.isNumberObject(new Number(0));
...@@ -3949,6 +4033,7 @@ Checks whether the input value is a promise. ...@@ -3949,6 +4033,7 @@ Checks whether the input value is a promise.
| boolean | Returns **true** if the input value is a promise; returns **false** otherwise.| | boolean | Returns **true** if the input value is a promise; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isPromise(Promise.resolve(1)); let result = that.isPromise(Promise.resolve(1));
...@@ -3976,6 +4061,7 @@ Checks whether the input value is a proxy. ...@@ -3976,6 +4061,7 @@ Checks whether the input value is a proxy.
| boolean | Returns **true** if the input value is a proxy; returns **false** otherwise.| | boolean | Returns **true** if the input value is a proxy; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
const target = {}; const target = {};
...@@ -4005,6 +4091,7 @@ Checks whether the input value is of the **RegExp** type. ...@@ -4005,6 +4091,7 @@ Checks whether the input value is of the **RegExp** type.
| boolean | Returns **true** if the input value is of the **RegExp** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **RegExp** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isRegExp(new RegExp('abc')); let result = that.isRegExp(new RegExp('abc'));
...@@ -4032,6 +4119,7 @@ Checks whether the input value is of the **Set** type. ...@@ -4032,6 +4119,7 @@ Checks whether the input value is of the **Set** type.
| boolean | Returns **true** if the input value is of the **Set** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **Set** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isSet(new Set()); let result = that.isSet(new Set());
...@@ -4059,6 +4147,7 @@ Checks whether the input value is of the **SetIterator** type. ...@@ -4059,6 +4147,7 @@ Checks whether the input value is of the **SetIterator** type.
| boolean | Returns **true** if the input value is of the **SetIterator** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **SetIterator** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
const set = new Set(); const set = new Set();
...@@ -4087,6 +4176,7 @@ Checks whether the input value is a string object. ...@@ -4087,6 +4176,7 @@ Checks whether the input value is a string object.
| boolean | Returns **true** if the input value is a string object; returns **false** otherwise.| | boolean | Returns **true** if the input value is a string object; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isStringObject(new String('foo')); let result = that.isStringObject(new String('foo'));
...@@ -4114,6 +4204,7 @@ Checks whether the input value is a symbol object. ...@@ -4114,6 +4204,7 @@ Checks whether the input value is a symbol object.
| boolean | Returns **true** if the input value is a symbol object; returns **false** otherwise.| | boolean | Returns **true** if the input value is a symbol object; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
const symbols = Symbol('foo'); const symbols = Symbol('foo');
...@@ -4144,6 +4235,7 @@ Checks whether the input value is of the **TypedArray** type. ...@@ -4144,6 +4235,7 @@ Checks whether the input value is of the **TypedArray** type.
| boolean | Returns **true** if the input value is of the **TypedArray** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **TypedArray** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isTypedArray(new Float64Array([])); let result = that.isTypedArray(new Float64Array([]));
...@@ -4171,6 +4263,7 @@ Checks whether the input value is of the **Uint8Array** type. ...@@ -4171,6 +4263,7 @@ Checks whether the input value is of the **Uint8Array** type.
| boolean | Returns **true** if the input value is of the **Uint8Array** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **Uint8Array** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isUint8Array(new Uint8Array([])); let result = that.isUint8Array(new Uint8Array([]));
...@@ -4198,6 +4291,7 @@ Checks whether the input value is of the **Uint8ClampedArray** type. ...@@ -4198,6 +4291,7 @@ Checks whether the input value is of the **Uint8ClampedArray** type.
| boolean | Returns **true** if the input value is of the **Uint8ClampedArray** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **Uint8ClampedArray** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isUint8ClampedArray(new Uint8ClampedArray([])); let result = that.isUint8ClampedArray(new Uint8ClampedArray([]));
...@@ -4225,6 +4319,7 @@ Checks whether the input value is of the **Uint16Array** type. ...@@ -4225,6 +4319,7 @@ Checks whether the input value is of the **Uint16Array** type.
| boolean | Returns **true** if the input value is of the **Uint16Array** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **Uint16Array** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isUint16Array(new Uint16Array([])); let result = that.isUint16Array(new Uint16Array([]));
...@@ -4252,6 +4347,7 @@ Checks whether the input value is of the **Uint32Array** type. ...@@ -4252,6 +4347,7 @@ Checks whether the input value is of the **Uint32Array** type.
| boolean | Returns **true** if the input value is of the **Uint32Array** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **Uint32Array** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isUint32Array(new Uint32Array([])); let result = that.isUint32Array(new Uint32Array([]));
...@@ -4279,6 +4375,7 @@ Checks whether the input value is of the **WeakMap** type. ...@@ -4279,6 +4375,7 @@ Checks whether the input value is of the **WeakMap** type.
| boolean | Returns **true** if the input value is of the **WeakMap** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **WeakMap** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isWeakMap(new WeakMap()); let result = that.isWeakMap(new WeakMap());
...@@ -4306,6 +4403,7 @@ Checks whether the input value is of the **WeakSet** type. ...@@ -4306,6 +4403,7 @@ Checks whether the input value is of the **WeakSet** type.
| boolean | Returns **true** if the input value is of the **WeakSet** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **WeakSet** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isWeakSet(new WeakSet()); let result = that.isWeakSet(new WeakSet());
...@@ -4333,6 +4431,7 @@ Checks whether the input value is of the **BigInt64Array** type. ...@@ -4333,6 +4431,7 @@ Checks whether the input value is of the **BigInt64Array** type.
| boolean | Returns **true** if the input value is of the **BigInt64Array** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **BigInt64Array** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isBigInt64Array(new BigInt64Array([])); let result = that.isBigInt64Array(new BigInt64Array([]));
...@@ -4360,6 +4459,7 @@ Checks whether the input value is of the **BigUint64Array** type. ...@@ -4360,6 +4459,7 @@ Checks whether the input value is of the **BigUint64Array** type.
| boolean | Returns **true** if the input value is of the **BigUint64Array** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **BigUint64Array** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isBigUint64Array(new BigUint64Array([])); let result = that.isBigUint64Array(new BigUint64Array([]));
...@@ -4387,6 +4487,7 @@ Checks whether the input value is a module namespace object. ...@@ -4387,6 +4487,7 @@ Checks whether the input value is a module namespace object.
| boolean | Returns **true** if the input value is a module namespace object; returns **false** otherwise.| | boolean | Returns **true** if the input value is a module namespace object; returns **false** otherwise.|
**Example** **Example**
```js ```js
import url from '@ohos.url' import url from '@ohos.url'
let that = new util.types(); let that = new util.types();
...@@ -4415,6 +4516,7 @@ Checks whether the input value is of the **SharedArrayBuffer** type. ...@@ -4415,6 +4516,7 @@ Checks whether the input value is of the **SharedArrayBuffer** type.
| boolean | Returns **true** if the input value is of the **SharedArrayBuffer** type; returns **false** otherwise.| | boolean | Returns **true** if the input value is of the **SharedArrayBuffer** type; returns **false** otherwise.|
**Example** **Example**
```js ```js
let that = new util.types(); let that = new util.types();
let result = that.isSharedArrayBuffer(new SharedArrayBuffer(0)); let result = that.isSharedArrayBuffer(new SharedArrayBuffer(0));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册