From 52d88c79f2bd8862740bb080569282d3d24e9cdf Mon Sep 17 00:00:00 2001 From: lixingyang-li Date: Wed, 27 Apr 2022 16:41:29 +0800 Subject: [PATCH] Modify the sample code language tag type for language compilation runtime Signed-off-by: lixingyang-li https://gitee.com/openharmony/docs/issues/I550NM --- .../reference/apis/js-apis-convertxml.md | 2 +- .../reference/apis/js-apis-process.md | 46 +- .../reference/apis/js-apis-uri.md | 12 +- .../reference/apis/js-apis-url.md | 34 +- .../reference/apis/js-apis-util.md | 1189 +++++++++-------- .../reference/apis/js-apis-xml.md | 28 +- .../reference/apis/js-apis-convertxml.md | 2 +- .../reference/apis/js-apis-process.md | 47 +- .../reference/apis/js-apis-uri.md | 12 +- .../reference/apis/js-apis-url.md | 34 +- .../reference/apis/js-apis-util.md | 1189 +++++++++-------- .../reference/apis/js-apis-xml.md | 28 +- 12 files changed, 1313 insertions(+), 1310 deletions(-) diff --git a/en/application-dev/reference/apis/js-apis-convertxml.md b/en/application-dev/reference/apis/js-apis-convertxml.md index f403580810..7bf2fc1da2 100644 --- a/en/application-dev/reference/apis/js-apis-convertxml.md +++ b/en/application-dev/reference/apis/js-apis-convertxml.md @@ -39,7 +39,7 @@ Converts an XML text into a JavaScript object. - Example - ``` + ```js let xml = '' + '' + diff --git a/en/application-dev/reference/apis/js-apis-process.md b/en/application-dev/reference/apis/js-apis-process.md index 2eb5e69b83..f99ddb6580 100755 --- a/en/application-dev/reference/apis/js-apis-process.md +++ b/en/application-dev/reference/apis/js-apis-process.md @@ -60,7 +60,7 @@ Waits until the child process ends. This method uses a promise to return the exi **Example** -``` +```js var child = process.runCmd('ls'); var result = child.wait(); result.then(val=>{ @@ -85,7 +85,7 @@ Obtains the standard output of the child process. **Example** -``` +```js var child = process.runCmd('ls'); var result = child.wait(); child.getOutput.then(val=>{ @@ -110,7 +110,7 @@ Obtains the standard error output of the child process. **Example** -``` +```js var child = process.runCmd('madir test.text'); var result = child.wait(); child.getErrorOutput.then(val=>{ @@ -129,7 +129,7 @@ Closes the child process in running. **Example** -``` +```js var child = process.runCmd('sleep 5; ls'); child.close(); ``` @@ -151,7 +151,7 @@ Sends a signal to the specified child process to terminate it. **Example** -``` +```js var child = process.runCmd('sleep 5; ls'); child.kill(9); ``` @@ -173,7 +173,7 @@ Checks whether this process is isolated. **Example** -``` +```js var result = process.isIsolatedProcess(); ``` @@ -200,7 +200,7 @@ Checks whether a UID belongs to this app. **Example** -``` +```js var result = process.isAppUid(688); ``` @@ -221,7 +221,7 @@ Checks whether this process is running in a 64-bit environment. **Example** -``` +```js var ressult = process.is64Bit(); ``` @@ -248,7 +248,7 @@ Obtains the process UID based on the process name. **Example** -``` +```js var pres = process.getUidForName("tool") ``` @@ -275,7 +275,7 @@ Obtains the thread priority based on the specified TID. **Example** -``` +```js var tid = process.getTid(); var pres = process.getThreadPriority(tid); ``` @@ -297,7 +297,7 @@ Obtains the duration, in milliseconds, from the time the system starts to the ti **Example** -``` +```js var realtime = process.getStartRealtime(); ``` @@ -317,7 +317,7 @@ Obtains the CPU time (in milliseconds) from the time the process starts to the c **Example** -``` +```js var result = process.getPastCpuTime() ; ``` @@ -344,7 +344,7 @@ Obtains the system configuration. **Example** -``` +```js var _SC_ARG_MAX = 0 var pres = process.getSystemConfig(_SC_ARG_MAX) ``` @@ -372,7 +372,7 @@ Obtains the value of an environment variable. **Example** -``` +```js var pres = process.getEnvironmentVar("PATH") ``` @@ -408,7 +408,7 @@ Forks a new process to run a shell command and returns the **ChildProcess** obje **Example** -``` +```js var child = process.runCmd('ls', { maxBuffer : 2 }); var result = child.wait(); child.getOutput.then(val=>{ @@ -427,7 +427,7 @@ Aborts a process and generates a core file. This method will cause a process to **Example** -``` +```js process.abort(); ``` @@ -455,7 +455,7 @@ Stores the events triggered by the user. **Example** -``` +```js process.on("data", (e)=>{ console.log("data callback"); }) @@ -484,7 +484,7 @@ Deletes the event stored by the user. **Example** -``` +```js process.on("data", (e)=>{ console.log("data callback"); }) @@ -510,7 +510,7 @@ Exercise caution when using this API. **Example** -``` +```js process.exit(0); ``` @@ -525,7 +525,7 @@ Obtains the working directory of this process. **Example** -``` +```js var path = process.cwd(); ``` @@ -546,7 +546,7 @@ Changes the working directory of this process. **Example** -``` +```js process.chdir('/system'); ``` @@ -567,7 +567,7 @@ Obtains the running time of this process. **Example** -``` +```js var time = process.uptime(); ``` @@ -594,7 +594,7 @@ Sends a signal to the specified process to terminate it. | boolean | Returns **true** if the signal is sent successfully; returns **false** otherwise.| **Example** -``` +```js var pres = process.pid var result = that.kill(pres, 28) ``` diff --git a/en/application-dev/reference/apis/js-apis-uri.md b/en/application-dev/reference/apis/js-apis-uri.md index a7af3cedf7..0975f28256 100644 --- a/en/application-dev/reference/apis/js-apis-uri.md +++ b/en/application-dev/reference/apis/js-apis-uri.md @@ -46,11 +46,11 @@ A constructor used to create a URI instance. **Example** -``` +```js var mm = 'http://username:password@host:8080/directory/file?foo=1&bar=2#fragment'; new uri.URI(mm); // Output 'http://username:password@host:8080/directory/file?foo=1&bar=2#fragment'; ``` -``` +```js new uri.URI('http://username:password@host:8080'); // Output 'http://username:password@host:8080'; ``` @@ -69,7 +69,7 @@ Obtains the query string applicable to this URL. **Example** -``` +```js const url = new uri.URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); url.toString() ``` @@ -95,7 +95,7 @@ Checks whether this URI is the same as another URI object. **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.equals(uriInstance1); @@ -115,7 +115,7 @@ Checks whether this URI is an absolute URI (whether the scheme component is defi **Example** -``` +```js const uriInstance = new uri.URI('http://username:password@www.qwer.com:8080?query=pppppp'); uriInstance.checkIsAbsolute(); ``` @@ -134,7 +134,7 @@ Normalizes the path of this URI. | URI | URI with the normalized path.| **Example** -``` +```js const uriInstance = new uri.URI('http://username:password@www.qwer.com:8080/path/path1/../path2/./path3?query=pppppp'); let uriInstance1 = uriInstance.normalize(); uriInstance1.path; diff --git a/en/application-dev/reference/apis/js-apis-url.md b/en/application-dev/reference/apis/js-apis-url.md index a679841ee2..b3d39d36eb 100755 --- a/en/application-dev/reference/apis/js-apis-url.md +++ b/en/application-dev/reference/apis/js-apis-url.md @@ -31,7 +31,7 @@ Creates a **URLSearchParams** instance. **Example** -``` +```js var objectParams = new URLSearchParams([ ['user1', 'abc1'], ['query2', 'first2'], ['query3', 'second3'] ]); var objectParams1 = new URLSearchParams({"fod" : 1 , "bard" : 2}); var objectParams2 = new URLSearchParams('?fod=1&bard=2'); @@ -55,7 +55,7 @@ Appends a key-value pair into the query string. **Example** -``` +```js let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let paramsObject = new URLSearchParams(urlObject.search.slice(1)); paramsObject.append('fod', 3); @@ -76,7 +76,7 @@ Deletes key-value pairs of the specified key. **Example** -``` +```js let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let paramsobject = new URLSearchParams(urlObject.search.slice(1)); paramsobject.delete('fod'); @@ -103,7 +103,7 @@ Obtains all the key-value pairs based on the specified key. **Example** -``` +```js let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let paramsObject = new URLSearchParams(urlObject.search.slice(1)); paramsObject.append('fod', 3); // Add a second value for the fod parameter. @@ -125,7 +125,7 @@ Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and th **Example** -``` +```js var searchParamsObject = new URLSearchParams("keyName1=valueName1&keyName2=valueName2"); for (var pair of searchParamsObject .entries()) { // Show keyName/valueName pairs console.log(pair[0]+ ', '+ pair[1]); @@ -156,7 +156,7 @@ Traverses the key-value pairs in the **URLSearchParams** instance by using a cal **Example** -``` +```js const myURLObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); myURLObject.searchParams.forEach((value, name, searchParams) => { console.log(name, value, myURLObject.searchParams === searchParams); @@ -185,7 +185,7 @@ Obtains the value of the first key-value pair based on the specified key. **Example** -``` +```js var paramsOject = new URLSearchParams(document.location.search.substring(1)); var name = paramsOject.get("name"); // is the string "Jonathan" var age = parseInt(paramsOject.get("age"), 10); // is the number 18 @@ -213,7 +213,7 @@ Checks whether a key has a value. **Example** -``` +```js let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let paramsObject = new URLSearchParams(urlObject.search.slice(1)); paramsObject.has('bard') === true; @@ -235,7 +235,7 @@ Sets the value for a key. If key-value pairs matching the specified key exist, t **Example** -``` +```js let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let paramsObject = new URLSearchParams(urlObject.search.slice(1)); paramsObject.set('baz', 3); // Add a third parameter. @@ -251,7 +251,7 @@ Sorts all key-value pairs contained in this object based on the Unicode code poi **Example** -``` +```js var searchParamsObject = new URLSearchParams("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 @@ -273,7 +273,7 @@ Obtains an ES6 iterator that contains the keys of all the key-value pairs. **Example** -``` +```js var searchParamsObject = new URLSearchParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing for (var key of searchParamsObject .keys()) { // Output key-value pairs console.log(key); @@ -295,7 +295,7 @@ Obtains an ES6 iterator that contains the values of all the key-value pairs. **Example** -``` +```js var searchParams = new URLSearchParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing for (var value of searchParams.values()) { console.log(value); @@ -318,7 +318,7 @@ Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and th **Example** -``` +```js const paramsObject = new URLSearchParams('fod=bay&edg=bap'); for (const [name, value] of paramsObject) { console.log(name, value); @@ -341,7 +341,7 @@ Obtains search parameters that are serialized as a string and, if necessary, per **Example** -``` +```js let url = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let params = new URLSearchParams(url.search.slice(1)); params.append('fod', 3); @@ -386,7 +386,7 @@ Creates a URL. **Example** -``` +```js var mm = 'http://username:password@host:8080'; var a = new URL("/", mm); // Output 'http://username:password@host:8080/'; var b = new URL(mm); // Output 'http://username:password@host:8080/'; @@ -416,7 +416,7 @@ Converts the parsed URL into a string. **Example** -``` +```js const url = new URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); url.toString() ``` @@ -436,7 +436,7 @@ Converts the parsed URL into a JSON string. | string | Website address in a serialized string.| **Example** -``` +```js const url = new 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 b4a031c8a8..ecc46e0c2d 100755 --- a/en/application-dev/reference/apis/js-apis-util.md +++ b/en/application-dev/reference/apis/js-apis-util.md @@ -23,18 +23,18 @@ Prints the input content in a formatted string. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | format | string | Yes| Format of the string to print.| - | ...args | Object[] | No| Data to format.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| format | string | Yes| Format of the string to print.| +| ...args | Object[] | No| Data to format.| **Return value** - | Type| Description| - | -------- | -------- | - | string | String in the specified format.| +| Type| Description| +| -------- | -------- | +| string | String in the specified format.| **Example** - ``` + ```js var res = util.printf("%s", "hello world!"); console.log(res); ``` @@ -49,17 +49,17 @@ Obtains detailed information about a system error code. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | errno | number | Yes| Error code generated.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| errno | number | Yes| Error code generated.| **Return value** - | Type| Description| - | -------- | -------- | - | string | Detailed information about the error code.| +| Type| Description| +| -------- | -------- | +| string | Detailed information about the error code.| **Example** - ``` + ```js var errnum = 10; // 10 is the system error code. var result = util.getErrorString(errnum); console.log("result = " + result); @@ -76,17 +76,17 @@ Calls back an asynchronous function. In the callback, the first parameter indica **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | original | Function | Yes| Asynchronous function.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| original | Function | Yes| Asynchronous function.| **Return value** - | Type| Description| - | -------- | -------- | - | 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.| +| Type| Description| +| -------- | -------- | +| 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** - ``` + ```js async function promiseFn() { return Promise.reject('value'); } @@ -107,17 +107,17 @@ Processes an asynchronous function and returns a promise version. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | original | Function | Yes| Asynchronous function.| +| 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 version.| +| Type| Description| +| -------- | -------- | +| Function | Function in the error-first style (that is, **(err, value) =>...** is called as the last parameter) and the promise version.| **Example** - ``` + ```js function aysnFun(str1, str2, callback) { if (typeof str1 === 'string' && typeof str2 === 'string') { callback(null, str1 + str2); @@ -154,20 +154,20 @@ A constructor used to create a **TextDecoder** object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | encoding | string | No| Encoding format.| - | options | Object | No| Encoding-related options, which include **fatal** and **ignoreBOM**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| encoding | string | No| Encoding format.| +| options | Object | No| Encoding-related options, which include **fatal** and **ignoreBOM**.| **Table 1** options - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fatal | boolean | No| Whether to display fatal errors.| - | ignoreBOM | boolean | No| Whether to ignore the BOM.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| fatal | boolean | No| Whether to display fatal errors.| +| ignoreBOM | boolean | No| Whether to ignore the BOM.| **Example** - ``` + ```js var textDecoder = new util.TextDecoder("utf-8",{ignoreBOM: true}); ``` @@ -181,24 +181,24 @@ Decodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | input | Unit8Array | Yes| Uint8Array to decode.| - | options | Object | No| Options related to decoding.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| input | Unit8Array | Yes| Uint8Array to decode.| +| options | Object | No| Options related to decoding.| **Table 2** options - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | stream | boolean | No| Whether to allow data blocks in subsequent **decode()**. If data is processed in blocks, set this parameter to **true**. If this is the last data block to process or data is not divided into blocks, set this parameter to **false**. The default value is **false**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| stream | boolean | No| Whether to allow data blocks in subsequent **decode()**. If data is processed in blocks, set this parameter to **true**. If this is the last data block to process or data is not divided into blocks, set this parameter to **false**. The default value is **false**.| **Return value** - | Type| Description| - | -------- | -------- | - | string | Data decoded.| +| Type| Description| +| -------- | -------- | +| string | Data decoded.| **Example** - ``` + ```js var textDecoder = new util.TextDecoder("utf-8",{ignoreBOM: true}); var result = new Uint8Array(6); result[0] = 0xEF; @@ -236,7 +236,7 @@ A constructor used to create a **TextEncoder** object. **System capability**: SystemCapability.Utils.Lang **Example** - ``` + ```js var textEncoder = new util.TextEncoder(); ``` @@ -250,17 +250,17 @@ Encodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | input | string | Yes| String to encode.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| input | string | Yes| String to encode.| **Return value** - | Type| Description| - | -------- | -------- | - | Uint8Array | Encoded text.| +| Type| Description| +| -------- | -------- | +| Uint8Array | Encoded text.| **Example** - ``` + ```js var textEncoder = new util.TextEncoder(); var result = new Uint8Array(buffer); result = textEncoder.encode("\uD800¥¥"); @@ -276,18 +276,18 @@ 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.| +| 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.| +| Type| Description| +| -------- | -------- | +| Uint8Array | Encoded text.| **Example** - ``` + ```js var that = new util.TextEncoder(); var buffer = new ArrayBuffer(4); this.dest = new Uint8Array(buffer); @@ -306,13 +306,13 @@ A constructor used to create a **RationalNumber** object. **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.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| numerator | number | Yes| Numerator, which is an integer.| +| denominator | number | Yes| Denominator, which is an integer.| **Example** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); ``` @@ -326,17 +326,17 @@ Creates a **RationalNumber** object based on the given string. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | rationalString | string | Yes| String used to create the **RationalNumber** object.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| rationalString | string | Yes| String used to create the **RationalNumber** object.| **Return value** - | Type| Description| - | -------- | -------- | - | object | **RationalNumber** object created.| +| Type| Description| +| -------- | -------- | +| object | **RationalNumber** object created.| **Example** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var rational = rationalNumer.creatRationalFromString("3/4"); ``` @@ -351,17 +351,18 @@ 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.| +| 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.| +| 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 var rationalNumber = new util.RationalNumber(1,2); var rational = rationalNumer.creatRationalFromString("3/4"); var result = rationalNumber.compareTo(rational); @@ -377,12 +378,12 @@ Obtains the value of this **RationalNumber** object as an integer or a floating- **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | number | An integer or a floating-point number.| +| Type| Description| +| -------- | -------- | +| number | An integer or a floating-point number.| **Example** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.valueOf(); ``` @@ -397,17 +398,17 @@ Checks whether this **RationalNumber** object equals the given object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | object | Object | Yes| Object used to compare with this **RationalNumber** object.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| object | Object | Yes| Object used to compare with this **RationalNumber** object.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the two objects are equal; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the two objects are equal; returns **false** otherwise.| **Example** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var rational = rationalNumer.creatRationalFromString("3/4"); var result = rationalNumber.equals(rational); @@ -423,18 +424,18 @@ 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.| +| 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.| +| Type| Description| +| -------- | -------- | +| number | Greatest common divisor obtained.| **Example** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.getCommonDivisor(4,6); ``` @@ -450,12 +451,12 @@ Obtains the numerator of this **RationalNumber** object. **Return value** - | Type| Description| - | -------- | -------- | - | number | Numerator of this **RationalNumber** object.| +| Type| Description| +| -------- | -------- | +| number | Numerator of this **RationalNumber** object.| **Example** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.getNumerator(); ``` @@ -470,12 +471,12 @@ Obtains the denominator of this **RationalNumber** object. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | number | Denominator of this **RationalNumber** object.| +| Type| Description| +| -------- | -------- | +| number | Denominator of this **RationalNumber** object.| **Example** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.getDenominator(); ``` @@ -490,12 +491,12 @@ Checks whether this **RationalNumber** object is **0**. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the value of this **RationalNumber** object is **0**; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the value of this **RationalNumber** object is **0**; returns **false** otherwise.| **Example** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.isZero(); ``` @@ -510,12 +511,12 @@ Checks whether this **RationalNumber** object is a Not a Number (NaN). **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if this **RationalNumber** object is a NaN (the denominator and numerator are both **0**); returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if this **RationalNumber** object is a NaN (the denominator and numerator are both **0**); returns **false** otherwise.| **Example** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.isNaN(); ``` @@ -530,12 +531,12 @@ Checks whether this **RationalNumber** object represents a finite value. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if this **RationalNumber** object represents a finite value (the denominator is not **0**); returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if this **RationalNumber** object represents a finite value (the denominator is not **0**); returns **false** otherwise.| **Example** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.isFinite(); ``` @@ -550,12 +551,12 @@ Obtains the string representation of this **RationalNumber** object. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | 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**.| +| Type| Description| +| -------- | -------- | +| 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** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.toString(); ``` @@ -571,7 +572,7 @@ Obtains the string representation of this **RationalNumber** object. | length | number | Yes| No| Total number of values in this buffer.| **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); pro.put(1,8); @@ -588,12 +589,12 @@ A constructor used to create an **LruBuffer** instance. The default capacity of **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 var lrubuffer= new util.LruBuffer(); ``` @@ -607,12 +608,12 @@ Changes the **LruBuffer** capacity. If the new capacity is less than or equal to **System capability**: SystemCapability.Utils.Lang **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 var pro = new util.LruBuffer(); var result = pro.updateCapacity(100); ``` @@ -627,12 +628,12 @@ Obtains the string representation of this **LruBuffer** object. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | string | String representation of this **LruBuffer** object.| +| Type| Description| +| -------- | -------- | +| string | String representation of this **LruBuffer** object.| **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); pro.get(2); @@ -650,12 +651,12 @@ Obtains the capacity of this buffer. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | number | Capacity of this buffer.| +| Type| Description| +| -------- | -------- | +| number | Capacity of this buffer.| **Example** - ``` + ```js var pro = new util.LruBuffer(); var result = pro.getCapacity(); ``` @@ -670,7 +671,7 @@ Clears key-value pairs from this buffer. The **afterRemoval()** method will be c **System capability**: SystemCapability.Utils.Lang **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.size(); @@ -687,12 +688,12 @@ Obtains the number of return values for **createDefault()**. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | number | Number of return values for **createDefault()**.| +| Type| Description| +| -------- | -------- | +| number | Number of return values for **createDefault()**.| **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(1,8); var result = pro.getCreateCount(); @@ -708,12 +709,12 @@ 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.| +| Type| Description| +| -------- | -------- | +| number | Number of times that the queried values are mismatched.| **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); pro.get(2); @@ -730,12 +731,12 @@ Obtains the number of removals from this buffer. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | number | Number of removals from the buffer.| +| Type| Description| +| -------- | -------- | +| number | Number of removals from the buffer.| **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); pro.updateCapacity(2); @@ -753,12 +754,12 @@ 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.| +| Type| Description| +| -------- | -------- | +| number | Number of times that the queried values are matched.| **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); pro.get(2); @@ -775,12 +776,12 @@ Obtains the number of additions to this buffer. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | number | Number of additions to the buffer.| +| Type| Description| +| -------- | -------- | +| number | Number of additions to the buffer.| **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.getPutCount(); @@ -796,12 +797,12 @@ 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.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the buffer does not contain any value.| **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.isEmpty(); @@ -817,17 +818,17 @@ 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.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Key based on which the value is queried.| **Return value** - | Type| Description| - | -------- | -------- | - | V \| undefind | Returns the value of the key if a match is found in the buffer; returns **undefined** otherwise.| +| Type| Description| +| -------- | -------- | +| V \| undefind | Returns the value of the key if a match is found in the buffer; returns **undefined** otherwise.| **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.get(2); @@ -843,18 +844,18 @@ 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.| +| 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. | +| 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 var pro = new util.LruBuffer(); var result = pro.put(2,10); ``` @@ -869,12 +870,12 @@ Obtains all values in this buffer, listed from the most to the least recently ac **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | V [] | All values in the buffer, listed from the most to the least recently accessed.| +| Type| Description| +| -------- | -------- | +| V [] | All values in the buffer, listed from the most to the least recently accessed.| **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); pro.put(2,"anhu"); @@ -892,12 +893,12 @@ Obtains all keys in this buffer, listed from the most to the least recently acce **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | K [] | All keys in the buffer, listed from the most to the least recently accessed.| +| Type| Description| +| -------- | -------- | +| K [] | All keys in the buffer, listed from the most to the least recently accessed.| **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.keys(); @@ -913,17 +914,17 @@ 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.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Key to remove.| **Return value** - | Type| Description| - | -------- | -------- | - | V \| undefind | 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.| +| Type| Description| +| -------- | -------- | +| V \| undefind | 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 var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.remove(20); @@ -939,15 +940,15 @@ 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.| +| 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 var arr = []; class ChildLruBuffer extends util.LruBuffer { @@ -984,17 +985,17 @@ Checks whether this buffer contains the specified key. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | key | K | Yes| Key to check.| +| 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.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the buffer contains the specified key; returns **false** otherwise.| **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.contains(20); @@ -1010,17 +1011,17 @@ 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.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Key of which the value is missing.| **Return value** - | Type| Description| - | -------- | -------- | - | V | Value of the key.| +| Type| Description| +| -------- | -------- | +| V | Value of the key.| **Example** - ``` + ```js var pro = new util.LruBuffer(); var result = pro.createDefault(50); ``` @@ -1035,12 +1036,12 @@ 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.| +| Type| Description| +| -------- | -------- | +| [K, V] | Iterable array.| **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.entries(); @@ -1056,12 +1057,12 @@ 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.| +| Type| Description| +| -------- | -------- | +| [K, V] | Two-dimensional array in key-value pairs.| **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro[symbol.iterator](); @@ -1076,7 +1077,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**. 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; } @@ -1088,7 +1089,7 @@ Create a class to implement the **compareTo** method. In the subsequent sample c Example -``` +```js class Temperature{ constructor(value){ this._temp = value; @@ -1115,13 +1116,13 @@ A constructor used to create a **Scope** object with the specified upper and low **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.| +| 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 var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var range = new util.Scope(tempLower, tempUpper); @@ -1137,12 +1138,12 @@ Obtains a string representation that contains this **Scope**. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | string | String representation containing the **Scope**.| +| Type| Description| +| -------- | -------- | +| string | String representation containing the **Scope**.| **Example** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var range = new util.Scope(tempLower, tempUpper); @@ -1159,17 +1160,17 @@ Obtains the intersection of this **Scope** and the given **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | range | [Scope](#scope8) | Yes| **Scope** specified.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| range | [Scope](#scope8) | Yes| **Scope** specified.| **Return value** - | Type| Description| - | -------- | -------- | - | [Scope](#scope8) | Intersection of this **Scope** and the given **Scope**.| +| Type| Description| +| -------- | -------- | +| [Scope](#scope8) | Intersection of this **Scope** and the given **Scope**.| **Example** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var range = new util.Scope(tempLower, tempUpper); @@ -1189,18 +1190,18 @@ 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.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| lowerObj | [ScopeType](#scopetype8) | Yes| Lower limit.| +| upperObj | [ScopeType](#scopetype8) | Yes| Upper limit.| **Return value** - | Type| Description| - | -------- | -------- | - | [Scope](#scope8) | Intersection of this **Scope** and the given lower and upper limits.| +| Type| Description| +| -------- | -------- | +| [Scope](#scope8) | Intersection of this **Scope** and the given lower and upper limits.| **Example** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var tempMiDF = new Temperature(35); @@ -1220,12 +1221,12 @@ Obtains the upper limit of this **Scope**. **Return value** - | Type| Description| - | -------- | -------- | - | [ScopeType](#scopetype8) | Upper limit of this **Scope**.| +| Type| Description| +| -------- | -------- | +| [ScopeType](#scopetype8) | Upper limit of this **Scope**.| **Example** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var range = new util.Scope(tempLower, tempUpper); @@ -1242,12 +1243,12 @@ Obtains the lower limit of this **Scope**. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | [ScopeType](#scopetype8) | Lower limit of this **Scope**.| +| Type| Description| +| -------- | -------- | +| [ScopeType](#scopetype8) | Lower limit of this **Scope**.| **Example** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var range = new util.Scope(tempLower, tempUpper); @@ -1264,18 +1265,18 @@ 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.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| lowerObj | [ScopeType](#scopetype8) | Yes| Lower limit.| +| upperObj | [ScopeType](#scopetype8) | Yes| Upper limit.| **Return value** - | Type| Description| - | -------- | -------- | - | [Scope](#scope8) | Union set of this **Scope** and the given lower and upper limits.| +| Type| Description| +| -------- | -------- | +| [Scope](#scope8) | Union set of this **Scope** and the given lower and upper limits.| **Example** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var tempMiDF = new Temperature(35); @@ -1294,17 +1295,17 @@ Obtains the union set of this **Scope** and the given **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | range | [Scope](#scope8) | Yes| **Scope** specified.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| range | [Scope](#scope8) | Yes| **Scope** specified.| **Return value** - | Type| Description| - | -------- | -------- | - | [Scope](#scope8) | Union set of this **Scope** and the given **Scope**.| +| Type| Description| +| -------- | -------- | +| [Scope](#scope8) | Union set of this **Scope** and the given **Scope**.| **Example** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var tempMiDF = new Temperature(35); @@ -1324,17 +1325,17 @@ 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.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | [ScopeType](#scopetype8) | Yes| Value specified.| **Return value** - | Type| Description| - | -------- | -------- | - | [Scope](#scope8) | Union set of this **Scope** and the given value.| +| Type| Description| +| -------- | -------- | +| [Scope](#scope8) | Union set of this **Scope** and the given value.| **Example** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var tempMiDF = new Temperature(35); @@ -1352,17 +1353,17 @@ Checks whether a value is within this **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | [ScopeType](#scopetype8) | Yes| Value specified.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | [ScopeType](#scopetype8) | Yes| Value specified.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the value is within this **Scope**; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the value is within this **Scope**; returns **false** otherwise.| **Example** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var tempMiDF = new Temperature(35); @@ -1380,17 +1381,17 @@ Checks whether a range is within this **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | range | [Scope](#scope8) | Yes| **Scope** specified.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| range | [Scope](#scope8) | Yes| **Scope** specified.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the range is within this **Scope**; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the range is within this **Scope**; returns **false** otherwise.| **Example** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var range = new util.Scope(tempLower, tempUpper); @@ -1410,17 +1411,17 @@ Limits a value to this **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | [ScopeType](#scopetype8) | Yes| Value specified.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | [ScopeType](#scopetype8) | Yes| Value specified.| **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**.| +| 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 var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var tempMiDF = new Temperature(35); @@ -1441,7 +1442,7 @@ A constructor used to create a **Base64** object. **System capability**: SystemCapability.Utils.Lang **Example** - ``` + ```js var base64 = new util.Base64(); ``` @@ -1455,17 +1456,17 @@ Encodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | src | Uint8Array | Yes| Uint8Array to encode.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| src | Uint8Array | Yes| Uint8Array to encode.| **Return value** - | Type| Description| - | -------- | -------- | - | Uint8Array | Uint8Array encoded.| +| Type| Description| +| -------- | -------- | +| Uint8Array | Uint8Array encoded.| **Example** - ``` + ```js var that = new util.Base64(); var array = new Uint8Array([115,49,51]); var result = that.encodeSync(array); @@ -1481,17 +1482,17 @@ Encodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | src | Uint8Array | Yes| Uint8Array to encode.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| src | Uint8Array | Yes| Uint8Array to encode.| **Return value** - | Type| Description| - | -------- | -------- | - | string | String encoded from the Uint8Array.| +| Type| Description| +| -------- | -------- | +| string | String encoded from the Uint8Array.| **Example** - ``` + ```js var that = new util.Base64(); var array = new Uint8Array([115,49,51]); var result = that.encodeToStringSync(array); @@ -1507,17 +1508,17 @@ Decodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | src | Uint8Array \| string | Yes| Uint8Array or string to decode.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| src | Uint8Array \| string | Yes| Uint8Array or string to decode.| **Return value** - | Type| Description| - | -------- | -------- | - | Uint8Array | Uint8Array decoded.| +| Type| Description| +| -------- | -------- | +| Uint8Array | Uint8Array decoded.| **Example** - ``` + ```js var that = new util.Base64(); var buff = 'czEz'; var result = that.decodeSync(buff); @@ -1533,17 +1534,17 @@ Encodes the input content asynchronously. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | src | Uint8Array | Yes| Uint8Array to encode asynchronously.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| src | Uint8Array | Yes| Uint8Array to encode asynchronously.| **Return value** - | Type| Description| - | -------- | -------- | - | Promise<Uint8Array> | Uint8Array obtained after asynchronous encoding.| +| Type| Description| +| -------- | -------- | +| Promise<Uint8Array> | Uint8Array obtained after asynchronous encoding.| **Example** - ``` + ```js var that = new util.Base64(); var array = new Uint8Array([115,49,51]); var rarray = new Uint8Array([99,122,69,122]); @@ -1564,17 +1565,17 @@ Encodes the input content asynchronously. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | src | Uint8Array | Yes| Uint8Array to encode asynchronously.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| src | Uint8Array | Yes| Uint8Array to encode asynchronously.| **Return value** - | Type| Description| - | -------- | -------- | - | Promise<string> | String obtained after asynchronous encoding.| +| Type| Description| +| -------- | -------- | +| Promise<string> | String obtained after asynchronous encoding.| **Example** - ``` + ```js var that = new util.Base64(); var array = new Uint8Array([115,49,51]); that.encodeToString(array).then(val=>{ @@ -1592,17 +1593,17 @@ 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.| +| 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.| +| Type| Description| +| -------- | -------- | +| Promise<Uint8Array> | Uint8Array obtained after asynchronous decoding.| **Example** - ``` + ```js var that = new util.Base64(); var array = new Uint8Array([99,122,69,122]); var rarray = new Uint8Array([115,49,51]); @@ -1626,7 +1627,7 @@ A constructor used to create a **types** object. **System capability**: SystemCapability.Utils.Lang **Example** - ``` + ```js var type = new util.types(); ``` @@ -1640,17 +1641,17 @@ Checks whether the input value is of the **ArrayBuffer** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isAnyArrayBuffer(new ArrayBuffer([])); ``` @@ -1667,17 +1668,17 @@ Checks whether the input value is of the **ArrayBufferView** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **ArrayBufferView** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **ArrayBufferView** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isArrayBufferView(new Int8Array([])); ``` @@ -1692,17 +1693,17 @@ Checks whether the input value is of the **arguments** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **arguments** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **arguments** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); function foo() { var result = that.isArgumentsObject(arguments); @@ -1720,17 +1721,17 @@ Checks whether the input value is of the **ArrayBuffer** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isArrayBuffer(new ArrayBuffer([])); ``` @@ -1745,17 +1746,17 @@ Checks whether the input value is an asynchronous function. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is an asynchronous function; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is an asynchronous function; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isAsyncFunction(async function foo() {}); ``` @@ -1770,17 +1771,17 @@ Checks whether the input value is of the **Boolean** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Boolean** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Boolean** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isBooleanObject(new Boolean(true)); ``` @@ -1795,17 +1796,17 @@ Checks whether the input value is of the **Boolean**, **Number**, **String**, or **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Boolean**, **Number**, **String**, or **Symbol** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Boolean**, **Number**, **String**, or **Symbol** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isBoxedPrimitive(new Boolean(false)); ``` @@ -1820,17 +1821,17 @@ Checks whether the input value is of the **DataView** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **DataView** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **DataView** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); const ab = new ArrayBuffer(20); var result = that.isDataView(new DataView(ab)); @@ -1846,17 +1847,17 @@ Checks whether the input value is of the **Date** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Date** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Date** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isDate(new Date()); ``` @@ -1871,17 +1872,17 @@ Checks whether the input value is of the **native external** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **native external** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **native external** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); const data = util.createExternalType(); var result = that.isExternal(data); @@ -1897,17 +1898,17 @@ Checks whether the input value is of the **Float32Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Float32Array** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Float32Array** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isFloat32Array(new Float32Array()); ``` @@ -1922,17 +1923,17 @@ Checks whether the input value is of the **Float64Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Float64Array** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Float64Array** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isFloat64Array(new Float64Array()); ``` @@ -1947,17 +1948,17 @@ Checks whether the input value is a generator function. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is a generator function; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is a generator function; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isGeneratorFunction(function* foo() {}); ``` @@ -1972,17 +1973,17 @@ Checks whether the input value is a generator object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is a generator object; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is a generator object; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); function* foo() {} const generator = foo(); @@ -1999,17 +2000,17 @@ Checks whether the input value is of the **Int8Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Int8Array** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Int8Array** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isInt8Array(new Int8Array([])); ``` @@ -2024,17 +2025,17 @@ Checks whether the input value is of the **Int16Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Int16Array** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Int16Array** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isInt16Array(new Int16Array([])); ``` @@ -2049,17 +2050,17 @@ Checks whether the input value is of the **Int32Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Int32Array** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Int32Array** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isInt32Array(new Int32Array([])); ``` @@ -2074,17 +2075,17 @@ Checks whether the input value is of the **Map** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Map** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Map** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isMap(new Map()); ``` @@ -2099,17 +2100,17 @@ Checks whether the input value is of the **MapIterator** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **MapIterator** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **MapIterator** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); const map = new Map(); var result = that.isMapIterator(map.keys()); @@ -2125,17 +2126,17 @@ Checks whether the input value is of the **Error** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Error** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Error** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isNativeError(new TypeError()); ``` @@ -2150,17 +2151,17 @@ Checks whether the input value is a number object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is a number object; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is a number object; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isNumberObject(new Number(0)); ``` @@ -2175,17 +2176,17 @@ Checks whether the input value is a promise. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is a promise; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is a promise; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isPromise(Promise.resolve(1)); ``` @@ -2200,17 +2201,17 @@ Checks whether the input value is a proxy. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is a proxy; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is a proxy; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); const target = {}; const proxy = new Proxy(target, {}); @@ -2227,17 +2228,17 @@ Checks whether the input value is of the **RegExp** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **RegExp** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **RegExp** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isRegExp(new RegExp('abc')); ``` @@ -2252,17 +2253,17 @@ Checks whether the input value is of the **Set** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Set** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Set** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isSet(new Set()); ``` @@ -2277,17 +2278,17 @@ Checks whether the input value is of the **SetIterator** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **SetIterator** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **SetIterator** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); const set = new Set(); var result = that.isSetIterator(set.keys()); @@ -2303,17 +2304,17 @@ Checks whether the input value is a string object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is a string object; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is a string object; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isStringObject(new String('foo')); ``` @@ -2328,17 +2329,17 @@ Checks whether the input value is a symbol object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is a symbol object; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is a symbol object; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); const symbols = Symbol('foo'); var result = that.isSymbolObject(Object(symbols)); @@ -2356,17 +2357,17 @@ Checks whether the input value is of the **TypedArray** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **TypedArray** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **TypedArray** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isTypedArray(new Float64Array([])); ``` @@ -2381,17 +2382,17 @@ Checks whether the input value is of the **Uint8Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Uint8Array** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Uint8Array** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isUint8Array(new Uint8Array([])); ``` @@ -2406,17 +2407,17 @@ Checks whether the input value is of the **Uint8ClampedArray** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Uint8ClampedArray** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Uint8ClampedArray** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isUint8ClampedArray(new Uint8ClampedArray([])); ``` @@ -2431,17 +2432,17 @@ Checks whether the input value is of the **Uint16Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Uint16Array** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Uint16Array** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isUint16Array(new Uint16Array([])); ``` @@ -2456,17 +2457,17 @@ Checks whether the input value is of the **Uint32Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Uint32Array** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Uint32Array** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isUint32Array(new Uint32Array([])); ``` @@ -2481,17 +2482,17 @@ Checks whether the input value is of the **WeakMap** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **WeakMap** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **WeakMap** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isWeakMap(new WeakMap()); ``` @@ -2506,17 +2507,17 @@ Checks whether the input value is of the **WeakSet** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **WeakSet** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **WeakSet** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isWeakSet(new WeakSet()); ``` diff --git a/en/application-dev/reference/apis/js-apis-xml.md b/en/application-dev/reference/apis/js-apis-xml.md index 65ad4b6437..124d845c0e 100644 --- a/en/application-dev/reference/apis/js-apis-xml.md +++ b/en/application-dev/reference/apis/js-apis-xml.md @@ -32,7 +32,7 @@ A constructor used to create an **XmlSerializer** instance. **Example** -``` +```js var arrayBuffer = new ArrayBuffer(1024); var bufView = new DataView(arrayBuffer); var thatSer = new xml.XmlSerializer(bufView); @@ -54,7 +54,7 @@ Sets an attribute. **Example** -``` +```js var thatSer = new xml.XmlSerializer(bufView); thatSer.setAttributes("importance", "high"); ``` @@ -74,8 +74,8 @@ Adds an empty element. **Example** -``` - var thatSer = new xml.XmlSerializer(bufView); +```js +var thatSer = new xml.XmlSerializer(bufView); thatSer.addEmptyElement("b"); // => ``` @@ -88,7 +88,7 @@ Sets a declaration. **Example** -``` +```js var thatSer = new xml.XmlSerializer(bufView); thatSer.setDeclaration() // => ; ``` @@ -108,7 +108,7 @@ Writes the start tag based on the given element name. **Example** -``` +```js var arrayBuffer = new ArrayBuffer(1024); var thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.startElement("notel"); @@ -124,7 +124,7 @@ Writes the end tag of the element. **Example** -``` +```js var thatSer = new xml.XmlSerializer(bufView); thatSer.setNamespace("h", "http://www.w3.org/TR/html4/"); thatSer.startElement("table"); @@ -149,7 +149,7 @@ Sets the namespace for an element tag. **Example** -``` +```js var arrayBuffer = new ArrayBuffer(1024); var thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.setDeclaration(); @@ -172,7 +172,7 @@ Sets the comment. **Example** -``` +```js var arrayBuffer = new ArrayBuffer(1024); var thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.startElement("note"); @@ -195,7 +195,7 @@ Sets CDATA attributes. **Example** -``` +```js var arrayBuffer = new ArrayBuffer(1028); var thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.setCDATA('root SYSTEM') // => ''; @@ -216,7 +216,7 @@ Sets **Text**. **Example** -``` +```js var arrayBuffer = new ArrayBuffer(1024); var thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.startElement("note"); @@ -240,7 +240,7 @@ Sets **DocType**. **Example** -``` +```js var arrayBuffer = new ArrayBuffer(1024); var thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.setDocType('root SYSTEM'); // => ''; @@ -265,7 +265,7 @@ Creates and returns an **XmlPullParser** object. The **XmlPullParser** object pa **Example** -``` +```js var strXml = '' + '' + @@ -297,7 +297,7 @@ Parses XML information. **Example** -``` +```js var strXml = '' + '' + diff --git a/zh-cn/application-dev/reference/apis/js-apis-convertxml.md b/zh-cn/application-dev/reference/apis/js-apis-convertxml.md index 0e4e1a1c71..30530aceb7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-convertxml.md +++ b/zh-cn/application-dev/reference/apis/js-apis-convertxml.md @@ -39,7 +39,7 @@ convert(xml: string, options?: ConvertOptions) : Object - 示例: - ``` + ```js let xml = '' + '' + diff --git a/zh-cn/application-dev/reference/apis/js-apis-process.md b/zh-cn/application-dev/reference/apis/js-apis-process.md index 8cf388df7a..e4e429a80f 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-process.md +++ b/zh-cn/application-dev/reference/apis/js-apis-process.md @@ -60,7 +60,7 @@ wait(): Promise<number> **示例:** -``` +```js var child = process.runCmd('ls'); var result = child.wait(); result.then(val=>{ @@ -85,7 +85,7 @@ getOutput(): Promise<Uint8Array> **示例:** -``` +```js var child = process.runCmd('ls'); var result = child.wait(); child.getOutput.then(val=>{ @@ -110,7 +110,7 @@ getErrorOutput(): Promise<Uint8Array> **示例:** -``` +```js var child = process.runCmd('madir test.text'); var result = child.wait(); child.getErrorOutput.then(val=>{ @@ -129,7 +129,7 @@ close(): void **示例:** -``` +```js var child = process.runCmd('sleep 5; ls'); child.close(); ``` @@ -151,7 +151,7 @@ kill(signal: number | string): void **示例:** -``` +```js var child = process.runCmd('sleep 5; ls'); child.kill(9); ``` @@ -173,7 +173,7 @@ isIsolatedProcess(): boolean **示例:** -``` +```js var result = process.isIsolatedProcess(); ``` @@ -200,7 +200,7 @@ isAppUid(v: number): boolean **示例:** -``` +```js var result = process.isAppUid(688); ``` @@ -221,7 +221,7 @@ is64Bit(): boolean **示例:** -``` +```js var ressult = process.is64Bit(); ``` @@ -248,7 +248,7 @@ getUidForName(v: string): number **示例:** -``` +```js var pres = process.getUidForName("tool") ``` @@ -275,7 +275,7 @@ getThreadPriority(v: number): number **示例:** -``` +```js var tid = process.getTid(); var pres = process.getThreadPriority(tid); ``` @@ -297,7 +297,7 @@ getStartRealtime(): number **示例:** -``` +```js var realtime = process.getStartRealtime(); ``` @@ -317,7 +317,7 @@ getPastCpuTime(): number **示例:** -``` +```js var result = process.getPastCpuTime() ; ``` @@ -344,7 +344,7 @@ getSystemConfig(name: number): number **示例:** -``` +```js var _SC_ARG_MAX = 0 var pres = process.getSystemConfig(_SC_ARG_MAX) ``` @@ -372,7 +372,7 @@ getEnvironmentVar(name: string): string **示例:** -``` +```js var pres = process.getEnvironmentVar("PATH") ``` @@ -408,7 +408,7 @@ runCmd(command: string, options?: { timeout : number, killSignal : number | stri **示例:** -``` +```js var child = process.runCmd('ls', { maxBuffer : 2 }); var result = child.wait(); child.getOutput.then(val=>{ @@ -427,7 +427,7 @@ abort(): void **示例:** -``` +```js process.abort(); ``` @@ -455,7 +455,7 @@ on(type: string, listener: EventListener): void **示例:** -``` +```js process.on("data", (e)=>{ console.log("data callback"); }) @@ -484,7 +484,7 @@ off(type: string): boolean **示例:** -``` +```js process.on("data", (e)=>{ console.log("data callback"); }) @@ -510,7 +510,7 @@ exit(code: number): void **示例:** -``` +```js process.exit(0); ``` @@ -525,7 +525,7 @@ cwd(): string **示例:** -``` +```js var path = process.cwd(); ``` @@ -546,7 +546,7 @@ chdir(dir: string): void **示例:** -``` +```js process.chdir('/system'); ``` @@ -567,7 +567,7 @@ uptime(): number **示例:** -``` +```js var time = process.uptime(); ``` @@ -594,7 +594,8 @@ kill(signal: number, pid: number): boolean | boolean | 信号是否发送成功。 | **示例:** -``` + +```js var pres = process.pid var result = that.kill(pres, 28) ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-uri.md b/zh-cn/application-dev/reference/apis/js-apis-uri.md index b23c9fc62c..c15f3ae771 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-uri.md +++ b/zh-cn/application-dev/reference/apis/js-apis-uri.md @@ -46,11 +46,11 @@ constructor是URI的构造函数。 **示例:** -``` +```js var mm = 'http://username:password@host:8080/directory/file?foo=1&bar=2#fragment'; new uri.URI(mm); // Output 'http://username:password@host:8080/directory/file?foo=1&bar=2#fragment'; ``` -``` +```js new uri.URI('http://username:password@host:8080'); // Output 'http://username:password@host:8080'; ``` @@ -69,7 +69,7 @@ toString(): string **示例:** -``` +```js const url = new uri.URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); url.toString() ``` @@ -95,7 +95,7 @@ equals(other: URI): boolean **示例:** -``` +```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.equals(uriInstance1); @@ -115,7 +115,7 @@ checkIsAbsolute(): boolean **示例:** -``` +```js const uriInstance = new uri.URI('http://username:password@www.qwer.com:8080?query=pppppp'); uriInstance.checkIsAbsolute(); ``` @@ -134,7 +134,7 @@ normalize(): URI | URI | 返回一个path被规范化后的URI对象。 | **示例:** -``` +```js const uriInstance = new uri.URI('http://username:password@www.qwer.com:8080/path/path1/../path2/./path3?query=pppppp'); let uriInstance1 = uriInstance.normalize(); uriInstance1.path; diff --git a/zh-cn/application-dev/reference/apis/js-apis-url.md b/zh-cn/application-dev/reference/apis/js-apis-url.md index 1c2c93f6e6..685e6ee224 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-url.md +++ b/zh-cn/application-dev/reference/apis/js-apis-url.md @@ -31,7 +31,7 @@ URLSearchParams的构造函数。 **示例:** -``` +```js var objectParams = new URLSearchParams([ ['user1', 'abc1'], ['query2', 'first2'], ['query3', 'second3'] ]); var objectParams1 = new URLSearchParams({"fod" : 1 , "bard" : 2}); var objectParams2 = new URLSearchParams('?fod=1&bard=2'); @@ -55,7 +55,7 @@ append(name: string, value: string): void **示例:** -``` +```js let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let paramsObject = new URLSearchParams(urlObject.search.slice(1)); paramsObject.append('fod', 3); @@ -76,7 +76,7 @@ delete(name: string): void **示例:** -``` +```js let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let paramsobject = new URLSearchParams(urlObject.search.slice(1)); paramsobject.delete('fod'); @@ -103,7 +103,7 @@ getAll(name: string): string[] **示例:** -``` +```js let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let paramsObject = new URLSearchParams(urlObject.search.slice(1)); paramsObject.append('fod', 3); // Add a second value for the fod parameter. @@ -125,7 +125,7 @@ entries(): IterableIterator<[string, string]> **示例:** -``` +```js var searchParamsObject = new URLSearchParams("keyName1=valueName1&keyName2=valueName2"); for (var pair of searchParamsObject .entries()) { // Show keyName/valueName pairs console.log(pair[0]+ ', '+ pair[1]); @@ -156,7 +156,7 @@ forEach(callbackfn: (value: string, key: string, searchParams: this) => void, th **示例:** -``` +```js const myURLObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); myURLObject.searchParams.forEach((value, name, searchParams) => { console.log(name, value, myURLObject.searchParams === searchParams); @@ -185,7 +185,7 @@ get(name: string): string | null **示例:** -``` +```js var paramsOject = new URLSearchParams(document.location.search.substring(1)); var name = paramsOject.get("name"); // is the string "Jonathan" var age = parseInt(paramsOject.get("age"), 10); // is the number 18 @@ -213,7 +213,7 @@ has(name: string): boolean **示例:** -``` +```js let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let paramsObject = new URLSearchParams(urlObject.search.slice(1)); paramsObject.has('bard') === true; @@ -235,7 +235,7 @@ set(name: string, value: string): void **示例:** -``` +```js let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let paramsObject = new URLSearchParams(urlObject.search.slice(1)); paramsObject.set('baz', 3); // Add a third parameter. @@ -251,7 +251,7 @@ sort(): void **示例:** -``` +```js var searchParamsObject = new URLSearchParams("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 @@ -273,7 +273,7 @@ keys(): IterableIterator<string> **示例:** -``` +```js var searchParamsObject = new URLSearchParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing for (var key of searchParamsObject .keys()) { // Output key-value pairs console.log(key); @@ -295,7 +295,7 @@ values(): IterableIterator<string> **示例:** -``` +```js var searchParams = new URLSearchParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing for (var value of searchParams.values()) { console.log(value); @@ -318,7 +318,7 @@ for (var value of searchParams.values()) { **示例:** -``` +```js const paramsObject = new URLSearchParams('fod=bay&edg=bap'); for (const [name, value] of paramsObject) { console.log(name, value); @@ -341,7 +341,7 @@ toString(): string **示例:** -``` +```js let url = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let params = new URLSearchParams(url.search.slice(1)); params.append('fod', 3); @@ -386,7 +386,7 @@ URL的构造函数。 **示例:** -``` +```js var mm = 'http://username:password@host:8080'; var a = new URL("/", mm); // Output 'http://username:password@host:8080/'; var b = new URL(mm); // Output 'http://username:password@host:8080/'; @@ -416,7 +416,7 @@ toString(): string **示例:** -``` +```js const url = new URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); url.toString() ``` @@ -436,7 +436,7 @@ toJSON(): string | string | 用于返回网址的字符串序列化。 | **示例:** -``` +```js const url = new URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); url.toJSON() ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-util.md b/zh-cn/application-dev/reference/apis/js-apis-util.md index 7f6d748816..4cf333c4ac 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-util.md +++ b/zh-cn/application-dev/reference/apis/js-apis-util.md @@ -23,18 +23,18 @@ printf(format: string, ...args: Object[]): string **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | format | string | 是 | 式样化字符串。 | - | ...args | Object[] | 否 | 待式样化数据。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| format | string | 是 | 式样化字符串。 | +| ...args | Object[] | 否 | 待式样化数据。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | string | 按特定格式式样化后的字符串。 | +| 类型 | 说明 | +| -------- | -------- | +| string | 按特定格式式样化后的字符串。 | **示例:** - ``` + ```js var res = util.printf("%s", "hello world!"); console.log(res); ``` @@ -49,17 +49,17 @@ getErrorString(errno: number): string **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | errno | number | 是 | 系统发生错误产生的错误码。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| errno | number | 是 | 系统发生错误产生的错误码。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | string | 错误码对应的详细信息。 | +| 类型 | 说明 | +| -------- | -------- | +| string | 错误码对应的详细信息。 | **示例:** - ``` + ```js var errnum = 10; // 10:a system error number var result = util.getErrorString(errnum); console.log("result = " + result); @@ -76,17 +76,17 @@ callbackWrapper(original: Function): (err: Object, value: Object )=>void **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | original | Function | 是 | 异步函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| original | Function | 是 | 异步函数。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Function | 返回一个第一个参数是拒绝原因(如果 Promise 已解决,则为 null),第二个参数是已解决的回调函数。 | +| 类型 | 说明 | +| -------- | -------- | +| Function | 返回一个第一个参数是拒绝原因(如果 Promise 已解决,则为 null),第二个参数是已解决的回调函数。 | **示例:** - ``` + ```js async function promiseFn() { return Promise.reject('value'); } @@ -107,17 +107,17 @@ promiseWrapper(original: (err: Object, value: Object) => void): Object **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | original | Function | 是 | 异步函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| original | Function | 是 | 异步函数。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Function | 采用遵循常见的错误优先的回调风格的函数(也就是将 (err, value) => ... 回调作为最后一个参数),并返回一个返回 promise 的版本。 | +| 类型 | 说明 | +| -------- | -------- | +| Function | 采用遵循常见的错误优先的回调风格的函数(也就是将 (err, value) => ... 回调作为最后一个参数),并返回一个返回 promise 的版本。 | **示例:** - ``` + ```js function aysnFun(str1, str2, callback) { if (typeof str1 === 'string' && typeof str2 === 'string') { callback(null, str1 + str2); @@ -154,20 +154,20 @@ TextDecoder的构造函数。 **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | encoding | string | 否 | 编码格式。 | - | options | Object | 否 | 编码相关选项参数,存在两个属性fatal和ignoreBOM。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| encoding | string | 否 | 编码格式。 | +| options | Object | 否 | 编码相关选项参数,存在两个属性fatal和ignoreBOM。 | **表1** options - | 名称 | 参数类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fatal | boolean | 否 | 是否显示致命错误。 | - | ignoreBOM | boolean | 否 | 是否忽略BOM标记。 | +| 名称 | 参数类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| fatal | boolean | 否 | 是否显示致命错误。 | +| ignoreBOM | boolean | 否 | 是否忽略BOM标记。 | **示例:** - ``` + ```js var textDecoder = new util.TextDecoder("utf-8",{ignoreBOM: true}); ``` @@ -181,24 +181,24 @@ decode(input: Uint8Array, options?: { stream?: false }): string **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | input | Unit8Array | 是 | 符合格式需要解码的数组。 | - | options | Object | 否 | 解码相关选项参数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| input | Unit8Array | 是 | 符合格式需要解码的数组。 | +| options | Object | 否 | 解码相关选项参数。 | **表2** options - | 名称 | 参数类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | stream | boolean | 否 | 在随后的decode()调用中是否跟随附加数据块。如果以块的形式处理数据,则设置为true;如果处理最后的数据块或数据未分块,则设置为false。默认为false。 | +| 名称 | 参数类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| stream | boolean | 否 | 在随后的decode()调用中是否跟随附加数据块。如果以块的形式处理数据,则设置为true;如果处理最后的数据块或数据未分块,则设置为false。默认为false。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | string | 解码后的数据。 | +| 类型 | 说明 | +| -------- | -------- | +| string | 解码后的数据。 | **示例:** - ``` + ```js var textDecoder = new util.TextDecoder("utf-8",{ignoreBOM: true}); var result = new Uint8Array(6); result[0] = 0xEF; @@ -236,7 +236,7 @@ TextEncoder的构造函数。 **系统能力:** SystemCapability.Utils.Lang **示例:** - ``` + ```js var textEncoder = new util.TextEncoder(); ``` @@ -250,17 +250,17 @@ encode(input?: string): Uint8Array **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | input | string | 是 | 需要编码的字符串。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| input | string | 是 | 需要编码的字符串。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Uint8Array | 返回编码后的文本。 | +| 类型 | 说明 | +| -------- | -------- | +| Uint8Array | 返回编码后的文本。 | **示例:** - ``` + ```js var textEncoder = new util.TextEncoder(); var result = new Uint8Array(buffer); result = textEncoder.encode("\uD800¥¥"); @@ -276,18 +276,18 @@ encodeInto(input: string, dest: Uint8Array, ): { read: number; written: number } **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | input | string | 是 | 需要编码的字符串。 | - | dest | Uint8Array | 是 | Uint8Array对象实例,用于将生成的UTF-8编码文本放入其中。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| input | string | 是 | 需要编码的字符串。 | +| dest | Uint8Array | 是 | Uint8Array对象实例,用于将生成的UTF-8编码文本放入其中。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Uint8Array | 返回编码后的文本。 | +| 类型 | 说明 | +| -------- | -------- | +| Uint8Array | 返回编码后的文本。 | **示例:** - ``` + ```js var that = new util.TextEncoder(); var buffer = new ArrayBuffer(4); this.dest = new Uint8Array(buffer); @@ -306,13 +306,13 @@ RationalNumber的构造函数。 **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | numerator | number | 是 | 分子,整数类型。 | - | denominator | number | 是 | 分母,整数类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| numerator | number | 是 | 分子,整数类型。 | +| denominator | number | 是 | 分母,整数类型。 | **示例:** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); ``` @@ -326,17 +326,17 @@ static createRationalFromString​(rationalString: string): RationalNumber​ **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | rationalString | string | 是 | 字符串格式。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| rationalString | string | 是 | 字符串格式。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | object | 返回有理数类的对象。 | +| 类型 | 说明 | +| -------- | -------- | +| object | 返回有理数类的对象。 | **示例:** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var rational = rationalNumer.creatRationalFromString("3/4"); ``` @@ -351,17 +351,17 @@ compareTo​(another: RationalNumber): number​ **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | another | RationalNumber | 是 | 其他的有理数对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| another | RationalNumber | 是 | 其他的有理数对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | number | 如果两个对象相等,则返回0;如果给定对象小于当前对象,则返回1;如果给定对象大于当前对象,则返回-1。 | +| 类型 | 说明 | +| -------- | -------- | +| number | 如果两个对象相等,则返回0;如果给定对象小于当前对象,则返回1;如果给定对象大于当前对象,则返回-1。 | **示例:** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var rational = rationalNumer.creatRationalFromString("3/4"); var result = rationalNumber.compareTo(rational); @@ -377,12 +377,12 @@ valueOf(): number **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | number | 返回整数或者浮点数的值。 | +| 类型 | 说明 | +| -------- | -------- | +| number | 返回整数或者浮点数的值。 | **示例:** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.valueOf(); ``` @@ -397,17 +397,17 @@ equals​(obj: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | object | Object | 是 | 其他类型对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| object | Object | 是 | 其他类型对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果给定对象与当前对象相同,则返回true;否则返回false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 如果给定对象与当前对象相同,则返回true;否则返回false。 | **示例:** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var rational = rationalNumer.creatRationalFromString("3/4"); var result = rationalNumber.equals(rational); @@ -423,18 +423,18 @@ static getCommonDivisor​(number1: number,number2: number): number **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | number1 | number | 是 | 整数类型。 | - | number2 | number | 是 | 整数类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| number1 | number | 是 | 整数类型。 | +| number2 | number | 是 | 整数类型。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | number | 返回两个给定数字的最大公约数。 | +| 类型 | 说明 | +| -------- | -------- | +| number | 返回两个给定数字的最大公约数。 | **示例:** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.getCommonDivisor(4,6); ``` @@ -450,12 +450,12 @@ getNumerator​(): number **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | number | 返回RationalNumber对象的分子的值。 | +| 类型 | 说明 | +| -------- | -------- | +| number | 返回RationalNumber对象的分子的值。 | **示例:** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.getNumerator(); ``` @@ -470,12 +470,12 @@ getDenominator​(): number **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | number | 返回RationalNumber对象的分母的值。 | +| 类型 | 说明 | +| -------- | -------- | +| number | 返回RationalNumber对象的分母的值。 | **示例:** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.getDenominator(); ``` @@ -490,12 +490,12 @@ isZero​():boolean **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果当前对象表示的值为0,则返回true;否则返回false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 如果当前对象表示的值为0,则返回true;否则返回false。 | **示例:** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.isZero(); ``` @@ -510,12 +510,12 @@ isNaN​(): boolean **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果分母和分子都为0,则返回true;否则返回false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 如果分母和分子都为0,则返回true;否则返回false。 | **示例:** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.isNaN(); ``` @@ -530,12 +530,12 @@ isFinite​():boolean **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果分母不为0,则返回true;否则返回false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 如果分母不为0,则返回true;否则返回false。 | **示例:** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.isFinite(); ``` @@ -550,12 +550,12 @@ toString​(): string **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | string | 返回Numerator/Denominator格式的字符串,例如3/5,如果当前对象的分子和分母都为0,则返回NaN。 | +| 类型 | 说明 | +| -------- | -------- | +| string | 返回Numerator/Denominator格式的字符串,例如3/5,如果当前对象的分子和分母都为0,则返回NaN。 | **示例:** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.toString(); ``` @@ -571,7 +571,7 @@ toString​(): string | length | number | 是 | 否 | 当前缓冲区中值的总数。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); pro.put(1,8); @@ -588,12 +588,12 @@ constructor(capacity?: number) **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | capacity | number | 否 | 指示要为缓冲区自定义的容量。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| capacity | number | 否 | 指示要为缓冲区自定义的容量。 | **示例:** - ``` + ```js var lrubuffer= new util.LruBuffer(); ``` @@ -607,12 +607,12 @@ updateCapacity(newCapacity: number): void **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | newCapacity | number | 是 | 指示要为缓冲区自定义的容量。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| newCapacity | number | 是 | 指示要为缓冲区自定义的容量。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); var result = pro.updateCapacity(100); ``` @@ -627,12 +627,12 @@ toString(): string **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | string | 返回对象的字符串表示形式。 | +| 类型 | 说明 | +| -------- | -------- | +| string | 返回对象的字符串表示形式。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); pro.get(2); @@ -650,12 +650,12 @@ getCapacity(): number **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | number | 返回当前缓冲区的容量。 | +| 类型 | 说明 | +| -------- | -------- | +| number | 返回当前缓冲区的容量。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); var result = pro.getCapacity(); ``` @@ -670,7 +670,7 @@ clear(): void **系统能力:** SystemCapability.Utils.Lang **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.size(); @@ -687,12 +687,12 @@ getCreateCount(): number **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | number | 返回createDefault()返回值的次数。 | +| 类型 | 说明 | +| -------- | -------- | +| number | 返回createDefault()返回值的次数。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(1,8); var result = pro.getCreateCount(); @@ -708,12 +708,12 @@ getMissCount(): number **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | number | 返回查询值不匹配的次数。 | +| 类型 | 说明 | +| -------- | -------- | +| number | 返回查询值不匹配的次数。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); pro.get(2); @@ -730,12 +730,12 @@ getRemovalCount(): number **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | number | 返回从缓冲区中驱逐的次数。 | +| 类型 | 说明 | +| -------- | -------- | +| number | 返回从缓冲区中驱逐的次数。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); pro.updateCapacity(2); @@ -753,12 +753,12 @@ getMatchCount(): number **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | number | 返回查询值匹配成功的次数。 | +| 类型 | 说明 | +| -------- | -------- | +| number | 返回查询值匹配成功的次数。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); pro.get(2); @@ -775,12 +775,12 @@ getPutCount(): number **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | number | 返回将值添加到缓冲区的次数。 | +| 类型 | 说明 | +| -------- | -------- | +| number | 返回将值添加到缓冲区的次数。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.getPutCount(); @@ -796,12 +796,12 @@ isEmpty(): boolean **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果当前缓冲区不包含任何值,则返回true。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 如果当前缓冲区不包含任何值,则返回true。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.isEmpty(); @@ -817,17 +817,17 @@ get(key: K): V | undefined **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | key | K | 是 | 要查询的键。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| key | K | 是 | 要查询的键。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | V \| undefind | 如果指定的键存在于缓冲区中,则返回与键关联的值;否则返回undefined。 | +| 类型 | 说明 | +| -------- | -------- | +| V \| undefind | 如果指定的键存在于缓冲区中,则返回与键关联的值;否则返回undefined。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.get(2); @@ -843,18 +843,18 @@ put(key: K,value: V): V **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | key | K | 是 | 要添加的密钥。 | - | value | V | 是 | 指示与要添加的键关联的值。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| key | K | 是 | 要添加的密钥。 | +| value | V | 是 | 指示与要添加的键关联的值。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | V | 返回与添加的键关联的值;如果要添加的键已经存在,则返回原始值,如果键或值为空,则抛出此异常。 | +| 类型 | 说明 | +| -------- | -------- | +| V | 返回与添加的键关联的值;如果要添加的键已经存在,则返回原始值,如果键或值为空,则抛出此异常。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); var result = pro.put(2,10); ``` @@ -869,12 +869,12 @@ values(): V[] **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | V [] | 按从最近访问到最近最少访问的顺序返回当前缓冲区中所有值的列表。 | +| 类型 | 说明 | +| -------- | -------- | +| V [] | 按从最近访问到最近最少访问的顺序返回当前缓冲区中所有值的列表。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); pro.put(2,"anhu"); @@ -892,12 +892,12 @@ keys(): K[] **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | K [] | 按升序返回当前缓冲区中所有键的列表,从最近访问到最近最少访问。 | +| 类型 | 说明 | +| -------- | -------- | +| K [] | 按升序返回当前缓冲区中所有键的列表,从最近访问到最近最少访问。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.keys(); @@ -913,17 +913,17 @@ remove(key: K): V | undefined **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | key | K | 是 | 要删除的密钥。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| key | K | 是 | 要删除的密钥。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | V \| undefind | 返回一个包含已删除键值对的Optional对象;如果key不存在,则返回一个空的Optional对象,如果key为null,则抛出异常。 | +| 类型 | 说明 | +| -------- | -------- | +| V \| undefind | 返回一个包含已删除键值对的Optional对象;如果key不存在,则返回一个空的Optional对象,如果key为null,则抛出异常。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.remove(20); @@ -939,15 +939,15 @@ afterRemoval(isEvict: boolean,key: K,value: V,newValue: V): void **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | isEvict | boolean | 否 | 因容量不足而调用该方法时,参数值为true,其他情况为false。 | - | key | K | 是 | 表示删除的键。 | - | value | V | 是 | 表示删除的值。 | - | newValue | V | 否 | 如果已调用put方法并且要添加的键已经存在,则参数值是关联的新值。其他情况下参数值为空。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| isEvict | boolean | 否 | 因容量不足而调用该方法时,参数值为true,其他情况为false。 | +| key | K | 是 | 表示删除的键。 | +| value | V | 是 | 表示删除的值。 | +| newValue | V | 否 | 如果已调用put方法并且要添加的键已经存在,则参数值是关联的新值。其他情况下参数值为空。 | **示例:** - ``` + ```js var arr = []; class ChildLruBuffer extends util.LruBuffer { @@ -984,17 +984,17 @@ contains(key: K): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | key | K | 是 | 表示要检查的键。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| key | K | 是 | 表示要检查的键。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果缓冲区包含指定的键,则返回 true。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 如果缓冲区包含指定的键,则返回 true。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.contains(20); @@ -1010,17 +1010,17 @@ createDefault(key: K): V **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | key | K | 是 | 表示丢失的键。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| key | K | 是 | 表示丢失的键。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | V | 返回与键关联的值。 | +| 类型 | 说明 | +| -------- | -------- | +| V | 返回与键关联的值。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); var result = pro.createDefault(50); ``` @@ -1035,12 +1035,12 @@ entries(): IterableIterator<[K,V]> **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | [K, V] | 返回一个可迭代数组。 | +| 类型 | 说明 | +| -------- | -------- | +| [K, V] | 返回一个可迭代数组。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.entries(); @@ -1056,12 +1056,12 @@ entries(): IterableIterator<[K,V]> **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | [K, V] | 返回一个键值对形式的二维数组。 | +| 类型 | 说明 | +| -------- | -------- | +| [K, V] | 返回一个键值对形式的二维数组。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro[symbol.iterator](); @@ -1076,7 +1076,7 @@ entries(): IterableIterator<[K,V]> 用于表示范围中的值的类型。该类型的值,类型可以为ScopeComparable或number。 ScopeComparable类型的值需要实现compareTo方法,确保传入的数据具有可比性。 -``` +```js interface ScopeComparable{ compareTo(other: ScopeComparable): boolean; } @@ -1088,7 +1088,7 @@ type ScopeType = ScopeComparable | number; 示例: -``` +```js class Temperature{ constructor(value){ this._temp = value; @@ -1115,13 +1115,13 @@ constructor(lowerObj: ScopeType, upperObj: ScopeType) **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | lowerObj | [ScopeType](#scopetype8) | 是 | 指定作用域实例的下限。 | - | upperObj | [ScopeType](#scopetype8) | 是 | 指定作用域实例的上限。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| lowerObj | [ScopeType](#scopetype8) | 是 | 指定作用域实例的下限。 | +| upperObj | [ScopeType](#scopetype8) | 是 | 指定作用域实例的上限。 | **示例:** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var range = new util.Scope(tempLower, tempUpper); @@ -1137,12 +1137,12 @@ toString(): string **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | string | 返回包含当前范围对象的字符串表示形式。 | +| 类型 | 说明 | +| -------- | -------- | +| string | 返回包含当前范围对象的字符串表示形式。 | **示例:** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var range = new util.Scope(tempLower, tempUpper); @@ -1159,17 +1159,17 @@ intersect(range: Scope): Scope **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | range | [Scope](#scope8) | 是 | 传入一个给定范围。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| range | [Scope](#scope8) | 是 | 传入一个给定范围。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | [Scope](#scope8) | 返回给定范围和当前范围的交集。 | +| 类型 | 说明 | +| -------- | -------- | +| [Scope](#scope8) | 返回给定范围和当前范围的交集。 | **示例:** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var range = new util.Scope(tempLower, tempUpper); @@ -1189,18 +1189,18 @@ intersect(lowerObj:ScopeType,upperObj:ScopeType):Scope **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | lowerObj | [ScopeType](#scopetype8) | 是 | 给定范围的下限。 | - | upperObj | [ScopeType](#scopetype8) | 是 | 给定范围的上限。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| lowerObj | [ScopeType](#scopetype8) | 是 | 给定范围的下限。 | +| upperObj | [ScopeType](#scopetype8) | 是 | 给定范围的上限。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | [Scope](#scope8) | 返回当前范围与给定下限和上限范围的交集。 | +| 类型 | 说明 | +| -------- | -------- | +| [Scope](#scope8) | 返回当前范围与给定下限和上限范围的交集。 | **示例:** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var tempMiDF = new Temperature(35); @@ -1220,12 +1220,12 @@ getUpper(): ScopeType **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | [ScopeType](#scopetype8) | 返回当前范围的上限值。 | +| 类型 | 说明 | +| -------- | -------- | +| [ScopeType](#scopetype8) | 返回当前范围的上限值。 | **示例:** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var range = new util.Scope(tempLower, tempUpper); @@ -1242,12 +1242,12 @@ getLower(): ScopeType **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | [ScopeType](#scopetype8) | 返回当前范围的下限值。 | +| 类型 | 说明 | +| -------- | -------- | +| [ScopeType](#scopetype8) | 返回当前范围的下限值。 | **示例:** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var range = new util.Scope(tempLower, tempUpper); @@ -1264,18 +1264,19 @@ expand(lowerObj: ScopeType,upperObj: ScopeType): Scope **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | lowerObj | [ScopeType](#scopetype8) | 是 | 给定范围的下限。 | - | upperObj | [ScopeType](#scopetype8) | 是 | 给定范围的上限。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| lowerObj | [ScopeType](#scopetype8) | 是 | 给定范围的下限。 | +| upperObj | [ScopeType](#scopetype8) | 是 | 给定范围的上限。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | [Scope](#scope8) | 返回当前范围和给定下限和上限的并集。 | +| 类型 | 说明 | +| -------- | -------- | +| [Scope](#scope8) | 返回当前范围和给定下限和上限的并集。 | **示例:** - ``` + + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var tempMiDF = new Temperature(35); @@ -1294,17 +1295,17 @@ expand(range: Scope): Scope **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | range | [Scope](#scope8) | 是 | 传入一个给定范围。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| range | [Scope](#scope8) | 是 | 传入一个给定范围。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | [Scope](#scope8) | 返回包括当前范围和给定范围的并集。 | +| 类型 | 说明 | +| -------- | -------- | +| [Scope](#scope8) | 返回包括当前范围和给定范围的并集。 | **示例:** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var tempMiDF = new Temperature(35); @@ -1324,17 +1325,17 @@ expand(value: ScopeType): Scope **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | [ScopeType](#scopetype8) | 是 | 传入一个给定值。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | [ScopeType](#scopetype8) | 是 | 传入一个给定值。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | [Scope](#scope8) | 返回包括当前范围和给定值的并集。 | +| 类型 | 说明 | +| -------- | -------- | +| [Scope](#scope8) | 返回包括当前范围和给定值的并集。 | **示例:** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var tempMiDF = new Temperature(35); @@ -1352,17 +1353,17 @@ contains(value: ScopeType): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | [ScopeType](#scopetype8) | 是 | 传入一个给定值。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | [ScopeType](#scopetype8) | 是 | 传入一个给定值。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果给定值包含在当前范围内返回true,否则返回false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 如果给定值包含在当前范围内返回true,否则返回false。 | **示例:** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var tempMiDF = new Temperature(35); @@ -1380,17 +1381,17 @@ contains(range: Scope): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | range | [Scope](#scope8) | 是 | 传入一个给定范围。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| range | [Scope](#scope8) | 是 | 传入一个给定范围。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果给定范围包含在当前范围内返回true,否则返回false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 如果给定范围包含在当前范围内返回true,否则返回false。 | **示例:** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var range = new util.Scope(tempLower, tempUpper); @@ -1410,17 +1411,17 @@ clamp(value: ScopeType): ScopeType **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | [ScopeType](#scopetype8) | 是 | 传入的给定值。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | [ScopeType](#scopetype8) | 是 | 传入的给定值。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | [ScopeType](#scopetype8) | 如果传入的value小于下限,则返回lowerObj;如果大于上限值则返回upperObj;如果在当前范围内,则返回value。 | +| 类型 | 说明 | +| -------- | -------- | +| [ScopeType](#scopetype8) | 如果传入的value小于下限,则返回lowerObj;如果大于上限值则返回upperObj;如果在当前范围内,则返回value。 | **示例:** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var tempMiDF = new Temperature(35); @@ -1441,7 +1442,7 @@ Base64的构造函数。 **系统能力:** SystemCapability.Utils.Lang **示例:** - ``` + ```js var base64 = new util.Base64(); ``` @@ -1455,17 +1456,17 @@ encodeSync(src: Uint8Array): Uint8Array **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | src | Uint8Array | 是 | 编码输入Uint8数组。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| src | Uint8Array | 是 | 编码输入Uint8数组。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Uint8Array | 返回编码后新分配的Uint8数组。 | +| 类型 | 说明 | +| -------- | -------- | +| Uint8Array | 返回编码后新分配的Uint8数组。 | **示例:** - ``` + ```js var that = new util.Base64(); var array = new Uint8Array([115,49,51]); var result = that.encodeSync(array); @@ -1481,17 +1482,17 @@ encodeToStringSync(src: Uint8Array): string **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | src | Uint8Array | 是 | 编码输入Uint8数组。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| src | Uint8Array | 是 | 编码输入Uint8数组。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | string | 返回编码后的字符串。 | +| 类型 | 说明 | +| -------- | -------- | +| string | 返回编码后的字符串。 | **示例:** - ``` + ```js var that = new util.Base64(); var array = new Uint8Array([115,49,51]); var result = that.encodeToStringSync(array); @@ -1507,17 +1508,17 @@ decodeSync(src: Uint8Array | string): Uint8Array **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | src | Uint8Array \| string | 是 | 解码输入Uint8数组或者字符串。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| src | Uint8Array \| string | 是 | 解码输入Uint8数组或者字符串。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Uint8Array | 返回解码后新分配的Uint8数组。 | +| 类型 | 说明 | +| -------- | -------- | +| Uint8Array | 返回解码后新分配的Uint8数组。 | **示例:** - ``` + ```js var that = new util.Base64(); var buff = 'czEz'; var result = that.decodeSync(buff); @@ -1533,17 +1534,17 @@ encode(src: Uint8Array): Promise<Uint8Array> **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | src | Uint8Array | 是 | 异步编码输入Uint8数组。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| src | Uint8Array | 是 | 异步编码输入Uint8数组。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<Uint8Array> | 返回异步编码后新分配的Uint8数组。 | +| 类型 | 说明 | +| -------- | -------- | +| Promise<Uint8Array> | 返回异步编码后新分配的Uint8数组。 | **示例:** - ``` + ```js var that = new util.Base64(); var array = new Uint8Array([115,49,51]); var rarray = new Uint8Array([99,122,69,122]); @@ -1564,17 +1565,17 @@ encodeToString(src: Uint8Array): Promise<string> **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | src | Uint8Array | 是 | 异步编码输入Uint8数组。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| src | Uint8Array | 是 | 异步编码输入Uint8数组。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<string> | 返回异步编码后的字符串。 | +| 类型 | 说明 | +| -------- | -------- | +| Promise<string> | 返回异步编码后的字符串。 | **示例:** - ``` + ```js var that = new util.Base64(); var array = new Uint8Array([115,49,51]); that.encodeToString(array).then(val=>{ @@ -1592,17 +1593,17 @@ decode(src: Uint8Array | string): Promise<Uint8Array> **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | src | Uint8Array \| string | 是 | 异步解码输入Uint8数组或者字符串。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| src | Uint8Array \| string | 是 | 异步解码输入Uint8数组或者字符串。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<Uint8Array> | 返回异步解码后新分配的Uint8数组。 | +| 类型 | 说明 | +| -------- | -------- | +| Promise<Uint8Array> | 返回异步解码后新分配的Uint8数组。 | **示例:** - ``` + ```js var that = new util.Base64(); var array = new Uint8Array([99,122,69,122]); var rarray = new Uint8Array([115,49,51]); @@ -1626,7 +1627,7 @@ Types的构造函数。 **系统能力:** SystemCapability.Utils.Lang **示例:** - ``` + ```js var type = new util.types(); ``` @@ -1640,17 +1641,17 @@ isAnyArrayBuffer(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是ArrayBuffer类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是ArrayBuffer类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); var result = that.isAnyArrayBuffer(new ArrayBuffer([])); ``` @@ -1667,17 +1668,17 @@ ArrayBufferView辅助类型包括:Int8Array、Int16Array、Int32Array、Uint8A **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的ArrayBufferView辅助类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的ArrayBufferView辅助类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); var result = that.isArrayBufferView(new Int8Array([])); ``` @@ -1692,17 +1693,17 @@ isArgumentsObject(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的arguments类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的arguments类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); function foo() { var result = that.isArgumentsObject(arguments); @@ -1720,17 +1721,17 @@ isArrayBuffer(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的ArrayBuffer类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的ArrayBuffer类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); var result = that.isArrayBuffer(new ArrayBuffer([])); ``` @@ -1745,17 +1746,17 @@ isAsyncFunction(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的异步函数类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的异步函数类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); var result = that.isAsyncFunction(async function foo() {}); ``` @@ -1770,17 +1771,17 @@ isBooleanObject(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Boolean对象类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Boolean对象类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); var result = that.isBooleanObject(new Boolean(true)); ``` @@ -1795,17 +1796,17 @@ isBoxedPrimitive(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Boolean或Number或String或Symbol对象类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Boolean或Number或String或Symbol对象类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); var result = that.isBoxedPrimitive(new Boolean(false)); ``` @@ -1820,17 +1821,17 @@ isDataView(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的DataView对象类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的DataView对象类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); const ab = new ArrayBuffer(20); var result = that.isDataView(new DataView(ab)); @@ -1846,17 +1847,17 @@ isDate(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Date对象类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Date对象类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); var result = that.isDate(new Date()); ``` @@ -1871,17 +1872,17 @@ isExternal(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含native External类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含native External类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); const data = util.createExternalType(); var result = that.isExternal(data); @@ -1897,17 +1898,17 @@ isFloat32Array(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Float32Array数组类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Float32Array数组类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); var result = that.isFloat32Array(new Float32Array()); ``` @@ -1922,17 +1923,17 @@ isFloat64Array(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Float64Array数组类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Float64Array数组类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); var result = that.isFloat64Array(new Float64Array()); ``` @@ -1947,17 +1948,17 @@ isGeneratorFunction(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的generator函数类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的generator函数类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); var result = that.isGeneratorFunction(function* foo() {}); ``` @@ -1972,17 +1973,17 @@ isGeneratorObject(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的generator对象类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的generator对象类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); function* foo() {} const generator = foo(); @@ -1999,17 +2000,17 @@ isInt8Array(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Int8Array数组类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Int8Array数组类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); var result = that.isInt8Array(new Int8Array([])); ``` @@ -2024,17 +2025,17 @@ isInt16Array(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Int16Array数组类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Int16Array数组类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); var result = that.isInt16Array(new Int16Array([])); ``` @@ -2049,17 +2050,17 @@ isInt32Array(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Int32Array数组类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Int32Array数组类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); var result = that.isInt32Array(new Int32Array([])); ``` @@ -2074,17 +2075,17 @@ isMap(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Map类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Map类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); var result = that.isMap(new Map()); ``` @@ -2099,17 +2100,17 @@ isMapIterator(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Map的Iterator类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Map的Iterator类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); const map = new Map(); var result = that.isMapIterator(map.keys()); @@ -2125,17 +2126,17 @@ isNativeError(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Error类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Error类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); var result = that.isNativeError(new TypeError()); ``` @@ -2150,17 +2151,17 @@ isNumberObject(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Number对象类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Number对象类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); var result = that.isNumberObject(new Number(0)); ``` @@ -2175,17 +2176,17 @@ isPromise(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Promise类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Promise类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); var result = that.isPromise(Promise.resolve(1)); ``` @@ -2200,17 +2201,17 @@ isProxy(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Proxy类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Proxy类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); const target = {}; const proxy = new Proxy(target, {}); @@ -2227,17 +2228,17 @@ isRegExp(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的RegExp类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的RegExp类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); var result = that.isRegExp(new RegExp('abc')); ``` @@ -2252,17 +2253,17 @@ isSet(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Set类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Set类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); var result = that.isSet(new Set()); ``` @@ -2277,17 +2278,17 @@ isSetIterator(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Set的Iterator类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Set的Iterator类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); const set = new Set(); var result = that.isSetIterator(set.keys()); @@ -2303,17 +2304,17 @@ isStringObject(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的String对象类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的String对象类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); var result = that.isStringObject(new String('foo')); ``` @@ -2328,17 +2329,17 @@ isSymbolObject(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Symbol对象类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Symbol对象类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); const symbols = Symbol('foo'); var result = that.isSymbolObject(Object(symbols)); @@ -2356,17 +2357,17 @@ TypedArray类型的辅助类型,包括Int8Array、Int16Array、Int32Array、Ui **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的TypedArray包含的类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的TypedArray包含的类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); var result = that.isTypedArray(new Float64Array([])); ``` @@ -2381,17 +2382,17 @@ isUint8Array(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Uint8Array数组类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Uint8Array数组类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); var result = that.isUint8Array(new Uint8Array([])); ``` @@ -2406,17 +2407,17 @@ isUint8ClampedArray(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Uint8ClampedArray数组类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Uint8ClampedArray数组类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); var result = that.isUint8ClampedArray(new Uint8ClampedArray([])); ``` @@ -2431,17 +2432,17 @@ isUint16Array(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Uint16Array数组类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Uint16Array数组类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); var result = that.isUint16Array(new Uint16Array([])); ``` @@ -2456,17 +2457,17 @@ isUint32Array(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Uint32Array数组类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Uint32Array数组类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); var result = that.isUint32Array(new Uint32Array([])); ``` @@ -2481,17 +2482,17 @@ isWeakMap(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的WeakMap类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的WeakMap类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); var result = that.isWeakMap(new WeakMap()); ``` @@ -2506,17 +2507,17 @@ isWeakSet(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的WeakSet类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的WeakSet类型为true,反之为false。 | **示例:** - ``` + ```js var that = new util.types(); var result = that.isWeakSet(new WeakSet()); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-xml.md b/zh-cn/application-dev/reference/apis/js-apis-xml.md index 558973a290..0ec2c2a72d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-xml.md +++ b/zh-cn/application-dev/reference/apis/js-apis-xml.md @@ -32,7 +32,7 @@ XmlSerializer的构造函数。 **示例:** -``` +```js var arrayBuffer = new ArrayBuffer(1024); var bufView = new DataView(arrayBuffer); var thatSer = new xml.XmlSerializer(bufView); @@ -54,7 +54,7 @@ setAttributes(name: string, value: string): void **示例:** -``` +```js var thatSer = new xml.XmlSerializer(bufView); thatSer.setAttributes("importance", "high"); ``` @@ -74,8 +74,8 @@ addEmptyElement(name: string): void **示例:** -``` - var thatSer = new xml.XmlSerializer(bufView); +```js +var thatSer = new xml.XmlSerializer(bufView); thatSer.addEmptyElement("b"); // => ``` @@ -88,7 +88,7 @@ setDeclaration(): void **示例:** -``` +```js var thatSer = new xml.XmlSerializer(bufView); thatSer.setDeclaration() // => ; ``` @@ -108,7 +108,7 @@ startElement(name: string): void **示例:** -``` +```js var arrayBuffer = new ArrayBuffer(1024); var thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.startElement("notel"); @@ -124,7 +124,7 @@ endElement(): void **示例:** -``` +```js var thatSer = new xml.XmlSerializer(bufView); thatSer.setNamespace("h", "http://www.w3.org/TR/html4/"); thatSer.startElement("table"); @@ -149,7 +149,7 @@ setNamespace(prefix: string, namespace: string): void **示例:** -``` +```js var arrayBuffer = new ArrayBuffer(1024); var thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.setDeclaration(); @@ -172,7 +172,7 @@ setComment(text: string): void **示例:** -``` +```js var arrayBuffer = new ArrayBuffer(1024); var thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.startElement("note"); @@ -195,7 +195,7 @@ setCDATA(text: string): void **示例:** -``` +```js var arrayBuffer = new ArrayBuffer(1028); var thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.setCDATA('root SYSTEM') // => ''; @@ -216,7 +216,7 @@ setText(text: string): void **示例:** -``` +```js var arrayBuffer = new ArrayBuffer(1024); var thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.startElement("note"); @@ -240,7 +240,7 @@ setDocType(text: string): void **示例:** -``` +```js var arrayBuffer = new ArrayBuffer(1024); var thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.setDocType('root SYSTEM'); // => ''; @@ -265,7 +265,7 @@ constructor(buffer: ArrayBuffer | DataView, encoding?: string) **示例:** -``` +```js var strXml = '' + '' + @@ -297,7 +297,7 @@ parse(option: ParseOptions): void **示例:** -``` +```js var strXml = '' + '' + -- GitLab