> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [convertToJSObject9+](#converttojsobject9) instead.
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and the first and second fields of each array are the key and value respectively.
Sets the value for a key. If key-value pairs matching the specified key exist, the value of the first key-value pair will be set to the specified value and other key-value pairs will be deleted. Otherwise, the key-value pair will be appended to the query string.
paramsObject.set('baz','3');// Add a third parameter.
```
### sort<sup>9+</sup>
sort(): void
Sorts all key-value pairs contained in this object based on the Unicode code points of the keys and returns undefined. This method uses a stable sorting algorithm, that is, the relative order between key-value pairs with equal keys is retained.
Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and the first and second fields of each array are the key and value respectively.
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.keys<sup>9+</sup>](#keys9) instead.
keys(): IterableIterator<string>
keys(): IterableIterator<string>
...
@@ -297,7 +685,10 @@ for (var key of searchParamsObject .keys()) { // Output key-value pairs
...
@@ -297,7 +685,10 @@ for (var key of searchParamsObject .keys()) { // Output key-value pairs
```
```
### values
### values<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.values<sup>9+</sup>](#values9) instead.
values(): IterableIterator<string>
values(): IterableIterator<string>
...
@@ -321,7 +712,10 @@ for (var value of searchParams.values()) {
...
@@ -321,7 +712,10 @@ for (var value of searchParams.values()) {
```
```
### [Symbol.iterator]
### [Symbol.iterator]<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.[Symbol.iterator]<sup>9+</sup>](#symbol.iterator9) instead.
Wraps an asynchronous function (or a function that returns a promise) into an error-first callback, which means that **(err, value) => ...** is used as the last parameter of the callback. In the callback, the first parameter indicates the cause of the rejection (the value is **null** if the promise has been resolved), and the second parameter indicates the resolved value.
Calls back an asynchronous function. In the callback, the first parameter indicates the cause of the rejection (the value is **null** if the promise has been resolved), and the second parameter indicates the resolved value.
| ignoreBOM | boolean | Yes| No| Whether to ignore the byte order marker (BOM). The default value is **false**, which indicates that the result contains the BOM.|
| ignoreBOM | boolean | Yes| No| Whether to ignore the byte order marker (BOM). The default value is **false**, which indicates that the result contains the BOM.|
### constructor<sup>9+</sup>
### constructor
constructor()
A constructor used to create a **TextDecoder** object.
| number | Returns **0** if the two objects are equal; returns **1** if the given object is less than this object; return **-1** if the given object is greater than this object.|
| 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
letpro=newutil.LRUCache();
letresult=pro.put(2,10);
```
### values<sup>9+</sup>
values(): V[]
Obtains all values in this buffer, listed from the most to the least recently accessed.
| V \| undefined | Returns an **Optional** object containing the removed key-value pair if the key exists in the buffer; returns an empty **Optional** object otherwise. If the key is null, an exception will be thrown.|
| 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
letarr=[];
classChildLruBuffer<K,V>extendsutil.LRUCache<K,V>
{
constructor()
{
super();
}
afterRemoval(isEvict,key,value,newValue)
{
if(isEvict===false)
{
arr=[key,value,newValue];
}
}
}
letlru=newChildLruBuffer();
lru.afterRemoval(false,10,30,null);
```
### contains<sup>9+</sup>
contains(key: K): boolean
Checks whether this buffer contains the specified key.
| string | String representation of this **LruBuffer** object.|
**Example**
```js
letpro=newutil.LruBuffer();
pro.put(2,10);
pro.put(2,10);
pro.get(2);
pro.get(2);
pro.remove(20);
pro.remove(20);
letresult=pro.toString();
letresult=pro.toString();
```
```
### getCapacity<sup>8+(deprecated)</sup>
### getCapacity<sup>8+</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [getCapacity9+](#getcapacity9) instead.
getCapacity(): number
getCapacity(): number
...
@@ -844,8 +1661,11 @@ Obtains the capacity of this buffer.
...
@@ -844,8 +1661,11 @@ Obtains the capacity of this buffer.
letresult=pro.getCapacity();
letresult=pro.getCapacity();
```
```
### clear<sup>8+(deprecated)</sup>
### clear<sup>8+</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [clear9+](#clear9) instead.
clear(): void
clear(): void
...
@@ -861,8 +1681,11 @@ Clears key-value pairs from this buffer. The **afterRemoval()** method will be c
...
@@ -861,8 +1681,11 @@ Clears key-value pairs from this buffer. The **afterRemoval()** method will be c
pro.clear();
pro.clear();
```
```
### getCreateCount<sup>8+(deprecated)</sup>
### getCreateCount<sup>8+</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [getCreateCount9+](#getcreatecount9) instead.
getCreateCount(): number
getCreateCount(): number
...
@@ -883,8 +1706,11 @@ Obtains the number of return values for **createDefault()**.
...
@@ -883,8 +1706,11 @@ Obtains the number of return values for **createDefault()**.
letresult=pro.getCreateCount();
letresult=pro.getCreateCount();
```
```
### getMissCount<sup>8+(deprecated)</sup>
### getMissCount<sup>8+</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [getMissCount9+](#getmisscount9) instead.
getMissCount(): number
getMissCount(): number
...
@@ -906,8 +1732,11 @@ Obtains the number of times that the queried values are mismatched.
...
@@ -906,8 +1732,11 @@ Obtains the number of times that the queried values are mismatched.
letresult=pro.getMissCount();
letresult=pro.getMissCount();
```
```
### getRemovalCount<sup>8+(deprecated)</sup>
### getRemovalCount<sup>8+</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [getRemovalCount9+](#getremovalcount9) instead.
getRemovalCount(): number
getRemovalCount(): number
...
@@ -930,8 +1759,11 @@ Obtains the number of removals from this buffer.
...
@@ -930,8 +1759,11 @@ Obtains the number of removals from this buffer.
letresult=pro.getRemovalCount();
letresult=pro.getRemovalCount();
```
```
### getMatchCount<sup>8+(deprecated)</sup>
### getMatchCount<sup>8+</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [getMatchCount9+](#getmatchcount9) instead.
getMatchCount(): number
getMatchCount(): number
...
@@ -953,8 +1785,11 @@ Obtains the number of times that the queried values are matched.
...
@@ -953,8 +1785,11 @@ Obtains the number of times that the queried values are matched.
letresult=pro.getMatchCount();
letresult=pro.getMatchCount();
```
```
### getPutCount<sup>8+(deprecated)</sup>
### getPutCount<sup>8+</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [getPutCount9+](#getputcount9) instead.
getPutCount(): number
getPutCount(): number
...
@@ -975,8 +1810,11 @@ Obtains the number of additions to this buffer.
...
@@ -975,8 +1810,11 @@ Obtains the number of additions to this buffer.
letresult=pro.getPutCount();
letresult=pro.getPutCount();
```
```
### isEmpty<sup>8+(deprecated)</sup>
### isEmpty<sup>8+</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [isEmpty9+](#isempty9) instead.
isEmpty(): boolean
isEmpty(): boolean
...
@@ -997,8 +1835,11 @@ Checks whether this buffer is empty.
...
@@ -997,8 +1835,11 @@ Checks whether this buffer is empty.
letresult=pro.isEmpty();
letresult=pro.isEmpty();
```
```
### get<sup>8+(deprecated)</sup>
### get<sup>8+</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [get9+](#get9) instead.
get(key: K): V | undefined
get(key: K): V | undefined
...
@@ -1016,7 +1857,7 @@ Obtains the value of the specified key.
...
@@ -1016,7 +1857,7 @@ Obtains the value of the specified key.
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| V\|undefined | Returns the value of the key if a match is found in the buffer; returns **undefined** otherwise.|
| V \| undefined | Returns the value of the key if a match is found in the buffer; returns **undefined** otherwise.|
**Example**
**Example**
```js
```js
...
@@ -1025,8 +1866,11 @@ Obtains the value of the specified key.
...
@@ -1025,8 +1866,11 @@ Obtains the value of the specified key.
letresult=pro.get(2);
letresult=pro.get(2);
```
```
### put<sup>8+(deprecated)</sup>
### put<sup>8+</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [put9+](#put9) instead.
put(key: K,value: V): V
put(key: K,value: V): V
...
@@ -1053,7 +1897,11 @@ Adds a key-value pair to this buffer.
...
@@ -1053,7 +1897,11 @@ Adds a key-value pair to this buffer.
letresult=pro.put(2,10);
letresult=pro.put(2,10);
```
```
### values<sup>8+</sup>
### values<sup>8+(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [values9+](#values9) instead.
values(): V[]
values(): V[]
...
@@ -1065,7 +1913,7 @@ Obtains all values in this buffer, listed from the most to the least recently ac
...
@@ -1065,7 +1913,7 @@ Obtains all values in this buffer, listed from the most to the least recently ac
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| V[] | All values in the buffer, listed from the most to the least recently accessed.|
| V [] | All values in the buffer, listed from the most to the least recently accessed.|
**Example**
**Example**
```js
```js
...
@@ -1076,8 +1924,11 @@ Obtains all values in this buffer, listed from the most to the least recently ac
...
@@ -1076,8 +1924,11 @@ Obtains all values in this buffer, listed from the most to the least recently ac
letresult=pro.values();
letresult=pro.values();
```
```
### keys<sup>8+(deprecated)</sup>
### keys<sup>8+</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [keys9+](#keys9) instead.
keys(): K[]
keys(): K[]
...
@@ -1089,7 +1940,7 @@ Obtains all keys in this buffer, listed from the most to the least recently acce
...
@@ -1089,7 +1940,7 @@ Obtains all keys in this buffer, listed from the most to the least recently acce
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| K[] | All keys in the buffer, listed from the most to the least recently accessed.|
| K [] | All keys in the buffer, listed from the most to the least recently accessed.|
**Example**
**Example**
```js
```js
...
@@ -1098,8 +1949,11 @@ Obtains all keys in this buffer, listed from the most to the least recently acce
...
@@ -1098,8 +1949,11 @@ Obtains all keys in this buffer, listed from the most to the least recently acce
letresult=pro.keys();
letresult=pro.keys();
```
```
### remove<sup>8+(deprecated)</sup>
### remove<sup>8+</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [remove9+](#remove9) instead.
remove(key: K): V | undefined
remove(key: K): V | undefined
...
@@ -1117,7 +1971,7 @@ Removes the specified key and its value from this buffer.
...
@@ -1117,7 +1971,7 @@ Removes the specified key and its value from this buffer.
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| V\|undefined | Returns an **Optional** object containing the removed key-value pair if the key exists in the buffer; returns an empty **Optional** object otherwise. If the key is null, an exception will be thrown.|
| V \| undefined | Returns an **Optional** object containing the removed key-value pair if the key exists in the buffer; returns an empty **Optional** object otherwise. If the key is null, an exception will be thrown.|
**Example**
**Example**
```js
```js
...
@@ -1126,8 +1980,11 @@ Removes the specified key and its value from this buffer.
...
@@ -1126,8 +1980,11 @@ Removes the specified key and its value from this buffer.
letresult=pro.remove(20);
letresult=pro.remove(20);
```
```
### afterRemoval<sup>8+(deprecated)</sup>
### afterRemoval<sup>8+</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [afterRemoval9+](#afterremoval9) instead.
| [K, V] | Two-dimensional array in key-value pairs.|
**Example**
```js
letpro=newutil.LruBuffer();
pro.put(2,10);
letresult=pro[Symbol.iterator]();
```
### ScopeType<sup>8+</sup>
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
interfaceScopeComparable{
compareTo(other:ScopeComparable):boolean;
}
typeScopeType=ScopeComparable|number;
```
Create a class to implement the **compareTo** method. In the subsequent sample code, **Temperature** is used as an example of the [ScopeType](#scopetype8) object.
Example
```js
classTemperature{
constructor(value){
// If TS is used for development, add the following code:
| value | [ScopeType](#scopetype8) | Yes | Value specified.|
Create a class to implement the **compareTo** method. In the subsequent sample code, **Temperature** is used as an example of the [ScopeType](#scopetype8) object.
| [ScopeType](#scopetype8) | Returns **lowerObj** if the specified value is less than the lower limit; returns **upperObj** if the specified value is greater than the upper limit; returns the specified value if it is within this **Scope**.|
Example
**Example**
```js
classTemperature{
constructor(value){
// If TS is used for development, add the following code: