Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
f2538d1f
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
f2538d1f
编写于
12月 20, 2022
作者:
O
openharmony_ci
提交者:
Gitee
12月 20, 2022
浏览文件
操作
浏览文件
下载
差异文件
!12461 Modify ets_ Interface description data of util module
Merge pull request !12461 from 小马奔腾/master
上级
1808eca4
8a70aed3
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
1948 addition
and
1700 deletion
+1948
-1700
zh-cn/application-dev/reference/apis/js-apis-convertxml.md
zh-cn/application-dev/reference/apis/js-apis-convertxml.md
+12
-4
zh-cn/application-dev/reference/apis/js-apis-uri.md
zh-cn/application-dev/reference/apis/js-apis-uri.md
+12
-4
zh-cn/application-dev/reference/apis/js-apis-url.md
zh-cn/application-dev/reference/apis/js-apis-url.md
+184
-46
zh-cn/application-dev/reference/apis/js-apis-util.md
zh-cn/application-dev/reference/apis/js-apis-util.md
+1519
-1516
zh-cn/application-dev/reference/errorcodes/errorcode-buffer.md
.../application-dev/reference/errorcodes/errorcode-buffer.md
+0
-55
zh-cn/application-dev/reference/errorcodes/errorcode-containers.md
...lication-dev/reference/errorcodes/errorcode-containers.md
+0
-75
zh-cn/application-dev/reference/errorcodes/errorcode-utils.md
...n/application-dev/reference/errorcodes/errorcode-utils.md
+221
-0
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-convertxml.md
浏览文件 @
f2538d1f
...
@@ -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
**参数:**
**参数:**
...
...
zh-cn/application-dev/reference/apis/js-apis-uri.md
浏览文件 @
f2538d1f
...
@@ -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
**参数:**
**参数:**
...
...
zh-cn/application-dev/reference/apis/js-apis-url.md
浏览文件 @
f2538d1f
...
@@ -366,18 +366,148 @@ params.append('fod', '3');
...
@@ -366,18 +366,148 @@ params.append('fod', '3');
console
.
log
(
params
.
toString
());
console
.
log
(
params
.
toString
());
```
```
## URLSearchParams<sup>(deprecated)</sup>
## URL
### 属性
**系统能力:**
以下各项对应的系统能力均为SystemCapability.Utils.Lang
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| hash | string | 是 | 是 | 获取和设置URL的片段部分。 |
| host | string | 是 | 是 | 获取和设置URL的主机部分。 |
| hostname | string | 是 | 是 | 获取和设置URL的主机名部分,不带端口。 |
| href | string | 是 | 是 | 获取和设置序列化的URL。 |
| origin | string | 是 | 否 | 获取URL源的只读序列化。 |
| password | string | 是 | 是 | 获取和设置URL的密码部分。 |
| pathname | string | 是 | 是 | 获取和设置URL的路径部分。 |
| port | string | 是 | 是 | 获取和设置URL的端口部分。 |
| protocol | string | 是 | 是 | 获取和设置URL的协议部分。 |
| search | string | 是 | 是 | 获取和设置URL的序列化查询部分。 |
| searchParams | URLSearchParams | 是 | 否 | 获取URLSearchParams表示URL查询参数的对象。 |
| URLParams | URLParams | 是 | 否 | 获取URLParams表示URL查询参数的对象。 |
| username | string | 是 | 是 | 获取和设置URL的用户名部分。 |
### constructor<sup>(deprecated)</sup>
### constructor<sup>(deprecated)</sup>
constructor(url: string, base?: string | URL)
URL的构造函数。
> **说明:**
> **说明:**
>
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[URLParams<sup>9+</sup>](#constructor9+)替代。
> 从API version 7开始支持,从API version 9开始废弃,建议使用[parseURL<sup>9+</sup>](#parseurl9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| url | string | 是 | 入参对象。 |
| base | string
\|
URL | 否 | 入参字符串或者对象。
<br/>
- string:字符串
<br/>
- URL:字符串或对象 |
**示例:**
```
js
let
mm
=
'
http://username:password@host:8080
'
;
let
a
=
new
Url
.
URL
(
"
/
"
,
mm
);
// Output 'http://username:password@host:8080/';
let
b
=
new
Url
.
URL
(
mm
);
// Output 'http://username:password@host:8080/';
new
Url
.
URL
(
'
path/path1
'
,
b
);
// Output 'http://username:password@host:8080/path/path1';
let
c
=
new
Url
.
URL
(
'
/path/path1
'
,
b
);
// Output 'http://username:password@host:8080/path/path1';
new
Url
.
URL
(
'
/path/path1
'
,
c
);
// Output 'http://username:password@host:8080/path/path1';
new
Url
.
URL
(
'
/path/path1
'
,
a
);
// Output 'http://username:password@host:8080/path/path1';
new
Url
.
URL
(
'
/path/path1
'
,
"
https://www.exampleUrl/fr-FR/toto
"
);
// Output https://www.exampleUrl/path/path1
new
Url
.
URL
(
'
/path/path1
'
,
''
);
// Raises a TypeError exception as '' is not a valid URL
new
Url
.
URL
(
'
/path/path1
'
);
// Raises a TypeError exception as '/path/path1' is not a valid URL
new
Url
.
URL
(
'
https://www.example.com
'
,
);
// Output https://www.example.com/
new
Url
.
URL
(
'
https://www.example.com
'
,
b
);
// Output https://www.example.com/
```
### parseURL<sup>9+</sup>
static parseURL(url : string, base?: string | URL): URL
URL静态成员函数。
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| url | string | 是 | 入参对象。 |
| base | string
\|
URL | 否 | 入参字符串或者对象。
<br/>
- string:字符串
<br/>
- URL:字符串或对象 |
**错误码:**
以下错误码的详细介绍请参见
[
语言基础类库错误码
](
../errorcodes/errorcode-utils.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------- |
| 10200002 | Invalid url string. |
**示例:**
```
js
let
mm
=
'
http://username:password@host:8080
'
;
Url
.
URL
.
parseURL
(
mm
);
// Output 'http://username:password@host:8080/';
```
### tostring
toString(): string
将解析过后的URL转化为字符串。
**系统能力:**
SystemCapability.Utils.Lang
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| string | 用于返回网址的字符串序列化。 |
**示例:**
```
js
const
url
=
new
Url
.
URL
(
'
http://username:password@host:8080/directory/file?query=pppppp#qwer=da
'
);
url
.
toString
();
```
### toJSON
toJSON(): string
将解析过后的URL转化为JSON字符串。
**系统能力:**
SystemCapability.Utils.Lang
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| string | 用于返回网址的字符串序列化。 |
**示例:**
```
js
const
url
=
new
Url
.
URL
(
'
http://username:password@host:8080/directory/file?query=pppppp#qwer=da
'
);
url
.
toJSON
();
```
## URLSearchParams<sup>(deprecated)</sup>
### constructor<sup>(deprecated)</sup>
constructor(init?: string
[][]
| Record
<
string, string
>
| string | URLSearchParams)
constructor(init?: string
[][]
| Record
<
string, string
>
| string | URLSearchParams)
URLSearchParams的构造函数。
URLSearchParams的构造函数。
> **说明:**
>
> 从API version 7开始支持,从API version 9开始废弃,建议使用[URLParams<sup>9+</sup>](#constructor9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
**参数:**
...
@@ -398,14 +528,14 @@ let params = new Url.URLSearchParams(urlObject.search);
...
@@ -398,14 +528,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
**参数:**
**参数:**
...
@@ -425,14 +555,14 @@ paramsObject.append('fod', '3');
...
@@ -425,14 +555,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
**参数:**
**参数:**
...
@@ -451,14 +581,14 @@ paramsobject.delete('fod');
...
@@ -451,14 +581,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
**参数:**
**参数:**
...
@@ -484,14 +614,14 @@ console.log(params.getAll('fod').toString()) // Output ["1","3"].
...
@@ -484,14 +614,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
**返回值:**
**返回值:**
...
@@ -511,14 +641,15 @@ for (var pair of searchParamsObject .entries()) { // Show keyName/valueName pair
...
@@ -511,14 +641,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
**参数:**
**参数:**
...
@@ -547,14 +678,15 @@ myURLObject.searchParams.forEach((value, name, searchParams) => {
...
@@ -547,14 +678,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
**参数:**
**参数:**
...
@@ -580,14 +712,15 @@ let age = parseInt(paramsObject.get("age"), 10); // is the number 18
...
@@ -580,14 +712,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
**参数:**
**参数:**
...
@@ -612,14 +745,15 @@ paramsObject.has('bard') === true;
...
@@ -612,14 +745,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
**参数:**
**参数:**
...
@@ -639,14 +773,15 @@ paramsObject.set('baz', '3'); // Add a third parameter.
...
@@ -639,14 +773,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
**示例:**
**示例:**
...
@@ -659,14 +794,15 @@ console.log(searchParamsObject.toString()); // Display the sorted query string /
...
@@ -659,14 +794,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
<
string
>
keys(): IterableIterator
<
string
>
返回一个所有键值对的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
**返回值:**
**返回值:**
...
@@ -686,14 +822,15 @@ for (var key of searchParamsObject .keys()) { // Output key-value pairs
...
@@ -686,14 +822,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
<
string
>
values(): IterableIterator
<
string
>
返回一个所有键值对的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
**返回值:**
**返回值:**
...
@@ -714,14 +851,14 @@ for (var value of searchParams.values()) {
...
@@ -714,14 +851,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
<
[string, string]
>
[Symbol.iterator]
\(
): IterableIterator
<
[string, string]
>
返回一个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
**返回值:**
**返回值:**
...
@@ -740,14 +877,15 @@ for (const [name, value] of paramsObject) {
...
@@ -740,14 +877,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
**返回值:**
**返回值:**
...
...
zh-cn/application-dev/reference/apis/js-apis-util.md
浏览文件 @
f2538d1f
...
@@ -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 )=
>
void
callbackWrapper(original: Function): (err: Object, value: Object )=
>
void
...
@@ -203,30 +139,6 @@ promisify(original: (err: Object, value: Object) => void): Function
...
@@ -203,30 +139,6 @@ promisify(original: (err: Object, value: Object) => void): Function
})
})
```
```
## util.promiseWrapper<sup>(deprecated)</sup>
promiseWrapper(original: (err: Object, value: Object) =
>
void): Object
对异步函数处理并返回一个promise的版本。
> **说明:**
>
> 此接口不可用,建议使用[util.promisify<sup>9+</sup>](#utilpromisify9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| original | Function | 是 | 异步函数。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Function | 采用遵循常见的错误优先的回调风格的函数(也就是将
(err,
value)
=
>
...
回调作为最后一个参数),并返回一个返回
promise
的版本。 |
## 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) =
>
void): Object
对异步函数处理并返回一个promise的版本。
> **说明:**
>
> 此接口不可用,建议使用[util.promisify<sup>9+</sup>](#utilpromisify9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| original | Function | 是 | 异步函数。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Function | 采用遵循常见的错误优先的回调风格的函数(也就是将
(err,
value)
=
>
...
回调作为最后一个参数),并返回一个返回
promise
的版本。 |
## 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
)
```
```
### encodeInto
Uint8Array<sup>9+
</sup>
### encodeInto
<sup>(deprecated)
</sup>
encodeInto
Uint8Array
(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
)
```
```
### encode
Into
<sup>(deprecated)</sup>
### encode<sup>(deprecated)</sup>
encode
Into(input: string, dest: Uint8Array, ): { read: number; written: number }
encode
(input?: string): Uint8Array
放置生成的UTF-8编码
文本。
通过输入参数编码后输出对应
文本。
> **说明:**
> **说明:**
>
>
> 从API
Version 7开始支持,从API Version 9开始废弃,建议使用[encodeIntoUint8Array<sup>9+</sup>](#encodeintouint8array
9)替代。
> 从API
version 7开始支持,从API version 9开始废弃,建议使用[encodeInto<sup>9+</sup>](#encodeinto
9)替代。
**系统能力:**
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,1026 +1564,987 @@ pro.put(2,10);
...
@@ -1564,1026 +1564,987 @@ pro.put(2,10);
let
result
=
pro
[
Symbol
.
iterator
]();
let
result
=
pro
[
Symbol
.
iterator
]();
```
```
## LruBuffer<sup>(deprecated)</sup>
> **说明:**
## ScopeHelper<sup>9+</sup>
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[LRUCache<sup>9+</sup>](#lrucache9)替代。
###
属性
###
constructor<sup>9+</sup>
**系统能力:**
以下各项对应的系统能力均为SystemCapability.Utils.Lang。
constructor(lowerObj: ScopeType, upperObj: ScopeType)
| 名称 | 类型 | 可读 | 可写 | 说明 |
用于创建指定下限和上限的作用域实例的构造函数,返回一个ScopeHelper对象。
| -------- | -------- | -------- | -------- | -------- |
| length | number | 是 | 否 | 当前缓冲区中值的总数。 |
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------ | ---- | ---------------------- |
| lowerObj |
[
ScopeType
](
#scopetype8
)
| 是 | 指定作用域实例的下限。 |
| upperObj |
[
ScopeType
](
#scopetype8
)
| 是 | 指定作用域实例的上限。 |
**示例:**
**示例:**
```
js
```
js
let
pro
=
new
util
.
LruBuffer
();
let
tempLower
=
new
Temperature
(
30
);
pro
.
put
(
2
,
10
);
let
tempUpper
=
new
Temperature
(
40
);
pro
.
put
(
1
,
8
);
let
range
=
new
util
.
ScopeHelper
(
tempLower
,
tempUpper
);
let
result
=
pro
.
length
;
```
```
### constructor<sup>(deprecated)</sup>
constructor(capacity?: number)
### toString<sup>9+</sup>
默认构造函数用于创建一个新的LruBuffer实例,默认容量为64。
toString(): string
> **说明:**
该字符串化方法返回一个包含当前范围的字符串表示形式。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[constructor<sup>9+</sup>](#constructor9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**
参数
:**
**
返回值
:**
|
参数名 | 类型 | 必填 | 说明
|
|
类型 | 说明
|
| ------
-- | -------- | -------- |
-------- |
| ------
| ------------------------------
-------- |
|
capacity | number | 否 | 指示要为缓冲区自定义的容量
。 |
|
string | 返回包含当前范围对象的字符串表示形式
。 |
**示例:**
**示例:**
```
js
```
js
let
lrubuffer
=
new
util
.
LruBuffer
();
let
tempLower
=
new
Temperature
(
30
);
let
tempUpper
=
new
Temperature
(
40
);
let
range
=
new
util
.
ScopeHelper
(
tempLower
,
tempUpper
);
let
result
=
range
.
toString
();
```
```
### updateCapacity<sup>(deprecated)</sup>
updateCapacity(newCapacity: number): void
### intersect<sup>9+</sup>
将缓冲区容量更新为指定容量,如果newCapacity小于或等于0,则抛出异常。
intersect(range: ScopeHelper): ScopeHelper
> **说明:**
获取给定范围和当前范围的交集。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[updateCapacity<sup>9+</sup>](#updatecapacity9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| ------ | ---------------------------- | ---- | ------------------ |
| newCapacity | number | 是 | 指示要为缓冲区自定义的容量。 |
| range |
[
ScopeHelper
](
#scopehelper9
)
| 是 | 传入一个给定范围。 |
**返回值:**
| 类型 | 说明 |
| ------------------------------ | ------------------------------ |
|
[
ScopeHelper9+
](
#scopehelper9
)
| 返回给定范围和当前范围的交集。 |
**示例:**
**示例:**
```
js
```
js
let
pro
=
new
util
.
LruBuffer
();
let
tempLower
=
new
Temperature
(
30
);
let
result
=
pro
.
updateCapacity
(
100
);
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
);
```
```
### toString<sup>(deprecated)</sup>
toString(): string
### intersect<sup>9+</sup>
返回对象的字符串表示形式。
intersect(lowerObj:ScopeType,upperObj:ScopeType):ScopeHelper
> **说明:**
获取当前范围与给定下限和上限范围的交集。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[toString<sup>9+</sup>](#tostring9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------ | ---- | ---------------- |
| lowerObj |
[
ScopeType
](
#scopetype8
)
| 是 | 给定范围的下限。 |
| upperObj |
[
ScopeType
](
#scopetype8
)
| 是 | 给定范围的上限。 |
**返回值:**
**返回值:**
| 类型
| 说明
|
| 类型
| 说明
|
| --------
|
-------- |
| --------
-------------------- | --------------------------------
-------- |
|
string | 返回对象的字符串表示形式
。 |
|
[
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
);
pro
.
remove
(
20
);
let
tempMidS
=
new
Temperature
(
39
);
let
result
=
pro
.
toString
();
let
range
=
new
util
.
ScopeHelper
(
tempLower
,
tempUpper
);
let
result
=
range
.
intersect
(
tempMiDF
,
tempMidS
);
```
```
### getCapacity<sup>(deprecated)</sup>
getCapacity(): number
### getUpper<sup>9+</sup>
获取当前缓冲区的容量。
getUpper(): ScopeType
> **说明:**
获取当前范围的上限。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[getCapacity<sup>9+</sup>](#getcapacity9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**返回值:**
**返回值:**
| 类型
| 说明
|
| 类型
| 说明
|
| --------
|
-------- |
| --------
---------------- | --------------
-------- |
|
number | 返回当前缓冲区的容量
。 |
|
[
ScopeType
](
#scopetype8
)
| 返回当前范围的上限值
。 |
**示例:**
**示例:**
```
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
result
=
range
.
getUpper
();
```
```
### clear<sup>(deprecated)</sup>
clear(): void
### getLower<sup>9+</sup>
从当前缓冲区清除键值对。后续会调用afterRemoval()方法执行后续操作。
getLower(): ScopeType
> **说明:**
获取当前范围的下限。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[clear<sup>9+</sup>](#clear9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**返回值:**
| 类型 | 说明 |
| ------------------------ | ---------------------- |
|
[
ScopeType
](
#scopetype8
)
| 返回当前范围的下限值。 |
**示例:**
**示例:**
```
js
```
js
let
pro
=
new
util
.
LruBuffer
(
);
let
tempLower
=
new
Temperature
(
30
);
pro
.
put
(
2
,
1
0
);
let
tempUpper
=
new
Temperature
(
4
0
);
let
result
=
pro
.
length
;
let
range
=
new
util
.
ScopeHelper
(
tempLower
,
tempUpper
)
;
pro
.
clea
r
();
let
result
=
range
.
getLowe
r
();
```
```
### getCreateCount<sup>(deprecated)</sup>
getCreateCount(): number
### expand<sup>9+</sup>
获取createDefault()返回值的次数。
expand(lowerObj: ScopeType,upperObj: ScopeType): ScopeHelper
> **说明:**
创建并返回包括当前范围和给定下限和上限的并集。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[getCreateCount<sup>9+</sup>](#getcreatecount9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
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
.
expand
(
tempMiDF
,
tempMidS
);
```
```
### getMissCount<sup>(deprecated)</sup>
getMissCount(): number
### expand<sup>9+</sup>
获取查询值不匹配的次数。
expand(range: ScopeHelper): ScopeHelper
> **说明:**
创建并返回包括当前范围和给定范围的并集。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[getMissCount<sup>9+</sup>](#getmisscount9)替代。
**系统能力:**
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
);
pro
.
get
(
2
);
let
tempMiDF
=
new
Temperature
(
35
);
let
result
=
pro
.
getMissCount
();
let
tempMidS
=
new
Temperature
(
39
);
let
range
=
new
util
.
ScopeHelper
(
tempLower
,
tempUpper
);
let
rangeFir
=
new
util
.
ScopeHelper
(
tempMiDF
,
tempMidS
);
let
result
=
range
.
expand
(
rangeFir
);
```
```
### getRemovalCount<sup>(deprecated)</sup>
getRemovalCount(): number
### expand<sup>9+</sup>
获取从缓冲区中逐出值的次数。
expand(value: ScopeType): ScopeHelper
> **说明:**
创建并返回包括当前范围和给定值的并集。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[getRemovalCount<sup>9+</sup>](#getremovalcount9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------------------ | ---- | ---------------- |
| value |
[
ScopeType
](
#scopetype8
)
| 是 | 传入一个给定值。 |
**返回值:**
**返回值:**
| 类型
| 说明
|
| 类型
| 说明
|
| --------
|
-------- |
| --------
-------------------- | ------------------------
-------- |
|
number | 返回从缓冲区中驱逐的次数
。 |
|
[
ScopeHelper
](
#scopehelper9
)
| 返回包括当前范围和给定值的并集
。 |
**示例:**
**示例:**
```
js
```
js
let
pro
=
new
util
.
LruBuffer
(
);
let
tempLower
=
new
Temperature
(
30
);
pro
.
put
(
2
,
1
0
);
let
tempUpper
=
new
Temperature
(
4
0
);
pro
.
updateCapacity
(
2
);
let
tempMiDF
=
new
Temperature
(
35
);
pro
.
put
(
50
,
22
);
let
range
=
new
util
.
ScopeHelper
(
tempLower
,
tempUpper
);
let
result
=
pro
.
getRemovalCount
(
);
let
result
=
range
.
expand
(
tempMiDF
);
```
```
### getMatchCount<sup>(deprecated)</sup>
getMatchCount(): number
### contains<sup>9+</sup>
获取查询值匹配成功的次数。
contains(value: ScopeType): boolean
> **说明:**
检查给定value是否包含在当前范围内。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[getMatchCount<sup>9+</sup>](#getmatchcount9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------------------ | ---- | ---------------- |
| value |
[
ScopeType
](
#scopetype8
)
| 是 | 传入一个给定值。 |
**返回值:**
**返回值:**
| 类型
| 说明
|
| 类型
| 说明
|
| -------
- |
-------- |
| -------
| -------------------------------------------
-------- |
|
number | 返回查询值匹配成功的次数
。 |
|
boolean | 如果给定值包含在当前范围内返回true,否则返回false
。 |
**示例:**
**示例:**
```
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
range
=
new
util
.
ScopeHelper
(
tempLower
,
tempUpper
);
range
.
contains
(
tempMiDF
);
```
```
### getPutCount<sup>(deprecated)</sup>
getPutCount(): number
### contains<sup>9+</sup>
获取将值添加到缓冲区的次数。
contains(range: ScopeHelper): boolean
> **说明:**
检查给定range是否在当前范围内。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[getPutCount<sup>9+</sup>](#getputcount9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**
返回值
:**
**
参数
:**
| 类型 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- |
| ------ | ---------------------------- | ---- | ------------------ |
| number | 返回将值添加到缓冲区的次数。 |
| range |
[
ScopeHelper
](
#scopehelper9
)
| 是 | 传入一个给定范围。 |
**返回值:**
| 类型 | 说明 |
| ------- | ----------------------------------------------------- |
| 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
.
getPutCount
();
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
);
```
```
### isEmpty<sup>(deprecated)</sup>
isEmpty(): boolean
### clamp<sup>9+</sup>
检查当前缓冲区是否为空。
clamp(value: ScopeType): ScopeType
> **说明:**
将给定值限定到当前范围内。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[isEmpty<sup>9+</sup>](#isempty9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------------------ | ---- | -------------- |
| value |
[
ScopeType
](
#scopetype8
)
| 是 | 传入的给定值。 |
**返回值:**
**返回值:**
| 类型
| 说明
|
| 类型
| 说明
|
| --------
|
-------- |
| --------
---------------- | ----------------------------------------------------
-------- |
|
boolean | 如果当前缓冲区不包含任何值,则返回tr
ue。 |
|
[
ScopeType
](
#scopetype8
)
| 如果传入的value小于下限,则返回lowerObj;如果大于上限值则返回upperObj;如果在当前范围内,则返回val
ue。 |
**示例:**
**示例:**
```
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
.
clamp
(
tempMiDF
);
```
```
##
# get<sup>(deprecated)
</sup>
##
Base64Helper<sup>9+
</sup>
get(key: K): V | undefined
### constructor<sup>9+</sup>
表示要查询的键。
constructor()
> **说明:**
Base64Helper的构造函数。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[get<sup>9+</sup>](#get9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| key | K | 是 | 要查询的键。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| V
\|
undefined | 如果指定的键存在于缓冲区中,则返回与键关联的值;否则返回undefined。 |
**示例:**
**示例:**
```
js
```
js
let
pro
=
new
util
.
LruBuffer
();
let
base64
=
new
util
.
Base64Helper
();
pro
.
put
(
2
,
10
);
let
result
=
pro
.
get
(
2
);
```
```
### put<sup>(deprecated)</sup>
### encodeSync<sup>9+</sup>
put(key: K,value: V): V
将键值对添加到缓冲区。
encodeSync(src: Uint8Array): Uint8Array
> **说明:**
通过输入参数编码后输出对应文本。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[put<sup>9+</sup>](#put9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| ------ | ---------- | ---- | ------------------- |
| key | K | 是 | 要添加的密钥。 |
| src | Uint8Array | 是 | 编码输入Uint8数组。 |
| value | V | 是 | 指示与要添加的键关联的值。 |
**返回值:**
**返回值:**
| 类型
| 说明
|
| 类型
| 说明
|
| --------
|
-------- |
| --------
-- | ---------------------
-------- |
|
V | 返回与添加的键关联的值;如果要添加的键已经存在,则返回原始值,如果键或值为空,则抛出此异常
。 |
|
Uint8Array | 返回编码后新分配的Uint8数组
。 |
**示例:**
**示例:**
```
js
```
js
let
pro
=
new
util
.
LruBuffer
();
let
that
=
new
util
.
Base64Helper
();
let
result
=
pro
.
put
(
2
,
10
);
let
array
=
new
Uint8Array
([
115
,
49
,
51
]);
let
result
=
that
.
encodeSync
(
array
);
```
```
### values<sup>(deprecated)</sup>
values(): V[]
### encodeToStringSync<sup>9+</sup>
获取当前缓冲区中所有值从最近访问到最近最少访问的顺序列表。
encodeToStringSync(src: Uint8Array): string
> **说明:**
通过输入参数编码后输出对应文本。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[values<sup>9+</sup>](#values9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------- | ---- | ------------------- |
| src | Uint8Array | 是 | 编码输入Uint8数组。 |
**返回值:**
**返回值:**
| 类型
| 说明
|
| 类型
| 说明
|
| ------
-- |
-------- |
| ------
| ------------
-------- |
|
V
[] | 按从最近访问到最近最少访问的顺序返回当前缓冲区中所有值的列表
。 |
|
string | 返回编码后的字符串
。 |
**示例:**
**示例:**
```
js
```
js
let
pro
=
new
util
.
LruBuffer
();
let
that
=
new
util
.
Base64Helper
();
pro
.
put
(
2
,
10
);
let
array
=
new
Uint8Array
([
115
,
49
,
51
]);
pro
.
put
(
2
,
"
anhu
"
);
let
result
=
that
.
encodeToStringSync
(
array
);
pro
.
put
(
"
afaf
"
,
"
grfb
"
);
let
result
=
pro
.
values
();
```
```
### keys<sup>(deprecated)</sup>
keys(): K[]
### decodeSync<sup>9+</sup>
获取当前缓冲区中所有键从最近访问到最近最少访问的升序列表。
decodeSync(src: Uint8Array | string): Uint8Array
> **说明:**
通过输入参数解码后输出对应文本。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[keys<sup>9+</sup>](#keys9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------------------------ | ---- | ----------------------------- |
| src | Uint8Array
\|
string | 是 | 解码输入Uint8数组或者字符串。 |
**返回值:**
**返回值:**
| 类型
| 说明
|
| 类型
| 说明
|
| --------
|
-------- |
| --------
-- | ---------------------
-------- |
|
K
[] | 按升序返回当前缓冲区中所有键的列表,从最近访问到最近最少访问
。 |
|
Uint8Array | 返回解码后新分配的Uint8数组
。 |
**示例:**
**示例:**
```
js
```
js
let
pro
=
new
util
.
LruBuff
er
();
let
that
=
new
util
.
Base64Help
er
();
pro
.
put
(
2
,
10
)
;
let
buff
=
'
czEz
'
;
let
result
=
pro
.
keys
(
);
let
result
=
that
.
decodeSync
(
buff
);
```
```
### remove<sup>(deprecated)</sup>
remove(key: K): V | undefined
### encode<sup>9+</sup>
从当前缓冲区中删除指定的键及其关联的值。
encode(src: Uint8Array): Promise
<
Uint8Array
>
> **说明:**
通过输入参数异步编码后输出对应文本。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[remove<sup>9+</sup>](#remove9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
**参数:**
| 参数名 | 类型
| 必填 | 说明
|
| 参数名 | 类型
| 必填 | 说明
|
| ------
-- | -------- | -------- |
-------- |
| ------
| ---------- | ---- | ---------------
-------- |
|
key | K | 是 | 要删除的密钥
。 |
|
src | Uint8Array | 是 | 异步编码输入Uint8数组
。 |
**返回值:**
**返回值:**
| 类型
| 说明
|
| 类型
| 说明
|
| --------
|
-------- |
| --------
----------------- | -------------------------
-------- |
|
V
\|
undefined | 返回一个包含已删除键值对的Optional对象;如果key不存在,则返回一个空的Optional对象,如果key为null,则抛出异常
。 |
|
Promise
<
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
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
())
}
})
```
```
### afterRemoval<sup>(deprecated)</sup>
afterRemoval(isEvict: boolean,key: K,value: V,newValue: V): void
### encodeToString<sup>9+</sup>
删除值后执行后续操作。
encodeToString(src: Uint8Array): Promise
<
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方法并且要添加的键已经存在,则参数值是关联的新值。其他情况下参数值为空。 |
| 类型 | 说明 |
| --------------------- | ------------------------ |
| Promise
<
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
]);
{
that
.
encodeToString
(
array
).
then
(
val
=>
{
constructor
()
console
.
log
(
val
)
{
})
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
### decode<sup>9+</sup>
检查当前缓冲区是否包含指定的键。
decode(src: Uint8Array | string): Promise
<
Uint8Array
>
> **说明:**
通过输入参数异步解码后输出对应文本。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[contains<sup>9+</sup>](#contains9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
**参数:**
| 参数名 | 类型
| 必填 | 说明
|
| 参数名 | 类型
| 必填 | 说明
|
| ------
-- | -------- | -------- |
-------- |
| ------
| ------------------------------ | ---- | -------------------------
-------- |
|
key | K | 是 | 表示要检查的键
。 |
|
src | Uint8Array
\|
string | 是 | 异步解码输入Uint8数组或者字符串
。 |
**返回值:**
**返回值:**
| 类型
| 说明
|
| 类型
| 说明
|
| --------
|
-------- |
| --------
----------------- | -------------------------
-------- |
|
boolean | 如果缓冲区包含指定的键,则返回
true
。 |
|
Promise
<
Uint8Array
>
| 返回异步解码后新分配的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
.
contains
(
20
);
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
())
}
})
```
```
### createDefault<sup>(deprecated)</sup>
createDefault(key: K): V
如果未计算特定键的值,则执行后续操作,参数表示丢失的键,返回与键关联的值。
## types<sup>8+</sup>
> **说明:**
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[createDefault<sup>9+</sup>](#createdefault9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
### constructor<sup>8+</sup>
| 参数名 | 类型 | 必填 | 说明 |
constructor()
| -------- | -------- | -------- | -------- |
| key | K | 是 | 表示丢失的键。 |
**返回值:**
Types的构造函数。
| 类型 | 说明 |
**系统能力:**
SystemCapability.Utils.Lang
| -------- | -------- |
| V | 返回与键关联的值。 |
**示例:**
**示例:**
```
js
```
js
let
pro
=
new
util
.
LruBuffer
();
let
type
=
new
util
.
types
();
let
result
=
pro
.
createDefault
(
50
);
```
```
### entries<sup>(deprecated)</sup>
entries(): IterableIterator
<
[K,V]
>
### isAnyArrayBuffer<sup>8+</sup>
允许迭代包含在这个对象中的所有键值对。
isAnyArrayBuffer(value: Object): boolean
> **说明:**
检查输入的value是否是ArrayBuffer类型。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[entries<sup>9+</sup>](#entries9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| -------- | -------- |
|
[K,
V] | 返回一个可迭代数组
。 |
|
boolean | 判断的结果,如果是ArrayBuffer类型为true,反之为false
。 |
**示例:**
**示例:**
```
js
```
js
let
pro
=
new
util
.
LruBuffer
();
let
that
=
new
util
.
types
();
pro
.
put
(
2
,
10
);
let
result
=
that
.
isAnyArrayBuffer
(
new
ArrayBuffer
(
0
));
let
result
=
pro
.
entries
();
```
```
### [Symbol.iterator]<sup>(deprecated)</sup>
[Symbol.iterator]
\(
): IterableIterator
<
[K, V]
>
### isArrayBufferView<sup>8+</sup>
返回一个键值对形式的二维数组。
isArrayBufferView(value: Object): boolean
> **说明:**
检查输入的value是否是内置ArrayBufferView辅助类型。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[Symbol.iterator<sup>9+</sup>](#symboliterator9)替代
。
ArrayBufferView辅助类型包括:Int8Array、Int16Array、Int32Array、Uint8Array、Uint8ClampedArray、Uint32Array、Float32Array、Float64Array、DataView
。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| -------- | -------- |
|
[K,
V] | 返回一个键值对形式的二维数组
。 |
|
boolean | 判断的结果,如果是内置包含的ArrayBufferView辅助类型为true,反之为false
。 |
**示例:**
**示例:**
```
js
```
js
let
pro
=
new
util
.
LruBuffer
();
let
that
=
new
util
.
types
();
pro
.
put
(
2
,
10
);
let
result
=
that
.
isArrayBufferView
(
new
Int8Array
([]));
let
result
=
pro
[
Symbol
.
iterator
]();
```
```
### ScopeType<sup>8+</sup>
用于表示范围中的值的类型。该类型的值,类型可以为ScopeComparable或number。
ScopeComparable类型的值需要实现compareTo方法,确保传入的数据具有可比性。
```
js
interface
ScopeComparable
{
compareTo
(
other
:
ScopeComparable
):
boolean
;
}
type
ScopeType
=
ScopeComparable
|
number
;
```
构造新类,实现compareTo方法。后续示例代码中,均通过Temperature,获取
[
ScopeType
](
#scopetype8
)
的实例化对象。
示例:
```
js
class
Temperature
{
constructor
(
value
){
// 当使用ts语言开发时,需要补充以下代码:
// private readonly _temp: Temperature;
this
.
_temp
=
value
;
}
compareTo
(
value
){
return
this
.
_temp
>=
value
.
getTemp
();
}
getTemp
(){
return
this
.
_temp
;
}
toString
(){
return
this
.
_temp
.
toString
();
}
}
```
## ScopeHelper<sup>9+</sup>
###
constructor<sup>9
+</sup>
###
isArgumentsObject<sup>8
+</sup>
constructor(lowerObj: ScopeType, upperObj: ScopeType)
isArgumentsObject(value: Object): boolean
用于创建指定下限和上限的作用域实例的构造函数,返回一个ScopeHelper对象
。
检查输入的value是否是一个arguments对象类型
。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------ | ---- | ---------------------- |
| -------- | -------- | -------- | -------- |
| lowerObj |
[
ScopeType
](
#scopetype8
)
| 是 | 指定作用域实例的下限。 |
| value | Object | 是 | 待检测对象。 |
| upperObj |
[
ScopeType
](
#scopetype8
)
| 是 | 指定作用域实例的上限。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| 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
f
=
foo
();
```
```
###
toString<sup>9
+</sup>
###
isArrayBuffer<sup>8
+</sup>
toString(): string
isArrayBuffer(value: Object): boolean
该字符串化方法返回一个包含当前范围的字符串表示形式
。
检查输入的value是否是ArrayBuffer类型
。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:**
**返回值:**
| 类型
| 说明
|
| 类型
| 说明
|
| ------
| ------------------------------
-------- |
| ------
-- |
-------- |
|
string | 返回包含当前范围对象的字符串表示形式
。 |
|
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
range
=
new
util
.
ScopeHelper
(
tempLower
,
tempUpper
);
let
result
=
range
.
toString
();
```
```
### i
ntersect<sup>9
+</sup>
### i
sAsyncFunction<sup>8
+</sup>
i
ntersect(range: ScopeHelper): ScopeHelper
i
sAsyncFunction(value: Object): boolean
获取给定范围和当前范围的交集
。
检查输入的value是否是一个异步函数类型
。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
**参数:**
| 参数名 | 类型
| 必填 | 说明
|
| 参数名 | 类型
| 必填 | 说明
|
| ------
| ---------------------------- | ---- | ----------
-------- |
| ------
-- | -------- | -------- |
-------- |
|
range |
[
ScopeHelper
](
#scopehelper9
)
| 是 | 传入一个给定范围
。 |
|
value | Object | 是 | 待检测对象
。 |
**返回值:**
**返回值:**
| 类型
| 说明
|
| 类型
| 说明
|
| --------
---------------------- | ----------------------
-------- |
| --------
|
-------- |
|
[
ScopeHelper9+
](
#scopehelper9
)
| 返回给定范围和当前范围的交集
。 |
|
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
tempMiDF
=
new
Temperature
(
35
);
let
tempMidS
=
new
Temperature
(
39
);
let
rangeFir
=
new
util
.
ScopeHelper
(
tempMiDF
,
tempMidS
);
range
.
intersect
(
rangeFir
);
```
```
### i
ntersect<sup>9
+</sup>
### i
sBooleanObject<sup>8
+</sup>
i
ntersect(lowerObj:ScopeType,upperObj:ScopeType):ScopeHelper
i
sBooleanObject(value: Object): boolean
获取当前范围与给定下限和上限范围的交集
。
检查输入的value是否是一个Boolean对象类型
。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------ | ---- | ---------------- |
| -------- | -------- | -------- | -------- |
| lowerObj |
[
ScopeType
](
#scopetype8
)
| 是 | 给定范围的下限。 |
| value | Object | 是 | 待检测对象。 |
| upperObj |
[
ScopeType
](
#scopetype8
)
| 是 | 给定范围的上限。 |
**返回值:**
**返回值:**
| 类型
| 说明
|
| 类型
| 说明
|
| --------
-------------------- | --------------------------------
-------- |
| --------
|
-------- |
|
[
ScopeHelper
](
#scopehelper9
)
| 返回当前范围与给定下限和上限范围的交集
。 |
|
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
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>
###
isBoxedPrimitive<sup>8
+</sup>
getUpper(): ScopeType
isBoxedPrimitive(value: Object): boolean
获取当前范围的上限
。
检查输入的value是否是Boolean或Number或String或Symbol对象类型
。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:**
**返回值:**
| 类型
| 说明
|
| 类型
| 说明
|
| --------
---------------- | --------------
-------- |
| --------
|
-------- |
|
[
ScopeType
](
#scopetype8
)
| 返回当前范围的上限值
。 |
|
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
range
=
new
util
.
ScopeHelper
(
tempLower
,
tempUpper
);
let
result
=
range
.
getUpper
();
```
```
###
getLower<sup>9
+</sup>
###
isDataView<sup>8
+</sup>
getLower(): ScopeType
isDataView(value: Object): boolean
获取当前范围的下限
。
检查输入的value是否是DataView类型
。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:**
**返回值:**
| 类型
| 说明
|
| 类型
| 说明
|
| --------
---------------- | --------------
-------- |
| --------
|
-------- |
|
[
ScopeType
](
#scopetype8
)
| 返回当前范围的下限值
。 |
|
boolean | 判断的结果,如果是内置包含的DataView对象类型为true,反之为false
。 |
**示例:**
**示例:**
```
js
```
js
let
tempLower
=
new
Temperature
(
30
);
let
that
=
new
util
.
types
();
let
tempUpper
=
new
Temperature
(
40
);
const
ab
=
new
ArrayBuffer
(
20
);
let
range
=
new
util
.
ScopeHelper
(
tempLower
,
tempUpper
);
let
result
=
that
.
isDataView
(
new
DataView
(
ab
));
let
result
=
range
.
getLower
();
```
```
###
expand<sup>9
+</sup>
###
isDate<sup>8
+</sup>
expand(lowerObj: ScopeType,upperObj: ScopeType): ScopeHelper
isDate(value: Object): boolean
创建并返回包括当前范围和给定下限和上限的并集
。
检查输入的value是否是Date类型
。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------ | ---- | ---------------- |
| -------- | -------- | -------- | -------- |
| lowerObj |
[
ScopeType
](
#scopetype8
)
| 是 | 给定范围的下限。 |
| value | Object | 是 | 待检测对象。 |
| upperObj |
[
ScopeType
](
#scopetype8
)
| 是 | 给定范围的上限。 |
**返回值:**
**返回值:**
| 类型
| 说明
|
| 类型
| 说明
|
| --------
-------------------- | ----------------------------
-------- |
| --------
|
-------- |
|
[
ScopeHelper
](
#scopehelper9
)
| 返回当前范围和给定下限和上限的并集
。 |
|
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
result
=
range
.
expand
(
tempMiDF
,
tempMidS
);
```
```
###
expand<sup>9
+</sup>
###
isExternal<sup>8
+</sup>
expand(range: ScopeHelper): ScopeHelper
isExternal(value: Object): boolean
创建并返回包括当前范围和给定范围的并集
。
检查输入的value是否是native External类型
。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
**参数:**
| 参数名 | 类型
| 必填 | 说明
|
| 参数名 | 类型
| 必填 | 说明
|
| ------
| ---------------------------- | ---- | ----------
-------- |
| ------
-- | -------- | -------- |
-------- |
|
range |
[
ScopeHelper
](
#scopehelper9
)
| 是 | 传入一个给定范围
。 |
|
value | Object | 是 | 待检测对象
。 |
**返回值:**
**返回值:**
| 类型
| 说明
|
| 类型
| 说明
|
| --------
-------------------- | --------------------------
-------- |
| --------
|
-------- |
|
[
ScopeHelper
](
#scopehelper9
)
| 返回包括当前范围和给定范围的并集
。 |
|
boolean | 判断的结果,如果是内置包含native
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
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>
###
isFloat32Array<sup>8
+</sup>
expand(value: ScopeType): ScopeHelper
isFloat32Array(value: Object): boolean
创建并返回包括当前范围和给定值的并集
。
检查输入的value是否是Float32Array数组类型
。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
**参数:**
| 参数名 | 类型
| 必填 | 说明
|
| 参数名 | 类型
| 必填 | 说明
|
| ------
| ------------------------ | ---- | --------
-------- |
| ------
-- | -------- | -------- |
-------- |
| value
|
[
ScopeType
](
#scopetype8
)
| 是 | 传入一个给定值
。 |
| value
| Object | 是 | 待检测对象
。 |
**返回值:**
**返回值:**
| 类型
| 说明
|
| 类型
| 说明
|
| --------
-------------------- | ------------------------
-------- |
| --------
|
-------- |
|
[
ScopeHelper
](
#scopehelper9
)
| 返回包括当前范围和给定值的并集
。 |
|
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
);
let
result
=
range
.
expand
(
tempMiDF
);
```
```
###
contains<sup>9
+</sup>
###
isFloat64Array<sup>8
+</sup>
contains(value: ScopeType
): boolean
isFloat64Array(value: Object
): boolean
检查
给定value是否包含在当前范围内
。
检查
输入的value是否是Float64Array数组类型
。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
**参数:**
| 参数名 | 类型
| 必填 | 说明
|
| 参数名 | 类型
| 必填 | 说明
|
| ------
| ------------------------ | ---- | --------
-------- |
| ------
-- | -------- | -------- |
-------- |
| value
|
[
ScopeType
](
#scopetype8
)
| 是 | 传入一个给定值
。 |
| 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
tempMiDF
=
new
Temperature
(
35
);
let
range
=
new
util
.
ScopeHelper
(
tempLower
,
tempUpper
);
range
.
contains
(
tempMiDF
);
```
```
###
contains<sup>9
+</sup>
###
isGeneratorFunction<sup>8
+</sup>
contains(range: ScopeHelper
): boolean
isGeneratorFunction(value: Object
): boolean
检查
给定range是否在当前范围内
。
检查
输入的value是否是generator函数类型
。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
**参数:**
| 参数名 | 类型
| 必填 | 说明
|
| 参数名 | 类型
| 必填 | 说明
|
| ------
| ---------------------------- | ---- | ----------
-------- |
| ------
-- | -------- | -------- |
-------- |
|
range |
[
ScopeHelper
](
#scopehelper9
)
| 是 | 传入一个给定范围
。 |
|
value | Object | 是 | 待检测对象
。 |
**返回值:**
**返回值:**
| 类型
| 说明
|
| 类型
| 说明
|
| -------
| ---------------------------------------------
-------- |
| -------
- |
-------- |
| boolean |
如果给定范围包含在当前范围内返回true,否则返回
false。 |
| 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
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>
###
isGeneratorObject<sup>8
+</sup>
clamp(value: ScopeType): ScopeType
isGeneratorObject(value: Object): boolean
将给定值限定到当前范围内
。
检查输入的value是否是generator对象类型
。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
**参数:**
| 参数名 | 类型
| 必填 | 说明
|
| 参数名 | 类型
| 必填 | 说明
|
| ------
| ------------------------ | ---- | ------
-------- |
| ------
-- | -------- | -------- |
-------- |
| value
|
[
ScopeType
](
#scopetype8
)
| 是 | 传入的给定值
。 |
| value
| Object | 是 | 待检测对象
。 |
**返回值:**
**返回值:**
| 类型
| 说明
|
| 类型
| 说明
|
| --------
---------------- | ----------------------------------------------------
-------- |
| --------
|
-------- |
|
[
ScopeType
](
#scopetype8
)
| 如果传入的value小于下限,则返回lowerObj;如果大于上限值则返回upperObj;如果在当前范围内,则返回valu
e。 |
|
boolean | 判断的结果,如果是内置包含的generator对象类型为true,反之为fals
e。 |
**示例:**
**示例:**
```
js
```
js
let
tempLower
=
new
Temperature
(
30
);
let
that
=
new
util
.
types
();
let
tempUpper
=
new
Temperature
(
40
);
function
*
foo
()
{}
let
tempMiDF
=
new
Temperature
(
35
);
const
generator
=
foo
();
let
range
=
new
util
.
ScopeHelper
(
tempLower
,
tempUpper
);
let
result
=
that
.
isGeneratorObject
(
generator
);
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)
### isInt8Array<sup>8+</sup>
用于创建指定下限和上限的作用域实例的构造函数,返回一个Scope对象。
> **说明:**
isInt8Array(value: Object): boolean
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[constructor<sup>9+</sup>](#constructor9)替代。
检查输入的value是否是Int8Array数组类型。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
...
@@ -2591,52 +2552,55 @@ constructor(lowerObj: ScopeType, upperObj: ScopeType)
...
@@ -2591,52 +2552,55 @@ constructor(lowerObj: ScopeType, upperObj: ScopeType)
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| lowerObj |
[
ScopeType
](
#scopetype8
)
| 是 | 指定作用域实例的下限。 |
| value | Object | 是 | 待检测对象。 |
| upperObj |
[
ScopeType
](
#scopetype8
)
| 是 | 指定作用域实例的上限。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| 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
);
```
```
### toString<sup>(deprecated)</sup>
toString(): string
### isInt16Array<sup>8+</sup>
该字符串化方法返回一个包含当前范围的字符串表示形式。
isInt16Array(value: Object): boolean
> **说明:**
检查输入的value是否是Int16Array数组类型。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[toString<sup>9+</sup>](#tostring9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| -------- | -------- |
|
string | 返回包含当前范围对象的字符串表示形式
。 |
|
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
result
=
range
.
toString
();
```
```
### intersect<sup>(deprecated)</sup>
intersect(range: Scope): 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
...
@@ -2644,35 +2608,27 @@ intersect(range: Scope): Scope
...
@@ -2644,35 +2608,27 @@ intersect(range: Scope): Scope
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
|
range |
[
Scope
](
#scopedeprecated
)
| 是 | 传入一个给定范围
。 |
|
value | Object | 是 | 待检测对象
。 |
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| -------- | -------- |
|
[
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
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
### isMap<sup>8+</sup>
获取当前范围与给定下限和上限范围的交集。
isMap(value: Object): boolean
> **说明:**
检查输入的value是否是Map类型。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[intersect<sup>9+</sup>](#intersect9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
...
@@ -2680,89 +2636,85 @@ intersect(lowerObj:ScopeType,upperObj:ScopeType):Scope
...
@@ -2680,89 +2636,85 @@ intersect(lowerObj:ScopeType,upperObj:ScopeType):Scope
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| lowerObj |
[
ScopeType
](
#scopetype8
)
| 是 | 给定范围的下限。 |
| value | Object | 是 | 待检测对象。 |
| upperObj |
[
ScopeType
](
#scopetype8
)
| 是 | 给定范围的上限。 |
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| -------- | -------- |
|
[
Scope
](
#scopedeprecated
)
| 返回当前范围与给定下限和上限范围的交集
。 |
|
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
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
### isMapIterator<sup>8+</sup>
获取当前范围的上限。
isMapIterator(value: Object): boolean
> **说明:**
检查输入的value是否是Map的Iterator类型。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[getUpper<sup>9+</sup>](#getupper9)替代。
**系统能力:**
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
.
getUpper
();
```
```
### getLower<sup>(deprecated)</sup>
getLower(): ScopeType
### isNativeError<sup>8+</sup>
获取当前范围的下限。
isNativeError(value: Object): boolean
> **说明:**
检查输入的value是否是Error类型。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[getLower<sup>9+</sup>](#getlower9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| -------- | -------- |
|
[
ScopeType
](
#scopetype8
)
| 返回当前范围的下限值
。 |
|
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
range
=
new
util
.
Scope
(
tempLower
,
tempUpper
);
let
result
=
range
.
getLower
();
```
```
### expand<sup>(deprecated)</sup>
expand(lowerObj: ScopeType,upperObj: ScopeType): 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
...
@@ -2770,35 +2722,27 @@ expand(lowerObj: ScopeType,upperObj: ScopeType): Scope
...
@@ -2770,35 +2722,27 @@ expand(lowerObj: ScopeType,upperObj: ScopeType): Scope
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| lowerObj |
[
ScopeType
](
#scopetype8
)
| 是 | 给定范围的下限。 |
| value | Object | 是 | 待检测对象。 |
| upperObj |
[
ScopeType
](
#scopetype8
)
| 是 | 给定范围的上限。 |
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| -------- | -------- |
|
[
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
result
=
range
.
expand
(
tempMiDF
,
tempMidS
);
```
```
### expand<sup>(deprecated)</sup>
expand(range: Scope): 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
...
@@ -2806,35 +2750,27 @@ expand(range: Scope): Scope
...
@@ -2806,35 +2750,27 @@ expand(range: Scope): Scope
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
|
range |
[
Scope
](
#scopedeprecated
)
| 是 | 传入一个给定范围
。 |
|
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
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
### isProxy<sup>8+</sup>
创建并返回包括当前范围和给定值的并集。
isProxy(value: Object): boolean
> **说明:**
检查输入的value是否是Proxy类型。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[expand<sup>9+</sup>](#expand9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
...
@@ -2842,33 +2778,29 @@ expand(value: ScopeType): Scope
...
@@ -2842,33 +2778,29 @@ expand(value: ScopeType): Scope
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| value |
[
ScopeType
](
#scopetype8
)
| 是 | 传入一个给定值
。 |
| value |
Object | 是 | 待检测对象
。 |
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| -------- | -------- |
|
[
Scope
](
#scopedeprecated
)
| 返回包括当前范围和给定值的并集
。 |
|
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
);
let
result
=
range
.
expand
(
tempMiDF
);
```
```
### contains<sup>(deprecated)</sup>
contains(value: ScopeType): boolean
### isRegExp<sup>8+</sup>
检查给定value是否包含在当前范围内。
isRegExp(value: Object): boolean
> **说明:**
检查输入的value是否是RegExp类型。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[contains<sup>9+</sup>](#contains9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
...
@@ -2876,33 +2808,27 @@ contains(value: ScopeType): boolean
...
@@ -2876,33 +2808,27 @@ contains(value: ScopeType): boolean
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| value |
[
ScopeType
](
#scopetype8
)
| 是 | 传入一个给定值
。 |
| 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
tempMiDF
=
new
Temperature
(
35
);
let
range
=
new
util
.
Scope
(
tempLower
,
tempUpper
);
range
.
contains
(
tempMiDF
);
```
```
### contains<sup>(deprecated)</sup>
contains(range: Scope): boolean
### isSet<sup>8+</sup>
检查给定range是否在当前范围内。
isSet(value: Object): boolean
> **说明:**
检查输入的value是否是Set类型。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[contains<sup>9+</sup>](#contains9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
...
@@ -2910,36 +2836,27 @@ contains(range: Scope): boolean
...
@@ -2910,36 +2836,27 @@ contains(range: Scope): boolean
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
|
range |
[
Scope
](
#scopedeprecated
)
| 是 | 传入一个给定范围
。 |
|
value | Object | 是 | 待检测对象
。 |
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| -------- | -------- |
| boolean |
如果给定范围包含在当前范围内返回true,否则返回
false。 |
| 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
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
### isSetIterator<sup>8+</sup>
将给定值限定到当前范围内。
isSetIterator(value: Object): boolean
> **说明:**
检查输入的value是否是Set的Iterator类型。
>
> 从API Version 8开始支持,从API Version 9开始废弃,建议使用[clamp<sup>9+</sup>](#clamp9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
...
@@ -2947,259 +2864,227 @@ clamp(value: ScopeType): ScopeType
...
@@ -2947,259 +2864,227 @@ clamp(value: ScopeType): ScopeType
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| value |
[
ScopeType
](
#scopetype8
)
| 是 | 传入的给定值
。 |
| value |
Object | 是 | 待检测对象
。 |
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| -------- | -------- |
|
[
ScopeType
](
#scopetype8
)
| 如果传入的value小于下限,则返回lowerObj;如果大于上限值则返回upperObj;如果在当前范围内,则返回valu
e。 |
|
boolean | 判断的结果,如果是内置包含的Set的Iterator类型为true,反之为fals
e。 |
**示例:**
**示例:**
```
js
```
js
let
tempLower
=
new
Temperature
(
30
);
let
that
=
new
util
.
types
();
let
tempUpper
=
new
Temperature
(
40
);
const
set
=
new
Set
();
let
tempMiDF
=
new
Temperature
(
35
);
let
result
=
that
.
isSetIterator
(
set
.
keys
());
let
range
=
new
util
.
Scope
(
tempLower
,
tempUpper
);
let
result
=
range
.
clamp
(
tempMiDF
);
```
```
## Base64Helper<sup>9+</sup>
### constructor<sup>9+</sup>
constructor()
Base64Helper的构造函数。
**系统能力:**
SystemCapability.Utils.Lang
**示例:**
```
js
let
base64
=
new
util
.
Base64Helper
();
```
###
encodeSync<sup>9
+</sup>
###
isStringObject<sup>8
+</sup>
encodeSync(src: Uint8Array): Uint8Array
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
\|
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
<
Uint8Array
>
isUint8Array(value: Object): boolean
通过输入参数异步编码后输出对应文本
。
检查输入的value是否是Uint8Array数组类型
。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
**参数:**
| 参数名 | 类型
| 必填 | 说明
|
| 参数名 | 类型
| 必填 | 说明
|
| ------
| ---------- | ---- | ---------------
-------- |
| ------
-- | -------- | -------- |
-------- |
|
src | Uint8Array | 是 | 异步编码输入Uint8数组
。 |
|
value | Object | 是 | 待检测对象
。 |
**返回值:**
**返回值:**
| 类型
| 说明
|
| 类型
| 说明
|
| --------
----------------- | -------------------------
-------- |
| --------
|
-------- |
|
Promise
<
Uint8Array
>
| 返回异步编码后新分配的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
<
string
>
isUint8ClampedArray(value: Object): boolean
通过输入参数异步编码后输出对应文本
。
检查输入的value是否是Uint8ClampedArray数组类型
。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
**参数:**
| 参数名 | 类型
| 必填 | 说明
|
| 参数名 | 类型
| 必填 | 说明
|
| ------
| ---------- | ---- | ---------------
-------- |
| ------
-- | -------- | -------- |
-------- |
|
src | Uint8Array | 是 | 异步编码输入Uint8数组
。 |
|
value | Object | 是 | 待检测对象
。 |
**返回值:**
**返回值:**
| 类型
| 说明
|
| 类型
| 说明
|
| --------
------------- | ----------------
-------- |
| --------
|
-------- |
|
Promise
<
string
>
| 返回异步编码后的字符串
。 |
|
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
<
Uint8Array
>
isUint16Array(value: Object): boolean
通过输入参数异步解码后输出对应文本
。
检查输入的value是否是Uint16Array数组类型
。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
**参数:**
| 参数名 | 类型
| 必填 | 说明
|
| 参数名 | 类型
| 必填 | 说明
|
| ------
| ------------------------------ | ---- | -------------------------
-------- |
| ------
-- | -------- | -------- |
-------- |
|
src | Uint8Array
\|
string | 是 | 异步解码输入Uint8数组或者字符串
。 |
|
value | Object | 是 | 待检测对象
。 |
**返回值:**
**返回值:**
| 类型
| 说明
|
| 类型
| 说明
|
| --------
----------------- | -------------------------
-------- |
| --------
|
-------- |
|
Promise
<
Uint8Array
>
| 返回异步解码后新分配的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 +3092,27 @@ encodeSync(src: Uint8Array): Uint8Array
...
@@ -3207,31 +3092,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 +3120,27 @@ encodeToStringSync(src: Uint8Array): string
...
@@ -3239,31 +3120,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 +3148,27 @@ decodeSync(src: Uint8Array | string): Uint8Array
...
@@ -3271,31 +3148,27 @@ decodeSync(src: Uint8Array | string): Uint8Array
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
|
src | Uint8Array
\|
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
<
Uint8Array
>
### 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 +3176,27 @@ encode(src: Uint8Array): Promise<Uint8Array>
...
@@ -3303,36 +3176,27 @@ encode(src: Uint8Array): Promise<Uint8Array>
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
|
src | Uint8Array | 是 | 异步编码输入Uint8数组
。 |
|
value | Object | 是 | 待检测对象
。 |
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| -------- | -------- |
|
Promise
<
Uint8Array
>
| 返回异步编码后新分配的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
<
string
>
### 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 +3204,28 @@ encodeToString(src: Uint8Array): Promise<string>
...
@@ -3340,34 +3204,28 @@ encodeToString(src: Uint8Array): Promise<string>
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
|
src | Uint8Array | 是 | 异步编码输入Uint8数组
。 |
|
value | Object | 是 | 待检测对象
。 |
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| -------- | -------- |
|
Promise
<
string
>
| 返回异步编码后的字符串
。 |
|
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
<
Uint8Array
>
### 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 +3233,53 @@ decode(src: Uint8Array | string): Promise<Uint8Array>
...
@@ -3375,50 +3233,53 @@ decode(src: Uint8Array | string): Promise<Uint8Array>
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
|
src | Uint8Array
\|
string | 是 | 异步解码输入Uint8数组或者字符串
。 |
|
value | Object | 是 | 待检测对象
。 |
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| -------- | -------- |
|
Promise
<
Uint8Array
>
| 返回异步解码后新分配的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 +3287,23 @@ isAnyArrayBuffer(value: Object): boolean
...
@@ -3426,29 +3287,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 +3311,257 @@ ArrayBufferView辅助类型包括:Int8Array、Int16Array、Int32Array、Uint8A
...
@@ -3456,255 +3311,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 | 是 | 待检测对象。 |
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| -------- | -------- |
|
boolean | 判断的结果,如果是内置包含的ArrayBuffer类型为true,反之为false
。 |
|
number | 返回当前缓冲区的容量
。 |
**示例:**
**示例:**
```
js
```
js
let
that
=
new
util
.
types
();
let
pro
=
new
util
.
LruBuffer
();
let
result
=
that
.
isArrayBuffer
(
new
ArrayBuffer
(
0
)
);
let
result
=
pro
.
getCapacity
(
);
```
```
### clear<sup>(deprecated)</sup>
### isAsyncFunction<sup>8+</sup>
clear(): void
isAsyncFunction(value: Object): boolean
从当前缓冲区清除键值对。后续会调用afterRemoval()方法执行后续操作。
检查输入的value是否是一个异步函数类型。
> **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[clear<sup>9+</sup>](#clear9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
**
参数
:**
**
示例
:**
| 参数名 | 类型 | 必填 | 说明 |
```
js
| -------- | -------- | -------- | -------- |
let
pro
=
new
util
.
LruBuffer
();
| value | Object | 是 | 待检测对象。 |
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
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| -------- | -------- |
|
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
External类型为true,反之为fals
e。 |
| boolean |
如果当前缓冲区不包含任何值,则返回tru
e。 |
**示例:**
**示例:**
```
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 +3569,31 @@ isFloat32Array(value: Object): boolean
...
@@ -3712,27 +3569,31 @@ isFloat32Array(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
|
value | Object | 是 | 待检测对象
。 |
|
key | K | 是 | 要查询的键
。 |
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| -------- | -------- |
|
boolean | 判断的结果,如果是内置包含的Float32Array数组类型为true,反之为false
。 |
|
V
\|
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 +3601,84 @@ isFloat64Array(value: Object): boolean
...
@@ -3740,85 +3601,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
[] | 按从最近访问到最近最少访问的顺序返回当前缓冲区中所有值的列表
。 |
**示例:**
**示例:**
```
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
[] | 按升序返回当前缓冲区中所有键的列表,从最近访问到最近最少访问
。 |
**示例:**
**示例:**
```
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,27 +3686,30 @@ isInt8Array(value: Object): boolean
...
@@ -3826,27 +3686,30 @@ isInt8Array(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
|
value | Object | 是 | 待检测对象
。 |
|
key | K | 是 | 要删除的密钥
。 |
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| -------- | -------- |
|
boolean | 判断的结果,如果是内置包含的Int8Array数组类型为true,反之为false
。 |
|
V
\|
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
...
@@ -3854,27 +3717,43 @@ isInt16Array(value: Object): boolean
...
@@ -3854,27 +3717,43 @@ isInt16Array(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| 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 +3761,31 @@ isInt32Array(value: Object): boolean
...
@@ -3882,27 +3761,31 @@ isInt32Array(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
|
value | Object | 是 | 待检测对象
。 |
|
key | K | 是 | 表示要检查的键
。 |
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| -------- | -------- |
| boolean |
判断的结果,如果是内置包含的Int32Array数组类型为true,反之为fals
e。 |
| boolean |
如果缓冲区包含指定的键,则返回
tru
e。 |
**示例:**
**示例:**
```
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,113 +3793,126 @@ isMap(value: Object): boolean
...
@@ -3910,113 +3793,126 @@ 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
<
[K,V]
>
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,
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
<
[K, V]
>
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,
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
]();
```
```
### ScopeType<sup>8+</sup>
### isNumberObject<sup>8+</sup>
用于表示范围中的值的类型。该类型的值,类型可以为ScopeComparable或number。
isNumberObject(value: Object): boolean
ScopeComparable类型的值需要实现compareTo方法,确保传入的数据具有可比性。
检查输入的value是否是Number对象类型。
```
js
interface
ScopeComparable
{
compareTo
(
other
:
ScopeComparable
):
boolean
;
}
type
ScopeType
=
ScopeComparable
|
number
;
```
**系统能力:**
SystemCapability.Utils.Lang
**参数:**
构造新类,实现compareTo方法。后续示例代码中,均通过Temperature,获取
[
ScopeType
](
#scopetype8
)
的实例化对象。
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
**返回值:**
示例:
```
js
class
Temperature
{
constructor
(
value
){
// 当使用ts语言开发时,需要补充以下代码:
// private readonly _temp: Temperature;
this
.
_temp
=
value
;
}
compareTo
(
value
){
return
this
.
_temp
>=
value
.
getTemp
();
}
getTemp
(){
return
this
.
_temp
;
}
toString
(){
return
this
.
_temp
.
toString
();
}
}
```
| 类型 | 说明 |
## Scope<sup>(deprecated)</sup>
| -------- | -------- |
| boolean | 判断的结果,如果是内置包含的Number对象类型为true,反之为false。 |
**示例:**
> **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[ScopeHelper<sup>9+</sup>](#scopehelper9)替代。
```
js
### constructor<sup>(deprecated)</sup>
let
that
=
new
util
.
types
();
let
result
=
that
.
isNumberObject
(
new
Number
(
0
));
```
constructor(lowerObj: ScopeType, upperObj: ScopeType)
### isPromise<sup>8+</sup>
用于创建指定下限和上限的作用域实例的构造函数,返回一个Scope对象。
isPromise(value: Object): boolean
> **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[constructor<sup>9+</sup>](#constructor9)替代。
检查输入的value是否是Promise类型。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
...
@@ -4024,27 +3920,52 @@ isPromise(value: Object): boolean
...
@@ -4024,27 +3920,52 @@ isPromise(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| value | Object | 是 | 待检测对象。 |
| lowerObj |
[
ScopeType
](
#scopetype8
)
| 是 | 指定作用域实例的下限。 |
| upperObj |
[
ScopeType
](
#scopetype8
)
| 是 | 指定作用域实例的上限。 |
**示例:**
```
js
let
tempLower
=
new
Temperature
(
30
);
let
tempUpper
=
new
Temperature
(
40
);
let
range
=
new
util
.
Scope
(
tempLower
,
tempUpper
);
```
### toString<sup>(deprecated)</sup>
toString(): string
该字符串化方法返回一个包含当前范围的字符串表示形式。
> **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[toString<sup>9+</sup>](#tostring9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| -------- | -------- |
|
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 +3973,35 @@ isProxy(value: Object): boolean
...
@@ -4052,29 +3973,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 +4009,89 @@ isRegExp(value: Object): boolean
...
@@ -4082,84 +4009,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 +4099,35 @@ isStringObject(value: Object): boolean
...
@@ -4167,27 +4099,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 +4135,35 @@ isSymbolObject(value: Object): boolean
...
@@ -4195,30 +4135,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 +4171,33 @@ TypedArray类型的辅助类型,包括Int8Array、Int16Array、Int32Array、Ui
...
@@ -4226,27 +4171,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 +4205,33 @@ isUint8Array(value: Object): boolean
...
@@ -4254,27 +4205,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 +4239,36 @@ isUint8ClampedArray(value: Object): boolean
...
@@ -4282,27 +4239,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 +4276,58 @@ isUint16Array(value: Object): boolean
...
@@ -4310,55 +4276,58 @@ isUint16Array(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| value |
Object | 是 | 待检测对象
。 |
| value |
[
ScopeType
](
#scopetype8
)
| 是 | 传入的给定值
。 |
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| -------- | -------- |
|
boolean | 判断的结果,如果是内置包含的Uint16Array数组类型为true,反之为fals
e。 |
|
[
ScopeType
](
#scopetype8
)
| 如果传入的value小于下限,则返回lowerObj;如果大于上限值则返回upperObj;如果在当前范围内,则返回valu
e。 |
**示例:**
**示例:**
```
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 +4335,31 @@ isWeakMap(value: Object): boolean
...
@@ -4366,27 +4335,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 +4367,31 @@ isWeakSet(value: Object): boolean
...
@@ -4394,27 +4367,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 +4399,31 @@ isBigInt64Array(value: Object): boolean
...
@@ -4422,27 +4399,31 @@ isBigInt64Array(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
|
value | Object | 是 | 待检测对象
。 |
|
src | Uint8Array
\|
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
<
Uint8Array
>
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 +4431,36 @@ isBigUint64Array(value: Object): boolean
...
@@ -4450,27 +4431,36 @@ isBigUint64Array(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
|
value | Object | 是 | 待检测对象
。 |
|
src | Uint8Array | 是 | 异步编码输入Uint8数组
。 |
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| -------- | -------- |
|
boolean | 判断的结果,如果是内置包含的BigUint64Array类型为true,反之为false
。 |
|
Promise
<
Uint8Array
>
| 返回异步编码后新分配的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
<
string
>
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 +4468,34 @@ isModuleNamespaceObject(value: Object): boolean
...
@@ -4478,28 +4468,34 @@ isModuleNamespaceObject(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
|
value | Object | 是 | 待检测对象
。 |
|
src | Uint8Array | 是 | 异步编码输入Uint8数组
。 |
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| -------- | -------- |
|
boolean | 判断的结果,如果是内置包含的Module Namespace Object类型为true,反之为false
。 |
|
Promise
<
string
>
| 返回异步编码后的字符串
。 |
**示例:**
**示例:**
```
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
<
Uint8Array
>
检查输入的value是否是SharedArrayBuffer类型。
通过输入参数异步解码后输出对应文本。
> **说明:**
>
> 从API version 8开始支持,从API version 9开始废弃,建议使用[decode<sup>9+</sup>](#decode9)替代。
**系统能力:**
SystemCapability.Utils.Lang
**系统能力:**
SystemCapability.Utils.Lang
...
@@ -4507,18 +4503,25 @@ isSharedArrayBuffer(value: Object): boolean
...
@@ -4507,18 +4503,25 @@ isSharedArrayBuffer(value: Object): boolean
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
|
value | Object | 是 | 待检测对象
。 |
|
src | Uint8Array
\|
string | 是 | 异步解码输入Uint8数组或者字符串
。 |
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------- | -------- |
| -------- | -------- |
|
boolean | 判断的结果,如果是内置包含的SharedArrayBuffer类型为true,反之为false
。 |
|
Promise
<
Uint8Array
>
| 返回异步解码后新分配的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
zh-cn/application-dev/reference/errorcodes/errorcode-buffer.md
已删除
100644 → 0
浏览文件 @
1808eca4
# 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
zh-cn/application-dev/reference/errorcodes/errorcode-containers.md
已删除
100644 → 0
浏览文件 @
1808eca4
# 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.
**错误描述**
操作的容器为空。
**可能原因**
容器是空的。
**处理步骤**
请先往容器内添加元素。
zh-cn/application-dev/reference/errorcodes/errorcode-utils.md
0 → 100644
浏览文件 @
f2538d1f
# 语言基础类库错误码
## 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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录