diff --git a/en/application-dev/reference/apis/figures/en-us_image_Add_Blur.png b/en/application-dev/reference/apis/figures/en-us_image_Add_Blur.png
new file mode 100644
index 0000000000000000000000000000000000000000..e3b0acfef7bffa4e6a8c9f9ab6a7dc9b809fa467
Binary files /dev/null and b/en/application-dev/reference/apis/figures/en-us_image_Add_Blur.png differ
diff --git a/en/application-dev/reference/apis/figures/en-us_image_Add_Brightness.png b/en/application-dev/reference/apis/figures/en-us_image_Add_Brightness.png
new file mode 100644
index 0000000000000000000000000000000000000000..997602e7d7c8ea440a4f344f6a480ea66022fabf
Binary files /dev/null and b/en/application-dev/reference/apis/figures/en-us_image_Add_Brightness.png differ
diff --git a/en/application-dev/reference/apis/figures/en-us_image_Add_Grayscale.png b/en/application-dev/reference/apis/figures/en-us_image_Add_Grayscale.png
new file mode 100644
index 0000000000000000000000000000000000000000..69990adea571b907fabd854eb531528d7a60dc8f
Binary files /dev/null and b/en/application-dev/reference/apis/figures/en-us_image_Add_Grayscale.png differ
diff --git a/en/application-dev/reference/apis/figures/en-us_image_Main_Color.png b/en/application-dev/reference/apis/figures/en-us_image_Main_Color.png
new file mode 100644
index 0000000000000000000000000000000000000000..25e130fcf37fc3654592f619c8a93b703a085e9a
Binary files /dev/null and b/en/application-dev/reference/apis/figures/en-us_image_Main_Color.png differ
diff --git a/en/application-dev/reference/apis/js-apis-convertxml.md b/en/application-dev/reference/apis/js-apis-convertxml.md
index 3a2f046c36b3c17bca7c87c71e18c69971b5683c..ab33a232ca03c9b8ee139f497cd6ea0f572debc7 100644
--- a/en/application-dev/reference/apis/js-apis-convertxml.md
+++ b/en/application-dev/reference/apis/js-apis-convertxml.md
@@ -15,8 +15,54 @@ import convertxml from '@ohos.convertxml';
## ConvertXML
+### convertToJSObject9+
-### convert
+convertToJSObject(xml: string, options?: ConvertOptions) : Object
+
+Converts an XML text into a JavaScript object.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ------- | --------------------------------- | ---- | --------------- |
+| xml | string | Yes | XML text to convert.|
+| options | [ConvertOptions](#convertoptions) | No | Options for conversion. |
+
+**Return value**
+
+| Type | Description |
+| ------ | ---------------------------- |
+| Object | JavaScript object.|
+
+**Example**
+
+```js
+let xml =
+ '' +
+ '' +
+ ' Happy' +
+ ' Work' +
+ ' Play' +
+ '';
+let conv = new convertxml.convertToJSObject();
+let options = {trim : false, declarationKey:"_declaration",
+ instructionKey : "_instruction", attributesKey : "_attributes",
+ textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype",
+ commentKey : "_comment", parentKey : "_parent", typeKey : "_type",
+ nameKey : "_name", elementsKey : "_elements"}
+let result = JSON.stringify(conv.convert(xml, options));
+console.log(result);
+// Output (non-compact)
+// {"_declaration":{"_attributes":{"version":"1.0","encoding":"utf-8"}},"_elements":[{"_type":"element","_name":"note","_attributes":{"importance":"high","logged":"true"},"_elements":[{"_type":"element","_name":"title","_elements":[{"_type":"text","_text":"Happy"}]},{"_type":"element","_name":"todo","_elements":[{"_type":"text","_text":"Work"}]},{"_type":"element","_name":"todo","_elements":[{"_type":"text","_text":"Play"}]}]}]}
+```
+
+### convert(deprecated)
+
+> **NOTE**
+>
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [convertToJSObject9+](#converttojsobject9) instead.
convert(xml: string, options?: ConvertOptions) : Object
@@ -24,7 +70,6 @@ Converts an XML text into a JavaScript object.
**System capability**: SystemCapability.Utils.Lang
-
**Parameters**
| Name | Type | Mandatory| Description |
diff --git a/en/application-dev/reference/apis/js-apis-effectKit.md b/en/application-dev/reference/apis/js-apis-effectKit.md
index cf2bb656da8705ff8352e00a06ce9149980959a4..d44645af1980b3a963bd73878dc040db60abe205 100644
--- a/en/application-dev/reference/apis/js-apis-effectKit.md
+++ b/en/application-dev/reference/apis/js-apis-effectKit.md
@@ -4,7 +4,7 @@ The **EffectKit** module provides basic image processing capabilities, including
This module provides the following classes:
-- [Filter](#filter): a class that provides the effect chain, which is a linked list of image processing effects.
+- [Filter](#filter): a class that adds a specified effect to the image source.
- [Color](#color): a class used to store the color picked.
- [ColorPicker](#colorpicker): a smart color picker.
@@ -43,7 +43,6 @@ Creates a **Filter** instance based on the pixel map.
import image from "@ohos.multimedia.image";
const color = new ArrayBuffer(96);
-let bufferArr = new Uint8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts).then((pixelMap) => {
let headFilter = effectKit.createEffect(pixelMap);
@@ -76,7 +75,6 @@ Creates a **ColorPicker** instance based on the pixel map. This API uses a promi
import image from "@ohos.multimedia.image";
const color = new ArrayBuffer(96);
-let bufferArr = new Uint8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts).then((pixelMap) => {
effectKit.createColorPicker(pixelMap).then(colorPicker => {
@@ -106,7 +104,6 @@ Creates a **ColorPicker** instance based on the pixel map. This API uses an asyn
import image from "@ohos.multimedia.image";
const color = new ArrayBuffer(96);
-let bufferArr = new Uint8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts).then((pixelMap) => {
effectKit.createColorPicker(pixelMap, (error, colorPicker) => {
@@ -181,6 +178,7 @@ Obtains the main color of the image and writes the result to a **[Color](#color)
let color = colorPicker.getMainColorSync();
console.log('get main color =' + color);
```
+![en-us_image_Main_Color.png](figures/en-us_image_Main_Color.png)
## Filter
@@ -204,7 +202,7 @@ Adds the blur effect to the filter linked list, and returns the head node of the
| Type | Description |
| :------------- | :---------------------------------------------- |
-| [Filter](#filter) | Head node of the filter linked list.|
+| [Filter](#filter) | Final image effect.|
**Example**
@@ -221,6 +219,7 @@ image.createPixelMap(color, opts).then((pixelMap) => {
}
})
```
+![en-us_image_Add_Blur.png](figures/en-us_image_Add_Blur.png)
### brightness
@@ -240,7 +239,7 @@ Adds the brightness effect to the filter linked list, and returns the head node
| Type | Description |
| :------------- | :---------------------------------------------- |
-| [Filter](#filter) | Head node of the filter linked list.|
+| [Filter](#filter) | Final image effect.|
**Example**
@@ -257,6 +256,7 @@ image.createPixelMap(color, opts).then((pixelMap) => {
}
})
```
+![en-us_image_Add_Brightness.png](figures/en-us_image_Add_Brightness.png)
### grayscale
@@ -270,7 +270,7 @@ Adds the grayscale effect to the filter linked list, and returns the head node o
| Type | Description |
| :------------- | :---------------------------------------------- |
-| [Filter](#filter) | Head node of the filter linked list.|
+| [Filter](#filter) | Final image effect.|
**Example**
@@ -286,10 +286,11 @@ image.createPixelMap(color, opts).then((pixelMap) => {
}
})
```
+![en-us_image_Add_Grayscale.png](figures/en-us_image_Add_Grayscale.png)
### getPixelMap
-getPixelMap(): image.PixelMap
+getPixelMap(): [image.PixelMap](js-apis-image.md#pixelmap7)
Obtains **image.PixelMap** of the source image to which the filter linked list is added.
diff --git a/en/application-dev/reference/apis/js-apis-uri.md b/en/application-dev/reference/apis/js-apis-uri.md
index faeb4f766d6c1417728f540fcab71551ee688abf..d058b555c87be4fe5f9601ef4b9f9c7198964463 100644
--- a/en/application-dev/reference/apis/js-apis-uri.md
+++ b/en/application-dev/reference/apis/js-apis-uri.md
@@ -77,7 +77,10 @@ result.toString()
```
-### equals
+### equals(deprecated)
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [equalsTo9+](#equalsto9) instead.
equals(other: URI): boolean
@@ -104,6 +107,33 @@ const uriInstance = new uri.URI('http://username:password@host:8080/directory/fi
const uriInstance1 = new uri.URI('http://username:password@host:8080/directory/file?query=pppppp#qwer=da#fragment');
uriInstance.equals(uriInstance1);
```
+### equalsTo9+
+
+equalsTo(other: URI): boolean
+
+Checks whether this URI is the same as another URI object.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type.| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| other | [URI](#uri) | Yes| URI object to compare.|
+
+**Return value**
+
+| Type.| Description|
+| -------- | -------- |
+| boolean | Returns **true** if the two URIs are the same; returns **false** otherwise.|
+
+**Example**
+
+```js
+const uriInstance = new uri.URI('http://username:password@host:8080/directory/file?query=pppppp#qwer=da');
+const uriInstance1 = new uri.URI('http://username:password@host:8080/directory/file?query=pppppp#qwer=da#fragment');
+uriInstance.equalsTo(uriInstance1);
+```
### checkIsAbsolute
diff --git a/en/application-dev/reference/apis/js-apis-url.md b/en/application-dev/reference/apis/js-apis-url.md
index 221decfb35ae0a6667eb9f96c60c713f8536949b..7d9c9e068863e9466b81145849c0b8507be62efe 100755
--- a/en/application-dev/reference/apis/js-apis-url.md
+++ b/en/application-dev/reference/apis/js-apis-url.md
@@ -4,21 +4,379 @@
>
> 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.
-
## Modules to Import
```
import Url from '@ohos.url'
```
+## URLParams9+
-## URLSearchParams
+### constructor9+
-### constructor
+constructor(init?: string[][] | Record<string, string> | string | URLParams)
+
+A constructor used to create a **URLParams** instance.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| init | string[][] \| Record<string, string> \| string \| URLParams | No| Input parameter objects, which include the following:
- **string[][]**: two-dimensional string array
- **Record<string, string>**: list of objects
- **string**: string
- **URLParams**: object|
+
+**Example**
+
+```js
+let objectParams = new Url.URLParams([ ['user1', 'abc1'], ['query2', 'first2'], ['query3', 'second3'] ]);
+let objectParams1 = new Url.URLParams({"fod" : '1' , "bard" : '2'});
+let objectParams2 = new Url.URLParams('?fod=1&bard=2');
+let urlObject = new Url.URL('https://developer.mozilla.org/?fod=1&bard=2');
+let params = new Url.URLParams(urlObject.search);
+```
+
+
+### append9+
+
+append(name: string, value: string): void
+
+Appends a key-value pair into the query string.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| name | string | Yes| Key of the key-value pair to append.|
+| value | string | Yes| Value of the key-value pair to append.|
+
+**Example**
+
+```js
+let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2');
+let paramsObject = new Url.URLParams(urlObject.search.slice(1));
+paramsObject.append('fod', '3');
+```
+
+
+### delete9+
+
+delete(name: string): void
+
+Deletes key-value pairs of the specified key.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| name | string | Yes| Key of the key-value pairs to delete.|
+
+**Example**
+
+```js
+let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2');
+let paramsobject = new Url.URLParams(urlObject.search.slice(1));
+paramsobject.delete('fod');
+```
+
+
+### getAll9+
+
+getAll(name: string): string[]
+
+Obtains all the key-value pairs based on the specified key.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| name | string | Yes| Key specified to obtain all key-value pairs.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| string[] | All key-value pairs matching the specified key.|
+
+**Example**
+
+```js
+let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2');
+let params = new Url.URLParams(urlObject.search.slice(1));
+params.append('fod', '3'); // Add a second value for the fod parameter.
+console.log(params.getAll('fod').toString()) // Output ["1","3"].
+```
+
+
+### entries9+
+
+entries(): IterableIterator<[string, string]>
+
+Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and the first and second fields of each array are the key and value respectively.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| IterableIterator<[string, string]> | ES6 iterator.|
+
+**Example**
+
+```js
+let searchParamsObject = new Url.URLParams("keyName1=valueName1&keyName2=valueName2");
+for (var pair of searchParamsObject .entries()) { // Show keyName/valueName pairs
+ console.log(pair[0]+ ', '+ pair[1]);
+}
+```
+
+
+### forEach9+
+
+forEach(callbackfn: (value: string, key: string, searchParams: this) => void, thisArg?: Object): void
+
+Traverses the key-value pairs in the **URLSearchParams** instance by using a callback.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| callbackfn | function | Yes| Callback invoked to traverse the key-value pairs in the **URLSearchParams** instance.|
+| thisArg | Object | No| Value to use when the callback is invoked.|
+
+**Table 1** callbackfn parameter description
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| value | string | Yes| Value that is currently traversed.|
+| key | string | Yes| Key that is currently traversed.|
+| searchParams | Object | Yes| Instance that invokes the **forEach** method.|
+
+**Example**
+
+```js
+const myURLObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2');
+myURLObject.URLParams.forEach((value, name, searchParams) => {
+ console.log(name, value, myURLObject.searchParams === searchParams);
+});
+```
+
+
+### get9+
+
+get(name: string): string | null
+
+Obtains the value of the first key-value pair based on the specified key.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| name | string | Yes| Key specified to obtain the value.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| string | Returns the value of the first key-value pair if obtained.|
+| null | Returns **null** if no value is obtained.|
+
+**Example**
+
+```js
+let paramsObject = new Url.URLParams('name=Jonathan&age=18');
+let name = paramsObject.get("name"); // is the string "Jonathan"
+let age = parseInt(paramsObject.get("age"), 10); // is the number 18
+```
+
+
+### has9+
+
+has(name: string): boolean
+
+Checks whether a key has a value.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| name | string | Yes| Key specified to search for its value.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| boolean | Returns **true** if the value exists; returns **false** otherwise.|
+
+**Example**
+
+```js
+let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2');
+let paramsObject = new Url.URLParams(urlObject.search.slice(1));
+paramsObject.has('bard') === true;
+```
+
+
+### set9+
+
+set(name: string, value: string): void
+
+Sets the value for a key. If key-value pairs matching the specified key exist, the value of the first key-value pair will be set to the specified value and other key-value pairs will be deleted. Otherwise, the key-value pair will be appended to the query string.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| name | string | Yes| Key of the value to set.|
+| value | string | Yes| Value to set.|
+
+**Example**
+
+```js
+let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2');
+let paramsObject = new Url.URLParams(urlObject.search.slice(1));
+paramsObject.set('baz', '3'); // Add a third parameter.
+```
+
+
+### sort9+
+
+sort(): void
+
+Sorts all key-value pairs contained in this object based on the Unicode code points of the keys and returns undefined. This method uses a stable sorting algorithm, that is, the relative order between key-value pairs with equal keys is retained.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Example**
+
+```js
+let searchParamsObject = new Url.URLParams("c=3&a=9&b=4&d=2"); // Create a test URLSearchParams object
+searchParamsObject.sort(); // Sort the key/value pairs
+console.log(searchParamsObject.toString()); // Display the sorted query string // Output a=9&b=2&c=3&d=4
+```
+
+
+### keys9+
+
+keys(): IterableIterator<string>
+
+Obtains an ES6 iterator that contains the keys of all the key-value pairs.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| IterableIterator<string> | ES6 iterator that contains the keys of all the key-value pairs.|
+
+**Example**
+
+```js
+let searchParamsObject = new Url.URLParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing
+for (var key of searchParamsObject .keys()) { // Output key-value pairs
+ console.log(key);
+}
+```
+
+
+### values9+
+
+values(): IterableIterator<string>
+
+Obtains an ES6 iterator that contains the values of all the key-value pairs.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| IterableIterator<string> | ES6 iterator that contains the values of all the key-value pairs.|
+
+**Example**
+
+```js
+let searchParams = new Url.URLParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing
+for (var value of searchParams.values()) {
+ console.log(value);
+}
+```
+
+
+### [Symbol.iterator]9+
+
+[Symbol.iterator]\(): IterableIterator<[string, string]>
+
+Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and the first and second fields of each array are the key and value respectively.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| IterableIterator<[string, string]> | ES6 iterator.|
+
+**Example**
+
+```js
+const paramsObject = new Url.URLParams('fod=bay&edg=bap');
+for (const [name, value] of paramsObject) {
+ console.log(name, value);
+}
+```
+
+
+### tostring9+
+
+toString(): string
+
+Obtains search parameters that are serialized as a string and, if necessary, percent-encodes the characters in the string.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| string | String of serialized search parameters, which is percent-encoded if necessary.|
+
+**Example**
+
+```js
+let url = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2');
+let params = new Url.URLParams(url.search.slice(1));
+params.append('fod', '3');
+console.log(params.toString());
+```
+
+## URLSearchParams(deprecated)
+
+### constructor(deprecated)
+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [URLParams9+](#constructor9+) instead.
constructor(init?: string[][] | Record<string, string> | string | URLSearchParams)
-Creates a **URLSearchParams** instance.
+A constructor used to create a **URLSearchParams** instance.
**System capability**: SystemCapability.Utils.Lang
@@ -38,8 +396,11 @@ let urlObject = new Url.URL('https://developer.mozilla.org/?fod=1&bard=2');
let params = new Url.URLSearchParams(urlObject.search);
```
+### append(deprecated)
-### append
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [URLParams9+.append9+](#append9) instead.
append(name: string, value: string): void
@@ -62,8 +423,11 @@ let paramsObject = new Url.URLSearchParams(urlObject.search.slice(1));
paramsObject.append('fod', '3');
```
+### delete(deprecated)
-### delete
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [URLParams9+.delete9+](#delete9) instead.
delete(name: string): void
@@ -85,8 +449,11 @@ let paramsobject = new Url.URLSearchParams(urlObject.search.slice(1));
paramsobject.delete('fod');
```
+### getAll(deprecated)
-### getAll
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [URLParams9+.getAll9+](#getall9) instead.
getAll(name: string): string[]
@@ -115,8 +482,11 @@ params.append('fod', '3'); // Add a second value for the fod parameter.
console.log(params.getAll('fod').toString()) // Output ["1","3"].
```
+### entries(deprecated)
-### entries
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [URLParams9+.entries9+](#entries9) instead.
entries(): IterableIterator<[string, string]>
@@ -140,7 +510,10 @@ for (var pair of searchParamsObject .entries()) { // Show keyName/valueName pair
```
-### forEach
+### forEach(deprecated)
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [URLParams9+.forEach9+](#foreach9) instead.
forEach(callbackfn: (value: string, key: string, searchParams: this) => void, thisArg?: Object): void
@@ -173,7 +546,10 @@ myURLObject.searchParams.forEach((value, name, searchParams) => {
```
-### get
+### get(deprecated)
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [URLParams9+.get9+](#get9) instead.
get(name: string): string | null
@@ -203,7 +579,10 @@ let age = parseInt(paramsObject.get("age"), 10); // is the number 18
```
-### has
+### has(deprecated)
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [URLParams9+.has9+](#has9) instead.
has(name: string): boolean
@@ -232,7 +611,10 @@ paramsObject.has('bard') === true;
```
-### set
+### set(deprecated)
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [URLParams9+.set9+](#set9) instead.
set(name: string, value: string): void
@@ -256,7 +638,10 @@ paramsObject.set('baz', '3'); // Add a third parameter.
```
-### sort
+### sort(deprecated)
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [URLParams9+.sort9+](#sort9) instead.
sort(): void
@@ -273,7 +658,10 @@ console.log(searchParamsObject.toString()); // Display the sorted query string /
```
-### keys
+### keys(deprecated)
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [URLParams9+.keys9+](#keys9) instead.
keys(): IterableIterator<string>
@@ -297,7 +685,10 @@ for (var key of searchParamsObject .keys()) { // Output key-value pairs
```
-### values
+### values(deprecated)
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [URLParams9+.values9+](#values9) instead.
values(): IterableIterator<string>
@@ -321,7 +712,10 @@ for (var value of searchParams.values()) {
```
-### [Symbol.iterator]
+### [Symbol.iterator](deprecated)
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [URLParams9+.[Symbol.iterator]9+](#symbol.iterator9) instead.
[Symbol.iterator]\(): IterableIterator<[string, string]>
@@ -344,8 +738,10 @@ for (const [name, value] of paramsObject) {
}
```
-
-### tostring
+### tostring(deprecated)
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [URLParams9+.tostring9+](#tostring9) instead.
toString(): string
@@ -368,7 +764,6 @@ params.append('fod', '3');
console.log(params.toString());
```
-
## URL
### Attributes
@@ -388,12 +783,13 @@ console.log(params.toString());
| protocol | string | Yes| Yes| Protocol in a URL.|
| search | string | Yes| Yes| Serialized query string in a URL.|
| searchParams | URLsearchParams | Yes| No| **URLSearchParams** object allowing access to the query parameters in a URL.|
+| URLParams | URLParams | Yes| No| **URLParams** object allowing access to the query parameters in a URL.|
| username | string | Yes| Yes| Username in a URL.|
### constructor
-constructor(url: string, base?: string | URL)
+constructor(url?: string, base?: string | URL)
Creates a URL.
@@ -423,6 +819,27 @@ new Url.URL('http://www.shanxi.com', ); // Output http://www.shanxi.com/
new Url.URL('http://www.shanxi.com', b); // Output http://www.shanxi.com/
```
+### parseURL9+
+
+static parseURL(inputUrl : string, inputBase ?: string | URL)
+
+Parses a URL.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| inputUrl | string | Yes| Input object.|
+| inputBase | string \| URL | No| Input parameter, which can be any of the following:
- **string**: string
- **URL**: string or object|
+
+**Example**
+
+```js
+let mm = 'http://username:password@host:8080';
+Url.URL.parseURL(mm); // Output 'http://username:password@host:8080/';
+```
### tostring
@@ -465,3 +882,4 @@ Converts the parsed URL into a JSON string.
const url = new Url.URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da');
url.toJSON();
```
+
diff --git a/en/application-dev/reference/apis/js-apis-util.md b/en/application-dev/reference/apis/js-apis-util.md
index 9d8332040bdcfece8717aacd79ea2eb579686cdd..4dbed0653a8618af5c0f83628dbc412e6639f0e1 100755
--- a/en/application-dev/reference/apis/js-apis-util.md
+++ b/en/application-dev/reference/apis/js-apis-util.md
@@ -15,11 +15,43 @@ This module provides common utility functions, such as **TextEncoder** and **Tex
import util from '@ohos.util';
```
-## util.printf
+## util.format9+
+
+format(format: string, ...args: Object[]): string
+
+Formats the specified values and inserts them into the string by replacing the wildcard in the string.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ------- | -------- | ---- | -------------- |
+| format | string | Yes | String.|
+| ...args | Object[] | No | Values to format. The formatted values will be replaced the wildcard in the string. |
+
+**Return value**
+
+| Type | Description |
+| ------ | ---------------------------- |
+| string | String containing the formatted values.|
+
+**Example**
+
+ ```js
+let res = util.format("%s", "hello world!");
+console.log(res);
+ ```
+
+## util.printf(deprecated)
+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [util.format9+](#utilformat9) instead.
printf(format: string, ...args: Object[]): string
-Prints the input content in a formatted string.
+Formats the specified values and inserts them into the string by replacing the wildcard in the string.
**System capability**: SystemCapability.Utils.Lang
@@ -27,14 +59,14 @@ Prints the input content in a formatted string.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| format | string | Yes| Format of the string to print.|
-| ...args | Object[] | No| Data to format.|
+| format | string | Yes| String.|
+| ...args | Object[] | No| Values to format. The formatted values will be replaced the wildcard in the string. |
**Return value**
| Type| Description|
| -------- | -------- |
-| string | String in the specified format.|
+| string | String containing the formatted values.|
**Example**
```js
@@ -42,8 +74,39 @@ Prints the input content in a formatted string.
console.log(res);
```
+## util.errnoToString9+
+
+errnoToString(errno: number): string
+
+Obtains detailed information about a system error code.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | -------------------------- |
+| errno | number | Yes | Error code generated.|
+
+**Return value**
+
+| Type | Description |
+| ------ | ---------------------- |
+| string | Detailed information about the error code.|
+
+**Example**
+
+ ```js
+let errnum = 10; // 10 is a system error code.
+let result = util.errnoToString(errnum);
+console.log("result = " + result);
+ ```
+
+## util.getErrorString(deprecated)
-## util.getErrorString
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [util.errnoToString9+](#utilerrnotostring9) instead.
getErrorString(errno: number): string
@@ -70,12 +133,11 @@ Obtains detailed information about a system error code.
console.log("result = " + result);
```
-
## util.callbackWrapper
callbackWrapper(original: Function): (err: Object, value: Object )=>void
-Wraps an asynchronous function (or a function that returns a promise) into an error-first callback, which means that **(err, value) => ...** is used as the last parameter of the callback. In the callback, 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.
+Calls back an asynchronous function. In the callback, 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.
**System capability**: SystemCapability.Utils.Lang
@@ -104,31 +166,6 @@ Wraps an asynchronous function (or a function that returns a promise) into an er
}, err)
```
-
-## util.promiseWrapper(deprecated)
-
-promiseWrapper(original: (err: Object, value: Object) => void): Object
-
-> **NOTE**
->
-> This API is deprecated since API version 9. You are advised to use **[util.promisify9+](#utilpromisify9)** instead.
-
-Wraps a function that follows the error-first callback paradigm into a promise.
-
-**System capability**: SystemCapability.Utils.Lang
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| original | Function | Yes| Asynchronous function.|
-
-**Return value**
-
-| Type| Description|
-| -------- | -------- |
-| Function | Function in the error-first style (that is, **(err, value) =>...** is called as the last parameter) and the promise.|
-
## util.promisify9+
promisify(original: (err: Object, value: Object) => void): Function
@@ -164,6 +201,30 @@ Processes an asynchronous function and returns a promise.
})
```
+## util.promiseWrapper(deprecated)
+
+promiseWrapper(original: (err: Object, value: Object) => void): Object
+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use **[util.promisify9+](#utilpromisify9)** instead.
+
+Processes an asynchronous function and returns a promise.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| original | Function | Yes| Asynchronous function.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Function | Function in the error-first style (that is, **(err, value) =>...** is called as the last parameter) and the promise.|
+
## util.randomUUID9+
randomUUID(entropyCache?: boolean): string
@@ -260,8 +321,46 @@ Parses a UUID from a string, as described in RFC 4122 version 4.
| fatal | boolean | Yes| No| Whether to display fatal errors.|
| ignoreBOM | boolean | Yes| No| Whether to ignore the byte order marker (BOM). The default value is **false**, which indicates that the result contains the BOM.|
+### constructor9+
-### constructor
+constructor()
+
+A constructor used to create a **TextDecoder** object.
+
+**System capability**: SystemCapability.Utils.Lang
+
+### create9+
+
+create(encoding?: string,options?: { fatal?: boolean; ignoreBOM?: boolean },): TextDecoder;
+
+Creates a **TextDecoder** object. It provides the same function as the deprecated argument constructor.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ------ | ---- | ------------------------------------------------ |
+| encoding | string | No | Encoding format. |
+| options | Object | No | Encoding-related options, which include **fatal** and **ignoreBOM**.|
+
+ **Table 1.1** options
+
+| Name | Type| Mandatory| Description |
+| --------- | -------- | ---- | ------------------ |
+| fatal | boolean | No | Whether to display fatal errors.|
+| ignoreBOM | boolean | No | Whether to ignore the BOM. |
+
+**Example**
+
+ ```js
+let textDecoder = new util.TextDecoder()
+textDecoder.create('utf-8', { ignoreBOM : true });
+ ```
+
+### constructor(deprecated)
+
+> **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 },)
@@ -288,7 +387,6 @@ A constructor used to create a **TextDecoder** object.
let textDecoder = new util.TextDecoder("utf-8",{ignoreBOM: true});
```
-
### decode
decode(input: Uint8Array, options?: { stream?: false }): string
@@ -399,8 +497,40 @@ A constructor used to create a **TextEncoder** object.
let textEncoder = new util.TextEncoder();
```
+### encodeInto9+
+
+encodeInto(input?: string): Uint8Array
+
+Encodes the input content.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------------------ |
+| input | string | Yes | String to encode.|
+
+**Return value**
+
+| Type | Description |
+| ---------- | ------------------ |
+| Uint8Array | Encoded text.|
+
+**Example**
+
+ ```js
+let textEncoder = new util.TextEncoder();
+let buffer = new ArrayBuffer(20);
+let result = new Uint8Array(buffer);
+result = textEncoder.encodeInto("\uD800¥¥");
+ ```
+
+### encode(deprecated)
-### encode
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [encodeInto9+](#encodeinto9) instead.
encode(input?: string): Uint8Array
@@ -428,8 +558,42 @@ Encodes the input content.
result = textEncoder.encode("\uD800¥¥");
```
+### encodeIntoUint8Array9+
+
+encodeIntoUint8Array(input: string, dest: Uint8Array, ): { read: number; written: number }
+
+Stores the UTF-8 encoded text.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ---------- | ---- | ------------------------------------------------------- |
+| input | string | Yes | String to encode. |
+| dest | Uint8Array | Yes | **Uint8Array** instance used to store the UTF-8 encoded text.|
+
+**Return value**
+
+| Type | Description |
+| ---------- | ------------------ |
+| Uint8Array | Encoded text.|
+
+**Example**
+
+ ```js
+let that = new util.TextEncoder()
+let buffer = new ArrayBuffer(4)
+let dest = new Uint8Array(buffer)
+let result = new Object()
+result = that.encodeInto('abcd', dest)
+ ```
+
+### encodeInto(deprecated)
-### encodeInto
+> **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 }
@@ -461,8 +625,47 @@ Stores the UTF-8 encoded text.
## RationalNumber8+
+### constructor9+
-### constructor8+
+constructor()
+
+A constructor used to create a **RationalNumber** object.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Example**
+
+ ```js
+let rationalNumber = new util.RationalNumber();
+ ```
+
+### parseRationalNumber9+
+
+parseRationalNumber(numerator: number,denominator: number)
+
+Parses a rational number. Previously, this processing is an internal action of the deprecated constructor.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | ------ | ---- | ---------------- |
+| numerator | number | Yes | Numerator, which is an integer.|
+| denominator | number | Yes | Denominator, which is an integer.|
+
+**Example**
+
+ ```js
+let rationalNumber = new util.RationalNumber();
+rationalNumber.parseRationalNumber(1,2)
+ ```
+
+### constructor8+(deprecated)
+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [constructor9+](#constructor9) instead.
constructor(numerator: number,denominator: number)
@@ -478,11 +681,11 @@ A constructor used to create a **RationalNumber** object.
| denominator | number | Yes| Denominator, which is an integer.|
**Example**
+
```js
let rationalNumber = new util.RationalNumber(1,2);
```
-
### createRationalFromString8+
static createRationalFromString(rationalString: string): RationalNumber
@@ -509,8 +712,39 @@ Creates a **RationalNumber** object based on the given string.
let rational = util.RationalNumber.createRationalFromString("3/4");
```
+### compare9+
+
+compare(another: RationalNumber): number
+
+Compares this **RationalNumber** object with a given object.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ------- | -------------- | ---- | ------------------ |
+| another | RationalNumber | Yes | Object used to compare with this **RationalNumber** object.|
+
+**Return value**
+
+| Type | Description |
+| ------ | ------------------------------------------------------------ |
+| 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**
+
+ ```js
+let rationalNumber = new util.RationalNumber(1,2);
+let rational = util.RationalNumber.createRationalFromString("3/4");
+let result = rationalNumber.compare(rational);
+ ```
+
+### compareTo8+(deprecated)
-### compareTo8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [compare9+](#compare9) instead.
compareTo(another: RationalNumber): number
@@ -537,7 +771,6 @@ Compares this **RationalNumber** object with a given object.
let result = rationalNumber.compareTo(rational);
```
-
### valueOf8+
valueOf(): number
@@ -558,7 +791,6 @@ Obtains the value of this **RationalNumber** object as an integer or a floating-
let result = rationalNumber.valueOf();
```
-
### equals8+
equals(obj: Object): boolean
@@ -586,8 +818,38 @@ Checks whether this **RationalNumber** object equals the given object.
let result = rationalNumber.equals(rational);
```
+### getCommonFactor9+
+
+getCommonFactor(number1: number,number2: number): number
+
+Obtains the greatest common divisor of two specified integers.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ------- | ------ | ---- | ---------- |
+| number1 | number | Yes | The first integer used to get the greatest common divisor.|
+| number2 | number | Yes | The second integer used to get the greatest common divisor.|
+
+**Return value**
+
+| Type | Description |
+| ------ | ------------------------------ |
+| number | Greatest common divisor obtained.|
-### getCommonDivisor8+
+**Example**
+
+ ```js
+let rationalNumber = new util.RationalNumber(1,2);
+let result = util.RationalNumber.getCommonFactor(4,6);
+ ```
+
+### getCommonDivisor8+(deprecated)
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [getCommonFactor9+](#getcommonfactor9) instead.
static getCommonDivisor(number1: number,number2: number): number
@@ -614,7 +876,6 @@ Obtains the greatest common divisor of two specified integers.
let result = util.RationalNumber.getCommonDivisor(4,6);
```
-
### getNumerator8+
getNumerator(): number
@@ -635,7 +896,6 @@ Obtains the numerator of this **RationalNumber** object.
let result = rationalNumber.getNumerator();
```
-
### getDenominator8+
getDenominator(): number
@@ -656,7 +916,6 @@ Obtains the denominator of this **RationalNumber** object.
let result = rationalNumber.getDenominator();
```
-
### isZero8+
isZero():boolean
@@ -677,7 +936,6 @@ Checks whether this **RationalNumber** object is **0**.
let result = rationalNumber.isZero();
```
-
### isNaN8+
isNaN(): boolean
@@ -698,7 +956,6 @@ Checks whether this **RationalNumber** object is a Not a Number (NaN).
let result = rationalNumber.isNaN();
```
-
### isFinite8+
isFinite():boolean
@@ -719,7 +976,6 @@ Checks whether this **RationalNumber** object represents a finite value.
let result = rationalNumber.isFinite();
```
-
### toString8+
toString(): string
@@ -740,46 +996,48 @@ Obtains the string representation of this **RationalNumber** object.
let result = rationalNumber.toString();
```
-## LruBuffer8+
+
+## LRUCache9+
### Attributes
**System capability**: SystemCapability.Utils.Lang
-| Name| Type| Readable| Writable| Description|
-| -------- | -------- | -------- | -------- | -------- |
-| length | number | Yes| No| Total number of values in this buffer.|
+| Name | Type | Readable| Writable| Description |
+| ------ | ------ | ---- | ---- | ---------------------- |
+| length | number | Yes | No | Total number of values in this buffer. |
**Example**
+
```js
- let pro = new util.LruBuffer();
- pro.put(2,10);
- pro.put(1,8);
- let result = pro.length;
+let pro = new util.LRUCache();
+pro.put(2,10);
+pro.put(1,8);
+let result = pro.length;
```
-
-### constructor8+
+### constructor9+
constructor(capacity?: number)
-A constructor used to create an **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.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| capacity | number | No| Capacity of the **LruBuffer** to create.|
+| Name | Type | Mandatory| Description |
+| -------- | ------ | ---- | ---------------------------- |
+| capacity | number | No | Capacity of the **LruBuffer** to create.|
**Example**
+
```js
- let lrubuffer= new util.LruBuffer();
+let lrubuffer= new util.LRUCache();
```
-### updateCapacity8+
+### updateCapacity9+
updateCapacity(newCapacity: number): void
@@ -789,18 +1047,19 @@ Changes the **LruBuffer** capacity. If the new capacity is less than or equal to
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| newCapacity | number | Yes| New capacity of the **LruBuffer**.|
+| Name | Type | Mandatory| Description |
+| ----------- | ------ | ---- | ---------------------------- |
+| newCapacity | number | Yes | New capacity of the **LruBuffer**.|
**Example**
+
```js
- let pro = new util.LruBuffer();
- let result = pro.updateCapacity(100);
+let pro = new util.LRUCache();
+let result = pro.updateCapacity(100);
```
-### toString8+
+### toString9+
toString(): string
@@ -810,21 +1069,579 @@ Obtains the string representation of this **LruBuffer** object.
**Return value**
-| Type| Description|
-| -------- | -------- |
+| Type | Description |
+| ------ | -------------------------- |
| string | String representation of this **LruBuffer** object.|
**Example**
+
```js
- let pro = new util.LruBuffer();
+let pro = new util.LRUCache();
+pro.put(2,10);
+pro.get(2);
+pro.remove(20);
+let result = pro.toString();
+ ```
+
+
+### getCapacity9+
+
+getCapacity(): number
+
+Obtains the capacity of this buffer.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Return value**
+
+| Type | Description |
+| ------ | ---------------------- |
+| number | Capacity of this buffer.|
+
+**Example**
+
+ ```js
+let pro = new util.LRUCache();
+let result = pro.getCapacity();
+ ```
+
+
+### clear9+
+
+clear(): void
+
+Clears key-value pairs from this buffer. The **afterRemoval()** method will be called to perform subsequent operations.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Example**
+
+ ```js
+let pro = new util.LRUCache();
+pro.put(2,10);
+let result = pro.length;
+pro.clear();
+ ```
+
+
+### getCreateCount9+
+
+getCreateCount(): number
+
+Obtains the number of return values for **createDefault()**.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Return value**
+
+| Type | Description |
+| ------ | --------------------------------- |
+| number | Number of return values for **createDefault()**.|
+
+**Example**
+
+ ```js
+let pro = new util.LRUCache();
+pro.put(1,8);
+let result = pro.getCreateCount();
+ ```
+
+
+### getMissCount9+
+
+getMissCount(): number
+
+Obtains the number of times that the queried values are mismatched.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Return value**
+
+| Type | Description |
+| ------ | ------------------------ |
+| number | Number of times that the queried values are mismatched.|
+
+**Example**
+
+ ```js
+let pro = new util.LRUCache();
+pro.put(2,10);
+pro.get(2);
+let result = pro.getMissCount();
+ ```
+
+
+### getRemovalCount9+
+
+getRemovalCount(): number
+
+Obtains the number of removals from this buffer.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Return value**
+
+| Type | Description |
+| ------ | -------------------------- |
+| number | Number of removals from the buffer.|
+
+**Example**
+
+ ```js
+let pro = new util.LRUCache();
+pro.put(2,10);
+pro.updateCapacity(2);
+pro.put(50,22);
+let result = pro.getRemovalCount();
+ ```
+
+
+### getMatchCount9+
+
+getMatchCount(): number
+
+Obtains the number of times that the queried values are matched.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Return value**
+
+| Type | Description |
+| ------ | -------------------------- |
+| number | Number of times that the queried values are matched.|
+
+**Example**
+
+ ```js
+let pro = new util.LRUCache();
+pro.put(2,10);
+pro.get(2);
+let result = pro.getMatchCount();
+ ```
+
+
+### getPutCount9+
+
+getPutCount(): number
+
+Obtains the number of additions to this buffer.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Return value**
+
+| Type | Description |
+| ------ | ---------------------------- |
+| number | Number of additions to the buffer.|
+
+**Example**
+
+ ```js
+let pro = new util.LRUCache();
+pro.put(2,10);
+let result = pro.getPutCount();
+ ```
+
+
+### isEmpty9+
+
+isEmpty(): boolean
+
+Checks whether this buffer is empty.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Return value**
+
+| Type | Description |
+| ------- | ---------------------------------------- |
+| boolean | Returns **true** if the buffer does not contain any value.|
+
+**Example**
+
+ ```js
+let pro = new util.LRUCache();
+pro.put(2,10);
+let result = pro.isEmpty();
+ ```
+
+
+### get9+
+
+get(key: K): V | undefined
+
+Obtains the value of the specified key.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description |
+| ------ | ---- | ---- | ------------ |
+| key | K | Yes | Key based on which the value is queried.|
+
+**Return value**
+
+| Type | Description |
+| ------------------------ | ------------------------------------------------------------ |
+| V \| undefined | Returns the value of the key if a match is found in the buffer; returns **undefined** otherwise.|
+
+**Example**
+
+ ```js
+let pro = new util.LRUCache();
+pro.put(2,10);
+let result = pro.get(2);
+ ```
+
+
+### put9+
+
+put(key: K,value: V): V
+
+Adds a key-value pair to this buffer.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description |
+| ------ | ---- | ---- | -------------------------- |
+| key | K | Yes | Key of the key-value pair to add. |
+| value | V | Yes | Value of the key-value pair to add.|
+
+**Return value**
+
+| Type| Description |
+| ---- | ------------------------------------------------------------ |
+| 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**
+
+ ```js
+let pro = new util.LRUCache();
+let result = pro.put(2,10);
+ ```
+
+### values9+
+
+values(): V[]
+
+Obtains all values in this buffer, listed from the most to the least recently accessed.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Return value**
+
+| Type | Description |
+| --------- | ------------------------------------------------------------ |
+| V [] | All values in the buffer, listed from the most to the least recently accessed.|
+
+**Example**
+
+ ```js
+let pro = new util.LRUCache();
+pro.put(2,10);
+pro.put(2,"anhu");
+pro.put("afaf","grfb");
+let result = pro.values();
+ ```
+
+
+### keys9+
+
+keys(): K[]
+
+Obtains all keys in this buffer, listed from the most to the least recently accessed.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Return value**
+
+| Type | Description |
+| --------- | ------------------------------------------------------------ |
+| K [] | All keys in the buffer, listed from the most to the least recently accessed.|
+
+**Example**
+
+ ```js
+let pro = new util.LRUCache();
+pro.put(2,10);
+let result = pro.keys();
+ ```
+
+
+### remove9+
+
+remove(key: K): V | undefined
+
+Removes the specified key and its value from this buffer.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description |
+| ------ | ---- | ---- | -------------- |
+| key | K | Yes | Key to remove.|
+
+**Return value**
+
+| Type | Description |
+| ------------------------ | ------------------------------------------------------------ |
+| V \| 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.|
+
+**Example**
+
+ ```js
+let pro = new util.LRUCache();
+pro.put(2,10);
+let result = pro.remove(20);
+ ```
+
+
+### afterRemoval9+
+
+afterRemoval(isEvict: boolean,key: K,value: V,newValue: V): void
+
+Performs subsequent operations after a value is removed.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| 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. |
+| key | K | Yes | Key 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.|
+
+**Example**
+
+ ```js
+let arr = [];
+class ChildLruBuffer extends util.LRUCache
+{
+ constructor()
+ {
+ super();
+ }
+ afterRemoval(isEvict, key, value, newValue)
+ {
+ if (isEvict === false)
+ {
+ arr = [key, value, newValue];
+ }
+ }
+}
+let lru = new ChildLruBuffer();
+lru.afterRemoval(false,10,30,null);
+ ```
+
+
+### contains9+
+
+contains(key: K): boolean
+
+Checks whether this buffer contains the specified key.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description |
+| ------ | ---- | ---- | ---------------- |
+| key | K | Yes | Key to check.|
+
+**Return value**
+
+| Type | Description |
+| ------- | ------------------------------------------ |
+| boolean | Returns **true** if the buffer contains the specified key; returns **false** otherwise.|
+
+**Example**
+
+ ```js
+let pro = new util.LRUCache();
+pro.put(2,10);
+let result = pro.contains(20);
+ ```
+
+
+### createDefault9+
+
+createDefault(key: K): V
+
+Creates a value if the value of the specified key is not available.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description |
+| ------ | ---- | ---- | -------------- |
+| key | K | Yes | Key of which the value is missing.|
+
+**Return value**
+
+| Type| Description |
+| ---- | ------------------ |
+| V | Value of the key.|
+
+**Example**
+
+ ```js
+let pro = new util.LRUCache();
+let result = pro.createDefault(50);
+ ```
+
+
+### entries9+
+
+entries(): IterableIterator<[K,V]>
+
+Obtains a new iterator object that contains all key-value pairs in this object.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Return value**
+
+| Type | Description |
+| ----------- | -------------------- |
+| [K, V] | Iterable array.|
+
+**Example**
+
+ ```js
+let pro = new util.LRUCache();
+pro.put(2,10);
+let result = pro.entries();
+ ```
+
+### [Symbol.iterator]9+
+
+[Symbol.iterator]\(): IterableIterator<[K, V]>
+
+Obtains a two-dimensional array in key-value pairs.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Return value**
+
+| Type | Description |
+| ----------- | ------------------------------ |
+| [K, V] | Two-dimensional array in key-value pairs.|
+
+**Example**
+
+ ```js
+let pro = new util.LRUCache();
+pro.put(2,10);
+let result = pro[Symbol.iterator]();
+ ```
+
+## LruBuffer8+(deprecated)
+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [LRUCache9+](#lrucache9) instead.
+
+### Attributes
+
+**System capability**: SystemCapability.Utils.Lang
+
+| Name| Type| Readable| Writable| Description|
+| -------- | -------- | -------- | -------- | -------- |
+| length | number | Yes| No| Total number of values in this buffer.|
+
+**Example**
+ ```js
+ let pro = new util.LruBuffer();
+ pro.put(2,10);
+ pro.put(1,8);
+ let result = pro.length;
+ ```
+
+### constructor8+(deprecated)
+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [constructor9+](#constructor9) instead.
+
+constructor(capacity?: number)
+
+A constructor used to create a **LruBuffer** instance. The default capacity of the buffer is 64.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| capacity | number | No| Capacity of the **LruBuffer** to create.|
+
+**Example**
+ ```js
+ let lrubuffer= new util.LruBuffer();
+ ```
+
+### updateCapacity8+(deprecated)
+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [updateCapacity9+](#updatecapacity9) instead.
+
+updateCapacity(newCapacity: number): void
+
+Changes the **LruBuffer** capacity. If the new capacity is less than or equal to **0**, an exception will be thrown.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| newCapacity | number | Yes| New capacity of the **LruBuffer**.|
+
+**Example**
+ ```js
+ let pro = new util.LruBuffer();
+ let result = pro.updateCapacity(100);
+ ```
+
+### toString8+(deprecated)
+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [toString9+](#tostring9) instead.
+
+toString(): string
+
+Obtains the string representation of this **LruBuffer** object.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| string | String representation of this **LruBuffer** object.|
+
+**Example**
+ ```js
+ let pro = new util.LruBuffer();
pro.put(2,10);
pro.get(2);
pro.remove(20);
let result = pro.toString();
```
+### getCapacity8+(deprecated)
-### getCapacity8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [getCapacity9+](#getcapacity9) instead.
getCapacity(): number
@@ -844,8 +1661,11 @@ Obtains the capacity of this buffer.
let result = pro.getCapacity();
```
+### clear8+(deprecated)
-### clear8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [clear9+](#clear9) instead.
clear(): void
@@ -861,8 +1681,11 @@ Clears key-value pairs from this buffer. The **afterRemoval()** method will be c
pro.clear();
```
+### getCreateCount8+(deprecated)
-### getCreateCount8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [getCreateCount9+](#getcreatecount9) instead.
getCreateCount(): number
@@ -883,8 +1706,11 @@ Obtains the number of return values for **createDefault()**.
let result = pro.getCreateCount();
```
+### getMissCount8+(deprecated)
-### getMissCount8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [getMissCount9+](#getmisscount9) instead.
getMissCount(): number
@@ -906,8 +1732,11 @@ Obtains the number of times that the queried values are mismatched.
let result = pro.getMissCount();
```
+### getRemovalCount8+(deprecated)
-### getRemovalCount8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [getRemovalCount9+](#getremovalcount9) instead.
getRemovalCount(): number
@@ -930,8 +1759,11 @@ Obtains the number of removals from this buffer.
let result = pro.getRemovalCount();
```
+### getMatchCount8+(deprecated)
-### getMatchCount8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [getMatchCount9+](#getmatchcount9) instead.
getMatchCount(): number
@@ -953,8 +1785,11 @@ Obtains the number of times that the queried values are matched.
let result = pro.getMatchCount();
```
+### getPutCount8+(deprecated)
-### getPutCount8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [getPutCount9+](#getputcount9) instead.
getPutCount(): number
@@ -975,8 +1810,11 @@ Obtains the number of additions to this buffer.
let result = pro.getPutCount();
```
+### isEmpty8+(deprecated)
-### isEmpty8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [isEmpty9+](#isempty9) instead.
isEmpty(): boolean
@@ -997,8 +1835,11 @@ Checks whether this buffer is empty.
let result = pro.isEmpty();
```
+### get8+(deprecated)
-### get8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [get9+](#get9) instead.
get(key: K): V | undefined
@@ -1016,7 +1857,7 @@ Obtains the value of the specified key.
| Type| Description|
| -------- | -------- |
-| V \| 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 buffer; returns **undefined** otherwise.|
**Example**
```js
@@ -1025,8 +1866,11 @@ Obtains the value of the specified key.
let result = pro.get(2);
```
+### put8+(deprecated)
-### put8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [put9+](#put9) instead.
put(key: K,value: V): V
@@ -1053,7 +1897,11 @@ Adds a key-value pair to this buffer.
let result = pro.put(2,10);
```
-### values8+
+### values8+(deprecated)
+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [values9+](#values9) instead.
values(): V[]
@@ -1065,7 +1913,7 @@ Obtains all values in this buffer, listed from the most to the least recently ac
| Type| Description|
| -------- | -------- |
-| V [] | All values in the buffer, listed from the most to the least recently accessed.|
+| V [] | All values in the buffer, listed from the most to the least recently accessed.|
**Example**
```js
@@ -1076,8 +1924,11 @@ Obtains all values in this buffer, listed from the most to the least recently ac
let result = pro.values();
```
+### keys8+(deprecated)
-### keys8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [keys9+](#keys9) instead.
keys(): K[]
@@ -1089,7 +1940,7 @@ Obtains all keys in this buffer, listed from the most to the least recently acce
| Type| Description|
| -------- | -------- |
-| K [] | All keys in the buffer, listed from the most to the least recently accessed.|
+| K [] | All keys in the buffer, listed from the most to the least recently accessed.|
**Example**
```js
@@ -1098,8 +1949,11 @@ Obtains all keys in this buffer, listed from the most to the least recently acce
let result = pro.keys();
```
+### remove8+(deprecated)
-### remove8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [remove9+](#remove9) instead.
remove(key: K): V | undefined
@@ -1117,7 +1971,7 @@ Removes the specified key and its value from this buffer.
| Type| Description|
| -------- | -------- |
-| V \| 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 \| 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.|
**Example**
```js
@@ -1126,8 +1980,11 @@ Removes the specified key and its value from this buffer.
let result = pro.remove(20);
```
+### afterRemoval8+(deprecated)
-### afterRemoval8+
+> **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
@@ -1165,8 +2022,11 @@ Performs subsequent operations after a value is removed.
lru.afterRemoval(false,10,30,null);
```
+### contains8+(deprecated)
-### contains8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [contains9+](#contains9) instead.
contains(key: K): boolean
@@ -1193,8 +2053,11 @@ Checks whether this buffer contains the specified key.
let result = pro.contains(20);
```
+### createDefault8+(deprecated)
-### createDefault8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [createDefault9+](#createdefault9) instead.
createDefault(key: K): V
@@ -1216,96 +2079,462 @@ Creates a value if the value of the specified key is not available.
**Example**
```js
- let pro = new util.LruBuffer();
- let result = pro.createDefault(50);
+ let pro = new util.LruBuffer();
+ let result = pro.createDefault(50);
+ ```
+
+### entries8+(deprecated)
+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [entries9+](#entries9) instead.
+
+entries(): IterableIterator<[K,V]>
+
+Obtains a new iterator object that contains all key-value pairs in this object.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| [K, V] | Iterable array.|
+
+**Example**
+ ```js
+ let pro = new util.LruBuffer();
+ pro.put(2,10);
+ let result = pro.entries();
+ ```
+
+### [Symbol.iterator]8+(deprecated)
+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [Symbol.iterator9+](#symboliterator9) instead.
+
+[Symbol.iterator]\(): IterableIterator<[K, V]>
+
+Obtains a two-dimensional array in key-value pairs.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| [K, V] | Two-dimensional array in key-value pairs.|
+
+**Example**
+ ```js
+ let pro = new util.LruBuffer();
+ pro.put(2,10);
+ let result = pro[Symbol.iterator]();
+ ```
+
+### ScopeType8+
+
+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.
+```js
+interface ScopeComparable{
+ compareTo(other: ScopeComparable): boolean;
+}
+type ScopeType = ScopeComparable | number;
+```
+
+
+Create a class to implement the **compareTo** method. In the subsequent sample code, **Temperature** is used as an example of the [ScopeType](#scopetype8) object.
+
+
+Example
+```js
+class Temperature{
+ constructor(value){
+ // If TS is used for development, add the following code:
+ // private readonly _temp: Temperature;
+ this._temp = value;
+ }
+ compareTo(value){
+ return this._temp >= value.getTemp();
+ }
+ getTemp(){
+ return this._temp;
+ }
+ toString(){
+ return this._temp.toString();
+ }
+}
+```
+
+## ScopeHelper9+
+
+### constructor9+
+
+constructor(lowerObj: ScopeType, upperObj: ScopeType)
+
+A constructor used to create a **ScopeHelper** object with the specified upper and lower limits.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------ | ---- | ---------------------- |
+| lowerObj | [ScopeType](#scopetype8) | Yes | Lower limit of the **Scope** object.|
+| upperObj | [ScopeType](#scopetype8) | Yes | Upper limit of the **Scope** object.|
+
+**Example**
+
+ ```js
+let tempLower = new Temperature(30);
+let tempUpper = new Temperature(40);
+let range = new util.ScopeHelper(tempLower, tempUpper);
+ ```
+
+
+### toString9+
+
+toString(): string
+
+Obtains a string representation that contains this **Scope**.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Return value**
+
+| Type | Description |
+| ------ | -------------------------------------- |
+| string | String representation containing the **Scope**.|
+
+**Example**
+
+ ```js
+let tempLower = new Temperature(30);
+let tempUpper = new Temperature(40);
+let range = new util.ScopeHelper(tempLower, tempUpper);
+let result = range.toString();
+ ```
+
+
+### intersect9+
+
+intersect(range: ScopeHelper): ScopeHelper
+
+Obtains the intersection of this **Scope** and the given **Scope**.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------------------------------ | ---- | ------------------ |
+| range | [ScopeHelper9+](#scopehelper9) | Yes | **Scope** specified.|
+
+**Return value**
+
+| Type | Description |
+| ------------------------------ | ------------------------------ |
+| [ScopeHelper9+](#scopehelper9) | Intersection of this **Scope** and the given **Scope**.|
+
+**Example**
+
+ ```js
+let tempLower = new Temperature(30);
+let tempUpper = new Temperature(40);
+let range = new util.ScopeHelper(tempLower, tempUpper);
+let tempMiDF = new Temperature(35);
+let tempMidS = new Temperature(39);
+let rangeFir = new util.ScopeHelper(tempMiDF, tempMidS);
+range.intersect(rangeFir );
+ ```
+
+
+### intersect9+
+
+intersect(lowerObj:ScopeType,upperObj:ScopeType):ScopeHelper
+
+Obtains the intersection of this **Scope** and the given lower and upper limits.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------ | ---- | ---------------- |
+| lowerObj | [ScopeType](#scopetype8) | Yes | Lower limit.|
+| upperObj | [ScopeType](#scopetype8) | Yes | Upper limit.|
+
+**Return value**
+
+| Type | Description |
+| ------------------------------ | ---------------------------------------- |
+| [ScopeHelper9+](#scopehelper9) | Intersection of this **Scope** and the given lower and upper limits.|
+
+**Example**
+
+ ```js
+let tempLower = new Temperature(30);
+let tempUpper = new Temperature(40);
+let tempMiDF = new Temperature(35);
+let tempMidS = new Temperature(39);
+let range = new util.ScopeHelper(tempLower, tempUpper);
+let result = range.intersect(tempMiDF, tempMidS);
+ ```
+
+
+### getUpper9+
+
+getUpper(): ScopeType
+
+Obtains the upper limit of this **Scope**.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Return value**
+
+| Type | Description |
+| ------------------------ | ---------------------- |
+| [ScopeType](#scopetype8) | Upper limit of this **Scope**.|
+
+**Example**
+
+ ```js
+let tempLower = new Temperature(30);
+let tempUpper = new Temperature(40);
+let range = new util.ScopeHelper(tempLower, tempUpper);
+let result = range.getUpper();
+ ```
+
+
+### getLower9+
+
+getLower(): ScopeType
+
+Obtains the lower limit of this **Scope**.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Return value**
+
+| Type | Description |
+| ------------------------ | ---------------------- |
+| [ScopeType](#scopetype8) | Lower limit of this **Scope**.|
+
+**Example**
+
+ ```js
+let tempLower = new Temperature(30);
+let tempUpper = new Temperature(40);
+let range = new util.ScopeHelper(tempLower, tempUpper);
+let result = range.getLower();
+ ```
+
+
+### expand9+
+
+expand(lowerObj: ScopeType,upperObj: ScopeType): ScopeHelper
+
+Obtains the union set of this **Scope** and the given lower and upper limits.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------ | ---- | ---------------- |
+| lowerObj | [ScopeType](#scopetype8) | Yes | Lower limit.|
+| upperObj | [ScopeType](#scopetype8) | Yes | Upper limit.|
+
+**Return value**
+
+| Type | Description |
+| ------------------------------ | ------------------------------------ |
+| [ScopeHelper9+](#scopehelper9) | Union set of this **Scope** and the given lower and upper limits.|
+
+**Example**
+
+ ```js
+let tempLower = new Temperature(30);
+let tempUpper = new Temperature(40);
+let tempMiDF = new Temperature(35);
+let tempMidS = new Temperature(39);
+let range = new util.ScopeHelper(tempLower, tempUpper);
+let result = range.expand(tempMiDF, tempMidS);
+ ```
+
+
+### expand9+
+
+expand(range: ScopeHelper): ScopeHelper
+
+Obtains the union set of this **Scope** and the given **Scope**.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------------------------------ | ---- | ------------------ |
+| range | [ScopeHelper9+](#scopehelper9) | Yes | **Scope** specified.|
+
+**Return value**
+
+| Type | Description |
+| ------------------------------ | ---------------------------------- |
+| [ScopeHelper9+](#scopehelper9) | Union set of this **Scope** and the given **Scope**.|
+
+**Example**
+
+ ```js
+let tempLower = new Temperature(30);
+let tempUpper = new Temperature(40);
+let tempMiDF = new Temperature(35);
+let tempMidS = new Temperature(39);
+let range = new util.ScopeHelper(tempLower, tempUpper);
+let rangeFir = new util.ScopeHelper(tempMiDF, tempMidS);
+let result = range.expand(rangeFir);
+ ```
+
+
+### expand9+
+
+expand(value: ScopeType): ScopeHelper
+
+Obtains the union set of this **Scope** and the given value.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------------------------ | ---- | ---------------- |
+| value | [ScopeType](#scopetype8) | Yes | Value specified.|
+
+**Return value**
+
+| Type | Description |
+| ------------------------------ | -------------------------------- |
+| [ScopeHelper9+](#scopehelper9) | Union set of this **Scope** and the given value.|
+
+**Example**
+
+ ```js
+let tempLower = new Temperature(30);
+let tempUpper = new Temperature(40);
+let tempMiDF = new Temperature(35);
+let range = new util.ScopeHelper(tempLower, tempUpper);
+let result = range.expand(tempMiDF);
```
-### entries8+
+### contains9+
-entries(): IterableIterator<[K,V]>
+contains(value: ScopeType): boolean
-Obtains a new iterator object that contains all key-value pairs in this object.
+Checks whether a value is within this **Scope**.
**System capability**: SystemCapability.Utils.Lang
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------------------------ | ---- | ---------------- |
+| value | [ScopeType](#scopetype8) | Yes | Value specified.|
+
**Return value**
-| Type| Description|
-| -------- | -------- |
-| [K, V] | Iterable array.|
+| Type | Description |
+| ------- | --------------------------------------------------- |
+| boolean | Returns **true** if the value is within this **Scope**; returns **false** otherwise.|
**Example**
+
```js
- let pro = new util.LruBuffer();
- pro.put(2,10);
- let result = pro.entries();
+let tempLower = new Temperature(30);
+let tempUpper = new Temperature(40);
+let tempMiDF = new Temperature(35);
+let range = new util.ScopeHelper(tempLower, tempUpper);
+range.contains(tempMiDF);
```
-### [Symbol.iterator]8+
+### contains9+
-[Symbol.iterator]\(): IterableIterator<[K, V]>
+contains(range: ScopeHelper): boolean
-Obtains a two-dimensional array in key-value pairs.
+Checks whether a range is within this **Scope**.
**System capability**: SystemCapability.Utils.Lang
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------------------------------ | ---- | ------------------ |
+| range | [ScopeHelper9+](#scopehelper9) | Yes | **Scope** specified.|
+
**Return value**
-| Type| Description|
-| -------- | -------- |
-| [K, V] | Two-dimensional array in key-value pairs.|
+| Type | Description |
+| ------- | ----------------------------------------------------- |
+| boolean | Returns **true** if the range is within this **Scope**; returns **false** otherwise.|
**Example**
+
```js
- let pro = new util.LruBuffer();
- pro.put(2,10);
- let result = pro[Symbol.iterator]();
+let tempLower = new Temperature(30);
+let tempUpper = new Temperature(40);
+let range = new util.ScopeHelper(tempLower, tempUpper);
+let tempLess = new Temperature(20);
+let tempMore = new Temperature(45);
+let rangeSec = new util.ScopeHelper(tempLess, tempMore);
+let result = range.contains(rangeSec);
```
-## Scope8+
+### clamp9+
+clamp(value: ScopeType): ScopeType
-### ScopeType8+
+Limits a value to this **Scope**.
-Defines the type of values in a **Scope** object. The value type can be **ScopeComparable** or **number**.
+**System capability**: SystemCapability.Utils.Lang
-The values of the **ScopeComparable** type are used to implement the **compareTo** method. Therefore, ensure that the input parameters are comparable.
-```js
-interface ScopeComparable{
- compareTo(other: ScopeComparable): boolean;
-}
-type ScopeType = ScopeComparable | number;
-```
+**Parameters**
+| Name| Type | Mandatory| Description |
+| ------ | ------------------------ | ---- | -------------- |
+| value | [ScopeType](#scopetype8) | Yes | Value specified.|
-Create a class to implement the **compareTo** method. In the subsequent sample code, **Temperature** is used as an example of the [ScopeType](#scopetype8) object.
+**Return value**
+| Type | Description |
+| ------------------------ | ------------------------------------------------------------ |
+| [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
-```js
-class Temperature{
- constructor(value){
- // If TS is used for development, add the following code:
- // private readonly _temp: Temperature;
- this._temp = value;
- }
- compareTo(value){
- return this._temp >= value.getTemp();
- }
- getTemp(){
- return this._temp;
- }
- toString(){
- return this._temp.toString();
- }
-}
-```
+**Example**
+ ```js
+let tempLower = new Temperature(30);
+let tempUpper = new Temperature(40);
+let tempMiDF = new Temperature(35);
+let range = new util.ScopeHelper(tempLower, tempUpper);
+let result = range.clamp(tempMiDF);
+ ```
-### constructor8+
+## Scope8+(deprecated)
+
+> **NOTE**
+>
+> This class is deprecated since API version 9. You are advised to use [ScopeHelper9+](#scopehelper9) instead.
+
+### constructor8+(deprecated)
+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [constructor9+](#constructor9) instead.
constructor(lowerObj: ScopeType, upperObj: ScopeType)
@@ -1327,8 +2556,11 @@ A constructor used to create a **Scope** object with the specified upper and low
let range = new util.Scope(tempLower, tempUpper);
```
+### toString8+(deprecated)
-### toString8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [toString9+](#tostring9) instead.
toString(): string
@@ -1350,8 +2582,11 @@ Obtains a string representation that contains this **Scope**.
let result = range.toString();
```
+### intersect8+(deprecated)
-### intersect8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [intersect9+](#intersect9) instead.
intersect(range: Scope): Scope
@@ -1372,6 +2607,7 @@ Obtains the intersection of this **Scope** and the given **Scope**.
| [Scope](#scope8) | Intersection of this **Scope** and the given **Scope**.|
**Example**
+
```js
let tempLower = new Temperature(30);
let tempUpper = new Temperature(40);
@@ -1382,8 +2618,11 @@ Obtains the intersection of this **Scope** and the given **Scope**.
range.intersect(rangeFir );
```
+### intersect8+(deprecated)
-### intersect8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [intersect9+](#intersect9) instead.
intersect(lowerObj:ScopeType,upperObj:ScopeType):Scope
@@ -1414,8 +2653,11 @@ Obtains the intersection of this **Scope** and the given lower and upper limits.
let result = range.intersect(tempMiDF, tempMidS);
```
+### getUpper8+(deprecated)
-### getUpper8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [getUpper9+](#getupper9) instead.
getUpper(): ScopeType
@@ -1437,8 +2679,11 @@ Obtains the upper limit of this **Scope**.
let result = range.getUpper();
```
+### getLower8+(deprecated)
-### getLower8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [getLower9+](#getlower9) instead.
getLower(): ScopeType
@@ -1460,8 +2705,11 @@ Obtains the lower limit of this **Scope**.
let result = range.getLower();
```
+### expand8+(deprecated)
-### expand8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [expand9+](#expand9) instead.
expand(lowerObj: ScopeType,upperObj: ScopeType): Scope
@@ -1493,8 +2741,11 @@ Obtains the union set of this **Scope** and the given lower and upper limits.
let result = range.expand(tempMiDF, tempMidS);
```
+### expand8+(deprecated)
-### expand8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [expand9+](#expand9) instead.
expand(range: Scope): Scope
@@ -1525,8 +2776,11 @@ Obtains the union set of this **Scope** and the given **Scope**.
let result = range.expand(rangeFir);
```
+### expand8+(deprecated)
-### expand8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [expand9+](#expand9) instead.
expand(value: ScopeType): Scope
@@ -1555,8 +2809,11 @@ Obtains the union set of this **Scope** and the given value.
let result = range.expand(tempMiDF);
```
+### contains8+(deprecated)
-### contains8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [contains9+](#contains9) instead.
contains(value: ScopeType): boolean
@@ -1585,8 +2842,11 @@ Checks whether a value is within this **Scope**.
range.contains(tempMiDF);
```
+### contains8+(deprecated)
-### contains8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [contains9+](#contains9) instead.
contains(range: Scope): boolean
@@ -1607,6 +2867,7 @@ Checks whether a range is within this **Scope**.
| boolean | Returns **true** if the range is within this **Scope**; returns **false** otherwise.|
**Example**
+
```js
let tempLower = new Temperature(30);
let tempUpper = new Temperature(40);
@@ -1617,8 +2878,11 @@ Checks whether a range is within this **Scope**.
let result = range.contains(rangeSec);
```
+### clamp8+(deprecated)
-### clamp8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [clamp9+](#clamp9) instead.
clamp(value: ScopeType): ScopeType
@@ -1647,11 +2911,219 @@ Limits a value to this **Scope**.
let result = range.clamp(tempMiDF);
```
+## Base64Helper9+
+
+### constructor9+
-## Base648+
+constructor()
+A constructor used to create a **Base64Helper** instance.
-### constructor8+
+**System capability**: SystemCapability.Utils.Lang
+
+**Example**
+
+ ```js
+let base64 = new util.Base64Helper();
+ ```
+
+### encodeSync9+
+
+encodeSync(src: Uint8Array): Uint8Array
+
+Encodes the input content.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ---------- | ---- | ------------------- |
+| src | Uint8Array | Yes | Uint8Array to encode.|
+
+**Return value**
+
+| Type | Description |
+| ---------- | ----------------------------- |
+| Uint8Array | Uint8Array encoded.|
+
+**Example**
+
+ ```js
+let that = new util.Base64Helper();
+let array = new Uint8Array([115,49,51]);
+let result = that.encodeSync(array);
+ ```
+
+
+### encodeToStringSync9+
+
+encodeToStringSync(src: Uint8Array): string
+
+Encodes the input content.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ---------- | ---- | ------------------- |
+| src | Uint8Array | Yes | Uint8Array to encode.|
+
+**Return value**
+
+| Type | Description |
+| ------ | -------------------- |
+| string | String encoded from the Uint8Array.|
+
+**Example**
+
+ ```js
+let that = new util.Base64Helper();
+let array = new Uint8Array([115,49,51]);
+let result = that.encodeToStringSync(array);
+ ```
+
+
+### decodeSync9+
+
+decodeSync(src: Uint8Array | string): Uint8Array
+
+Decodes the input content.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------------------------------ | ---- | ----------------------------- |
+| src | Uint8Array \| string | Yes | Uint8Array or string to decode.|
+
+**Return value**
+
+| Type | Description |
+| ---------- | ----------------------------- |
+| Uint8Array | Uint8Array decoded.|
+
+**Example**
+
+ ```js
+let that = new util.Base64Helper();
+let buff = 'czEz';
+let result = that.decodeSync(buff);
+ ```
+
+
+### encode9+
+
+encode(src: Uint8Array): Promise<Uint8Array>
+
+Encodes the input content asynchronously.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ---------- | ---- | ----------------------- |
+| src | Uint8Array | Yes | Uint8Array to encode asynchronously.|
+
+**Return value**
+
+| Type | Description |
+| ------------------------- | --------------------------------- |
+| Promise<Uint8Array> | Uint8Array obtained after asynchronous encoding.|
+
+**Example**
+
+ ```js
+let that = new util.Base64Helper();
+let array = new Uint8Array([115,49,51]);
+let rarray = new Uint8Array([99,122,69,122]);
+that.encode(array).then(val=>{
+ for (var i = 0; i < rarray.length; i++) {
+ console.log(val[i].toString())
+ }
+})
+ ```
+
+
+### encodeToString9+
+
+encodeToString(src: Uint8Array): Promise<string>
+
+Encodes the input content asynchronously.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ---------- | ---- | ----------------------- |
+| src | Uint8Array | Yes | Uint8Array to encode asynchronously.|
+
+**Return value**
+
+| Type | Description |
+| --------------------- | ------------------------ |
+| Promise<string> | String obtained after asynchronous encoding.|
+
+**Example**
+
+ ```js
+let that = new util.Base64Helper();
+let array = new Uint8Array([115,49,51]);
+that.encodeToString(array).then(val=>{
+ console.log(val)
+})
+ ```
+
+
+### decode9+
+
+decode(src: Uint8Array | string): Promise<Uint8Array>
+
+Decodes the input content asynchronously.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------------------------------ | ---- | --------------------------------- |
+| src | Uint8Array \| string | Yes | Uint8Array or string to decode asynchronously.|
+
+**Return value**
+
+| Type | Description |
+| ------------------------- | --------------------------------- |
+| Promise<Uint8Array> | Uint8Array obtained after asynchronous decoding.|
+
+**Example**
+
+ ```js
+let that = new util.Base64Helper();
+let array = new Uint8Array([99,122,69,122]);
+let rarray = new Uint8Array([115,49,51]);
+that.decode(array).then(val=>{
+ for (var i = 0; i < rarray.length; i++) {
+ console.log(val[i].toString())
+ }
+})
+ ```
+
+
+## Base648+(deprecated)
+
+> **NOTE**
+>
+> This class is deprecated since API version 9. You are advised to use [Base64Helper9+](#base64helper9) instead.
+
+### constructor8+(deprecated)
+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [constructor9+](#constructor9) instead.
constructor()
@@ -1664,8 +3136,11 @@ A constructor used to create a **Base64** object.
let base64 = new util.Base64();
```
+### encodeSync8+(deprecated)
-### encodeSync8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [encodeSync9+](#encodesync9) instead.
encodeSync(src: Uint8Array): Uint8Array
@@ -1686,14 +3161,18 @@ Encodes the input content.
| Uint8Array | Uint8Array encoded.|
**Example**
+
```js
let that = new util.Base64();
let array = new Uint8Array([115,49,51]);
let result = that.encodeSync(array);
```
+### encodeToStringSync8+(deprecated)
-### encodeToStringSync8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [encodeToStringSync9+](#encodetostringsync9) instead.
encodeToStringSync(src: Uint8Array): string
@@ -1720,8 +3199,11 @@ Encodes the input content.
let result = that.encodeToStringSync(array);
```
+### decodeSync8+(deprecated)
-### decodeSync8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [decodeSync9+](#decodesync9) instead.
decodeSync(src: Uint8Array | string): Uint8Array
@@ -1733,7 +3215,7 @@ Decodes the input content.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| src | Uint8Array \| string | Yes| Uint8Array or string to decode.|
+| src | Uint8Array \| string | Yes| Uint8Array or string to decode.|
**Return value**
@@ -1748,8 +3230,11 @@ Decodes the input content.
let result = that.decodeSync(buff);
```
+### encode8+(deprecated)
-### encode8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [encode9+](#encode9) instead.
encode(src: Uint8Array): Promise<Uint8Array>
@@ -1781,8 +3266,11 @@ Encodes the input content asynchronously.
})
```
+### encodeToString8+(deprecated)
-### encodeToString8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [encodeToString9+](#encodetostring9) instead.
encodeToString(src: Uint8Array): Promise<string>
@@ -1811,8 +3299,11 @@ Encodes the input content asynchronously.
})
```
+### decode8+(deprecated)
-### decode8+
+> **NOTE**
+>
+> This API is deprecated since API version 9. You are advised to use [decode9+](#decode9) instead.
decode(src: Uint8Array | string): Promise<Uint8Array>
@@ -1824,7 +3315,7 @@ Decodes the input content asynchronously.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| src | Uint8Array \| string | Yes| Uint8Array or string to decode asynchronously.|
+| src | Uint8Array \| string | Yes| Uint8Array or string to decode asynchronously.|
**Return value**
@@ -1844,7 +3335,6 @@ Decodes the input content asynchronously.
})
```
-
## types8+
@@ -2929,3 +4419,4 @@ Checks whether the input value is of the **SharedArrayBuffer** type.
let that = new util.types();
let result = that.isSharedArrayBuffer(new SharedArrayBuffer(0));
```
+