提交 b2d38eb4 编写于 作者: X xdmal

Master syncs to the monthly branch

Master syncs to the monthly branch
Signed-off-by: Nxdmal <maxiaodong16@huawei.com>
上级 58df2a1e
# @ohos.convertxml (xml转换JavaScript) # @ohos.convertxml (xml转换JavaScript)
本模块提供转换xml文本为JavaScript对象的选项 本模块提供转换xml文本为JavaScript对象的功能
> **说明:** > **说明:**
> >
...@@ -36,6 +36,14 @@ convertToJSObject(xml: string, options?: ConvertOptions) : Object ...@@ -36,6 +36,14 @@ convertToJSObject(xml: string, options?: ConvertOptions) : Object
| ------ | ---------------------------- | | ------ | ---------------------------- |
| Object | 处理后返回的JavaScript对象。 | | Object | 处理后返回的JavaScript对象。 |
**错误码:**
以下错误码的详细介绍请参见[语言基础类库错误码](../errorcodes/errorcode-utils.md)
| 错误码ID | 错误信息 |
| -------- | -------- |
| 10200002 | Invalid xml string. |
**示例:** **示例:**
```js ```js
...@@ -60,14 +68,14 @@ console.log(result); ...@@ -60,14 +68,14 @@ console.log(result);
### convert<sup>(deprecated)</sup> ### convert<sup>(deprecated)</sup>
> **说明:**
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[convertToJSObject9+](#converttojsobject9)替代。
convert(xml: string, options?: ConvertOptions) : Object convert(xml: string, options?: ConvertOptions) : Object
转换xml文本为JavaScript对象。 转换xml文本为JavaScript对象。
> **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[convertToJSObject<sup>9+</sup>](#converttojsobject9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
...@@ -109,7 +117,7 @@ console.log(result); ...@@ -109,7 +117,7 @@ console.log(result);
转换选项。 转换选项。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ----------------- | -------- | ---- | ----------------------------------------------------------- | | ----------------- | -------- | ---- | ----------------------------------------------------------- |
......
...@@ -44,6 +44,14 @@ constructor是URI的构造函数。 ...@@ -44,6 +44,14 @@ constructor是URI的构造函数。
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| uri | string | 是 | 入参对象。 | | uri | string | 是 | 入参对象。 |
**错误码:**
以下错误码的详细介绍请参见[语言基础类库错误码](../errorcodes/errorcode-utils.md)
| 错误码ID | 错误信息 |
| -------- | -------- |
| 10200002 | Invalid uri string. |
**示例:** **示例:**
```js ```js
...@@ -79,14 +87,14 @@ result.toString() ...@@ -79,14 +87,14 @@ result.toString()
### equals<sup>(deprecated)</sup> ### equals<sup>(deprecated)</sup>
> **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[equalsTo<sup>9+</sup>](#equalsto9)替代。
equals(other: URI): boolean equals(other: URI): boolean
判断此URI是否与其他URI对象相等。 判断此URI是否与其他URI对象相等。
> **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[equalsTo<sup>9+</sup>](#equalsto9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
......
...@@ -11,7 +11,6 @@ import Url from '@ohos.url' ...@@ -11,7 +11,6 @@ import Url from '@ohos.url'
``` ```
## URLParams<sup>9+</sup> ## URLParams<sup>9+</sup>
### constructor<sup>9+</sup> ### constructor<sup>9+</sup>
constructor(init?: string[][] | Record&lt;string, string&gt; | string | URLSearchParams) constructor(init?: string[][] | Record&lt;string, string&gt; | string | URLSearchParams)
...@@ -370,7 +369,7 @@ console.log(params.toString()); ...@@ -370,7 +369,7 @@ console.log(params.toString());
### 属性 ### 属性
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
...@@ -384,7 +383,7 @@ console.log(params.toString()); ...@@ -384,7 +383,7 @@ console.log(params.toString());
| port | string | 是 | 是 | 获取和设置URL的端口部分。 | | port | string | 是 | 是 | 获取和设置URL的端口部分。 |
| protocol | string | 是 | 是 | 获取和设置URL的协议部分。 | | protocol | string | 是 | 是 | 获取和设置URL的协议部分。 |
| search | string | 是 | 是 | 获取和设置URL的序列化查询部分。 | | search | string | 是 | 是 | 获取和设置URL的序列化查询部分。 |
| searchParams<sup>(deprecated)</sup> | [URLSearchParams](#urlsearchparamsdeprecated) | 是 | 否 | 获取URLSearchParams表示URL查询参数的对象。<br/>- **说明:** 此属性从API version 7开始支持,从API version 9开始被废弃。建议使用params<sup>9+</sup>替代。| | searchParams<sup>(deprecated)</sup> | [URLSearchParams](#urlsearchparamsdeprecated) | 是 | 否 | 获取URLSearchParams表示URL查询参数的对象。<br/>- **说明:** 此属性从API version 7开始支持,从API version 9开始被废弃。建议使用params<sup>9+</sup>替代。 |
| params<sup>9+</sup> | [URLParams](#urlparams9) | 是 | 否 | 获取URLParams表示URL查询参数的对象。 | | params<sup>9+</sup> | [URLParams](#urlparams9) | 是 | 否 | 获取URLParams表示URL查询参数的对象。 |
| username | string | 是 | 是 | 获取和设置URL的用户名部分。 | | username | string | 是 | 是 | 获取和设置URL的用户名部分。 |
...@@ -467,7 +466,6 @@ const url = new Url.URL('https://username:password@host:8080/directory/file?quer ...@@ -467,7 +466,6 @@ const url = new Url.URL('https://username:password@host:8080/directory/file?quer
url.toString(); url.toString();
``` ```
### toJSON ### toJSON
toJSON(): string toJSON(): string
...@@ -492,14 +490,14 @@ url.toJSON(); ...@@ -492,14 +490,14 @@ url.toJSON();
### constructor<sup>(deprecated)</sup> ### constructor<sup>(deprecated)</sup>
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[URLParams<sup>9+</sup>](#constructor9+)替代。
constructor(init?: string[][] | Record&lt;string, string&gt; | string | URLSearchParams) constructor(init?: string[][] | Record&lt;string, string&gt; | string | URLSearchParams)
URLSearchParams的构造函数。 URLSearchParams的构造函数。
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[URLParams<sup>9+</sup>](#constructor9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
...@@ -520,14 +518,14 @@ let params = new Url.URLSearchParams(urlObject.search); ...@@ -520,14 +518,14 @@ let params = new Url.URLSearchParams(urlObject.search);
### append<sup>(deprecated)</sup> ### append<sup>(deprecated)</sup>
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[URLParams<sup>9+</sup>.append<sup>9+</sup>](#append9)替代。
append(name: string, value: string): void append(name: string, value: string): void
将新的键值对插入到查询字符串。 将新的键值对插入到查询字符串。
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[URLParams<sup>9+</sup>.append<sup>9+</sup>](#append9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
...@@ -547,14 +545,14 @@ paramsObject.append('fod', '3'); ...@@ -547,14 +545,14 @@ paramsObject.append('fod', '3');
### delete<sup>(deprecated)</sup> ### delete<sup>(deprecated)</sup>
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[URLParams<sup>9+</sup>.delete<sup>9+</sup>](#delete9)替代。
delete(name: string): void delete(name: string): void
删除指定名称的键值对。 删除指定名称的键值对。
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[URLParams<sup>9+</sup>.delete<sup>9+</sup>](#delete9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
...@@ -573,14 +571,14 @@ paramsobject.delete('fod'); ...@@ -573,14 +571,14 @@ paramsobject.delete('fod');
### getAll<sup>(deprecated)</sup> ### getAll<sup>(deprecated)</sup>
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[URLParams<sup>9+</sup>.getAll<sup>9+</sup>](#getall9)替代。
getAll(name: string): string[] getAll(name: string): string[]
获取指定名称的所有键值对。 获取指定名称的所有键值对。
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[URLParams<sup>9+</sup>.getAll<sup>9+</sup>](#getall9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
...@@ -606,14 +604,14 @@ console.log(params.getAll('fod').toString()) // Output ["1","3"]. ...@@ -606,14 +604,14 @@ console.log(params.getAll('fod').toString()) // Output ["1","3"].
### entries<sup>(deprecated)</sup> ### entries<sup>(deprecated)</sup>
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[URLParams<sup>9+</sup>.entries<sup>9+</sup>](#entries9)替代。
entries(): IterableIterator<[string, string]> entries(): IterableIterator<[string, string]>
返回一个ES6的迭代器,迭代器的每一项都是一个 JavaScript Array。Array的第一项是name,Array的第二项是value。 返回一个ES6的迭代器,迭代器的每一项都是一个 JavaScript Array。Array的第一项是name,Array的第二项是value。
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[URLParams<sup>9+</sup>.entries<sup>9+</sup>](#entries9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**返回值:** **返回值:**
...@@ -633,14 +631,15 @@ for (var pair of searchParamsObject .entries()) { // Show keyName/valueName pair ...@@ -633,14 +631,15 @@ for (var pair of searchParamsObject .entries()) { // Show keyName/valueName pair
### forEach<sup>(deprecated)</sup> ### forEach<sup>(deprecated)</sup>
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[URLParams<sup>9+</sup>.forEach<sup>9+</sup>](#foreach9)替代。
forEach(callbackFn: (value: string, key: string, searchParams: this) => void, thisArg?: Object): void forEach(callbackFn: (value: string, key: string, searchParams: this) => void, thisArg?: Object): void
通过回调函数来遍历URLSearchParams实例对象上的键值对。 通过回调函数来遍历URLSearchParams实例对象上的键值对。
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[URLParams<sup>9+</sup>.forEach<sup>9+</sup>](#foreach9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
...@@ -669,14 +668,15 @@ myURLObject.searchParams.forEach((value, name, searchParams) => { ...@@ -669,14 +668,15 @@ myURLObject.searchParams.forEach((value, name, searchParams) => {
### get<sup>(deprecated)</sup> ### get<sup>(deprecated)</sup>
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[URLParams<sup>9+</sup>.get<sup>9+</sup>](#get9)替代。
get(name: string): string | null get(name: string): string | null
获取指定名称对应的第一个值。 获取指定名称对应的第一个值。
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[URLParams<sup>9+</sup>.get<sup>9+</sup>](#get9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
...@@ -702,14 +702,15 @@ let age = parseInt(paramsObject.get("age"), 10); // is the number 18 ...@@ -702,14 +702,15 @@ let age = parseInt(paramsObject.get("age"), 10); // is the number 18
### has<sup>(deprecated)</sup> ### has<sup>(deprecated)</sup>
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[URLParams<sup>9+</sup>.has<sup>9+</sup>](#has9)替代。
has(name: string): boolean has(name: string): boolean
判断一个指定的键名对应的值是否存在。 判断一个指定的键名对应的值是否存在。
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[URLParams<sup>9+</sup>.has<sup>9+</sup>](#has9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
...@@ -734,14 +735,15 @@ paramsObject.has('bard') === true; ...@@ -734,14 +735,15 @@ paramsObject.has('bard') === true;
### set<sup>(deprecated)</sup> ### set<sup>(deprecated)</sup>
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[URLParams<sup>9+</sup>.set<sup>9+</sup>](#set9)替代。
set(name: string, value: string): void set(name: string, value: string): void
将与name关联的URLSearchParams对象中的值设置为value。如果存在名称为name的键值对,请将第一个键值对的值设置为value并删除所有其他值。如果不是,则将键值对附加到查询字符串。 将与name关联的URLSearchParams对象中的值设置为value。如果存在名称为name的键值对,请将第一个键值对的值设置为value并删除所有其他值。如果不是,则将键值对附加到查询字符串。
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[URLParams<sup>9+</sup>.set<sup>9+</sup>](#set9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
...@@ -761,14 +763,15 @@ paramsObject.set('baz', '3'); // Add a third parameter. ...@@ -761,14 +763,15 @@ paramsObject.set('baz', '3'); // Add a third parameter.
### sort<sup>(deprecated)</sup> ### sort<sup>(deprecated)</sup>
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[URLParams<sup>9+</sup>.sort<sup>9+</sup>](#sort9)替代。
sort(): void sort(): void
对包含在此对象中的所有键值对进行排序,并返回undefined。排序顺序是根据键的Unicode代码点。该方法使用稳定的排序算法 (即,将保留具有相等键的键值对之间的相对顺序)。 对包含在此对象中的所有键值对进行排序,并返回undefined。排序顺序是根据键的Unicode代码点。该方法使用稳定的排序算法 (即,将保留具有相等键的键值对之间的相对顺序)。
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[URLParams<sup>9+</sup>.sort<sup>9+</sup>](#sort9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**示例:** **示例:**
...@@ -781,14 +784,15 @@ console.log(searchParamsObject.toString()); // Display the sorted query string / ...@@ -781,14 +784,15 @@ console.log(searchParamsObject.toString()); // Display the sorted query string /
### keys<sup>(deprecated)</sup> ### keys<sup>(deprecated)</sup>
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[URLParams<sup>9+</sup>.keys<sup>9+</sup>](#keys9)替代。
keys(): IterableIterator&lt;string&gt; keys(): IterableIterator&lt;string&gt;
返回一个所有键值对的name的ES6迭代器。 返回一个所有键值对的name的ES6迭代器。
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[URLParams<sup>9+</sup>.keys<sup>9+</sup>](#keys9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**返回值:** **返回值:**
...@@ -808,14 +812,15 @@ for (var key of searchParamsObject .keys()) { // Output key-value pairs ...@@ -808,14 +812,15 @@ for (var key of searchParamsObject .keys()) { // Output key-value pairs
### values<sup>(deprecated)</sup> ### values<sup>(deprecated)</sup>
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[URLParams<sup>9+</sup>.values<sup>9+</sup>](#values9)替代。
values(): IterableIterator&lt;string&gt; values(): IterableIterator&lt;string&gt;
返回一个所有键值对的value的ES6迭代器。 返回一个所有键值对的value的ES6迭代器。
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[URLParams<sup>9+</sup>.values<sup>9+</sup>](#values9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**返回值:** **返回值:**
...@@ -836,14 +841,14 @@ for (var value of searchParams.values()) { ...@@ -836,14 +841,14 @@ for (var value of searchParams.values()) {
### [Symbol.iterator]<sup>(deprecated)</sup> ### [Symbol.iterator]<sup>(deprecated)</sup>
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[[Symbol.iterator]<sup>9+</sup>](#symboliterator9)替代。
[Symbol.iterator]\(): IterableIterator&lt;[string, string]&gt; [Symbol.iterator]\(): IterableIterator&lt;[string, string]&gt;
返回一个ES6的迭代器,迭代器的每一项都是一个 JavaScript Array。Array的第一项是name,Array的第二项是value。 返回一个ES6的迭代器,迭代器的每一项都是一个 JavaScript Array。Array的第一项是name,Array的第二项是value。
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[[Symbol.iterator]<sup>9+</sup>](#symboliterator9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**返回值:** **返回值:**
...@@ -862,14 +867,15 @@ for (const [name, value] of paramsObject) { ...@@ -862,14 +867,15 @@ for (const [name, value] of paramsObject) {
``` ```
### tostring<sup>(deprecated)</sup> ### tostring<sup>(deprecated)</sup>
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[tostring<sup>9+</sup>](#tostring9)替代。
toString(): string toString(): string
返回序列化为字符串的搜索参数,必要时对字符进行百分比编码。 返回序列化为字符串的搜索参数,必要时对字符进行百分比编码。
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[tostring<sup>9+</sup>](#tostring9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**返回值:** **返回值:**
......
...@@ -41,38 +41,6 @@ let res = util.format("%s", "hello world!"); ...@@ -41,38 +41,6 @@ let res = util.format("%s", "hello world!");
console.log(res); console.log(res);
``` ```
## util.printf<sup>(deprecated)</sup>
printf(format: string, ...args: Object[]): string
通过式样化字符串对输入的内容按特定格式输出。
> **说明:**
>
> 从API Version 7开始支持,从API Version 9开始废弃,建议使用[util.format<sup>9+</sup>](#utilformat9)替代。
**系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| format | string | 是 | 式样化字符串。 |
| ...args | Object[] | 否 | 替换式样化字符串通配符的数据。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| string | 按特定格式式样化后的字符串。 |
**示例:**
```js
let res = util.printf("%s", "hello world!");
console.log(res);
```
## util.errnoToString<sup>9+</sup> ## util.errnoToString<sup>9+</sup>
errnoToString(errno: number): string errnoToString(errno: number): string
...@@ -101,38 +69,6 @@ let result = util.errnoToString(errnum); ...@@ -101,38 +69,6 @@ let result = util.errnoToString(errnum);
console.log("result = " + result); console.log("result = " + result);
``` ```
## util.getErrorString<sup>(deprecated)</sup>
getErrorString(errno: number): string
获取系统错误码对应的详细信息。
> **说明:**
>
> 从API Version 7开始支持,从API Version 9开始废弃,建议使用[util.errnoToString<sup>9+</sup>](#utilerrnotostring9)替代。
**系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| errno | number | 是 | 系统发生错误产生的错误码。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| string | 错误码对应的详细信息。 |
**示例:**
```js
let errnum = 10; // 10 : a system error number
let result = util.getErrorString(errnum);
console.log("result = " + result);
```
## util.callbackWrapper ## util.callbackWrapper
callbackWrapper(original: Function): (err: Object, value: Object )=&gt;void callbackWrapper(original: Function): (err: Object, value: Object )=&gt;void
...@@ -203,30 +139,6 @@ promisify(original: (err: Object, value: Object) =&gt; void): Function ...@@ -203,30 +139,6 @@ promisify(original: (err: Object, value: Object) =&gt; void): Function
}) })
``` ```
## util.promiseWrapper<sup>(deprecated)</sup>
promiseWrapper(original: (err: Object, value: Object) =&gt; void): Object
对异步函数处理并返回一个promise的版本。
> **说明:**
>
> 此接口不可用,建议使用[util.promisify<sup>9+</sup>](#utilpromisify9)替代。
**系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| original | Function | 是 | 异步函数。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Function | 采用遵循常见的错误优先的回调风格的函数(也就是将&nbsp;(err,&nbsp;value)&nbsp;=&gt;&nbsp;...&nbsp;回调作为最后一个参数),并返回一个返回&nbsp;promise&nbsp;的版本。 |
## util.randomUUID<sup>9+</sup> ## util.randomUUID<sup>9+</sup>
randomUUID(entropyCache?: boolean): string randomUUID(entropyCache?: boolean): string
...@@ -314,6 +226,96 @@ parseUUID(uuid: string): Uint8Array ...@@ -314,6 +226,96 @@ parseUUID(uuid: string): Uint8Array
// 132,189,247,150,102,204,70,85,155,137,214,33,141,16,15,156 // 132,189,247,150,102,204,70,85,155,137,214,33,141,16,15,156
``` ```
## util.printf<sup>(deprecated)</sup>
printf(format: string, ...args: Object[]): string
通过式样化字符串对输入的内容按特定格式输出。
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[util.format<sup>9+</sup>](#utilformat9)替代。
**系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| format | string | 是 | 式样化字符串。 |
| ...args | Object[] | 否 | 替换式样化字符串通配符的数据。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| string | 按特定格式式样化后的字符串。 |
**示例:**
```js
let res = util.printf("%s", "hello world!");
console.log(res);
```
## util.getErrorString<sup>(deprecated)</sup>
getErrorString(errno: number): string
获取系统错误码对应的详细信息。
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[util.errnoToString<sup>9+</sup>](#utilerrnotostring9)替代。
**系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| errno | number | 是 | 系统发生错误产生的错误码。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| string | 错误码对应的详细信息。 |
**示例:**
```js
let errnum = 10; // 10 : a system error number
let result = util.getErrorString(errnum);
console.log("result = " + result);
```
## util.promiseWrapper<sup>(deprecated)</sup>
promiseWrapper(original: (err: Object, value: Object) =&gt; void): Object
对异步函数处理并返回一个promise的版本。
> **说明:**
>
> 此接口不可用,建议使用[util.promisify<sup>9+</sup>](#utilpromisify9)替代。
**系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| original | Function | 是 | 异步函数。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Function | 采用遵循常见的错误优先的回调风格的函数(也就是将&nbsp;(err,&nbsp;value)&nbsp;=&gt;&nbsp;...&nbsp;回调作为最后一个参数),并返回一个返回&nbsp;promise&nbsp;的版本。 |
## TextDecoder ## TextDecoder
### 属性 ### 属性
...@@ -363,38 +365,6 @@ let textDecoder = new util.TextDecoder() ...@@ -363,38 +365,6 @@ let textDecoder = new util.TextDecoder()
textDecoder.create('utf-8', { ignoreBOM : true }); textDecoder.create('utf-8', { ignoreBOM : true });
``` ```
### constructor<sup>(deprecated)</sup>
constructor(encoding?: string, options?: { fatal?: boolean; ignoreBOM?: boolean },)
TextDecoder的构造函数。
> **说明:**
>
> 从API Version 7开始支持,从API Version 9开始废弃,建议使用[constructor<sup>9+</sup>](#constructor9)替代。
**系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| encoding | string | 否 | 编码格式。 |
| options | Object | 否 | 编码相关选项参数,存在两个属性fatal和ignoreBOM。 |
**表1** options
| 名称 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| fatal | boolean | 否 | 是否显示致命错误。 |
| ignoreBOM | boolean | 否 | 是否忽略BOM标记。 |
**示例:**
```js
let textDecoder = new util.TextDecoder("utf-8",{ignoreBOM: true});
```
### decode ### decode
decode(input: Uint8Array, options?: { stream?: false }): string decode(input: Uint8Array, options?: { stream?: false }): string
...@@ -482,6 +452,37 @@ decodeWithStream(input: Uint8Array, options?: { stream?: boolean }): string ...@@ -482,6 +452,37 @@ decodeWithStream(input: Uint8Array, options?: { stream?: boolean }): string
console.log("retStr = " + retStr); console.log("retStr = " + retStr);
``` ```
### constructor<sup>(deprecated)</sup>
constructor(encoding?: string, options?: { fatal?: boolean; ignoreBOM?: boolean },)
TextDecoder的构造函数。
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[constructor<sup>9+</sup>](#constructor9)替代。
**系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| encoding | string | 否 | 编码格式。 |
| options | Object | 否 | 编码相关选项参数,存在两个属性fatal和ignoreBOM。 |
**表1** options
| 名称 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| fatal | boolean | 否 | 是否显示致命错误。 |
| ignoreBOM | boolean | 否 | 是否忽略BOM标记。 |
**示例:**
```js
let textDecoder = new util.TextDecoder("utf-8",{ignoreBOM: true});
```
## TextEncoder ## TextEncoder
...@@ -537,78 +538,80 @@ let result = new Uint8Array(buffer); ...@@ -537,78 +538,80 @@ let result = new Uint8Array(buffer);
result = textEncoder.encodeInto("\uD800¥¥"); result = textEncoder.encodeInto("\uD800¥¥");
``` ```
### encode<sup>(deprecated)</sup> ### encodeIntoUint8Array<sup>9+</sup>
encode(input?: string): Uint8Array
通过输入参数编码后输出对应文本。 encodeIntoUint8Array(input: string, dest: Uint8Array, ): { read: number; written: number }
> **说明:** 放置生成的UTF-8编码文本。
>
> 从API Version 7开始支持,从API Version 9开始废弃,建议使用[encodeInto<sup>9+</sup>](#encodeinto9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | ------ | ---------- | ---- | ------------------------------------------------------- |
| input | string | 否 | 需要编码的字符串。 | | input | string | 是 | 需要编码的字符串。 |
| dest | Uint8Array | 是 | Uint8Array对象实例,用于将生成的UTF-8编码文本放入其中。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | ---------- | ------------------ |
| Uint8Array | 返回编码后的文本。 | | Uint8Array | 返回编码后的文本。 |
**示例:** **示例:**
```js ```js
let textEncoder = new util.TextEncoder(); let that = new util.TextEncoder()
let buffer = new ArrayBuffer(20); let buffer = new ArrayBuffer(4)
let result = new Uint8Array(buffer); let dest = new Uint8Array(buffer)
result = textEncoder.encode("\uD800¥¥"); let result = new Object()
result = that.encodeInto('abcd', dest)
``` ```
### encodeIntoUint8Array<sup>9+</sup> ### encodeInto<sup>(deprecated)</sup>
encodeIntoUint8Array(input: string, dest: Uint8Array, ): { read: number; written: number } encodeInto(input: string, dest: Uint8Array, ): { read: number; written: number }
放置生成的UTF-8编码文本。 放置生成的UTF-8编码文本。
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[encodeIntoUint8Array<sup>9+</sup>](#encodeintouint8array9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------- | ---- | ------------------------------------------------------- | | -------- | -------- | -------- | -------- |
| input | string | 是 | 需要编码的字符串。 | | input | string | 是 | 需要编码的字符串。 |
| dest | Uint8Array | 是 | Uint8Array对象实例,用于将生成的UTF-8编码文本放入其中。 | | dest | Uint8Array | 是 | Uint8Array对象实例,用于将生成的UTF-8编码文本放入其中。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ---------- | ------------------ | | -------- | -------- |
| Uint8Array | 返回编码后的文本。 | | Uint8Array | 返回编码后的文本。 |
**示例:** **示例:**
```js ```js
let that = new util.TextEncoder() let that = new util.TextEncoder()
let buffer = new ArrayBuffer(4) let buffer = new ArrayBuffer(4)
let dest = new Uint8Array(buffer) let dest = new Uint8Array(buffer)
let result = new Object() let result = new Object()
result = that.encodeInto('abcd', dest) result = that.encodeInto('abcd', dest)
``` ```
### encodeInto<sup>(deprecated)</sup> ### encode<sup>(deprecated)</sup>
encodeInto(input: string, dest: Uint8Array, ): { read: number; written: number } encode(input?: string): Uint8Array
放置生成的UTF-8编码文本。 通过输入参数编码后输出对应文本。
> **说明:** > **说明:**
> >
> 从API Version 7开始支持,从API Version 9开始废弃,建议使用[encodeIntoUint8Array<sup>9+</sup>](#encodeintouint8array9)替代。 > 从API version 7开始支持,从API version 9开始废弃,建议使用[encodeInto<sup>9+</sup>](#encodeinto9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -616,8 +619,7 @@ encodeInto(input: string, dest: Uint8Array, ): { read: number; written: number } ...@@ -616,8 +619,7 @@ encodeInto(input: string, dest: Uint8Array, ): { read: number; written: number }
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| input | string | 是 | 需要编码的字符串。 | | input | string | 否 | 需要编码的字符串。 |
| dest | Uint8Array | 是 | Uint8Array对象实例,用于将生成的UTF-8编码文本放入其中。 |
**返回值:** **返回值:**
...@@ -627,11 +629,10 @@ encodeInto(input: string, dest: Uint8Array, ): { read: number; written: number } ...@@ -627,11 +629,10 @@ encodeInto(input: string, dest: Uint8Array, ): { read: number; written: number }
**示例:** **示例:**
```js ```js
let that = new util.TextEncoder() let textEncoder = new util.TextEncoder();
let buffer = new ArrayBuffer(4) let buffer = new ArrayBuffer(20);
let dest = new Uint8Array(buffer) let result = new Uint8Array(buffer);
let result = new Object() result = textEncoder.encode("\uD800¥¥");
result = that.encodeInto('abcd', dest)
``` ```
## RationalNumber<sup>8+</sup> ## RationalNumber<sup>8+</sup>
...@@ -671,31 +672,6 @@ parseRationalNumber(numerator: number,denominator: number): RationalNumber ...@@ -671,31 +672,6 @@ parseRationalNumber(numerator: number,denominator: number): RationalNumber
let rationalNumber = util.RationalNumber.parseRationalNumber(1,2) let rationalNumber = util.RationalNumber.parseRationalNumber(1,2)
``` ```
### constructor<sup>(deprecated)</sup>
constructor(numerator: number,denominator: number)
RationalNumber的构造函数。
> **说明:**
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[constructor<sup>9+</sup>](#constructor9)替代。
**系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| numerator | number | 是 | 分子,整数类型。 |
| denominator | number | 是 | 分母,整数类型。 |
**示例:**
```js
let rationalNumber = new util.RationalNumber(1,2);
```
### createRationalFromString<sup>8+</sup> ### createRationalFromString<sup>8+</sup>
static createRationalFromString​(rationalString: string): RationalNumber​ static createRationalFromString​(rationalString: string): RationalNumber​
...@@ -751,38 +727,6 @@ let rational = util.RationalNumber.createRationalFromString("3/4"); ...@@ -751,38 +727,6 @@ let rational = util.RationalNumber.createRationalFromString("3/4");
let result = rationalNumber.compare(rational); let result = rationalNumber.compare(rational);
``` ```
### compareTo<sup>(deprecated)</sup>
compareTo​(another: RationalNumber): number​
将当前的RationalNumber对象与给定的对象进行比较。
> **说明:**
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[compare<sup>9+</sup>](#compare9)替代。
**系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| another | RationalNumber | 是 | 其他的有理数对象。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| number | 如果两个对象相等,则返回0;如果给定对象小于当前对象,则返回1;如果给定对象大于当前对象,则返回-1。 |
**示例:**
```js
let rationalNumber = new util.RationalNumber(1,2);
let rational = util.RationalNumber.createRationalFromString("3/4");
let result = rationalNumber.compareTo(rational);
```
### valueOf<sup>8+</sup> ### valueOf<sup>8+</sup>
valueOf(): number valueOf(): number
...@@ -860,38 +804,6 @@ let rationalNumber = new util.RationalNumber(1,2); ...@@ -860,38 +804,6 @@ let rationalNumber = new util.RationalNumber(1,2);
let result = util.RationalNumber.getCommonFactor(4,6); let result = util.RationalNumber.getCommonFactor(4,6);
``` ```
### getCommonDivisor<sup>(deprecated)</sup>
static getCommonDivisor​(number1: number,number2: number): number
获取两个指定整数的最大公约数。
> **说明:**
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[getCommonFactor<sup>9+</sup>](#getcommonfactor9)替代。
**系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| number1 | number | 是 | 整数类型。 |
| number2 | number | 是 | 整数类型。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| number | 返回两个给定数字的最大公约数。 |
**示例:**
```js
let rationalNumber = new util.RationalNumber(1,2);
let result = util.RationalNumber.getCommonDivisor(4,6);
```
### getNumerator<sup>8+</sup> ### getNumerator<sup>8+</sup>
getNumerator​(): number getNumerator​(): number
...@@ -1018,6 +930,94 @@ let rationalNumber = new util.RationalNumber(1,2); ...@@ -1018,6 +930,94 @@ let rationalNumber = new util.RationalNumber(1,2);
let result = rationalNumber.toString(); let result = rationalNumber.toString();
``` ```
### constructor<sup>(deprecated)</sup>
constructor(numerator: number,denominator: number)
RationalNumber的构造函数。
> **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[constructor<sup>9+</sup>](#constructor9)替代。
**系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| numerator | number | 是 | 分子,整数类型。 |
| denominator | number | 是 | 分母,整数类型。 |
**示例:**
```js
let rationalNumber = new util.RationalNumber(1,2);
```
### compareTo<sup>(deprecated)</sup>
compareTo​(another: RationalNumber): number​
将当前的RationalNumber对象与给定的对象进行比较。
> **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[compare<sup>9+</sup>](#compare9)替代。
**系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| another | RationalNumber | 是 | 其他的有理数对象。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| number | 如果两个对象相等,则返回0;如果给定对象小于当前对象,则返回1;如果给定对象大于当前对象,则返回-1。 |
**示例:**
```js
let rationalNumber = new util.RationalNumber(1,2);
let rational = util.RationalNumber.createRationalFromString("3/4");
let result = rationalNumber.compareTo(rational);
```
### getCommonDivisor<sup>(deprecated)</sup>
static getCommonDivisor​(number1: number,number2: number): number
获取两个指定整数的最大公约数。
> **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[getCommonFactor<sup>9+</sup>](#getcommonfactor9)替代。
**系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| number1 | number | 是 | 整数类型。 |
| number2 | number | 是 | 整数类型。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| number | 返回两个给定数字的最大公约数。 |
**示例:**
```js
let rationalNumber = new util.RationalNumber(1,2);
let result = util.RationalNumber.getCommonDivisor(4,6);
```
## LRUCache<sup>9+</sup> ## LRUCache<sup>9+</sup>
...@@ -1564,619 +1564,564 @@ pro.put(2,10); ...@@ -1564,619 +1564,564 @@ pro.put(2,10);
let result = pro[Symbol.iterator](); let result = pro[Symbol.iterator]();
``` ```
## LruBuffer<sup>(deprecated)</sup>
> **说明:**
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[LRUCache<sup>9+</sup>](#lrucache9)替代。
### 属性
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Utils.Lang。
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| length | number | 是 | 否 | 当前缓冲区中值的总数。 |
**示例:**
```js
let pro = new util.LruBuffer();
pro.put(2,10);
pro.put(1,8);
let result = pro.length;
```
### constructor<sup>(deprecated)</sup> ## ScopeHelper<sup>9+</sup>
constructor(capacity?: number) ### constructor<sup>9+</sup>
默认构造函数用于创建一个新的LruBuffer实例,默认容量为64。 constructor(lowerObj: ScopeType, upperObj: ScopeType)
> **说明:** 用于创建指定下限和上限的作用域实例的构造函数,返回一个ScopeHelper对象。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[constructor<sup>9+</sup>](#constructor9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | ------------------------ | ---- | ---------------------- |
| capacity | number | 否 | 指示要为缓冲区自定义的容量。 | | lowerObj | [ScopeType](#scopetype8) | 是 | 指定作用域实例的下限。 |
| upperObj | [ScopeType](#scopetype8) | 是 | 指定作用域实例的上限。 |
**示例:** **示例:**
```js ```js
let lrubuffer= new util.LruBuffer(); let tempLower = new Temperature(30);
let tempUpper = new Temperature(40);
let range = new util.ScopeHelper(tempLower, tempUpper);
``` ```
### updateCapacity<sup>(deprecated)</sup>
updateCapacity(newCapacity: number): void ### toString<sup>9+</sup>
将缓冲区容量更新为指定容量,如果newCapacity小于或等于0,则抛出异常。
> **说明:**
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[updateCapacity<sup>9+</sup>](#updatecapacity9)替代。
**系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| newCapacity | number | 是 | 指示要为缓冲区自定义的容量。 |
**示例:**
```js
let pro = new util.LruBuffer();
let result = pro.updateCapacity(100);
```
### toString<sup>(deprecated)</sup>
toString(): string toString(): string
返回对象的字符串表示形式。 该字符串化方法返回一个包含当前范围的字符串表示形式。
> **说明:**
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[toString<sup>9+</sup>](#tostring9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | ------ | -------------------------------------- |
| string | 返回对象的字符串表示形式。 | | string | 返回包含当前范围对象的字符串表示形式。 |
**示例:** **示例:**
```js ```js
let pro = new util.LruBuffer(); let tempLower = new Temperature(30);
pro.put(2,10); let tempUpper = new Temperature(40);
pro.get(2); let range = new util.ScopeHelper(tempLower, tempUpper);
pro.remove(20); let result = range.toString();
let result = pro.toString();
``` ```
### getCapacity<sup>(deprecated)</sup>
getCapacity(): number ### intersect<sup>9+</sup>
获取当前缓冲区的容量。 intersect(range: ScopeHelper): ScopeHelper
> **说明:** 获取给定范围和当前范围的交集。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[getCapacity<sup>9+</sup>](#getcapacity9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------------------------- | ---- | ------------------ |
| range | [ScopeHelper](#scopehelper9) | 是 | 传入一个给定范围。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | ------------------------------ | ------------------------------ |
| number | 返回当前缓冲区的容量。 | | [ScopeHelper9+](#scopehelper9) | 返回给定范围和当前范围的交集。 |
**示例:** **示例:**
```js ```js
let pro = new util.LruBuffer(); let tempLower = new Temperature(30);
let result = pro.getCapacity(); let tempUpper = new Temperature(40);
let range = new util.ScopeHelper(tempLower, tempUpper);
let tempMiDF = new Temperature(35);
let tempMidS = new Temperature(39);
let rangeFir = new util.ScopeHelper(tempMiDF, tempMidS);
range.intersect(rangeFir );
``` ```
### clear<sup>(deprecated)</sup>
clear(): void ### intersect<sup>9+</sup>
从当前缓冲区清除键值对。后续会调用afterRemoval()方法执行后续操作。 intersect(lowerObj:ScopeType,upperObj:ScopeType):ScopeHelper
> **说明:** 获取当前范围与给定下限和上限范围的交集。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[clear<sup>9+</sup>](#clear9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**示例:** **参数:**
```js
let pro = new util.LruBuffer();
pro.put(2,10);
let result = pro.length;
pro.clear();
```
### getCreateCount<sup>(deprecated)</sup>
getCreateCount(): number
获取createDefault()返回值的次数。
> **说明:**
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[getCreateCount<sup>9+</sup>](#getcreatecount9)替代。
**系统能力:** SystemCapability.Utils.Lang | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------ | ---- | ---------------- |
| lowerObj | [ScopeType](#scopetype8) | 是 | 给定范围的下限。 |
| upperObj | [ScopeType](#scopetype8) | 是 | 给定范围的上限。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | ---------------------------- | ---------------------------------------- |
| number | 返回createDefault()返回值的次数。 | | [ScopeHelper](#scopehelper9) | 返回当前范围与给定下限和上限范围的交集。 |
**示例:** **示例:**
```js ```js
let pro = new util.LruBuffer(); let tempLower = new Temperature(30);
pro.put(1,8); let tempUpper = new Temperature(40);
let result = pro.getCreateCount(); let tempMiDF = new Temperature(35);
let tempMidS = new Temperature(39);
let range = new util.ScopeHelper(tempLower, tempUpper);
let result = range.intersect(tempMiDF, tempMidS);
``` ```
### getMissCount<sup>(deprecated)</sup>
getMissCount(): number ### getUpper<sup>9+</sup>
获取查询值不匹配的次数。 getUpper(): ScopeType
> **说明:** 获取当前范围的上限。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[getMissCount<sup>9+</sup>](#getmisscount9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | ------------------------ | ---------------------- |
| number | 返回查询值不匹配的次数。 | | [ScopeType](#scopetype8) | 返回当前范围的上限值。 |
**示例:** **示例:**
```js ```js
let pro = new util.LruBuffer(); let tempLower = new Temperature(30);
pro.put(2,10); let tempUpper = new Temperature(40);
pro.get(2); let range = new util.ScopeHelper(tempLower, tempUpper);
let result = pro.getMissCount(); let result = range.getUpper();
``` ```
### getRemovalCount<sup>(deprecated)</sup>
getRemovalCount(): number ### getLower<sup>9+</sup>
获取从缓冲区中逐出值的次数。 getLower(): ScopeType
> **说明:** 获取当前范围的下限。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[getRemovalCount<sup>9+</sup>](#getremovalcount9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | ------------------------ | ---------------------- |
| number | 返回从缓冲区中驱逐的次数。 | | [ScopeType](#scopetype8) | 返回当前范围的下限值。 |
**示例:** **示例:**
```js ```js
let pro = new util.LruBuffer(); let tempLower = new Temperature(30);
pro.put(2,10); let tempUpper = new Temperature(40);
pro.updateCapacity(2); let range = new util.ScopeHelper(tempLower, tempUpper);
pro.put(50,22); let result = range.getLower();
let result = pro.getRemovalCount();
``` ```
### getMatchCount<sup>(deprecated)</sup>
getMatchCount(): number ### expand<sup>9+</sup>
获取查询值匹配成功的次数。 expand(lowerObj: ScopeType,upperObj: ScopeType): ScopeHelper
> **说明:** 创建并返回包括当前范围和给定下限和上限的并集。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[getMatchCount<sup>9+</sup>](#getmatchcount9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------ | ---- | ---------------- |
| lowerObj | [ScopeType](#scopetype8) | 是 | 给定范围的下限。 |
| upperObj | [ScopeType](#scopetype8) | 是 | 给定范围的上限。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | ---------------------------- | ------------------------------------ |
| number | 返回查询值匹配成功的次数。 | | [ScopeHelper](#scopehelper9) | 返回当前范围和给定下限和上限的并集。 |
**示例:** **示例:**
```js ```js
let pro = new util.LruBuffer(); let tempLower = new Temperature(30);
pro.put(2,10); let tempUpper = new Temperature(40);
pro.get(2); let tempMiDF = new Temperature(35);
let result = pro.getMatchCount(); let tempMidS = new Temperature(39);
let range = new util.ScopeHelper(tempLower, tempUpper);
let result = range.expand(tempMiDF, tempMidS);
``` ```
### getPutCount<sup>(deprecated)</sup>
getPutCount(): number ### expand<sup>9+</sup>
获取将值添加到缓冲区的次数。 expand(range: ScopeHelper): ScopeHelper
> **说明:** 创建并返回包括当前范围和给定范围的并集。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[getPutCount<sup>9+</sup>](#getputcount9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------------------------- | ---- | ------------------ |
| range | [ScopeHelper](#scopehelper9) | 是 | 传入一个给定范围。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | ---------------------------- | ---------------------------------- |
| number | 返回将值添加到缓冲区的次数。 | | [ScopeHelper](#scopehelper9) | 返回包括当前范围和给定范围的并集。 |
**示例:** **示例:**
```js ```js
let pro = new util.LruBuffer(); let tempLower = new Temperature(30);
pro.put(2,10); let tempUpper = new Temperature(40);
let result = pro.getPutCount(); let tempMiDF = new Temperature(35);
let tempMidS = new Temperature(39);
let range = new util.ScopeHelper(tempLower, tempUpper);
let rangeFir = new util.ScopeHelper(tempMiDF, tempMidS);
let result = range.expand(rangeFir);
``` ```
### isEmpty<sup>(deprecated)</sup>
isEmpty(): boolean ### expand<sup>9+</sup>
检查当前缓冲区是否为空。 expand(value: ScopeType): ScopeHelper
> **说明:** 创建并返回包括当前范围和给定值的并集。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[isEmpty<sup>9+</sup>](#isempty9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------------------ | ---- | ---------------- |
| value | [ScopeType](#scopetype8) | 是 | 传入一个给定值。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | ---------------------------- | -------------------------------- |
| boolean | 如果当前缓冲区不包含任何值,则返回true。 | | [ScopeHelper](#scopehelper9) | 返回包括当前范围和给定值的并集。 |
**示例:** **示例:**
```js ```js
let pro = new util.LruBuffer(); let tempLower = new Temperature(30);
pro.put(2,10); let tempUpper = new Temperature(40);
let result = pro.isEmpty(); let tempMiDF = new Temperature(35);
let range = new util.ScopeHelper(tempLower, tempUpper);
let result = range.expand(tempMiDF);
``` ```
### get<sup>(deprecated)</sup>
get(key: K): V | undefined ### contains<sup>9+</sup>
表示要查询的键。 contains(value: ScopeType): boolean
> **说明:** 检查给定value是否包含在当前范围内。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[get<sup>9+</sup>](#get9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | ------ | ------------------------ | ---- | ---------------- |
| key | K | 是 | 要查询的键。 | | value | [ScopeType](#scopetype8) | 是 | 传入一个给定值。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | ------- | --------------------------------------------------- |
| V&nbsp;\|&nbsp;undefined | 如果指定的键存在于缓冲区中,则返回与键关联的值;否则返回undefined。 | | boolean | 如果给定值包含在当前范围内返回true,否则返回false。 |
**示例:** **示例:**
```js ```js
let pro = new util.LruBuffer(); let tempLower = new Temperature(30);
pro.put(2,10); let tempUpper = new Temperature(40);
let result = pro.get(2); let tempMiDF = new Temperature(35);
let range = new util.ScopeHelper(tempLower, tempUpper);
range.contains(tempMiDF);
``` ```
### put<sup>(deprecated)</sup>
put(key: K,value: V): V ### contains<sup>9+</sup>
将键值对添加到缓冲区。 contains(range: ScopeHelper): boolean
> **说明:** 检查给定range是否在当前范围内。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[put<sup>9+</sup>](#put9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | ------ | ---------------------------- | ---- | ------------------ |
| key | K | 是 | 要添加的密钥。 | | range | [ScopeHelper](#scopehelper9) | 是 | 传入一个给定范围。 |
| value | V | 是 | 指示与要添加的键关联的值。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | ------- | ----------------------------------------------------- |
| V | 返回与添加的键关联的值;如果要添加的键已经存在,则返回原始值,如果键或值为空,则抛出此异常。 | | boolean | 如果给定范围包含在当前范围内返回true,否则返回false。 |
**示例:** **示例:**
```js ```js
let pro = new util.LruBuffer(); let tempLower = new Temperature(30);
let result = pro.put(2,10); let tempUpper = new Temperature(40);
let range = new util.ScopeHelper(tempLower, tempUpper);
let tempLess = new Temperature(20);
let tempMore = new Temperature(45);
let rangeSec = new util.ScopeHelper(tempLess, tempMore);
let result = range.contains(rangeSec);
``` ```
### values<sup>(deprecated)</sup>
values(): V[] ### clamp<sup>9+</sup>
获取当前缓冲区中所有值从最近访问到最近最少访问的顺序列表。 clamp(value: ScopeType): ScopeType
> **说明:** 将给定值限定到当前范围内。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[values<sup>9+</sup>](#values9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------------------ | ---- | -------------- |
| value | [ScopeType](#scopetype8) | 是 | 传入的给定值。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | ------------------------ | ------------------------------------------------------------ |
| V&nbsp;[] | 按从最近访问到最近最少访问的顺序返回当前缓冲区中所有值的列表。 | | [ScopeType](#scopetype8) | 如果传入的value小于下限,则返回lowerObj;如果大于上限值则返回upperObj;如果在当前范围内,则返回value。 |
**示例:** **示例:**
```js ```js
let pro = new util.LruBuffer(); let tempLower = new Temperature(30);
pro.put(2,10); let tempUpper = new Temperature(40);
pro.put(2,"anhu"); let tempMiDF = new Temperature(35);
pro.put("afaf","grfb"); let range = new util.ScopeHelper(tempLower, tempUpper);
let result = pro.values(); let result = range.clamp(tempMiDF);
``` ```
### keys<sup>(deprecated)</sup> ## Base64Helper<sup>9+</sup>
keys(): K[] ### constructor<sup>9+</sup>
获取当前缓冲区中所有键从最近访问到最近最少访问的升序列表。 constructor()
> **说明:** Base64Helper的构造函数。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[keys<sup>9+</sup>](#keys9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| K&nbsp;[] | 按升序返回当前缓冲区中所有键的列表,从最近访问到最近最少访问。 |
**示例:** **示例:**
```js ```js
let pro = new util.LruBuffer(); let base64 = new util.Base64Helper();
pro.put(2,10);
let result = pro.keys();
``` ```
### remove<sup>(deprecated)</sup> ### encodeSync<sup>9+</sup>
remove(key: K): V | undefined
从当前缓冲区中删除指定的键及其关联的值。 encodeSync(src: Uint8Array): Uint8Array
> **说明:** 通过输入参数编码后输出对应文本。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[remove<sup>9+</sup>](#remove9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | ------ | ---------- | ---- | ------------------- |
| key | K | 是 | 要删除的密钥。 | | src | Uint8Array | 是 | 编码输入Uint8数组。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | ---------- | ----------------------------- |
| V&nbsp;\|&nbsp;undefined | 返回一个包含已删除键值对的Optional对象;如果key不存在,则返回一个空的Optional对象,如果key为null,则抛出异常。 | | Uint8Array | 返回编码后新分配的Uint8数组。 |
**示例:** **示例:**
```js ```js
let pro = new util.LruBuffer(); let that = new util.Base64Helper();
pro.put(2,10); let array = new Uint8Array([115,49,51]);
let result = pro.remove(20); let result = that.encodeSync(array);
``` ```
### afterRemoval<sup>(deprecated)</sup>
afterRemoval(isEvict: boolean,key: K,value: V,newValue: V): void ### encodeToStringSync<sup>9+</sup>
删除值后执行后续操作。 encodeToStringSync(src: Uint8Array): string
> **说明:** 通过输入参数编码后输出对应文本。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[afterRemoval<sup>9+</sup>](#afterremoval9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | ------ | ---------- | ---- | ------------------- |
| isEvict | boolean | 是 | 因容量不足而调用该方法时,参数值为true,其他情况为false。 | | src | Uint8Array | 是 | 编码输入Uint8数组。 |
| key | K | 是 | 表示删除的键。 |
| value | V | 是 | 表示删除的值。 | **返回值:**
| newValue | V | 是 | 如果已调用put方法并且要添加的键已经存在,则参数值是关联的新值。其他情况下参数值为空。 |
| 类型 | 说明 |
| ------ | -------------------- |
| string | 返回编码后的字符串。 |
**示例:** **示例:**
```js ```js
let arr = []; let that = new util.Base64Helper();
class ChildLruBuffer<K, V> extends util.LruBuffer<K, V> let array = new Uint8Array([115,49,51]);
{ let result = that.encodeToStringSync(array);
constructor()
{
super();
}
afterRemoval(isEvict, key, value, newValue)
{
if (isEvict === false)
{
arr = [key, value, newValue];
}
}
}
let lru = new ChildLruBuffer();
lru.afterRemoval(false,10,30,null);
``` ```
### contains<sup>(deprecated)</sup>
contains(key: K): boolean ### decodeSync<sup>9+</sup>
检查当前缓冲区是否包含指定的键。
decodeSync(src: Uint8Array | string): Uint8Array
> **说明:** 通过输入参数解码后输出对应文本。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[contains<sup>9+</sup>](#contains9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | ------ | ------------------------------ | ---- | ----------------------------- |
| key | K | 是 | 表示要检查的键。 | | src | Uint8Array&nbsp;\|&nbsp;string | 是 | 解码输入Uint8数组或者字符串。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | ---------- | ----------------------------- |
| boolean | 如果缓冲区包含指定的键,则返回&nbsp;true。 | | Uint8Array | 返回解码后新分配的Uint8数组。 |
**示例:** **示例:**
```js ```js
let pro = new util.LruBuffer(); let that = new util.Base64Helper();
pro.put(2,10); let buff = 'czEz';
let result = pro.contains(20); let result = that.decodeSync(buff);
``` ```
### createDefault<sup>(deprecated)</sup>
createDefault(key: K): V ### encode<sup>9+</sup>
如果未计算特定键的值,则执行后续操作,参数表示丢失的键,返回与键关联的值。 encode(src: Uint8Array): Promise&lt;Uint8Array&gt;
> **说明:** 通过输入参数异步编码后输出对应文本。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[createDefault<sup>9+</sup>](#createdefault9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | ------ | ---------- | ---- | ----------------------- |
| key | K | 是 | 表示丢失的键。 | | src | Uint8Array | 是 | 异步编码输入Uint8数组。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | ------------------------- | --------------------------------- |
| V | 返回与键关联的值。 | | Promise&lt;Uint8Array&gt; | 返回异步编码后新分配的Uint8数组。 |
**示例:** **示例:**
```js ```js
let pro = new util.LruBuffer(); let that = new util.Base64Helper();
let result = pro.createDefault(50); let array = new Uint8Array([115,49,51]);
let rarray = new Uint8Array([99,122,69,122]);
that.encode(array).then(val=>{
for (var i = 0; i < rarray.length; i++) {
console.log(val[i].toString())
}
})
``` ```
### entries<sup>(deprecated)</sup>
entries(): IterableIterator&lt;[K,V]&gt; ### encodeToString<sup>9+</sup>
允许迭代包含在这个对象中的所有键值对。 encodeToString(src: Uint8Array): Promise&lt;string&gt;
> **说明:** 通过输入参数异步编码后输出对应文本。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[entries<sup>9+</sup>](#entries9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------- | ---- | ----------------------- |
| src | Uint8Array | 是 | 异步编码输入Uint8数组。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | --------------------- | ------------------------ |
| [K,&nbsp;V] | 返回一个可迭代数组。 | | Promise&lt;string&gt; | 返回异步编码后的字符串。 |
**示例:** **示例:**
```js ```js
let pro = new util.LruBuffer(); let that = new util.Base64Helper();
pro.put(2,10); let array = new Uint8Array([115,49,51]);
let result = pro.entries(); that.encodeToString(array).then(val=>{
console.log(val)
})
``` ```
### [Symbol.iterator]<sup>(deprecated)</sup>
[Symbol.iterator]\(): IterableIterator&lt;[K, V]&gt; ### decode<sup>9+</sup>
返回一个键值对形式的二维数组。 decode(src: Uint8Array | string): Promise&lt;Uint8Array&gt;
> **说明:** 通过输入参数异步解码后输出对应文本。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[Symbol.iterator<sup>9+</sup>](#symboliterator9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------------------------ | ---- | --------------------------------- |
| src | Uint8Array&nbsp;\|&nbsp;string | 是 | 异步解码输入Uint8数组或者字符串。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | ------------------------- | --------------------------------- |
| [K,&nbsp;V] | 返回一个键值对形式的二维数组。 | | Promise&lt;Uint8Array&gt; | 返回异步解码后新分配的Uint8数组。 |
**示例:** **示例:**
```js ```js
let pro = new util.LruBuffer(); let that = new util.Base64Helper();
pro.put(2,10); let array = new Uint8Array([99,122,69,122]);
let result = pro[Symbol.iterator](); let rarray = new Uint8Array([115,49,51]);
that.decode(array).then(val=>{
for (var i = 0; i < rarray.length; i++) {
console.log(val[i].toString())
}
})
``` ```
### ScopeType<sup>8+</sup> ## ScopeType<sup>8+</sup>
用于表示范围中的值的类型。该类型的值,类型可以为ScopeComparable或number。 用于表示范围中的值的类型。该类型的值,类型可以为ScopeComparable或number。
...@@ -2213,377 +2158,399 @@ class Temperature{ ...@@ -2213,377 +2158,399 @@ class Temperature{
} }
``` ```
## ScopeHelper<sup>9+</sup> ## types<sup>8+</sup>
### constructor<sup>9+</sup>
constructor(lowerObj: ScopeType, upperObj: ScopeType) ### constructor<sup>8+</sup>
用于创建指定下限和上限的作用域实例的构造函数,返回一个ScopeHelper对象。 constructor()
Types的构造函数。
**系统能力:** SystemCapability.Utils.Lang
**示例:**
```js
let type = new util.types();
```
### isAnyArrayBuffer<sup>8+</sup>
isAnyArrayBuffer(value: Object): boolean
检查输入的value是否是ArrayBuffer类型。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------ | ---- | ---------------------- | | -------- | -------- | -------- | -------- |
| lowerObj | [ScopeType](#scopetype8) | 是 | 指定作用域实例的下限。 | | value | Object | 是 | 待检测对象。 |
| upperObj | [ScopeType](#scopetype8) | 是 | 指定作用域实例的上限。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| boolean | 判断的结果,如果是ArrayBuffer类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let tempLower = new Temperature(30); let that = new util.types();
let tempUpper = new Temperature(40); let result = that.isAnyArrayBuffer(new ArrayBuffer(0));
let range = new util.ScopeHelper(tempLower, tempUpper);
``` ```
### toString<sup>9+</sup> ### isArrayBufferView<sup>8+</sup>
toString(): string isArrayBufferView(value: Object): boolean
该字符串化方法返回一个包含当前范围的字符串表示形式。 检查输入的value是否是内置ArrayBufferView辅助类型。
ArrayBufferView辅助类型包括:Int8Array、Int16Array、Int32Array、Uint8Array、Uint8ClampedArray、Uint32Array、Float32Array、Float64Array、DataView。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------ | -------------------------------------- | | -------- | -------- |
| string | 返回包含当前范围对象的字符串表示形式。 | | boolean | 判断的结果,如果是内置包含的ArrayBufferView辅助类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let tempLower = new Temperature(30); let that = new util.types();
let tempUpper = new Temperature(40); let result = that.isArrayBufferView(new Int8Array([]));
let range = new util.ScopeHelper(tempLower, tempUpper);
let result = range.toString();
``` ```
### intersect<sup>9+</sup> ### isArgumentsObject<sup>8+</sup>
intersect(range: ScopeHelper): ScopeHelper isArgumentsObject(value: Object): boolean
获取给定范围和当前范围的交集 检查输入的value是否是一个arguments对象类型
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------------------------- | ---- | ------------------ | | -------- | -------- | -------- | -------- |
| range | [ScopeHelper](#scopehelper9) | 是 | 传入一个给定范围。 | | value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------------------------------ | ------------------------------ | | -------- | -------- |
| [ScopeHelper9+](#scopehelper9) | 返回给定范围和当前范围的交集。 | | boolean | 判断的结果,如果是内置包含的arguments类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let tempLower = new Temperature(30); let that = new util.types();
let tempUpper = new Temperature(40); function foo() {
let range = new util.ScopeHelper(tempLower, tempUpper); var result = that.isArgumentsObject(arguments);
let tempMiDF = new Temperature(35); }
let tempMidS = new Temperature(39); let f = foo();
let rangeFir = new util.ScopeHelper(tempMiDF, tempMidS);
range.intersect(rangeFir );
``` ```
### intersect<sup>9+</sup> ### isArrayBuffer<sup>8+</sup>
intersect(lowerObj:ScopeType,upperObj:ScopeType):ScopeHelper isArrayBuffer(value: Object): boolean
获取当前范围与给定下限和上限范围的交集 检查输入的value是否是ArrayBuffer类型
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------ | ---- | ---------------- | | -------- | -------- | -------- | -------- |
| lowerObj | [ScopeType](#scopetype8) | 是 | 给定范围的下限。 | | value | Object | 是 | 待检测对象。 |
| upperObj | [ScopeType](#scopetype8) | 是 | 给定范围的上限。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ---------------------------- | ---------------------------------------- | | -------- | -------- |
| [ScopeHelper](#scopehelper9) | 返回当前范围与给定下限和上限范围的交集。 | | boolean | 判断的结果,如果是内置包含的ArrayBuffer类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let tempLower = new Temperature(30); let that = new util.types();
let tempUpper = new Temperature(40); let result = that.isArrayBuffer(new ArrayBuffer(0));
let tempMiDF = new Temperature(35);
let tempMidS = new Temperature(39);
let range = new util.ScopeHelper(tempLower, tempUpper);
let result = range.intersect(tempMiDF, tempMidS);
``` ```
### getUpper<sup>9+</sup> ### isAsyncFunction<sup>8+</sup>
getUpper(): ScopeType isAsyncFunction(value: Object): boolean
获取当前范围的上限 检查输入的value是否是一个异步函数类型
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------------------------ | ---------------------- | | -------- | -------- |
| [ScopeType](#scopetype8) | 返回当前范围的上限值。 | | boolean | 判断的结果,如果是内置包含的异步函数类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let tempLower = new Temperature(30); let that = new util.types();
let tempUpper = new Temperature(40); let result = that.isAsyncFunction(async function foo() {});
let range = new util.ScopeHelper(tempLower, tempUpper);
let result = range.getUpper();
``` ```
### getLower<sup>9+</sup> ### isBooleanObject<sup>8+</sup>
getLower(): ScopeType isBooleanObject(value: Object): boolean
获取当前范围的下限 检查输入的value是否是一个Boolean对象类型
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------------------------ | ---------------------- | | -------- | -------- |
| [ScopeType](#scopetype8) | 返回当前范围的下限值。 | | boolean | 判断的结果,如果是内置包含的Boolean对象类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let tempLower = new Temperature(30); let that = new util.types();
let tempUpper = new Temperature(40); let result = that.isBooleanObject(new Boolean(true));
let range = new util.ScopeHelper(tempLower, tempUpper);
let result = range.getLower();
``` ```
### expand<sup>9+</sup> ### isBoxedPrimitive<sup>8+</sup>
expand(lowerObj: ScopeType,upperObj: ScopeType): ScopeHelper isBoxedPrimitive(value: Object): boolean
创建并返回包括当前范围和给定下限和上限的并集 检查输入的value是否是Boolean或Number或String或Symbol对象类型
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------ | ---- | ---------------- | | -------- | -------- | -------- | -------- |
| lowerObj | [ScopeType](#scopetype8) | 是 | 给定范围的下限。 | | value | Object | 是 | 待检测对象。 |
| upperObj | [ScopeType](#scopetype8) | 是 | 给定范围的上限。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ---------------------------- | ------------------------------------ | | -------- | -------- |
| [ScopeHelper](#scopehelper9) | 返回当前范围和给定下限和上限的并集。 | | boolean | 判断的结果,如果是内置包含的Boolean或Number或String或Symbol对象类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let tempLower = new Temperature(30); let that = new util.types();
let tempUpper = new Temperature(40); let result = that.isBoxedPrimitive(new Boolean(false));
let tempMiDF = new Temperature(35);
let tempMidS = new Temperature(39);
let range = new util.ScopeHelper(tempLower, tempUpper);
let result = range.expand(tempMiDF, tempMidS);
``` ```
### expand<sup>9+</sup> ### isDataView<sup>8+</sup>
expand(range: ScopeHelper): ScopeHelper isDataView(value: Object): boolean
创建并返回包括当前范围和给定范围的并集 检查输入的value是否是DataView类型
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------------------------- | ---- | ------------------ | | -------- | -------- | -------- | -------- |
| range | [ScopeHelper](#scopehelper9) | 是 | 传入一个给定范围。 | | value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ---------------------------- | ---------------------------------- | | -------- | -------- |
| [ScopeHelper](#scopehelper9) | 返回包括当前范围和给定范围的并集。 | | boolean | 判断的结果,如果是内置包含的DataView对象类型为true,反之为false。 |
**示例:**
```js
let that = new util.types();
const ab = new ArrayBuffer(20);
let result = that.isDataView(new DataView(ab));
```
### isDate<sup>8+</sup>
isDate(value: Object): boolean
检查输入的value是否是Date类型。
**系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| boolean | 判断的结果,如果是内置包含的Date对象类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let tempLower = new Temperature(30); let that = new util.types();
let tempUpper = new Temperature(40); let result = that.isDate(new Date());
let tempMiDF = new Temperature(35);
let tempMidS = new Temperature(39);
let range = new util.ScopeHelper(tempLower, tempUpper);
let rangeFir = new util.ScopeHelper(tempMiDF, tempMidS);
let result = range.expand(rangeFir);
``` ```
### expand<sup>9+</sup> ### isExternal<sup>8+</sup>
expand(value: ScopeType): ScopeHelper isExternal(value: Object): boolean
创建并返回包括当前范围和给定值的并集 检查输入的value是否是native External类型
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------------------ | ---- | ---------------- | | -------- | -------- | -------- | -------- |
| value | [ScopeType](#scopetype8) | 是 | 传入一个给定值。 | | value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ---------------------------- | -------------------------------- | | -------- | -------- |
| [ScopeHelper](#scopehelper9) | 返回包括当前范围和给定值的并集。 | | boolean | 判断的结果,如果是内置包含native&nbsp;External类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let tempLower = new Temperature(30); let that = new util.types();
let tempUpper = new Temperature(40); let result = that.isExternal(true);
let tempMiDF = new Temperature(35);
let range = new util.ScopeHelper(tempLower, tempUpper);
let result = range.expand(tempMiDF);
``` ```
### contains<sup>9+</sup> ### isFloat32Array<sup>8+</sup>
contains(value: ScopeType): boolean isFloat32Array(value: Object): boolean
检查给定value是否包含在当前范围内 检查输入的value是否是Float32Array数组类型
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------------------ | ---- | ---------------- | | -------- | -------- | -------- | -------- |
| value | [ScopeType](#scopetype8) | 是 | 传入一个给定值。 | | value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------- | --------------------------------------------------- | | -------- | -------- |
| boolean | 如果给定值包含在当前范围内返回true,否则返回false。 | | boolean | 判断的结果,如果是内置包含的Float32Array数组类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let tempLower = new Temperature(30); let that = new util.types();
let tempUpper = new Temperature(40); let result = that.isFloat32Array(new Float32Array());
let tempMiDF = new Temperature(35);
let range = new util.ScopeHelper(tempLower, tempUpper);
range.contains(tempMiDF);
``` ```
### contains<sup>9+</sup> ### isFloat64Array<sup>8+</sup>
contains(range: ScopeHelper): boolean isFloat64Array(value: Object): boolean
检查给定range是否在当前范围内 检查输入的value是否是Float64Array数组类型
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------------------------- | ---- | ------------------ | | -------- | -------- | -------- | -------- |
| range | [ScopeHelper](#scopehelper9) | 是 | 传入一个给定范围。 | | value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------- | ----------------------------------------------------- | | -------- | -------- |
| boolean | 如果给定范围包含在当前范围内返回true,否则返回false。 | | boolean | 判断的结果,如果是内置包含的Float64Array数组类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let tempLower = new Temperature(30); let that = new util.types();
let tempUpper = new Temperature(40); let result = that.isFloat64Array(new Float64Array());
let range = new util.ScopeHelper(tempLower, tempUpper);
let tempLess = new Temperature(20);
let tempMore = new Temperature(45);
let rangeSec = new util.ScopeHelper(tempLess, tempMore);
let result = range.contains(rangeSec);
``` ```
### clamp<sup>9+</sup> ### isGeneratorFunction<sup>8+</sup>
clamp(value: ScopeType): ScopeType isGeneratorFunction(value: Object): boolean
将给定值限定到当前范围内 检查输入的value是否是generator函数类型
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------------------ | ---- | -------------- | | -------- | -------- | -------- | -------- |
| value | [ScopeType](#scopetype8) | 是 | 传入的给定值。 | | value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------------------------ | ------------------------------------------------------------ | | -------- | -------- |
| [ScopeType](#scopetype8) | 如果传入的value小于下限,则返回lowerObj;如果大于上限值则返回upperObj;如果在当前范围内,则返回value。 | | boolean | 判断的结果,如果是内置包含的generator函数类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let tempLower = new Temperature(30); let that = new util.types();
let tempUpper = new Temperature(40); let result = that.isGeneratorFunction(function* foo() {});
let tempMiDF = new Temperature(35);
let range = new util.ScopeHelper(tempLower, tempUpper);
let result = range.clamp(tempMiDF);
``` ```
## Scope<sup>(deprecated)</sup>
> **说明:**
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[ScopeHelper<sup>9+</sup>](#scopehelper9)替代。
### constructor<sup>(deprecated)</sup>
constructor(lowerObj: ScopeType, upperObj: ScopeType)
用于创建指定下限和上限的作用域实例的构造函数,返回一个Scope对象。 ### isGeneratorObject<sup>8+</sup>
> **说明:** isGeneratorObject(value: Object): boolean
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[constructor<sup>9+</sup>](#constructor9)替代。
检查输入的value是否是generator对象类型。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -2591,52 +2558,57 @@ constructor(lowerObj: ScopeType, upperObj: ScopeType) ...@@ -2591,52 +2558,57 @@ constructor(lowerObj: ScopeType, upperObj: ScopeType)
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| lowerObj | [ScopeType](#scopetype8) | 是 | 指定作用域实例的下限。 | | value | Object | 是 | 待检测对象。 |
| upperObj | [ScopeType](#scopetype8) | 是 | 指定作用域实例的上限。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| boolean | 判断的结果,如果是内置包含的generator对象类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let tempLower = new Temperature(30); let that = new util.types();
let tempUpper = new Temperature(40); function* foo() {}
let range = new util.Scope(tempLower, tempUpper); const generator = foo();
let result = that.isGeneratorObject(generator);
``` ```
### toString<sup>(deprecated)</sup>
toString(): string ### isInt8Array<sup>8+</sup>
该字符串化方法返回一个包含当前范围的字符串表示形式。 isInt8Array(value: Object): boolean
> **说明:** 检查输入的value是否是Int8Array数组类型。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[toString<sup>9+</sup>](#tostring9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| string | 返回包含当前范围对象的字符串表示形式。 | | boolean | 判断的结果,如果是内置包含的Int8Array数组类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let tempLower = new Temperature(30); let that = new util.types();
let tempUpper = new Temperature(40); let result = that.isInt8Array(new Int8Array([]));
let range = new util.Scope(tempLower, tempUpper);
let result = range.toString();
``` ```
### intersect<sup>(deprecated)</sup>
intersect(range: Scope): Scope ### isInt16Array<sup>8+</sup>
获取给定范围和当前范围的交集。 isInt16Array(value: Object): boolean
> **说明:** 检查输入的value是否是Int16Array数组类型。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[intersect<sup>9+</sup>](#intersect9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -2644,35 +2616,27 @@ intersect(range: Scope): Scope ...@@ -2644,35 +2616,27 @@ intersect(range: Scope): Scope
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| range | [Scope](#scopedeprecated) | 是 | 传入一个给定范围。 | | value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| [Scope](#scopedeprecated) | 返回给定范围和当前范围的交集。 | | boolean | 判断的结果,如果是内置包含的Int16Array数组类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let tempLower = new Temperature(30); let that = new util.types();
let tempUpper = new Temperature(40); let result = that.isInt16Array(new Int16Array([]));
let range = new util.Scope(tempLower, tempUpper);
let tempMiDF = new Temperature(35);
let tempMidS = new Temperature(39);
let rangeFir = new util.Scope(tempMiDF, tempMidS);
range.intersect(rangeFir );
``` ```
### intersect<sup>(deprecated)</sup>
intersect(lowerObj:ScopeType,upperObj:ScopeType):Scope ### isInt32Array<sup>8+</sup>
获取当前范围与给定下限和上限范围的交集。 isInt32Array(value: Object): boolean
> **说明:** 检查输入的value是否是Int32Array数组类型。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[intersect<sup>9+</sup>](#intersect9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -2680,89 +2644,85 @@ intersect(lowerObj:ScopeType,upperObj:ScopeType):Scope ...@@ -2680,89 +2644,85 @@ intersect(lowerObj:ScopeType,upperObj:ScopeType):Scope
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| lowerObj | [ScopeType](#scopetype8) | 是 | 给定范围的下限。 | | value | Object | 是 | 待检测对象。 |
| upperObj | [ScopeType](#scopetype8) | 是 | 给定范围的上限。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| [Scope](#scopedeprecated) | 返回当前范围与给定下限和上限范围的交集。 | | boolean | 判断的结果,如果是内置包含的Int32Array数组类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let tempLower = new Temperature(30); let that = new util.types();
let tempUpper = new Temperature(40); let result = that.isInt32Array(new Int32Array([]));
let tempMiDF = new Temperature(35);
let tempMidS = new Temperature(39);
let range = new util.Scope(tempLower, tempUpper);
let result = range.intersect(tempMiDF, tempMidS);
``` ```
### getUpper<sup>(deprecated)</sup>
getUpper(): ScopeType ### isMap<sup>8+</sup>
获取当前范围的上限。 isMap(value: Object): boolean
> **说明:** 检查输入的value是否是Map类型。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[getUpper<sup>9+</sup>](#getupper9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| [ScopeType](#scopetype8) | 返回当前范围的上限值。 | | boolean | 判断的结果,如果是内置包含的Map类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let tempLower = new Temperature(30); let that = new util.types();
let tempUpper = new Temperature(40); let result = that.isMap(new Map());
let range = new util.Scope(tempLower, tempUpper);
let result = range.getUpper();
``` ```
### getLower<sup>(deprecated)</sup>
getLower(): ScopeType ### isMapIterator<sup>8+</sup>
获取当前范围的下限。 isMapIterator(value: Object): boolean
> **说明:** 检查输入的value是否是Map的Iterator类型。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[getLower<sup>9+</sup>](#getlower9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| [ScopeType](#scopetype8) | 返回当前范围的下限值。 | | boolean | 判断的结果,如果是内置包含的Map的Iterator类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let tempLower = new Temperature(30); let that = new util.types();
let tempUpper = new Temperature(40); const map = new Map();
let range = new util.Scope(tempLower, tempUpper); let result = that.isMapIterator(map.keys());
let result = range.getLower();
``` ```
### expand<sup>(deprecated)</sup>
expand(lowerObj: ScopeType,upperObj: ScopeType): Scope ### isNativeError<sup>8+</sup>
创建并返回包括当前范围和给定下限和上限的并集。 isNativeError(value: Object): boolean
> **说明:** 检查输入的value是否是Error类型。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[expand<sup>9+</sup>](#expand9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -2770,35 +2730,27 @@ expand(lowerObj: ScopeType,upperObj: ScopeType): Scope ...@@ -2770,35 +2730,27 @@ expand(lowerObj: ScopeType,upperObj: ScopeType): Scope
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| lowerObj | [ScopeType](#scopetype8) | 是 | 给定范围的下限。 | | value | Object | 是 | 待检测对象。 |
| upperObj | [ScopeType](#scopetype8) | 是 | 给定范围的上限。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| [Scope](#scopedeprecated) | 返回当前范围和给定下限和上限的并集。 | | boolean | 判断的结果,如果是内置包含的Error类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let tempLower = new Temperature(30); let that = new util.types();
let tempUpper = new Temperature(40); let result = that.isNativeError(new TypeError());
let tempMiDF = new Temperature(35);
let tempMidS = new Temperature(39);
let range = new util.Scope(tempLower, tempUpper);
let result = range.expand(tempMiDF, tempMidS);
``` ```
### expand<sup>(deprecated)</sup>
expand(range: Scope): Scope ### isNumberObject<sup>8+</sup>
创建并返回包括当前范围和给定范围的并集。 isNumberObject(value: Object): boolean
> **说明:** 检查输入的value是否是Number对象类型。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[expand<sup>9+</sup>](#expand9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -2806,35 +2758,27 @@ expand(range: Scope): Scope ...@@ -2806,35 +2758,27 @@ expand(range: Scope): Scope
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| range | [Scope](#scopedeprecated) | 是 | 传入一个给定范围。 | | value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| [Scope](#scopedeprecated) | 返回包括当前范围和给定范围的并集。 | | boolean | 判断的结果,如果是内置包含的Number对象类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let tempLower = new Temperature(30); let that = new util.types();
let tempUpper = new Temperature(40); let result = that.isNumberObject(new Number(0));
let tempMiDF = new Temperature(35);
let tempMidS = new Temperature(39);
let range = new util.Scope(tempLower, tempUpper);
let rangeFir = new util.Scope(tempMiDF, tempMidS);
let result = range.expand(rangeFir);
``` ```
### expand<sup>(deprecated)</sup>
expand(value: ScopeType): Scope ### isPromise<sup>8+</sup>
创建并返回包括当前范围和给定值的并集。 isPromise(value: Object): boolean
> **说明:** 检查输入的value是否是Promise类型。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[expand<sup>9+</sup>](#expand9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -2842,33 +2786,27 @@ expand(value: ScopeType): Scope ...@@ -2842,33 +2786,27 @@ expand(value: ScopeType): Scope
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | [ScopeType](#scopetype8) | 是 | 传入一个给定值。 | | value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| [Scope](#scopedeprecated) | 返回包括当前范围和给定值的并集。 | | boolean | 判断的结果,如果是内置包含的Promise类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let tempLower = new Temperature(30); let that = new util.types();
let tempUpper = new Temperature(40); let result = that.isPromise(Promise.resolve(1));
let tempMiDF = new Temperature(35);
let range = new util.Scope(tempLower, tempUpper);
let result = range.expand(tempMiDF);
``` ```
### contains<sup>(deprecated)</sup>
contains(value: ScopeType): boolean ### isProxy<sup>8+</sup>
检查给定value是否包含在当前范围内。 isProxy(value: Object): boolean
> **说明:** 检查输入的value是否是Proxy类型。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[contains<sup>9+</sup>](#contains9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -2876,33 +2814,29 @@ contains(value: ScopeType): boolean ...@@ -2876,33 +2814,29 @@ contains(value: ScopeType): boolean
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | [ScopeType](#scopetype8) | 是 | 传入一个给定值。 | | value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 如果给定值包含在当前范围内返回true,否则返回false。 | | boolean | 判断的结果,如果是内置包含的Proxy类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let tempLower = new Temperature(30); let that = new util.types();
let tempUpper = new Temperature(40); const target = {};
let tempMiDF = new Temperature(35); const proxy = new Proxy(target, {});
let range = new util.Scope(tempLower, tempUpper); let result = that.isProxy(proxy);
range.contains(tempMiDF);
``` ```
### contains<sup>(deprecated)</sup>
contains(range: Scope): boolean ### isRegExp<sup>8+</sup>
检查给定range是否在当前范围内。 isRegExp(value: Object): boolean
> **说明:** 检查输入的value是否是RegExp类型。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[contains<sup>9+</sup>](#contains9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -2910,36 +2844,27 @@ contains(range: Scope): boolean ...@@ -2910,36 +2844,27 @@ contains(range: Scope): boolean
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| range | [Scope](#scopedeprecated) | 是 | 传入一个给定范围。 | | value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 如果给定范围包含在当前范围内返回true,否则返回false。 | | boolean | 判断的结果,如果是内置包含的RegExp类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let tempLower = new Temperature(30); let that = new util.types();
let tempUpper = new Temperature(40); let result = that.isRegExp(new RegExp('abc'));
let range = new util.Scope(tempLower, tempUpper);
let tempLess = new Temperature(20);
let tempMore = new Temperature(45);
let rangeSec = new util.Scope(tempLess, tempMore);
let result = range.contains(rangeSec);
``` ```
### clamp<sup>(deprecated)</sup>
clamp(value: ScopeType): ScopeType ### isSet<sup>8+</sup>
将给定值限定到当前范围内。 isSet(value: Object): boolean
> **说明:** 检查输入的value是否是Set类型。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[clamp<sup>9+</sup>](#clamp9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -2947,259 +2872,255 @@ clamp(value: ScopeType): ScopeType ...@@ -2947,259 +2872,255 @@ clamp(value: ScopeType): ScopeType
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | [ScopeType](#scopetype8) | 是 | 传入的给定值。 | | value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| [ScopeType](#scopetype8) | 如果传入的value小于下限,则返回lowerObj;如果大于上限值则返回upperObj;如果在当前范围内,则返回value。 | | boolean | 判断的结果,如果是内置包含的Set类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let tempLower = new Temperature(30); let that = new util.types();
let tempUpper = new Temperature(40); let result = that.isSet(new Set());
let tempMiDF = new Temperature(35);
let range = new util.Scope(tempLower, tempUpper);
let result = range.clamp(tempMiDF);
``` ```
## Base64Helper<sup>9+</sup>
### constructor<sup>9+</sup> ### isSetIterator<sup>8+</sup>
constructor() isSetIterator(value: Object): boolean
Base64Helper的构造函数 检查输入的value是否是Set的Iterator类型
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| boolean | 判断的结果,如果是内置包含的Set的Iterator类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let base64 = new util.Base64Helper(); let that = new util.types();
const set = new Set();
let result = that.isSetIterator(set.keys());
``` ```
### encodeSync<sup>9+</sup>
encodeSync(src: Uint8Array): Uint8Array ### isStringObject<sup>8+</sup>
通过输入参数编码后输出对应文本。 isStringObject(value: Object): boolean
检查输入的value是否是String对象类型。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------- | ---- | ------------------- | | -------- | -------- | -------- | -------- |
| src | Uint8Array | 是 | 编码输入Uint8数组。 | | value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ---------- | ----------------------------- | | -------- | -------- |
| Uint8Array | 返回编码后新分配的Uint8数组。 | | boolean | 判断的结果,如果是内置包含的String对象类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let that = new util.Base64Helper(); let that = new util.types();
let array = new Uint8Array([115,49,51]); let result = that.isStringObject(new String('foo'));
let result = that.encodeSync(array);
``` ```
### encodeToStringSync<sup>9+</sup> ### isSymbolObjec<sup>8+</sup>
encodeToStringSync(src: Uint8Array): string isSymbolObject(value: Object): boolean
通过输入参数编码后输出对应文本 检查输入的value是否是Symbol对象类型
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------- | ---- | ------------------- | | -------- | -------- | -------- | -------- |
| src | Uint8Array | 是 | 编码输入Uint8数组。 | | value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------ | -------------------- | | -------- | -------- |
| string | 返回编码后的字符串。 | | boolean | 判断的结果,如果是内置包含的Symbol对象类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let that = new util.Base64Helper(); let that = new util.types();
let array = new Uint8Array([115,49,51]); const symbols = Symbol('foo');
let result = that.encodeToStringSync(array); let result = that.isSymbolObject(Object(symbols));
``` ```
### decodeSync<sup>9+</sup> ### isTypedArray<sup>8+</sup>
decodeSync(src: Uint8Array | string): Uint8Array isTypedArray(value: Object): boolean
通过输入参数解码后输出对应文本。 检查输入的value是否是TypedArray类型的辅助类型。
TypedArray类型的辅助类型,包括Int8Array、Int16Array、Int32Array、Uint8Array、Uint8ClampedArray、Uint16Array、Uint32Array、Float32Array、Float64Array、DataView。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------------------------ | ---- | ----------------------------- | | -------- | -------- | -------- | -------- |
| src | Uint8Array&nbsp;\|&nbsp;string | 是 | 解码输入Uint8数组或者字符串。 | | value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ---------- | ----------------------------- | | -------- | -------- |
| Uint8Array | 返回解码后新分配的Uint8数组。 | | boolean | 判断的结果,如果是内置包含的TypedArray包含的类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let that = new util.Base64Helper(); let that = new util.types();
let buff = 'czEz'; let result = that.isTypedArray(new Float64Array([]));
let result = that.decodeSync(buff);
``` ```
### encode<sup>9+</sup> ### isUint8Array<sup>8+</sup>
encode(src: Uint8Array): Promise&lt;Uint8Array&gt; isUint8Array(value: Object): boolean
通过输入参数异步编码后输出对应文本 检查输入的value是否是Uint8Array数组类型
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------- | ---- | ----------------------- | | -------- | -------- | -------- | -------- |
| src | Uint8Array | 是 | 异步编码输入Uint8数组。 | | value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------------------------- | --------------------------------- | | -------- | -------- |
| Promise&lt;Uint8Array&gt; | 返回异步编码后新分配的Uint8数组。 | | boolean | 判断的结果,如果是内置包含的Uint8Array数组类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let that = new util.Base64Helper(); let that = new util.types();
let array = new Uint8Array([115,49,51]); let result = that.isUint8Array(new Uint8Array([]));
let rarray = new Uint8Array([99,122,69,122]);
that.encode(array).then(val=>{
for (var i = 0; i < rarray.length; i++) {
console.log(val[i].toString())
}
})
``` ```
### encodeToString<sup>9+</sup> ### isUint8ClampedArray<sup>8+</sup>
encodeToString(src: Uint8Array): Promise&lt;string&gt; isUint8ClampedArray(value: Object): boolean
通过输入参数异步编码后输出对应文本 检查输入的value是否是Uint8ClampedArray数组类型
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------- | ---- | ----------------------- | | -------- | -------- | -------- | -------- |
| src | Uint8Array | 是 | 异步编码输入Uint8数组。 | | value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| --------------------- | ------------------------ | | -------- | -------- |
| Promise&lt;string&gt; | 返回异步编码后的字符串。 | | boolean | 判断的结果,如果是内置包含的Uint8ClampedArray数组类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let that = new util.Base64Helper(); let that = new util.types();
let array = new Uint8Array([115,49,51]); let result = that.isUint8ClampedArray(new Uint8ClampedArray([]));
that.encodeToString(array).then(val=>{
console.log(val)
})
``` ```
### decode<sup>9+</sup> ### isUint16Array<sup>8+</sup>
decode(src: Uint8Array | string): Promise&lt;Uint8Array&gt; isUint16Array(value: Object): boolean
通过输入参数异步解码后输出对应文本 检查输入的value是否是Uint16Array数组类型
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------------------------ | ---- | --------------------------------- | | -------- | -------- | -------- | -------- |
| src | Uint8Array&nbsp;\|&nbsp;string | 是 | 异步解码输入Uint8数组或者字符串。 | | value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------------------------- | --------------------------------- | | -------- | -------- |
| Promise&lt;Uint8Array&gt; | 返回异步解码后新分配的Uint8数组。 | | boolean | 判断的结果,如果是内置包含的Uint16Array数组类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let that = new util.Base64Helper(); let that = new util.types();
let array = new Uint8Array([99,122,69,122]); let result = that.isUint16Array(new Uint16Array([]));
let rarray = new Uint8Array([115,49,51]);
that.decode(array).then(val=>{
for (var i = 0; i < rarray.length; i++) {
console.log(val[i].toString())
}
})
``` ```
## Base64<sup>(deprecated)</sup> ### isUint32Array<sup>8+</sup>
> **说明:** isUint32Array(value: Object): boolean
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[Base64Helper<sup>9+</sup>](#base64helper9)替代。
### constructor<sup>(deprecated)</sup> 检查输入的value是否是Uint32Array数组类型。
constructor() **系统能力:** SystemCapability.Utils.Lang
Base64的构造函数。 **参数:**
> **说明:** | 参数名 | 类型 | 必填 | 说明 |
> | -------- | -------- | -------- | -------- |
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[constructor<sup>9+</sup>](#constructor9)替代。 | value | Object | 是 | 待检测对象。 |
**系统能力:** SystemCapability.Utils.Lang **返回值:**
| 类型 | 说明 |
| -------- | -------- |
| boolean | 判断的结果,如果是内置包含的Uint32Array数组类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let base64 = new util.Base64(); let that = new util.types();
let result = that.isUint32Array(new Uint32Array([]));
``` ```
### encodeSync<sup>(deprecated)</sup>
encodeSync(src: Uint8Array): Uint8Array ### isWeakMap<sup>8+</sup>
通过输入参数编码后输出对应文本。 isWeakMap(value: Object): boolean
> **说明:** 检查输入的value是否是WeakMap类型。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[encodeSync<sup>9+</sup>](#encodesync9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -3207,31 +3128,27 @@ encodeSync(src: Uint8Array): Uint8Array ...@@ -3207,31 +3128,27 @@ encodeSync(src: Uint8Array): Uint8Array
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| src | Uint8Array | 是 | 编码输入Uint8数组。 | | value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Uint8Array | 返回编码后新分配的Uint8数组。 | | boolean | 判断的结果,如果是内置包含的WeakMap类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let that = new util.Base64(); let that = new util.types();
let array = new Uint8Array([115,49,51]); let result = that.isWeakMap(new WeakMap());
let result = that.encodeSync(array);
``` ```
### encodeToStringSync<sup>(deprecated)</sup>
encodeToStringSync(src: Uint8Array): string ### isWeakSet<sup>8+</sup>
通过输入参数编码后输出对应文本。 isWeakSet(value: Object): boolean
> **说明:** 检查输入的value是否是WeakSet类型。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[encodeToStringSync<sup>9+</sup>](#encodetostringsync9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -3239,31 +3156,27 @@ encodeToStringSync(src: Uint8Array): string ...@@ -3239,31 +3156,27 @@ encodeToStringSync(src: Uint8Array): string
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| src | Uint8Array | 是 | 编码输入Uint8数组。 | | value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| string | 返回编码后的字符串。 | | boolean | 判断的结果,如果是内置包含的WeakSet类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let that = new util.Base64(); let that = new util.types();
let array = new Uint8Array([115,49,51]); let result = that.isWeakSet(new WeakSet());
let result = that.encodeToStringSync(array);
``` ```
### decodeSync<sup>(deprecated)</sup>
decodeSync(src: Uint8Array | string): Uint8Array ### isBigInt64Array<sup>8+</sup>
通过输入参数解码后输出对应文本。 isBigInt64Array(value: Object): boolean
> **说明:** 检查输入的value是否是BigInt64Array类型。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[decodeSync<sup>9+</sup>](#decodesync9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -3271,31 +3184,27 @@ decodeSync(src: Uint8Array | string): Uint8Array ...@@ -3271,31 +3184,27 @@ decodeSync(src: Uint8Array | string): Uint8Array
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| src | Uint8Array&nbsp;\|&nbsp;string | 是 | 解码输入Uint8数组或者字符串。 | | value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Uint8Array | 返回解码后新分配的Uint8数组。 | | boolean | 判断的结果,如果是内置包含的BigInt64Array类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let that = new util.Base64(); let that = new util.types();
let buff = 'czEz'; let result = that.isBigInt64Array(new BigInt64Array([]));
let result = that.decodeSync(buff);
``` ```
### encode<sup>(deprecated)</sup>
encode(src: Uint8Array): Promise&lt;Uint8Array&gt; ### isBigUint64Array<sup>8+</sup>
通过输入参数异步编码后输出对应文本。 isBigUint64Array(value: Object): boolean
> **说明:** 检查输入的value是否是BigUint64Array类型。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[encode<sup>9+</sup>](#encode9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -3303,36 +3212,27 @@ encode(src: Uint8Array): Promise&lt;Uint8Array&gt; ...@@ -3303,36 +3212,27 @@ encode(src: Uint8Array): Promise&lt;Uint8Array&gt;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| src | Uint8Array | 是 | 异步编码输入Uint8数组。 | | value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Promise&lt;Uint8Array&gt; | 返回异步编码后新分配的Uint8数组。 | | boolean | 判断的结果,如果是内置包含的BigUint64Array类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let that = new util.Base64(); let that = new util.types();
let array = new Uint8Array([115,49,51]); let result = that.isBigUint64Array(new BigUint64Array([]));
let rarray = new Uint8Array([99,122,69,122]);
that.encode(array).then(val=>{
for (var i = 0; i < rarray.length; i++) {
console.log(val[i].toString())
}
})
``` ```
### encodeToString<sup>(deprecated)</sup>
encodeToString(src: Uint8Array): Promise&lt;string&gt; ### isModuleNamespaceObject<sup>8+</sup>
通过输入参数异步编码后输出对应文本。 isModuleNamespaceObject(value: Object): boolean
> **说明:** 检查输入的value是否是Module Namespace Object类型。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[encodeToString<sup>9+</sup>](#encodetostring9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -3340,34 +3240,28 @@ encodeToString(src: Uint8Array): Promise&lt;string&gt; ...@@ -3340,34 +3240,28 @@ encodeToString(src: Uint8Array): Promise&lt;string&gt;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| src | Uint8Array | 是 | 异步编码输入Uint8数组。 | | value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Promise&lt;string&gt; | 返回异步编码后的字符串。 | | boolean | 判断的结果,如果是内置包含的Module Namespace Object类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let that = new util.Base64(); import url from '@ohos.url'
let array = new Uint8Array([115,49,51]); let that = new util.types();
that.encodeToString(array).then(val=>{ let result = that.isModuleNamespaceObject(url);
console.log(val)
})
``` ```
### decode<sup>(deprecated)</sup>
decode(src: Uint8Array | string): Promise&lt;Uint8Array&gt; ### isSharedArrayBuffer<sup>8+</sup>
通过输入参数异步解码后输出对应文本。 isSharedArrayBuffer(value: Object): boolean
> **说明:** 检查输入的value是否是SharedArrayBuffer类型。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[decode<sup>9+</sup>](#decode9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -3375,50 +3269,53 @@ decode(src: Uint8Array | string): Promise&lt;Uint8Array&gt; ...@@ -3375,50 +3269,53 @@ decode(src: Uint8Array | string): Promise&lt;Uint8Array&gt;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| src | Uint8Array&nbsp;\|&nbsp;string | 是 | 异步解码输入Uint8数组或者字符串。 | | value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Promise&lt;Uint8Array&gt; | 返回异步解码后新分配的Uint8数组。 | | boolean | 判断的结果,如果是内置包含的SharedArrayBuffer类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let that = new util.Base64(); let that = new util.types();
let array = new Uint8Array([99,122,69,122]); let result = that.isSharedArrayBuffer(new SharedArrayBuffer(0));
let rarray = new Uint8Array([115,49,51]);
that.decode(array).then(val=>{
for (var i = 0; i < rarray.length; i++) {
console.log(val[i].toString())
}
})
``` ```
## types<sup>8+</sup> ## LruBuffer<sup>(deprecated)</sup>
### constructor<sup>8+</sup> > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[LRUCache<sup>9+</sup>](#lrucache9)替代。
constructor() ### 属性
Types的构造函数 **系统能力:** 以下各项对应的系统能力均为SystemCapability.Utils.Lang
**系统能力:** SystemCapability.Utils.Lang | 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| length | number | 是 | 否 | 当前缓冲区中值的总数。 |
**示例:** **示例:**
```js ```js
let type = new util.types(); let pro = new util.LruBuffer();
pro.put(2,10);
pro.put(1,8);
let result = pro.length;
``` ```
### constructor<sup>(deprecated)</sup>
### isAnyArrayBuffer<sup>8+</sup> constructor(capacity?: number)
isAnyArrayBuffer(value: Object): boolean 默认构造函数用于创建一个新的LruBuffer实例,默认容量为64。
检查输入的value是否是ArrayBuffer类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[constructor<sup>9+</sup>](#constructor9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -3426,29 +3323,23 @@ isAnyArrayBuffer(value: Object): boolean ...@@ -3426,29 +3323,23 @@ isAnyArrayBuffer(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 | | capacity | number | 否 | 指示要为缓冲区自定义的容量。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| boolean | 判断的结果,如果是ArrayBuffer类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let lrubuffer= new util.LruBuffer();
let result = that.isAnyArrayBuffer(new ArrayBuffer(0));
``` ```
### updateCapacity<sup>(deprecated)</sup>
### isArrayBufferView<sup>8+</sup> updateCapacity(newCapacity: number): void
isArrayBufferView(value: Object): boolean
检查输入的value是否是内置ArrayBufferView辅助类型 将缓冲区容量更新为指定容量,如果newCapacity小于或等于0,则抛出异常
ArrayBufferView辅助类型包括:Int8Array、Int16Array、Int32Array、Uint8Array、Uint8ClampedArray、Uint32Array、Float32Array、Float64Array、DataView。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[updateCapacity<sup>9+</sup>](#updatecapacity9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -3456,255 +3347,257 @@ ArrayBufferView辅助类型包括:Int8Array、Int16Array、Int32Array、Uint8A ...@@ -3456,255 +3347,257 @@ ArrayBufferView辅助类型包括:Int8Array、Int16Array、Int32Array、Uint8A
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 | | newCapacity | number | 是 | 指示要为缓冲区自定义的容量。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| boolean | 判断的结果,如果是内置包含的ArrayBufferView辅助类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let pro = new util.LruBuffer();
let result = that.isArrayBufferView(new Int8Array([])); let result = pro.updateCapacity(100);
``` ```
### toString<sup>(deprecated)</sup>
### isArgumentsObject<sup>8+</sup> toString(): string
isArgumentsObject(value: Object): boolean 返回对象的字符串表示形式。
检查输入的value是否是一个arguments对象类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[toString<sup>9+</sup>](#tostring9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的arguments类型为true,反之为false。 | | string | 返回对象的字符串表示形式。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let pro = new util.LruBuffer();
function foo() { pro.put(2,10);
var result = that.isArgumentsObject(arguments); pro.get(2);
} pro.remove(20);
let f = foo(); let result = pro.toString();
``` ```
### getCapacity<sup>(deprecated)</sup>
### isArrayBuffer<sup>8+</sup> getCapacity(): number
isArrayBuffer(value: Object): boolean 获取当前缓冲区的容量。
检查输入的value是否是ArrayBuffer类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[getCapacity<sup>9+</sup>](#getcapacity9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **返回值:**
| 参数名 | 类型 | 必填 | 说明 | | 类型 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- |
| value | Object | 是 | 待检测对象。 | | number | 返回当前缓冲区的容量。 |
**返回值:** **示例:**
```js
let pro = new util.LruBuffer();
let result = pro.getCapacity();
```
### clear<sup>(deprecated)</sup>
clear(): void
从当前缓冲区清除键值对。后续会调用afterRemoval()方法执行后续操作。
> **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[clear<sup>9+</sup>](#clear9)替代。
| 类型 | 说明 | **系统能力:** SystemCapability.Utils.Lang
| -------- | -------- |
| boolean | 判断的结果,如果是内置包含的ArrayBuffer类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let pro = new util.LruBuffer();
let result = that.isArrayBuffer(new ArrayBuffer(0)); pro.put(2,10);
let result = pro.length;
pro.clear();
``` ```
### getCreateCount<sup>(deprecated)</sup>
### isAsyncFunction<sup>8+</sup> getCreateCount(): number
isAsyncFunction(value: Object): boolean 获取createDefault()返回值的次数。
检查输入的value是否是一个异步函数类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[getCreateCount<sup>9+</sup>](#getcreatecount9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的异步函数类型为true,反之为false。 | | number | 返回createDefault()返回值的次数。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let pro = new util.LruBuffer();
let result = that.isAsyncFunction(async function foo() {}); pro.put(1,8);
let result = pro.getCreateCount();
``` ```
### getMissCount<sup>(deprecated)</sup>
### isBooleanObject<sup>8+</sup> getMissCount(): number
isBooleanObject(value: Object): boolean 获取查询值不匹配的次数。
检查输入的value是否是一个Boolean对象类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[getMissCount<sup>9+</sup>](#getmisscount9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的Boolean对象类型为true,反之为false。 | | number | 返回查询值不匹配的次数。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let pro = new util.LruBuffer();
let result = that.isBooleanObject(new Boolean(true)); pro.put(2,10);
pro.get(2);
let result = pro.getMissCount();
``` ```
### getRemovalCount<sup>(deprecated)</sup>
### isBoxedPrimitive<sup>8+</sup> getRemovalCount(): number
isBoxedPrimitive(value: Object): boolean 获取从缓冲区中逐出值的次数。
检查输入的value是否是Boolean或Number或String或Symbol对象类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[getRemovalCount<sup>9+</sup>](#getremovalcount9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的Boolean或Number或String或Symbol对象类型为true,反之为false。 | | number | 返回从缓冲区中驱逐的次数。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let pro = new util.LruBuffer();
let result = that.isBoxedPrimitive(new Boolean(false)); pro.put(2,10);
pro.updateCapacity(2);
pro.put(50,22);
let result = pro.getRemovalCount();
``` ```
### getMatchCount<sup>(deprecated)</sup>
### isDataView<sup>8+</sup> getMatchCount(): number
isDataView(value: Object): boolean 获取查询值匹配成功的次数。
检查输入的value是否是DataView类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[getMatchCount<sup>9+</sup>](#getmatchcount9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的DataView对象类型为true,反之为false。 | | number | 返回查询值匹配成功的次数。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let pro = new util.LruBuffer();
const ab = new ArrayBuffer(20); pro.put(2,10);
let result = that.isDataView(new DataView(ab)); pro.get(2);
let result = pro.getMatchCount();
``` ```
### getPutCount<sup>(deprecated)</sup>
### isDate<sup>8+</sup> getPutCount(): number
isDate(value: Object): boolean 获取将值添加到缓冲区的次数。
检查输入的value是否是Date类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[getPutCount<sup>9+</sup>](#getputcount9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的Date对象类型为true,反之为false。 | | number | 返回将值添加到缓冲区的次数。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let pro = new util.LruBuffer();
let result = that.isDate(new Date()); pro.put(2,10);
let result = pro.getPutCount();
``` ```
### isEmpty<sup>(deprecated)</sup>
### isExternal<sup>8+</sup> isEmpty(): boolean
isExternal(value: Object): boolean 检查当前缓冲区是否为空。
检查输入的value是否是native External类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[isEmpty<sup>9+</sup>](#isempty9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含native&nbsp;External类型为true,反之为false。 | | boolean | 如果当前缓冲区不包含任何值,则返回true。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let pro = new util.LruBuffer();
let result = that.isExternal(true); pro.put(2,10);
let result = pro.isEmpty();
``` ```
### get<sup>(deprecated)</sup>
### isFloat32Array<sup>8+</sup> get(key: K): V | undefined
isFloat32Array(value: Object): boolean 表示要查询的键。
检查输入的value是否是Float32Array数组类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[get<sup>9+</sup>](#get9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -3712,27 +3605,31 @@ isFloat32Array(value: Object): boolean ...@@ -3712,27 +3605,31 @@ isFloat32Array(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 | | key | K | 是 | 要查询的键。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的Float32Array数组类型为true,反之为false。 | | V&nbsp;\|&nbsp;undefined | 如果指定的键存在于缓冲区中,则返回与键关联的值;否则返回undefined。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let pro = new util.LruBuffer();
let result = that.isFloat32Array(new Float32Array()); pro.put(2,10);
let result = pro.get(2);
``` ```
### put<sup>(deprecated)</sup>
### isFloat64Array<sup>8+</sup> put(key: K,value: V): V
isFloat64Array(value: Object): boolean 将键值对添加到缓冲区。
检查输入的value是否是Float64Array数组类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[put<sup>9+</sup>](#put9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -3740,85 +3637,84 @@ isFloat64Array(value: Object): boolean ...@@ -3740,85 +3637,84 @@ isFloat64Array(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 | | key | K | 是 | 要添加的密钥。 |
| value | V | 是 | 指示与要添加的键关联的值。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的Float64Array数组类型为true,反之为false。 | | V | 返回与添加的键关联的值;如果要添加的键已经存在,则返回原始值,如果键或值为空,则抛出此异常。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let pro = new util.LruBuffer();
let result = that.isFloat64Array(new Float64Array()); let result = pro.put(2,10);
``` ```
### values<sup>(deprecated)</sup>
### isGeneratorFunction<sup>8+</sup> values(): V[]
isGeneratorFunction(value: Object): boolean 获取当前缓冲区中所有值从最近访问到最近最少访问的顺序列表。
检查输入的value是否是generator函数类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[values<sup>9+</sup>](#values9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的generator函数类型为true,反之为false。 | | V&nbsp;[] | 按从最近访问到最近最少访问的顺序返回当前缓冲区中所有值的列表。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let pro = new util.LruBuffer();
let result = that.isGeneratorFunction(function* foo() {}); pro.put(2,10);
pro.put(2,"anhu");
pro.put("afaf","grfb");
let result = pro.values();
``` ```
### keys<sup>(deprecated)</sup>
### isGeneratorObject<sup>8+</sup> keys(): K[]
isGeneratorObject(value: Object): boolean 获取当前缓冲区中所有键从最近访问到最近最少访问的升序列表。
检查输入的value是否是generator对象类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[keys<sup>9+</sup>](#keys9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的generator对象类型为true,反之为false。 | | K&nbsp;[] | 按升序返回当前缓冲区中所有键的列表,从最近访问到最近最少访问。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let pro = new util.LruBuffer();
function* foo() {} pro.put(2,10);
const generator = foo(); let result = pro.keys();
let result = that.isGeneratorObject(generator);
``` ```
### remove<sup>(deprecated)</sup>
### isInt8Array<sup>8+</sup> remove(key: K): V | undefined
isInt8Array(value: Object): boolean 从当前缓冲区中删除指定的键及其关联的值。
检查输入的value是否是Int8Array数组类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[remove<sup>9+</sup>](#remove9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -3826,55 +3722,74 @@ isInt8Array(value: Object): boolean ...@@ -3826,55 +3722,74 @@ isInt8Array(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 | | key | K | 是 | 要删除的密钥。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的Int8Array数组类型为true,反之为false。 | | V&nbsp;\|&nbsp;undefined | 返回一个包含已删除键值对的Optional对象;如果key不存在,则返回一个空的Optional对象,如果key为null,则抛出异常。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let pro = new util.LruBuffer();
let result = that.isInt8Array(new Int8Array([])); pro.put(2,10);
let result = pro.remove(20);
``` ```
### afterRemoval<sup>(deprecated)</sup>
### isInt16Array<sup>8+</sup> afterRemoval(isEvict: boolean,key: K,value: V,newValue: V): void
isInt16Array(value: Object): boolean 删除值后执行后续操作。
检查输入的value是否是Int16Array数组类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[afterRemoval<sup>9+</sup>](#afterremoval9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 | | isEvict | boolean | 是 | 因容量不足而调用该方法时,参数值为true,其他情况为false。 |
| key | K | 是 | 表示删除的键。 |
**返回值:** | value | V | 是 | 表示删除的值。 |
| newValue | V | 是 | 如果已调用put方法并且要添加的键已经存在,则参数值是关联的新值。其他情况下参数值为空。 |
| 类型 | 说明 |
| -------- | -------- |
| boolean | 判断的结果,如果是内置包含的Int16Array数组类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let arr = [];
let result = that.isInt16Array(new Int16Array([])); class ChildLruBuffer<K, V> extends util.LruBuffer<K, V>
{
constructor()
{
super();
}
afterRemoval(isEvict, key, value, newValue)
{
if (isEvict === false)
{
arr = [key, value, newValue];
}
}
}
let lru = new ChildLruBuffer();
lru.afterRemoval(false,10,30,null);
``` ```
### contains<sup>(deprecated)</sup>
### isInt32Array<sup>8+</sup> contains(key: K): boolean
isInt32Array(value: Object): boolean 检查当前缓冲区是否包含指定的键。
检查输入的value是否是Int32Array数组类型。
> **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[contains<sup>9+</sup>](#contains9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -3882,27 +3797,31 @@ isInt32Array(value: Object): boolean ...@@ -3882,27 +3797,31 @@ isInt32Array(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 | | key | K | 是 | 表示要检查的键。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的Int32Array数组类型为true,反之为false。 | | boolean | 如果缓冲区包含指定的键,则返回&nbsp;true。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let pro = new util.LruBuffer();
let result = that.isInt32Array(new Int32Array([])); pro.put(2,10);
let result = pro.contains(20);
``` ```
### createDefault<sup>(deprecated)</sup>
### isMap<sup>8+</sup> createDefault(key: K): V
isMap(value: Object): boolean 如果未计算特定键的值,则执行后续操作,参数表示丢失的键,返回与键关联的值。
检查输入的value是否是Map类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[createDefault<sup>9+</sup>](#createdefault9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -3910,85 +3829,89 @@ isMap(value: Object): boolean ...@@ -3910,85 +3829,89 @@ isMap(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 | | key | K | 是 | 表示丢失的键。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的Map类型为true,反之为false。 | | V | 返回与键关联的值。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let pro = new util.LruBuffer();
let result = that.isMap(new Map()); let result = pro.createDefault(50);
``` ```
### entries<sup>(deprecated)</sup>
### isMapIterator<sup>8+</sup> entries(): IterableIterator&lt;[K,V]&gt;
isMapIterator(value: Object): boolean 允许迭代包含在这个对象中的所有键值对。
检查输入的value是否是Map的Iterator类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[entries<sup>9+</sup>](#entries9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的Map的Iterator类型为true,反之为false。 | | [K,&nbsp;V] | 返回一个可迭代数组。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let pro = new util.LruBuffer();
const map = new Map(); pro.put(2,10);
let result = that.isMapIterator(map.keys()); let result = pro.entries();
``` ```
### [Symbol.iterator]<sup>(deprecated)</sup>
### isNativeError<sup>8+</sup> [Symbol.iterator]\(): IterableIterator&lt;[K, V]&gt;
isNativeError(value: Object): boolean 返回一个键值对形式的二维数组。
检查输入的value是否是Error类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[Symbol.iterator<sup>9+</sup>](#symboliterator9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的Error类型为true,反之为false。 | | [K,&nbsp;V] | 返回一个键值对形式的二维数组。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let pro = new util.LruBuffer();
let result = that.isNativeError(new TypeError()); pro.put(2,10);
let result = pro[Symbol.iterator]();
``` ```
## Scope<sup>(deprecated)</sup>
### isNumberObject<sup>8+</sup> > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[ScopeHelper<sup>9+</sup>](#scopehelper9)替代。
isNumberObject(value: Object): boolean ### constructor<sup>(deprecated)</sup>
constructor(lowerObj: ScopeType, upperObj: ScopeType)
用于创建指定下限和上限的作用域实例的构造函数,返回一个Scope对象。
> **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[constructor<sup>9+</sup>](#constructor9)替代。
检查输入的value是否是Number对象类型。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -3996,55 +3919,52 @@ isNumberObject(value: Object): boolean ...@@ -3996,55 +3919,52 @@ isNumberObject(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 | | lowerObj | [ScopeType](#scopetype8) | 是 | 指定作用域实例的下限。 |
| upperObj | [ScopeType](#scopetype8) | 是 | 指定作用域实例的上限。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| boolean | 判断的结果,如果是内置包含的Number对象类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let tempLower = new Temperature(30);
let result = that.isNumberObject(new Number(0)); let tempUpper = new Temperature(40);
let range = new util.Scope(tempLower, tempUpper);
``` ```
### toString<sup>(deprecated)</sup>
### isPromise<sup>8+</sup> toString(): string
isPromise(value: Object): boolean 该字符串化方法返回一个包含当前范围的字符串表示形式。
检查输入的value是否是Promise类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[toString<sup>9+</sup>](#tostring9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的Promise类型为true,反之为false。 | | string | 返回包含当前范围对象的字符串表示形式。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let tempLower = new Temperature(30);
let result = that.isPromise(Promise.resolve(1)); let tempUpper = new Temperature(40);
let range = new util.Scope(tempLower, tempUpper);
let result = range.toString();
``` ```
### intersect<sup>(deprecated)</sup>
### isProxy<sup>8+</sup> intersect(range: Scope): Scope
isProxy(value: Object): boolean 获取给定范围和当前范围的交集。
检查输入的value是否是Proxy类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[intersect<sup>9+</sup>](#intersect9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -4052,29 +3972,35 @@ isProxy(value: Object): boolean ...@@ -4052,29 +3972,35 @@ isProxy(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 | | range | [Scope](#scopedeprecated) | 是 | 传入一个给定范围。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的Proxy类型为true,反之为false。 | | [Scope](#scopedeprecated) | 返回给定范围和当前范围的交集。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let tempLower = new Temperature(30);
const target = {}; let tempUpper = new Temperature(40);
const proxy = new Proxy(target, {}); let range = new util.Scope(tempLower, tempUpper);
let result = that.isProxy(proxy); let tempMiDF = new Temperature(35);
let tempMidS = new Temperature(39);
let rangeFir = new util.Scope(tempMiDF, tempMidS);
range.intersect(rangeFir );
``` ```
### intersect<sup>(deprecated)</sup>
### isRegExp<sup>8+</sup> intersect(lowerObj:ScopeType,upperObj:ScopeType):Scope
isRegExp(value: Object): boolean 获取当前范围与给定下限和上限范围的交集。
检查输入的value是否是RegExp类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[intersect<sup>9+</sup>](#intersect9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -4082,84 +4008,89 @@ isRegExp(value: Object): boolean ...@@ -4082,84 +4008,89 @@ isRegExp(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 | | lowerObj | [ScopeType](#scopetype8) | 是 | 给定范围的下限。 |
| upperObj | [ScopeType](#scopetype8) | 是 | 给定范围的上限。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的RegExp类型为true,反之为false。 | | [Scope](#scopedeprecated) | 返回当前范围与给定下限和上限范围的交集。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let tempLower = new Temperature(30);
let result = that.isRegExp(new RegExp('abc')); let tempUpper = new Temperature(40);
let tempMiDF = new Temperature(35);
let tempMidS = new Temperature(39);
let range = new util.Scope(tempLower, tempUpper);
let result = range.intersect(tempMiDF, tempMidS);
``` ```
### getUpper<sup>(deprecated)</sup>
### isSet<sup>8+</sup> getUpper(): ScopeType
isSet(value: Object): boolean 获取当前范围的上限。
检查输入的value是否是Set类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[getUpper<sup>9+</sup>](#getupper9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的Set类型为true,反之为false。 | | [ScopeType](#scopetype8) | 返回当前范围的上限值。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let tempLower = new Temperature(30);
let result = that.isSet(new Set()); let tempUpper = new Temperature(40);
let range = new util.Scope(tempLower, tempUpper);
let result = range.getUpper();
``` ```
### getLower<sup>(deprecated)</sup>
### isSetIterator<sup>8+</sup> getLower(): ScopeType
isSetIterator(value: Object): boolean 获取当前范围的下限。
检查输入的value是否是Set的Iterator类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[getLower<sup>9+</sup>](#getlower9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的Set的Iterator类型为true,反之为false。 | | [ScopeType](#scopetype8) | 返回当前范围的下限值。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let tempLower = new Temperature(30);
const set = new Set(); let tempUpper = new Temperature(40);
let result = that.isSetIterator(set.keys()); let range = new util.Scope(tempLower, tempUpper);
let result = range.getLower();
``` ```
### expand<sup>(deprecated)</sup>
### isStringObject<sup>8+</sup> expand(lowerObj: ScopeType,upperObj: ScopeType): Scope
isStringObject(value: Object): boolean 创建并返回包括当前范围和给定下限和上限的并集。
检查输入的value是否是String对象类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[expand<sup>9+</sup>](#expand9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -4167,27 +4098,35 @@ isStringObject(value: Object): boolean ...@@ -4167,27 +4098,35 @@ isStringObject(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 | | lowerObj | [ScopeType](#scopetype8) | 是 | 给定范围的下限。 |
| upperObj | [ScopeType](#scopetype8) | 是 | 给定范围的上限。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的String对象类型为true,反之为false。 | | [Scope](#scopedeprecated) | 返回当前范围和给定下限和上限的并集。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let tempLower = new Temperature(30);
let result = that.isStringObject(new String('foo')); let tempUpper = new Temperature(40);
let tempMiDF = new Temperature(35);
let tempMidS = new Temperature(39);
let range = new util.Scope(tempLower, tempUpper);
let result = range.expand(tempMiDF, tempMidS);
``` ```
### expand<sup>(deprecated)</sup>
### isSymbolObjec<sup>8+</sup> expand(range: Scope): Scope
isSymbolObject(value: Object): boolean 创建并返回包括当前范围和给定范围的并集。
检查输入的value是否是Symbol对象类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[expand<sup>9+</sup>](#expand9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -4195,30 +4134,35 @@ isSymbolObject(value: Object): boolean ...@@ -4195,30 +4134,35 @@ isSymbolObject(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 | | range | [Scope](#scopedeprecated) | 是 | 传入一个给定范围。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的Symbol对象类型为true,反之为false。 | | [Scope](#scopedeprecated) | 返回包括当前范围和给定范围的并集。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let tempLower = new Temperature(30);
const symbols = Symbol('foo'); let tempUpper = new Temperature(40);
let result = that.isSymbolObject(Object(symbols)); let tempMiDF = new Temperature(35);
let tempMidS = new Temperature(39);
let range = new util.Scope(tempLower, tempUpper);
let rangeFir = new util.Scope(tempMiDF, tempMidS);
let result = range.expand(rangeFir);
``` ```
### expand<sup>(deprecated)</sup>
### isTypedArray<sup>8+</sup> expand(value: ScopeType): Scope
isTypedArray(value: Object): boolean
检查输入的value是否是TypedArray类型的辅助类型 创建并返回包括当前范围和给定值的并集
TypedArray类型的辅助类型,包括Int8Array、Int16Array、Int32Array、Uint8Array、Uint8ClampedArray、Uint16Array、Uint32Array、Float32Array、Float64Array、DataView。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[expand<sup>9+</sup>](#expand9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -4226,27 +4170,33 @@ TypedArray类型的辅助类型,包括Int8Array、Int16Array、Int32Array、Ui ...@@ -4226,27 +4170,33 @@ TypedArray类型的辅助类型,包括Int8Array、Int16Array、Int32Array、Ui
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 | | value | [ScopeType](#scopetype8) | 是 | 传入一个给定值。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的TypedArray包含的类型为true,反之为false。 | | [Scope](#scopedeprecated) | 返回包括当前范围和给定值的并集。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let tempLower = new Temperature(30);
let result = that.isTypedArray(new Float64Array([])); let tempUpper = new Temperature(40);
let tempMiDF = new Temperature(35);
let range = new util.Scope(tempLower, tempUpper);
let result = range.expand(tempMiDF);
``` ```
### contains<sup>(deprecated)</sup>
### isUint8Array<sup>8+</sup> contains(value: ScopeType): boolean
isUint8Array(value: Object): boolean 检查给定value是否包含在当前范围内。
检查输入的value是否是Uint8Array数组类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[contains<sup>9+</sup>](#contains9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -4254,27 +4204,33 @@ isUint8Array(value: Object): boolean ...@@ -4254,27 +4204,33 @@ isUint8Array(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 | | value | [ScopeType](#scopetype8) | 是 | 传入一个给定值。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的Uint8Array数组类型为true,反之为false。 | | boolean | 如果给定值包含在当前范围内返回true,否则返回false。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let tempLower = new Temperature(30);
let result = that.isUint8Array(new Uint8Array([])); let tempUpper = new Temperature(40);
let tempMiDF = new Temperature(35);
let range = new util.Scope(tempLower, tempUpper);
range.contains(tempMiDF);
``` ```
### contains<sup>(deprecated)</sup>
### isUint8ClampedArray<sup>8+</sup> contains(range: Scope): boolean
isUint8ClampedArray(value: Object): boolean 检查给定range是否在当前范围内。
检查输入的value是否是Uint8ClampedArray数组类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[contains<sup>9+</sup>](#contains9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -4282,27 +4238,36 @@ isUint8ClampedArray(value: Object): boolean ...@@ -4282,27 +4238,36 @@ isUint8ClampedArray(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 | | range | [Scope](#scopedeprecated) | 是 | 传入一个给定范围。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的Uint8ClampedArray数组类型为true,反之为false。 | | boolean | 如果给定范围包含在当前范围内返回true,否则返回false。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let tempLower = new Temperature(30);
let result = that.isUint8ClampedArray(new Uint8ClampedArray([])); let tempUpper = new Temperature(40);
let range = new util.Scope(tempLower, tempUpper);
let tempLess = new Temperature(20);
let tempMore = new Temperature(45);
let rangeSec = new util.Scope(tempLess, tempMore);
let result = range.contains(rangeSec);
``` ```
### clamp<sup>(deprecated)</sup>
### isUint16Array<sup>8+</sup>
isUint16Array(value: Object): boolean clamp(value: ScopeType): ScopeType
检查输入的value是否是Uint16Array数组类型。 将给定值限定到当前范围内。
> **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[clamp<sup>9+</sup>](#clamp9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -4310,55 +4275,58 @@ isUint16Array(value: Object): boolean ...@@ -4310,55 +4275,58 @@ isUint16Array(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 | | value | [ScopeType](#scopetype8) | 是 | 传入的给定值。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的Uint16Array数组类型为true,反之为false。 | | [ScopeType](#scopetype8) | 如果传入的value小于下限,则返回lowerObj;如果大于上限值则返回upperObj;如果在当前范围内,则返回value。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let tempLower = new Temperature(30);
let result = that.isUint16Array(new Uint16Array([])); let tempUpper = new Temperature(40);
let tempMiDF = new Temperature(35);
let range = new util.Scope(tempLower, tempUpper);
let result = range.clamp(tempMiDF);
``` ```
### isUint32Array<sup>8+</sup> ## Base64<sup>(deprecated)</sup>
isUint32Array(value: Object): boolean
检查输入的value是否是Uint32Array数组类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[Base64Helper<sup>9+</sup>](#base64helper9)替代。
**系统能力:** SystemCapability.Utils.Lang ### constructor<sup>(deprecated)</sup>
**参数:** constructor()
| 参数名 | 类型 | 必填 | 说明 | Base64的构造函数。
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:** > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[constructor<sup>9+</sup>](#constructor9)替代。
| 类型 | 说明 | **系统能力:** SystemCapability.Utils.Lang
| -------- | -------- |
| boolean | 判断的结果,如果是内置包含的Uint32Array数组类型为true,反之为false。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let base64 = new util.Base64();
let result = that.isUint32Array(new Uint32Array([]));
``` ```
### encodeSync<sup>(deprecated)</sup>
### isWeakMap<sup>8+</sup> encodeSync(src: Uint8Array): Uint8Array
isWeakMap(value: Object): boolean 通过输入参数编码后输出对应文本。
检查输入的value是否是WeakMap类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[encodeSync<sup>9+</sup>](#encodesync9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -4366,27 +4334,31 @@ isWeakMap(value: Object): boolean ...@@ -4366,27 +4334,31 @@ isWeakMap(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 | | src | Uint8Array | 是 | 编码输入Uint8数组。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的WeakMap类型为true,反之为false。 | | Uint8Array | 返回编码后新分配的Uint8数组。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let that = new util.Base64();
let result = that.isWeakMap(new WeakMap()); let array = new Uint8Array([115,49,51]);
let result = that.encodeSync(array);
``` ```
### encodeToStringSync<sup>(deprecated)</sup>
### isWeakSet<sup>8+</sup> encodeToStringSync(src: Uint8Array): string
isWeakSet(value: Object): boolean 通过输入参数编码后输出对应文本。
检查输入的value是否是WeakSet类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[encodeToStringSync<sup>9+</sup>](#encodetostringsync9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -4394,27 +4366,31 @@ isWeakSet(value: Object): boolean ...@@ -4394,27 +4366,31 @@ isWeakSet(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 | | src | Uint8Array | 是 | 编码输入Uint8数组。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的WeakSet类型为true,反之为false。 | | string | 返回编码后的字符串。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let that = new util.Base64();
let result = that.isWeakSet(new WeakSet()); let array = new Uint8Array([115,49,51]);
let result = that.encodeToStringSync(array);
``` ```
### decodeSync<sup>(deprecated)</sup>
### isBigInt64Array<sup>8+</sup> decodeSync(src: Uint8Array | string): Uint8Array
isBigInt64Array(value: Object): boolean 通过输入参数解码后输出对应文本。
检查输入的value是否是BigInt64Array类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[decodeSync<sup>9+</sup>](#decodesync9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -4422,27 +4398,31 @@ isBigInt64Array(value: Object): boolean ...@@ -4422,27 +4398,31 @@ isBigInt64Array(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 | | src | Uint8Array&nbsp;\|&nbsp;string | 是 | 解码输入Uint8数组或者字符串。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的BigInt64Array类型为true,反之为false。 | | Uint8Array | 返回解码后新分配的Uint8数组。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let that = new util.Base64();
let result = that.isBigInt64Array(new BigInt64Array([])); let buff = 'czEz';
let result = that.decodeSync(buff);
``` ```
### encode<sup>(deprecated)</sup>
### isBigUint64Array<sup>8+</sup> encode(src: Uint8Array): Promise&lt;Uint8Array&gt;
isBigUint64Array(value: Object): boolean 通过输入参数异步编码后输出对应文本。
检查输入的value是否是BigUint64Array类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[encode<sup>9+</sup>](#encode9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -4450,27 +4430,36 @@ isBigUint64Array(value: Object): boolean ...@@ -4450,27 +4430,36 @@ isBigUint64Array(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 | | src | Uint8Array | 是 | 异步编码输入Uint8数组。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的BigUint64Array类型为true,反之为false。 | | Promise&lt;Uint8Array&gt; | 返回异步编码后新分配的Uint8数组。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let that = new util.Base64();
let result = that.isBigUint64Array(new BigUint64Array([])); let array = new Uint8Array([115,49,51]);
let rarray = new Uint8Array([99,122,69,122]);
that.encode(array).then(val=>{
for (var i = 0; i < rarray.length; i++) {
console.log(val[i].toString())
}
})
``` ```
### encodeToString<sup>(deprecated)</sup>
### isModuleNamespaceObject<sup>8+</sup> encodeToString(src: Uint8Array): Promise&lt;string&gt;
isModuleNamespaceObject(value: Object): boolean 通过输入参数异步编码后输出对应文本。
检查输入的value是否是Module Namespace Object类型。 > **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[encodeToString<sup>9+</sup>](#encodetostring9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -4478,28 +4467,34 @@ isModuleNamespaceObject(value: Object): boolean ...@@ -4478,28 +4467,34 @@ isModuleNamespaceObject(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 | | src | Uint8Array | 是 | 异步编码输入Uint8数组。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的Module Namespace Object类型为true,反之为false。 | | Promise&lt;string&gt; | 返回异步编码后的字符串。 |
**示例:** **示例:**
```js ```js
import url from '@ohos.url' let that = new util.Base64();
let that = new util.types(); let array = new Uint8Array([115,49,51]);
let result = that.isModuleNamespaceObject(url); that.encodeToString(array).then(val=>{
console.log(val)
})
``` ```
### decode<sup>(deprecated)</sup>
### isSharedArrayBuffer<sup>8+</sup>
isSharedArrayBuffer(value: Object): boolean decode(src: Uint8Array | string): Promise&lt;Uint8Array&gt;
检查输入的value是否是SharedArrayBuffer类型。 通过输入参数异步解码后输出对应文本。
> **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[decode<sup>9+</sup>](#decode9)替代。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -4507,18 +4502,25 @@ isSharedArrayBuffer(value: Object): boolean ...@@ -4507,18 +4502,25 @@ isSharedArrayBuffer(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 | | src | Uint8Array&nbsp;\|&nbsp;string | 是 | 异步解码输入Uint8数组或者字符串。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| boolean | 判断的结果,如果是内置包含的SharedArrayBuffer类型为true,反之为false。 | | Promise&lt;Uint8Array&gt; | 返回异步解码后新分配的Uint8数组。 |
**示例:** **示例:**
```js ```js
let that = new util.types(); let that = new util.Base64();
let result = that.isSharedArrayBuffer(new SharedArrayBuffer(0)); let array = new Uint8Array([99,122,69,122]);
let rarray = new Uint8Array([115,49,51]);
that.decode(array).then(val=>{
for (var i = 0; i < rarray.length; i++) {
console.log(val[i].toString())
}
})
``` ```
<!--no_check--> <!--no_check-->
\ No newline at end of file
# buffer错误码
## 10200001 参数范围越界错误
**错误信息**
The value of ${param} is out of range.
**错误描述**
调用接口时某个参数超出了其正常范围的取值。
**可能原因**
某个参数取值超出可用范围。
**处理步骤**
检查所传参数是否在可用取值范围内。
## 10200009 Buffer size 错误
**错误信息**
Buffer size must be a multiple of ${size}
**错误描述**
Buffer的长度必须是${size}的整数倍,${size}为16-bits,32-bits或者64-bits。
**可能原因**
Buffer的长度不是${size}的整数倍,${size}为16-bits,32-bits或者64-bits。
**处理步骤**
请检查Buffer的长度值。
## 10200013 只读属性设置错误
**错误信息**
Cannot set property ${propertyName} of Buffer which has only a getter.
**错误描述**
Buffer的属性${propertyName}只读,不能进行设置。
**可能原因**
将${propertyName}放在了等号左边(即对属性值进行设置)。
**处理步骤**
请检查属性${propertyName}是否在等号左边。
\ No newline at end of file
# containers错误码
## 10200012 构造函数调用异常
**错误信息**
The {className}'s constructor cannot be directly invoked.
**错误描述**
构造语言容器类的构造方法不支持直接调用。
**可能原因**
调用构造函数时未使用new关键字。
**处理步骤**
检查是否使用直接调用了语言容器类的方法,建议使用new关键字创建语言容器类。
## 10200011 传入的this object不是容器类的实例
**错误信息**
The {methodName} method cannot be bound.
**错误描述**
调用语言容器类的方法时,传入的this object不是容器类的实例语言,容器类的方法不支持bind。
**可能原因**
容器类的方法不支持bind。
**处理步骤**
1.检查是否使用bind API调用语言容器类的方法。
2.检查是否把语言容器类的方法赋值给不是语言容器实例的对象来调用。
## 10200001 参数范围越界异常
**错误信息**
The parameter value is out of range.
**错误描述**
调用接口时某个参数超出了其正常范围的取值。
**可能原因**
该错误码表示范围异常,可能原因某个参数越界异常。
**处理步骤**
请检查所传参数是否在正常取值范围内。
## 10200010 容器为空
**错误信息**
The container is empty.
**错误描述**
操作的容器为空。
**可能原因**
容器是空的。
**处理步骤**
请先往容器内添加元素。
# 语言基础类库错误码
## 10200001 参数范围越界错误
**错误信息**
The value of ${param} is out of range.
**错误描述**
调用接口时某个参数超出了其正常范围的取值。
**可能原因**
某个参数索引超出可用范围。
**处理步骤**
检查输入参数的索引是否越界。
## 10200002 参数解析错误
**错误信息**
Invalid ${param} string.
**错误描述**
规范字符串解析失败。
**可能原因**
调用接口时,某个字符串类型的参数为非规范的字符串,导致解析该字符串失败。
**处理步骤**
检查输入字符串的格式。
## 10200003 Worker初始化失败
**错误信息**
Worker initialization failure.
**错误描述**
调用接口时Worker未能正常初始化。
**可能原因**
1. 创建Worker的数量超出限制。
2. 设置Worker对象的选择项不正确。
**处理步骤**
1. 检查Worker的数量是否超出8个,如果存在,及时销毁空闲的Worker。
2. 如果设置WorkerOptions,检查参数类型及其合法性。
## 10200004 Worker处于非运行状态
**错误信息**
Worker instance is not running.
**错误描述**
调用接口时Worker对象处于非运行状态。
**可能原因**
当调用接口时,Worker实例化对象已经被销毁,或正在被销毁。
**处理步骤**
当调用接口时,确保Worker对象处于正常运行状态,未被执行销毁操作。
## 10200005 Worker不支持某API
**错误信息**
The invoked API is not supported in workers.
**错误描述**
Worker不支持某API。
**可能原因**
调用Worker线程中不支持的API。
**处理步骤**
确保使用Worker线程中支持的API。
## 10200006 Worker传输信息序列化异常
**错误信息**
Serializing an uncaught exception failed.
**错误描述**
Worker传输信息序列化异常。
**可能原因**
传输信息不属于合法的可序列化对象。
**处理步骤**
确保传输信息属于Worker支持的合法序列化对象。
## 10200007 Worker文件路径异常
**错误信息**
The worker file patch is invalid path.
**错误描述**
文件路径异常,无法正确加载Worker。
**可能原因**
Worker文件路径异常导致无法正常编译生成合法的worker.abc。
**处理步骤**
确保Worker文件路径符合创建Worker对象的规范,参见API参考中[constructor<sup>9+</sup>](../apis/js-apis-worker.md#constructor9)接口的示例。
## 10200009 Buffer的长度错误
**错误信息**
Buffer size must be a multiple of ${size}.
**错误描述**
Buffer的长度错误,不符合要求。
**可能原因**
Buffer的长度错误,不符合要求。Buffer长度要求为size的整数倍。其中size为16-bits、32-bits或者64-bits。
**处理步骤**
确保Buffer长度符合要求。
Buffer长度要求为size的整数倍。其中size为16-bits、32-bits或者64-bits。
## 10200010 容器为空
**错误信息**
The container is empty.
**错误描述**
操作的容器为空。
**可能原因**
操作的容器为空,未添加相关元素。
**处理步骤**
确保操作的容器不为空,空容器请先向容器内添加元素。
## 10200011 传入的this.object不是容器类的实例
**错误信息**
The {methodName} method cannot be bound.
**错误描述**
调用语言容器类的方法时,传入的this.object不是容器类的实例语言,容器类的方法不支持bind。
**可能原因**
容器类的方法不支持bind。
**处理步骤**
1. 检查是否使用bind API调用语言容器类的方法。
2. 检查是否把语言容器类的方法赋值给不是语言容器实例的对象来调用。
## 10200012 构造函数调用异常
**错误信息**
The {className}'s constructor cannot be directly invoked.
**错误描述**
构造语言容器类的构造方法不支持直接调用。
**可能原因**
调用构造函数时未使用new关键字。
**处理步骤**
检查是否使用直接调用了语言容器类的方法,建议使用new关键字创建语言容器类。
## 10200013 只读属性设置错误
**错误信息**
Cannot set property ${propertyName} of Buffer which has only a getter.
**错误描述**
Buffer的属性${propertyName}只读,不能进行设置。
**可能原因**
对Buffer的只读属性进行设置,导致异常。
**处理步骤**
不要对Buffer只读属性进行相关设置。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册