@@ -26,16 +26,16 @@ Creates a **URLSearchParams** instance.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| init | string[][] \| Record<string, string> \| string \| URLSearchParams | No| Input parameter objects, which include the following:<br>- **string[][]**: two-dimensional string array<br>- **Record<string, string>**: list of objects<br>- **string**: string<br>- **URLSearchParams**: object|
| init | string[][]\| Record<string, string>\| string \| URLSearchParams | No| Input parameter objects, which include the following:<br>- **string[][]**: two-dimensional string array<br>- **Record<string, string>**: list of objects<br>- **string**: string<br>- **URLSearchParams**: object|
| string | Detailed information about the error code.|
**Example**
```js
varerrnum=10;// 10 is a system error code.
varresult=util.getErrorString(errnum);
leterrnum=10;// 10 is a system error code.
letresult=util.getErrorString(errnum);
console.log("result = "+result);
```
...
...
@@ -82,6 +86,7 @@ Calls back an asynchronous function. In the callback, the first parameter indica
| 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.|
...
...
@@ -91,8 +96,8 @@ Calls back an asynchronous function. In the callback, the first parameter indica
asyncfunctionpromiseFn(){
returnPromise.reject('value');
}
varerr="type err";
varcb=util.callbackWrapper(promiseFn);
leterr="type err";
letcb=util.callbackWrapper(promiseFn);
cb((err,ret)=>{
console.log(err);
console.log(ret);
...
...
@@ -105,7 +110,6 @@ Calls back an asynchronous function. In the callback, the first parameter indica
| input | Uint8Array | Yes| Uint8Array to decode.|
...
...
@@ -217,14 +310,15 @@ Decodes the input content.
| 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**.|
| input | Uint8Array | 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 **decodeWithStream()**. 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**.|
| 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.|
| 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
varrationalNumber=newutil.RationalNumber(1,2);
varresult=rationalNumber.toString();
letrationalNumber=newutil.RationalNumber(1,2);
letresult=rationalNumber.toString();
```
## LruBuffer<sup>8+</sup>
...
...
@@ -595,10 +751,10 @@ Obtains the string representation of this **RationalNumber** object.
**Example**
```js
varpro=newutil.LruBuffer();
letpro=newutil.LruBuffer();
pro.put(2,10);
pro.put(1,8);
varresult=pro.length;
letresult=pro.length;
```
...
...
@@ -611,13 +767,14 @@ A constructor used to create an **LruBuffer** instance. The default capacity of
| key | K | Yes| Key of the key-value pair to add.|
| value | V | Yes| Value of the key-value pair to add.|
**Return value**
| Type| Description|
| -------- | -------- |
| V | Returns the existing value if the key already exists; returns the value added otherwise. If the key or value is null, an exception will be thrown. |
**Example**
```js
varpro=newutil.LruBuffer();
varresult=pro.put(2,10);
letpro=newutil.LruBuffer();
letresult=pro.put(2,10);
```
### values<sup>8+</sup>
values(): V[]
...
...
@@ -892,17 +1061,18 @@ Obtains all values in this buffer, listed from the most to the least recently ac
| 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
varpro=newutil.LruBuffer();
letpro=newutil.LruBuffer();
pro.put(2,10);
varresult=pro.remove(20);
letresult=pro.remove(20);
```
...
...
@@ -962,6 +1135,7 @@ Performs subsequent operations after a value is removed.
| 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**.|
**Example**
```js
vartempLower=newTemperature(30);
vartempUpper=newTemperature(40);
vartempMiDF=newTemperature(35);
varrange=newutil.Scope(tempLower,tempUpper);
varresult=range.clamp(tempMiDF);
lettempLower=newTemperature(30);
lettempUpper=newTemperature(40);
lettempMiDF=newTemperature(35);
letrange=newutil.Scope(tempLower,tempUpper);
letresult=range.clamp(tempMiDF);
```
...
...
@@ -1461,7 +1660,7 @@ A constructor used to create a **Base64** object.
**Example**
```js
varbase64=newutil.Base64();
letbase64=newutil.Base64();
```
...
...
@@ -1474,20 +1673,22 @@ Encodes the input content.