js-apis-util.md 61.2 KB
Newer Older
W
wusongqing 已提交
1
# util
Z
zengyawen 已提交
2 3


W
wusongqing 已提交
4 5
> **NOTE**
>
W
wusongqing 已提交
6
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Z
zengyawen 已提交
7

W
wusongqing 已提交
8

W
wusongqing 已提交
9
This module provides common utility functions, such as **TextEncoder** and **TextDecoder** for string encoding and decoding, **RationalNumber** for rational number operations, **LruBuffer** for buffer management, **Scope** for range determination, **Base64** for Base64 encoding and decoding, and **Types** for checks of built-in object types.
W
wusongqing 已提交
10 11 12


## Modules to Import
Z
zengyawen 已提交
13 14 15 16 17

```
import util from '@ohos.util';
```

W
wusongqing 已提交
18
## util.printf
Z
zengyawen 已提交
19

W
wusongqing 已提交
20
printf(format: string,  ...args: Object[]): string
Z
zengyawen 已提交
21 22 23

Prints the input content in a formatted string.

W
wusongqing 已提交
24 25 26
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
27 28 29 30
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| format | string | Yes| Format of the string to print.|
| ...args | Object[] | No| Data to format.|
W
wusongqing 已提交
31

W
wusongqing 已提交
32
**Return value**
W
wusongqing 已提交
33 34 35
| Type| Description|
| -------- | -------- |
| string | String in the specified format.|
W
wusongqing 已提交
36

W
wusongqing 已提交
37
**Example**
38
  ```js
W
wusongqing 已提交
39 40 41 42 43 44 45 46
  var res = util.printf("%s", "hello world!");
  console.log(res);
  ```


## util.getErrorString

getErrorString(errno: number): string
Z
zengyawen 已提交
47 48 49

Obtains detailed information about a system error code.

W
wusongqing 已提交
50 51 52
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
53 54 55
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| errno | number | Yes| Error code generated.|
W
wusongqing 已提交
56

W
wusongqing 已提交
57
**Return value**
W
wusongqing 已提交
58 59 60
| Type| Description|
| -------- | -------- |
| string | Detailed information about the error code.|
W
wusongqing 已提交
61

W
wusongqing 已提交
62
**Example**
63
  ```js
W
wusongqing 已提交
64 65 66 67 68 69 70 71 72 73 74
  var errnum = 10; // 10 is the system error code.
  var result = util.getErrorString(errnum);
  console.log("result = " + result);
  ```


## util.callbackWrapper

callbackWrapper(original: Function): (err: Object, value: Object )=>void

Calls back an asynchronous function. In the callback, the first parameter indicates the cause of the rejection (the value is **null** if the promise has been resolved), and the second parameter indicates the resolved value.
Z
zengyawen 已提交
75

W
wusongqing 已提交
76 77 78 79
**System capability**: SystemCapability.Utils.Lang

**Parameters**

W
wusongqing 已提交
80 81 82
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| original | Function | Yes| Asynchronous function.|
Z
zengyawen 已提交
83

W
wusongqing 已提交
84
**Return value**
W
wusongqing 已提交
85 86 87
| Type| Description|
| -------- | -------- |
| Function | Callback, in which the first parameter indicates the cause of the rejection (the value is **null** if the promise has been resolved) and the second parameter indicates the resolved value.|
Z
zengyawen 已提交
88

W
wusongqing 已提交
89
**Example**
90
  ```js
W
wusongqing 已提交
91 92 93
  async function promiseFn() {
      return Promise.reject('value');
  }
S
shikai-123 已提交
94
  var err = "type err";
W
wusongqing 已提交
95 96 97 98
  var cb = util.callbackWrapper(promiseFn);
  cb((err, ret) => {
      console.log(err);
      console.log(ret);
S
shikai-123 已提交
99
  }, err)
W
wusongqing 已提交
100 101 102
  ```


S
shikai-123 已提交
103
## util.promiseWrapper<sup>(deprecated)</sup>
W
wusongqing 已提交
104 105

promiseWrapper(original: (err: Object, value: Object) =&gt; void): Object
Z
zengyawen 已提交
106

S
shikai-123 已提交
107 108 109
> **Introduce**<br/>
> Starting from API version 9, it is recommended to use [util.promisewrapper9 +] (\utilpromisewrapper9) instead.

Z
zengyawen 已提交
110 111
Processes an asynchronous function and returns a promise version.

W
wusongqing 已提交
112 113 114
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
115 116 117
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| original | Function | Yes| Asynchronous function.|
W
wusongqing 已提交
118

W
wusongqing 已提交
119
**Return value**
W
wusongqing 已提交
120 121 122
| Type| Description|
| -------- | -------- |
| Function | Function in the error-first style (that is, **(err, value) =>...** is called as the last parameter) and the promise version.|
W
wusongqing 已提交
123

S
shikai-123 已提交
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
**Example**
  ```js
  function aysnFun() {
    return 0;
  }
  let newPromiseObj = util.promiseWrapper(aysnFun);
  newPromiseObj().then(res => {
    console.log(res);
  })
  ```

## util.promiseWrapper<sup>9+</sup>

promiseWrapper(original: (err: Object, value: Object) =&gt; void): Function

Processes an asynchronous function and returns a promise function.

**System capability**: SystemCapability.Utils.Lang

**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| original | Function | Yes| Asynchronous function.|

**Return value**
| Type| Description|
| -------- | -------- |
| Function | Function in the error-first style (that is, **(err, value) =>...** is called as the last parameter) and the promise version.|

W
wusongqing 已提交
153
**Example**
154
  ```js
S
shikai-123 已提交
155 156 157 158 159 160
  function aysnFun(str1, str2) {
    if (typeof str1 === 'object' && typeof str2 === 'object') {
      return str2
    } else {
      return str1
    }
W
wusongqing 已提交
161
  }
S
shikai-123 已提交
162 163 164
  let newPromiseObj = util.promiseWrapper(aysnFun);
  newPromiseObj({ err: "type error" }, {value:'HelloWorld'}).then(res => {
    console.log(res);
W
wusongqing 已提交
165 166 167 168 169 170 171 172
  })
  ```


## TextDecoder

### Attributes

W
wusongqing 已提交
173 174
**System capability**: SystemCapability.Utils.Lang

W
wusongqing 已提交
175 176 177 178 179
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| encoding | string | Yes| No| Encoding format.<br>- Supported formats: utf-8, ibm866, iso-8859-2, iso-8859-3, iso-8859-4, iso-8859-5, iso-8859-6, iso-8859-7, iso-8859-8, iso-8859-8-i, iso-8859-10, iso-8859-13, iso-8859-14, iso-8859-15, koi8-r, koi8-u, macintosh, windows-874, windows-1250, windows-1251, windows-1252, windows-1253, windows-1254, windows-1255, windows-1256, windows-1257, windows-1258, x-mac-cyrilli, gbk, gb18030, big5, euc-jp, iso-2022-jp, shift_jis, euc-kr, utf-16be, utf-16le|
| fatal | boolean | Yes| No| Whether to display fatal errors.|
| ignoreBOM | boolean | Yes| No| Whether to ignore the byte order marker (BOM). The default value is **false**, which indicates that the result contains the BOM.|
W
wusongqing 已提交
180 181 182 183


### constructor

S
shikai-123 已提交
184
constructor(encoding?: string, options?: { fatal?: boolean; ignoreBOM?: boolean },)
W
wusongqing 已提交
185 186 187

A constructor used to create a **TextDecoder** object.

W
wusongqing 已提交
188 189 190
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
191 192 193 194
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| encoding | string | No| Encoding format.|
| options | Object | No| Encoding-related options, which include **fatal** and **ignoreBOM**.|
W
wusongqing 已提交
195 196

  **Table 1** options
W
wusongqing 已提交
197

W
wusongqing 已提交
198 199 200 201
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| fatal | boolean | No| Whether to display fatal errors.|
| ignoreBOM | boolean | No| Whether to ignore the BOM.|
W
wusongqing 已提交
202

W
wusongqing 已提交
203
**Example**
204
  ```js
X
xdmal 已提交
205
  var textDecoder = new util.TextDecoder("utf-8",{ignoreBOM: true});
W
wusongqing 已提交
206 207 208 209 210
  ```


### decode

S
shikai-123 已提交
211
decode(input: Uint8Array, options?: { stream?: false }): string
Z
zengyawen 已提交
212

Z
zengyawen 已提交
213
Decodes the input content.
Z
zengyawen 已提交
214

W
wusongqing 已提交
215 216 217
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
218 219 220 221
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| input | Unit8Array | Yes| Uint8Array to decode.|
| options | Object | No| Options related to decoding.|
W
wusongqing 已提交
222 223

  **Table 2** options
W
wusongqing 已提交
224

W
wusongqing 已提交
225 226 227
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| stream | boolean | No| Whether to allow data blocks in subsequent **decode()**. If data is processed in blocks, set this parameter to **true**. If this is the last data block to process or data is not divided into blocks, set this parameter to **false**. The default value is **false**.|
Z
zengyawen 已提交
228

W
wusongqing 已提交
229
**Return value**
W
wusongqing 已提交
230 231 232
| Type| Description|
| -------- | -------- |
| string | Data decoded.|
Z
zengyawen 已提交
233

W
wusongqing 已提交
234
**Example**
235
  ```js
X
xdmal 已提交
236
  var textDecoder = new util.TextDecoder("utf-8",{ignoreBOM: true});
W
wusongqing 已提交
237 238 239 240 241 242 243 244
  var result = new Uint8Array(6);
  result[0] = 0xEF;
  result[1] = 0xBB;
  result[2] = 0xBF;
  result[3] = 0x61;
  result[4] = 0x62;
  result[5] = 0x63;
  console.log("input num:");
X
xdmal 已提交
245
  var retStr = textDecoder.decode( result , {stream: false});
W
wusongqing 已提交
246 247
  console.log("retStr = " + retStr);
  ```
Z
zengyawen 已提交
248 249


W
wusongqing 已提交
250
## TextEncoder
Z
zengyawen 已提交
251

W
wusongqing 已提交
252
### Attributes
Z
zengyawen 已提交
253

W
wusongqing 已提交
254 255
**System capability**: SystemCapability.Utils.Lang

W
wusongqing 已提交
256 257 258
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| encoding | string | Yes| No| Encoding format. The default format is **utf-8**.|
Z
zengyawen 已提交
259 260


W
wusongqing 已提交
261
### constructor
Z
zengyawen 已提交
262

W
wusongqing 已提交
263
constructor()
Z
zengyawen 已提交
264

W
wusongqing 已提交
265
A constructor used to create a **TextEncoder** object.
Z
zengyawen 已提交
266

W
wusongqing 已提交
267 268 269
**System capability**: SystemCapability.Utils.Lang

**Example**
270
  ```js
W
wusongqing 已提交
271 272 273 274 275 276
  var textEncoder = new util.TextEncoder();
  ```


### encode

X
xdmal 已提交
277
encode(input?: string): Uint8Array
Z
zengyawen 已提交
278

Z
zengyawen 已提交
279
Encodes the input content.
Z
zengyawen 已提交
280

W
wusongqing 已提交
281 282 283
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
284 285 286
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| input | string | Yes| String to encode.|
W
wusongqing 已提交
287

W
wusongqing 已提交
288
**Return value**
W
wusongqing 已提交
289 290 291
| Type| Description|
| -------- | -------- |
| Uint8Array | Encoded text.|
W
wusongqing 已提交
292

W
wusongqing 已提交
293
**Example**
294
  ```js
W
wusongqing 已提交
295
  var textEncoder = new util.TextEncoder();
296
  var buffer = new ArrayBuffer(20);
W
wusongqing 已提交
297 298 299 300 301 302 303
  var result = new Uint8Array(buffer);
  result = textEncoder.encode("\uD800¥¥");
  ```


### encodeInto

X
xdmal 已提交
304
encodeInto(input: string, dest: Uint8Array, ): { read: number; written: number }
Z
zengyawen 已提交
305 306 307

Stores the UTF-8 encoded text.

W
wusongqing 已提交
308 309 310
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
311 312 313 314
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| input | string | Yes| String to encode.|
| dest | Uint8Array | Yes| **Uint8Array** instance used to store the UTF-8 encoded text.|
Z
zengyawen 已提交
315

W
wusongqing 已提交
316
**Return value**
W
wusongqing 已提交
317 318 319
| Type| Description|
| -------- | -------- |
| Uint8Array | Encoded text.|
Z
zengyawen 已提交
320

W
wusongqing 已提交
321
**Example**
322
  ```js
S
shikai-123 已提交
323 324 325 326 327
  var that = new util.TextEncoder()
  var buffer = new ArrayBuffer(4)
  var dest = new Uint8Array(buffer)
  var result = new Object()
  result = that.encodeInto('abcd', dest)
W
wusongqing 已提交
328
  ```
Z
zengyawen 已提交
329

W
wusongqing 已提交
330
## RationalNumber<sup>8+</sup>
Z
zengyawen 已提交
331 332


W
wusongqing 已提交
333
### constructor<sup>8+</sup>
Z
zengyawen 已提交
334

X
xdmal 已提交
335
constructor(numerator: number,denominator: number)
Z
zengyawen 已提交
336

W
wusongqing 已提交
337
A constructor used to create a **RationalNumber** object.
Z
zengyawen 已提交
338

W
wusongqing 已提交
339 340 341
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
342 343 344 345
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| numerator | number | Yes| Numerator, which is an integer.|
| denominator | number | Yes| Denominator, which is an integer.|
Z
zengyawen 已提交
346

W
wusongqing 已提交
347
**Example**
348
  ```js
W
wusongqing 已提交
349 350
  var rationalNumber = new util.RationalNumber(1,2);
  ```
Z
zengyawen 已提交
351 352


W
wusongqing 已提交
353
### createRationalFromString<sup>8+</sup>
Z
zengyawen 已提交
354

X
xdmal 已提交
355
static createRationalFromString​(rationalString: string): RationalNumber​
Z
zengyawen 已提交
356

W
wusongqing 已提交
357
Creates a **RationalNumber** object based on the given string.
Z
zengyawen 已提交
358

W
wusongqing 已提交
359 360 361
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
362 363 364
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| rationalString | string | Yes| String used to create the **RationalNumber** object.|
Z
zengyawen 已提交
365

W
wusongqing 已提交
366
**Return value**
W
wusongqing 已提交
367 368 369
| Type| Description|
| -------- | -------- |
| object | **RationalNumber** object created.|
Z
zengyawen 已提交
370

W
wusongqing 已提交
371
**Example**
372
  ```js
W
wusongqing 已提交
373
  var rationalNumber = new util.RationalNumber(1,2);
S
shikai-123 已提交
374
  var rational = util.RationalNumber.createRationalFromString("3/4");
W
wusongqing 已提交
375
  ```
Z
zengyawen 已提交
376 377


W
wusongqing 已提交
378
### compareTo<sup>8+</sup>
Z
zengyawen 已提交
379

X
xdmal 已提交
380
compareTo​(another: RationalNumber): number​
Z
zengyawen 已提交
381

W
wusongqing 已提交
382
Compares this **RationalNumber** object with a given object.
Z
zengyawen 已提交
383

W
wusongqing 已提交
384 385 386
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
387 388 389
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| another | RationalNumber | Yes| Object used to compare with this **RationalNumber** object.|
Z
zengyawen 已提交
390

W
wusongqing 已提交
391
**Return value**
W
wusongqing 已提交
392 393 394
| Type| Description|
| -------- | -------- |
| number | Returns **0** if the two objects are equal; returns **1** if the given object is less than this object; return **-1** if the given object is greater than this object.|
Z
zengyawen 已提交
395

W
wusongqing 已提交
396
**Example**
397
  ```js
W
wusongqing 已提交
398
  var rationalNumber = new util.RationalNumber(1,2);
S
shikai-123 已提交
399
  var rational = util.RationalNumber.createRationalFromString("3/4");
W
wusongqing 已提交
400 401
  var result = rationalNumber.compareTo(rational);
  ```
Z
zengyawen 已提交
402 403


W
wusongqing 已提交
404
### valueOf<sup>8+</sup>
Z
zengyawen 已提交
405

X
xdmal 已提交
406
valueOf(): number
Z
zengyawen 已提交
407

W
wusongqing 已提交
408
Obtains the value of this **RationalNumber** object as an integer or a floating-point number.
Z
zengyawen 已提交
409

W
wusongqing 已提交
410 411 412
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
413 414 415
| Type| Description|
| -------- | -------- |
| number | An integer or a floating-point number.|
Z
zengyawen 已提交
416

W
wusongqing 已提交
417
**Example**
418
  ```js
W
wusongqing 已提交
419 420 421
  var rationalNumber = new util.RationalNumber(1,2);
  var result = rationalNumber.valueOf();
  ```
Z
zengyawen 已提交
422 423


W
wusongqing 已提交
424
### equals<sup>8+</sup>
Z
zengyawen 已提交
425

X
xdmal 已提交
426
equals​(obj: Object): boolean
Z
zengyawen 已提交
427

W
wusongqing 已提交
428
Checks whether this **RationalNumber** object equals the given object.
Z
zengyawen 已提交
429

W
wusongqing 已提交
430 431 432
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
433 434 435
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| object | Object | Yes| Object used to compare with this **RationalNumber** object.|
Z
zengyawen 已提交
436

W
wusongqing 已提交
437
**Return value**
W
wusongqing 已提交
438 439 440
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the two objects are equal; returns **false** otherwise.|
Z
zengyawen 已提交
441

W
wusongqing 已提交
442
**Example**
443
  ```js
W
wusongqing 已提交
444
  var rationalNumber = new util.RationalNumber(1,2);
S
shikai-123 已提交
445
  var rational = util.RationalNumber.createRationalFromString("3/4");
W
wusongqing 已提交
446 447
  var result = rationalNumber.equals(rational);
  ```
Z
zengyawen 已提交
448 449


W
wusongqing 已提交
450
### getCommonDivisor<sup>8+</sup>
Z
zengyawen 已提交
451

X
xdmal 已提交
452
static getCommonDivisor​(number1: number,number2: number): number
Z
zengyawen 已提交
453

W
wusongqing 已提交
454
Obtains the greatest common divisor of two specified integers.
Z
zengyawen 已提交
455

W
wusongqing 已提交
456 457 458
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
459 460 461 462
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| number1 | number | Yes| The first integer used to get the greatest common divisor.|
| number2 | number | Yes| The second integer used to get the greatest common divisor.|
Z
zengyawen 已提交
463

W
wusongqing 已提交
464
**Return value**
W
wusongqing 已提交
465 466 467
| Type| Description|
| -------- | -------- |
| number | Greatest common divisor obtained.|
Z
zengyawen 已提交
468

W
wusongqing 已提交
469
**Example**
470
  ```js
W
wusongqing 已提交
471
  var rationalNumber = new util.RationalNumber(1,2);
S
shikai-123 已提交
472
  var result = util.RationalNumber.getCommonDivisor(4,6);
W
wusongqing 已提交
473
  ```
Z
zengyawen 已提交
474 475


W
wusongqing 已提交
476
### getNumerator<sup>8+</sup>
Z
zengyawen 已提交
477

X
xdmal 已提交
478
getNumerator​(): number
Z
zengyawen 已提交
479

W
wusongqing 已提交
480
Obtains the numerator of this **RationalNumber** object.
Z
zengyawen 已提交
481

W
wusongqing 已提交
482 483 484 485
**System capability**: SystemCapability.Utils.Lang

**Return value**

W
wusongqing 已提交
486 487 488
| Type| Description|
| -------- | -------- |
| number | Numerator of this **RationalNumber** object.|
Z
zengyawen 已提交
489

W
wusongqing 已提交
490
**Example**
491
  ```js
W
wusongqing 已提交
492 493 494
  var rationalNumber = new util.RationalNumber(1,2);
  var result = rationalNumber.getNumerator();
  ```
Z
zengyawen 已提交
495 496


W
wusongqing 已提交
497
### getDenominator<sup>8+</sup>
Z
zengyawen 已提交
498

X
xdmal 已提交
499
getDenominator​(): number
Z
zengyawen 已提交
500

W
wusongqing 已提交
501
Obtains the denominator of this **RationalNumber** object.
Z
zengyawen 已提交
502

W
wusongqing 已提交
503 504 505
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
506 507 508
| Type| Description|
| -------- | -------- |
| number | Denominator of this **RationalNumber** object.|
Z
zengyawen 已提交
509

W
wusongqing 已提交
510
**Example**
511
  ```js
W
wusongqing 已提交
512 513 514
  var rationalNumber = new util.RationalNumber(1,2);
  var result = rationalNumber.getDenominator();
  ```
Z
zengyawen 已提交
515 516


W
wusongqing 已提交
517
### isZero<sup>8+</sup>
Z
zengyawen 已提交
518

W
wusongqing 已提交
519
isZero​():boolean
Z
zengyawen 已提交
520

W
wusongqing 已提交
521
Checks whether this **RationalNumber** object is **0**.
Z
zengyawen 已提交
522

W
wusongqing 已提交
523 524 525
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
526 527 528
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the value of this **RationalNumber** object is **0**; returns **false** otherwise.|
Z
zengyawen 已提交
529

W
wusongqing 已提交
530
**Example**
531
  ```js
W
wusongqing 已提交
532 533 534
  var rationalNumber = new util.RationalNumber(1,2);
  var result = rationalNumber.isZero();
  ```
Z
zengyawen 已提交
535 536


W
wusongqing 已提交
537
### isNaN<sup>8+</sup>
Z
zengyawen 已提交
538

X
xdmal 已提交
539
isNaN​(): boolean
Z
zengyawen 已提交
540

W
wusongqing 已提交
541
Checks whether this **RationalNumber** object is a Not a Number (NaN).
Z
zengyawen 已提交
542

W
wusongqing 已提交
543 544 545
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
546 547 548
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if this **RationalNumber** object is a NaN (the denominator and numerator are both **0**); returns **false** otherwise.|
Z
zengyawen 已提交
549

W
wusongqing 已提交
550
**Example**
551
  ```js
W
wusongqing 已提交
552 553 554
  var rationalNumber = new util.RationalNumber(1,2);
  var result = rationalNumber.isNaN();
  ```
Z
zengyawen 已提交
555 556


W
wusongqing 已提交
557
### isFinite<sup>8+</sup>
Z
zengyawen 已提交
558

W
wusongqing 已提交
559
isFinite​():boolean
Z
zengyawen 已提交
560

W
wusongqing 已提交
561
Checks whether this **RationalNumber** object represents a finite value.
Z
zengyawen 已提交
562

W
wusongqing 已提交
563 564 565
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
566 567 568
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if this **RationalNumber** object represents a finite value (the denominator is not **0**); returns **false** otherwise.|
Z
zengyawen 已提交
569

W
wusongqing 已提交
570
**Example**
571
  ```js
W
wusongqing 已提交
572 573 574
  var rationalNumber = new util.RationalNumber(1,2);
  var result = rationalNumber.isFinite();
  ```
Z
zengyawen 已提交
575 576


W
wusongqing 已提交
577
### toString<sup>8+</sup>
Z
zengyawen 已提交
578

X
xdmal 已提交
579
toString​(): string
Z
zengyawen 已提交
580

W
wusongqing 已提交
581
Obtains the string representation of this **RationalNumber** object.
Z
zengyawen 已提交
582

W
wusongqing 已提交
583 584 585
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
586 587 588
| Type| Description|
| -------- | -------- |
| string | Returns **NaN** if the numerator and denominator of this object are both **0**; returns a string in Numerator/Denominator format otherwise, for example, **3/5**.|
Z
zengyawen 已提交
589

W
wusongqing 已提交
590
**Example**
591
  ```js
W
wusongqing 已提交
592 593 594
  var rationalNumber = new util.RationalNumber(1,2);
  var result = rationalNumber.toString();
  ```
Z
zengyawen 已提交
595

W
wusongqing 已提交
596
## LruBuffer<sup>8+</sup>
Z
zengyawen 已提交
597

W
wusongqing 已提交
598
### Attributes
Z
zengyawen 已提交
599

W
wusongqing 已提交
600 601
**System capability**: SystemCapability.Utils.Lang

W
wusongqing 已提交
602 603 604
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| length | number | Yes| No| Total number of values in this buffer.|
Z
zengyawen 已提交
605

W
wusongqing 已提交
606
**Example**
607
  ```js
W
wusongqing 已提交
608 609 610 611 612
  var pro = new util.LruBuffer();
  pro.put(2,10);
  pro.put(1,8);
  var result = pro.length;
  ```
Z
zengyawen 已提交
613 614


W
wusongqing 已提交
615
### constructor<sup>8+</sup>
Z
zengyawen 已提交
616

X
xdmal 已提交
617
constructor(capacity?: number)
Z
zengyawen 已提交
618

W
wusongqing 已提交
619
A constructor used to create an **LruBuffer** instance. The default capacity of the buffer is 64.
Z
zengyawen 已提交
620

W
wusongqing 已提交
621 622 623
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
624 625 626
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| capacity | number | No| Capacity of the **LruBuffer** to create.|
Z
zengyawen 已提交
627

W
wusongqing 已提交
628
**Example**
629
  ```js
W
wusongqing 已提交
630 631
  var lrubuffer= new util.LruBuffer();
  ```
Z
zengyawen 已提交
632 633


W
wusongqing 已提交
634
### updateCapacity<sup>8+</sup>
Z
zengyawen 已提交
635

X
xdmal 已提交
636
updateCapacity(newCapacity: number): void
Z
zengyawen 已提交
637

W
wusongqing 已提交
638
Changes the **LruBuffer** capacity. If the new capacity is less than or equal to **0**, an exception will be thrown.
Z
zengyawen 已提交
639

W
wusongqing 已提交
640 641 642
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
643 644 645
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| newCapacity | number | Yes| New capacity of the **LruBuffer**.|
Z
zengyawen 已提交
646

W
wusongqing 已提交
647
**Example**
648
  ```js
W
wusongqing 已提交
649 650 651
  var pro = new util.LruBuffer();
  var result = pro.updateCapacity(100);
  ```
Z
zengyawen 已提交
652 653


W
wusongqing 已提交
654
### toString<sup>8+</sup>
Z
zengyawen 已提交
655

X
xdmal 已提交
656
toString(): string
Z
zengyawen 已提交
657

W
wusongqing 已提交
658
Obtains the string representation of this **LruBuffer** object.
Z
zengyawen 已提交
659

W
wusongqing 已提交
660 661 662
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
663 664 665
| Type| Description|
| -------- | -------- |
| string | String representation of this **LruBuffer** object.|
W
wusongqing 已提交
666

W
wusongqing 已提交
667
**Example**
668
  ```js
W
wusongqing 已提交
669 670 671 672 673 674 675 676 677 678
  var pro = new util.LruBuffer();
  pro.put(2,10);
  pro.get(2);
  pro.remove(20);
  var result = pro.toString();
  ```


### getCapacity<sup>8+</sup>

X
xdmal 已提交
679
getCapacity(): number
W
wusongqing 已提交
680 681 682

Obtains the capacity of this buffer.

W
wusongqing 已提交
683 684 685
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
686 687 688
| Type| Description|
| -------- | -------- |
| number | Capacity of this buffer.|
W
wusongqing 已提交
689

W
wusongqing 已提交
690
**Example**
691
  ```js
W
wusongqing 已提交
692 693 694
  var pro = new util.LruBuffer();
  var result = pro.getCapacity();
  ```
Z
zengyawen 已提交
695 696


W
wusongqing 已提交
697
### clear<sup>8+</sup>
Z
zengyawen 已提交
698

X
xdmal 已提交
699
clear(): void
Z
zengyawen 已提交
700

W
wusongqing 已提交
701
Clears key-value pairs from this buffer. The **afterRemoval()** method will be called to perform subsequent operations.
Z
zengyawen 已提交
702

W
wusongqing 已提交
703 704 705
**System capability**: SystemCapability.Utils.Lang

**Example**
706
  ```js
W
wusongqing 已提交
707 708
  var pro = new util.LruBuffer();
  pro.put(2,10);
S
shikai-123 已提交
709
  var result = pro.length;
W
wusongqing 已提交
710 711
  pro.clear();
  ```
Z
zengyawen 已提交
712 713


W
wusongqing 已提交
714
### getCreateCount<sup>8+</sup>
Z
zengyawen 已提交
715

X
xdmal 已提交
716
getCreateCount(): number
W
wusongqing 已提交
717 718 719

Obtains the number of return values for **createDefault()**.

W
wusongqing 已提交
720 721 722
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
723 724 725
| Type| Description|
| -------- | -------- |
| number | Number of return values for **createDefault()**.|
W
wusongqing 已提交
726

W
wusongqing 已提交
727
**Example**
728
  ```js
W
wusongqing 已提交
729 730 731 732 733 734 735 736
  var pro = new util.LruBuffer();
  pro.put(1,8);
  var result = pro.getCreateCount();
  ```


### getMissCount<sup>8+</sup>

X
xdmal 已提交
737
getMissCount(): number
W
wusongqing 已提交
738 739 740

Obtains the number of times that the queried values are mismatched.

W
wusongqing 已提交
741 742 743
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
744 745 746
| Type| Description|
| -------- | -------- |
| number | Number of times that the queried values are mismatched.|
W
wusongqing 已提交
747

W
wusongqing 已提交
748
**Example**
749
  ```js
W
wusongqing 已提交
750 751 752 753 754 755 756 757 758
  var pro = new util.LruBuffer();
  pro.put(2,10);
  pro.get(2);
  var result = pro.getMissCount();
  ```


### getRemovalCount<sup>8+</sup>

X
xdmal 已提交
759
getRemovalCount(): number
W
wusongqing 已提交
760 761 762

Obtains the number of removals from this buffer.

W
wusongqing 已提交
763 764 765
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
766 767 768
| Type| Description|
| -------- | -------- |
| number | Number of removals from the buffer.|
W
wusongqing 已提交
769

W
wusongqing 已提交
770
**Example**
771
  ```js
W
wusongqing 已提交
772 773 774 775 776 777 778 779 780 781
  var pro = new util.LruBuffer();
  pro.put(2,10);
  pro.updateCapacity(2);
  pro.put(50,22);
  var result = pro.getRemovalCount();
  ```


### getMatchCount<sup>8+</sup>

X
xdmal 已提交
782
getMatchCount(): number
W
wusongqing 已提交
783 784 785

Obtains the number of times that the queried values are matched.

W
wusongqing 已提交
786 787 788
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
789 790 791
| Type| Description|
| -------- | -------- |
| number | Number of times that the queried values are matched.|
W
wusongqing 已提交
792

W
wusongqing 已提交
793
**Example**
794
  ```js
W
wusongqing 已提交
795 796 797 798 799 800 801 802 803
  var pro = new util.LruBuffer();
  pro.put(2,10);
  pro.get(2);
  var result = pro.getMatchCount();
  ```


### getPutCount<sup>8+</sup>

X
xdmal 已提交
804
getPutCount(): number
W
wusongqing 已提交
805 806 807

Obtains the number of additions to this buffer.

W
wusongqing 已提交
808 809 810
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
811 812 813
| Type| Description|
| -------- | -------- |
| number | Number of additions to the buffer.|
W
wusongqing 已提交
814

W
wusongqing 已提交
815
**Example**
816
  ```js
W
wusongqing 已提交
817 818 819 820 821 822 823 824
  var pro = new util.LruBuffer();
  pro.put(2,10);
  var result = pro.getPutCount();
  ```


### isEmpty<sup>8+</sup>

X
xdmal 已提交
825
isEmpty(): boolean
W
wusongqing 已提交
826 827 828

Checks whether this buffer is empty.

W
wusongqing 已提交
829 830 831
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
832 833 834
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the buffer does not contain any value.|
W
wusongqing 已提交
835

W
wusongqing 已提交
836
**Example**
837
  ```js
W
wusongqing 已提交
838 839 840 841 842 843 844 845
  var pro = new util.LruBuffer();
  pro.put(2,10);
  var result = pro.isEmpty();
  ```


### get<sup>8+</sup>

W
wusongqing 已提交
846
get(key: K): V | undefined
Z
zengyawen 已提交
847 848 849

Obtains the value of the specified key.

W
wusongqing 已提交
850 851 852
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
853 854 855
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | K | Yes| Key based on which the value is queried.|
W
wusongqing 已提交
856

W
wusongqing 已提交
857
**Return value**
W
wusongqing 已提交
858 859 860
| Type| Description|
| -------- | -------- |
| V \| undefind | Returns the value of the key if a match is found in the buffer; returns **undefined** otherwise.|
W
wusongqing 已提交
861

W
wusongqing 已提交
862
**Example**
863
  ```js
W
wusongqing 已提交
864 865 866 867 868 869 870 871
  var pro = new util.LruBuffer();
  pro.put(2,10);
  var result  = pro.get(2);
  ```


### put<sup>8+</sup>

X
xdmal 已提交
872
put(key: K,value: V): V
Z
zengyawen 已提交
873 874 875

Adds a key-value pair to this buffer.

W
wusongqing 已提交
876 877 878
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
879 880 881 882
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | K | Yes| Key of the key-value pair to add.|
| value | V | Yes| Value of the key-value pair to add.|
Z
zengyawen 已提交
883

W
wusongqing 已提交
884
**Return value**
W
wusongqing 已提交
885 886 887
| Type| Description|
| -------- | -------- |
| V | Returns the existing value if the key already exists; returns the value added otherwise. If the key or value is null, an exception will be thrown. |
Z
zengyawen 已提交
888

W
wusongqing 已提交
889
**Example**
890
  ```js
W
wusongqing 已提交
891 892 893
  var pro = new util.LruBuffer();
  var result = pro.put(2,10);
  ```
Z
zengyawen 已提交
894 895


W
wusongqing 已提交
896
### values<sup>8+</sup>
Z
zengyawen 已提交
897

X
xdmal 已提交
898
values(): V[]
W
wusongqing 已提交
899 900

Obtains all values in this buffer, listed from the most to the least recently accessed.
Z
zengyawen 已提交
901

W
wusongqing 已提交
902 903 904
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
905 906 907
| Type| Description|
| -------- | -------- |
| V [] | All values in the buffer, listed from the most to the least recently accessed.|
Z
zengyawen 已提交
908

W
wusongqing 已提交
909
**Example**
910
  ```js
W
wusongqing 已提交
911 912 913 914 915 916
  var pro = new util.LruBuffer();
  pro.put(2,10);
  pro.put(2,"anhu");
  pro.put("afaf","grfb");
  var result = pro.values();
  ```
Z
zengyawen 已提交
917 918


W
wusongqing 已提交
919 920
### keys<sup>8+</sup>

X
xdmal 已提交
921
keys(): K[]
Z
zengyawen 已提交
922 923 924

Obtains all keys in this buffer, listed from the most to the least recently accessed.

W
wusongqing 已提交
925 926 927
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
928 929 930
| Type| Description|
| -------- | -------- |
| K [] | All keys in the buffer, listed from the most to the least recently accessed.|
W
wusongqing 已提交
931

W
wusongqing 已提交
932
**Example**
933
  ```js
W
wusongqing 已提交
934 935 936 937 938 939 940 941
  var pro = new util.LruBuffer();
  pro.put(2,10);
  var result = pro.keys();
  ```


### remove<sup>8+</sup>

W
wusongqing 已提交
942
remove(key: K): V | undefined
W
wusongqing 已提交
943 944 945

Removes the specified key and its value from this buffer.

W
wusongqing 已提交
946 947 948
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
949 950 951
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | K | Yes| Key to remove.|
W
wusongqing 已提交
952

W
wusongqing 已提交
953
**Return value**
W
wusongqing 已提交
954 955 956
| Type| Description|
| -------- | -------- |
| V \| undefind | Returns an **Optional** object containing the removed key-value pair if the key exists in the buffer; returns an empty **Optional** object otherwise. If the key is null, an exception will be thrown.|
W
wusongqing 已提交
957

W
wusongqing 已提交
958
**Example**
959
  ```js
W
wusongqing 已提交
960 961 962 963 964 965 966 967
  var pro = new util.LruBuffer();
  pro.put(2,10);
  var result = pro.remove(20);
  ```


### afterRemoval<sup>8+</sup>

X
xdmal 已提交
968
afterRemoval(isEvict: boolean,key: K,value: V,newValue: V): void
W
wusongqing 已提交
969 970 971

Performs subsequent operations after a value is removed.

W
wusongqing 已提交
972 973 974
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
975 976 977 978 979 980
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| isEvict | boolean | No| Whether the buffer capacity is insufficient. If the value is **true**, this method is called due to insufficient capacity.|
| key | K | Yes| Key removed.|
| value | V | Yes| Value removed.|
| newValue | V | No| New value for the key if the **put()** method is called and the key to be added already exists. In other cases, this parameter is left blank.|
W
wusongqing 已提交
981

W
wusongqing 已提交
982
**Example**
983
  ```js
W
wusongqing 已提交
984
  var arr = [];
S
shikai-123 已提交
985
  var arr = [];
W
wusongqing 已提交
986 987 988 989 990 991 992 993 994 995 996 997 998 999
  class ChildLruBuffer extends util.LruBuffer
  {
  	constructor()
  	{
  		super();
  	}
  	afterRemoval(isEvict, key, value, newValue)
  	{
  		if (isEvict === false)
  		{
  			arr = [key, value, newValue];
  		}
  	}
  }
S
shikai-123 已提交
1000 1001
  var lru = new ChildLruBuffer();
  lru.afterRemoval(false,10,30,null);
W
wusongqing 已提交
1002 1003 1004 1005 1006
  ```


### contains<sup>8+</sup>

X
xdmal 已提交
1007
contains(key: K): boolean
W
wusongqing 已提交
1008 1009

Checks whether this buffer contains the specified key.
Z
zengyawen 已提交
1010

W
wusongqing 已提交
1011 1012 1013
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1014 1015 1016
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | K | Yes| Key to check.|
Z
zengyawen 已提交
1017

W
wusongqing 已提交
1018
**Return value**
W
wusongqing 已提交
1019 1020 1021
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the buffer contains the specified key; returns **false** otherwise.|
Z
zengyawen 已提交
1022

W
wusongqing 已提交
1023
**Example**
1024
  ```js
W
wusongqing 已提交
1025 1026 1027 1028
  var pro = new util.LruBuffer();
  pro.put(2,10);
  var result = pro.contains(20);
  ```
Z
zengyawen 已提交
1029 1030


W
wusongqing 已提交
1031 1032
### createDefault<sup>8+</sup>

X
xdmal 已提交
1033
createDefault(key: K): V
Z
zengyawen 已提交
1034 1035 1036

Creates a value if the value of the specified key is not available.

W
wusongqing 已提交
1037 1038 1039
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1040 1041 1042
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | K | Yes| Key of which the value is missing.|
Z
zengyawen 已提交
1043

W
wusongqing 已提交
1044
**Return value**
W
wusongqing 已提交
1045 1046 1047
| Type| Description|
| -------- | -------- |
| V | Value of the key.|
Z
zengyawen 已提交
1048

W
wusongqing 已提交
1049
**Example**
1050
  ```js
W
wusongqing 已提交
1051 1052 1053
  var pro = new util.LruBuffer();
  var result = pro.createDefault(50);
  ```
Z
zengyawen 已提交
1054 1055


W
wusongqing 已提交
1056
### entries<sup>8+</sup>
Z
zengyawen 已提交
1057

X
xdmal 已提交
1058
entries(): IterableIterator&lt;[K,V]&gt;
Z
zengyawen 已提交
1059

W
wusongqing 已提交
1060
Obtains a new iterator object that contains all key-value pairs in this object.
Z
zengyawen 已提交
1061

W
wusongqing 已提交
1062 1063 1064
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
1065 1066 1067
| Type| Description|
| -------- | -------- |
| [K, V] | Iterable array.|
Z
zengyawen 已提交
1068

W
wusongqing 已提交
1069
**Example**
1070
  ```js
W
wusongqing 已提交
1071 1072 1073 1074
  var pro = new util.LruBuffer();
  pro.put(2,10);
  var result = pro.entries();
  ```
Z
zengyawen 已提交
1075 1076


W
wusongqing 已提交
1077
### [Symbol.iterator]<sup>8+</sup>
Z
zengyawen 已提交
1078

W
wusongqing 已提交
1079
[Symbol.iterator]\(): IterableIterator&lt;[K, V]&gt;
Z
zengyawen 已提交
1080

W
wusongqing 已提交
1081
Obtains a two-dimensional array in key-value pairs.
Z
zengyawen 已提交
1082

W
wusongqing 已提交
1083 1084 1085
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
1086 1087 1088
| Type| Description|
| -------- | -------- |
| [K, V] | Two-dimensional array in key-value pairs.|
Z
zengyawen 已提交
1089

W
wusongqing 已提交
1090
**Example**
1091
  ```js
W
wusongqing 已提交
1092 1093
  var pro = new util.LruBuffer();
  pro.put(2,10);
S
shikai-123 已提交
1094
  var result = pro[Symbol.iterator]();
W
wusongqing 已提交
1095
  ```
Z
zengyawen 已提交
1096 1097


W
wusongqing 已提交
1098
## Scope<sup>8+</sup>
Z
zengyawen 已提交
1099 1100


W
wusongqing 已提交
1101
### ScopeType<sup>8+</sup>
Z
zengyawen 已提交
1102

W
wusongqing 已提交
1103
Defines the type of values in a **Scope** object. The value type can be **ScopeComparable** or **number**.
Z
zengyawen 已提交
1104

W
wusongqing 已提交
1105
The values of the **ScopeComparable** type are used to implement the **compareTo** method. Therefore, ensure that the input parameters are comparable.
1106
```js
Z
zengyawen 已提交
1107
interface ScopeComparable{
X
xdmal 已提交
1108
    compareTo(other: ScopeComparable): boolean;
Z
zengyawen 已提交
1109
}
W
wusongqing 已提交
1110
type ScopeType = ScopeComparable | number;
Z
zengyawen 已提交
1111 1112 1113
```


W
wusongqing 已提交
1114
Create a class to implement the **compareTo** method. In the subsequent sample code, **Temperature** is used as an example of the [ScopeType](#scopetype8) object.
Z
zengyawen 已提交
1115

W
wusongqing 已提交
1116 1117

Example
1118
```js
Z
zengyawen 已提交
1119 1120
class Temperature{
    constructor(value){
W
wusongqing 已提交
1121 1122
       // If TS is used for development, add the following code:
       // private readonly _temp: Temperature;
Z
zengyawen 已提交
1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137
       this._temp = value;
    }
    comapreTo(value){
       return this._temp >= value.getTemp();
    }
    getTemp(){
       return this._temp;
    }
    toString(){
       return this._temp.toString();
    }
}
```


W
wusongqing 已提交
1138 1139
### constructor<sup>8+</sup>

X
xdmal 已提交
1140
constructor(lowerObj: ScopeType, upperObj: ScopeType)
W
wusongqing 已提交
1141 1142 1143

A constructor used to create a **Scope** object with the specified upper and lower limits.

W
wusongqing 已提交
1144 1145 1146
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1147 1148 1149 1150
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| lowerObj | [ScopeType](#scopetype8) | Yes| Lower limit of the **Scope** object.|
| upperObj | [ScopeType](#scopetype8) | Yes| Upper limit of the **Scope** object.|
W
wusongqing 已提交
1151

W
wusongqing 已提交
1152
**Example**
1153
  ```js
W
wusongqing 已提交
1154 1155 1156 1157 1158 1159 1160 1161
  var tempLower = new Temperature(30);
  var tempUpper = new Temperature(40);
  var range = new util.Scope(tempLower, tempUpper);
  ```


### toString<sup>8+</sup>

X
xdmal 已提交
1162
toString(): string
W
wusongqing 已提交
1163 1164 1165

Obtains a string representation that contains this **Scope**.

W
wusongqing 已提交
1166 1167 1168
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
1169 1170 1171
| Type| Description|
| -------- | -------- |
| string | String representation containing the **Scope**.|
W
wusongqing 已提交
1172

W
wusongqing 已提交
1173
**Example**
1174
  ```js
W
wusongqing 已提交
1175 1176 1177 1178 1179 1180 1181 1182 1183
  var tempLower = new Temperature(30);
  var tempUpper = new Temperature(40);
  var range = new util.Scope(tempLower, tempUpper);
  var result = range.toString();
  ```


### intersect<sup>8+</sup>

X
xdmal 已提交
1184
intersect(range: Scope): Scope
W
wusongqing 已提交
1185 1186 1187

Obtains the intersection of this **Scope** and the given **Scope**.

W
wusongqing 已提交
1188 1189 1190
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1191 1192 1193
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| range | [Scope](#scope8) | Yes| **Scope** specified.|
W
wusongqing 已提交
1194

W
wusongqing 已提交
1195
**Return value**
W
wusongqing 已提交
1196 1197 1198
| Type| Description|
| -------- | -------- |
| [Scope](#scope8) | Intersection of this **Scope** and the given **Scope**.|
W
wusongqing 已提交
1199

W
wusongqing 已提交
1200
**Example**
1201
  ```js
W
wusongqing 已提交
1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213
  var tempLower = new Temperature(30);
  var tempUpper = new Temperature(40);
  var range = new util.Scope(tempLower, tempUpper);
  var tempMiDF = new Temperature(35);
  var tempMidS = new Temperature(39);
  var rangeFir = new util.Scope(tempMiDF, tempMidS);
  range.intersect(rangeFir );
  ```


### intersect<sup>8+</sup>

W
wusongqing 已提交
1214
intersect(lowerObj:ScopeType,upperObj:ScopeType):Scope
W
wusongqing 已提交
1215 1216 1217

Obtains the intersection of this **Scope** and the given lower and upper limits.

W
wusongqing 已提交
1218 1219 1220
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1221 1222 1223 1224
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| lowerObj | [ScopeType](#scopetype8) | Yes| Lower limit.|
| upperObj | [ScopeType](#scopetype8) | Yes| Upper limit.|
W
wusongqing 已提交
1225

W
wusongqing 已提交
1226
**Return value**
W
wusongqing 已提交
1227 1228 1229
| Type| Description|
| -------- | -------- |
| [Scope](#scope8) | Intersection of this **Scope** and the given lower and upper limits.|
W
wusongqing 已提交
1230

W
wusongqing 已提交
1231
**Example**
1232
  ```js
W
wusongqing 已提交
1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243
  var tempLower = new Temperature(30);
  var tempUpper = new Temperature(40);
  var tempMiDF = new Temperature(35);
  var tempMidS = new Temperature(39);
  var range = new util.Scope(tempLower, tempUpper);
  var result = range.intersect(tempMiDF, tempMidS);
  ```


### getUpper<sup>8+</sup>

X
xdmal 已提交
1244
getUpper(): ScopeType
W
wusongqing 已提交
1245 1246 1247

Obtains the upper limit of this **Scope**.

W
wusongqing 已提交
1248 1249 1250 1251
**System capability**: SystemCapability.Utils.Lang

**Return value**

W
wusongqing 已提交
1252 1253 1254
| Type| Description|
| -------- | -------- |
| [ScopeType](#scopetype8) | Upper limit of this **Scope**.|
W
wusongqing 已提交
1255

W
wusongqing 已提交
1256
**Example**
1257
  ```js
W
wusongqing 已提交
1258 1259 1260 1261 1262 1263 1264 1265 1266
  var tempLower = new Temperature(30);
  var tempUpper = new Temperature(40);
  var range = new util.Scope(tempLower, tempUpper);
  var result = range.getUpper();
  ```


### getLower<sup>8+</sup>

X
xdmal 已提交
1267
getLower(): ScopeType
W
wusongqing 已提交
1268 1269 1270

Obtains the lower limit of this **Scope**.

W
wusongqing 已提交
1271 1272 1273
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
1274 1275 1276
| Type| Description|
| -------- | -------- |
| [ScopeType](#scopetype8) | Lower limit of this **Scope**.|
W
wusongqing 已提交
1277

W
wusongqing 已提交
1278
**Example**
1279
  ```js
W
wusongqing 已提交
1280 1281 1282 1283 1284 1285 1286 1287 1288
  var tempLower = new Temperature(30);
  var tempUpper = new Temperature(40);
  var range = new util.Scope(tempLower, tempUpper);
  var result = range.getLower();
  ```


### expand<sup>8+</sup>

X
xdmal 已提交
1289
expand(lowerObj: ScopeType,upperObj: ScopeType): Scope
W
wusongqing 已提交
1290 1291 1292

Obtains the union set of this **Scope** and the given lower and upper limits.

W
wusongqing 已提交
1293 1294 1295
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1296 1297 1298 1299
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| lowerObj | [ScopeType](#scopetype8) | Yes| Lower limit.|
| upperObj | [ScopeType](#scopetype8) | Yes| Upper limit.|
W
wusongqing 已提交
1300

W
wusongqing 已提交
1301
**Return value**
W
wusongqing 已提交
1302 1303 1304
| Type| Description|
| -------- | -------- |
| [Scope](#scope8) | Union set of this **Scope** and the given lower and upper limits.|
W
wusongqing 已提交
1305

W
wusongqing 已提交
1306
**Example**
W
wusongqing 已提交
1307

1308
  ```js
W
wusongqing 已提交
1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319
  var tempLower = new Temperature(30);
  var tempUpper = new Temperature(40);
  var tempMiDF = new Temperature(35);
  var tempMidS = new Temperature(39);
  var range = new util.Scope(tempLower, tempUpper);
  var result = range.expand(tempMiDF, tempMidS);
  ```


### expand<sup>8+</sup>

W
wusongqing 已提交
1320
expand(range: Scope): Scope
W
wusongqing 已提交
1321 1322 1323

Obtains the union set of this **Scope** and the given **Scope**.

W
wusongqing 已提交
1324 1325 1326
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1327 1328 1329
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| range | [Scope](#scope8) | Yes| **Scope** specified.|
W
wusongqing 已提交
1330

W
wusongqing 已提交
1331
**Return value**
W
wusongqing 已提交
1332 1333 1334
| Type| Description|
| -------- | -------- |
| [Scope](#scope8) | Union set of this **Scope** and the given **Scope**.|
W
wusongqing 已提交
1335

W
wusongqing 已提交
1336
**Example**
1337
  ```js
W
wusongqing 已提交
1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349
  var tempLower = new Temperature(30);
  var tempUpper = new Temperature(40);
  var tempMiDF = new Temperature(35);
  var tempMidS = new Temperature(39);
  var range = new util.Scope(tempLower, tempUpper);
  var rangeFir = new util.Scope(tempMiDF, tempMidS);
  var result = range.expand(rangeFir);
  ```


### expand<sup>8+</sup>

X
xdmal 已提交
1350
expand(value: ScopeType): Scope
W
wusongqing 已提交
1351 1352 1353

Obtains the union set of this **Scope** and the given value.

W
wusongqing 已提交
1354 1355 1356
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1357 1358 1359
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | [ScopeType](#scopetype8) | Yes| Value specified.|
W
wusongqing 已提交
1360

W
wusongqing 已提交
1361
**Return value**
W
wusongqing 已提交
1362 1363 1364
| Type| Description|
| -------- | -------- |
| [Scope](#scope8) | Union set of this **Scope** and the given value.|
Z
zengyawen 已提交
1365

W
wusongqing 已提交
1366
**Example**
1367
  ```js
W
wusongqing 已提交
1368 1369 1370 1371 1372 1373
  var tempLower = new Temperature(30);
  var tempUpper = new Temperature(40);
  var tempMiDF = new Temperature(35);
  var range = new util.Scope(tempLower, tempUpper);
  var result = range.expand(tempMiDF);
  ```
Z
zengyawen 已提交
1374 1375


W
wusongqing 已提交
1376
### contains<sup>8+</sup>
Z
zengyawen 已提交
1377

X
xdmal 已提交
1378
contains(value: ScopeType): boolean
Z
zengyawen 已提交
1379

W
wusongqing 已提交
1380
Checks whether a value is within this **Scope**.
Z
zengyawen 已提交
1381

W
wusongqing 已提交
1382 1383 1384
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1385 1386 1387
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | [ScopeType](#scopetype8) | Yes| Value specified.|
Z
zengyawen 已提交
1388

W
wusongqing 已提交
1389
**Return value**
W
wusongqing 已提交
1390 1391 1392
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the value is within this **Scope**; returns **false** otherwise.|
W
wusongqing 已提交
1393

W
wusongqing 已提交
1394
**Example**
1395
  ```js
W
wusongqing 已提交
1396 1397 1398 1399 1400 1401 1402 1403 1404 1405
  var tempLower = new Temperature(30);
  var tempUpper = new Temperature(40);
  var tempMiDF = new Temperature(35);
  var range = new util.Scope(tempLower, tempUpper);
  range.contains(tempMiDF);
  ```


### contains<sup>8+</sup>

X
xdmal 已提交
1406
contains(range: Scope): boolean
W
wusongqing 已提交
1407 1408 1409

Checks whether a range is within this **Scope**.

W
wusongqing 已提交
1410 1411 1412
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1413 1414 1415
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| range | [Scope](#scope8) | Yes| **Scope** specified.|
W
wusongqing 已提交
1416

W
wusongqing 已提交
1417
**Return value**
W
wusongqing 已提交
1418 1419 1420
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the range is within this **Scope**; returns **false** otherwise.|
W
wusongqing 已提交
1421

W
wusongqing 已提交
1422
**Example**
1423
  ```js
W
wusongqing 已提交
1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435
  var tempLower = new Temperature(30);
  var tempUpper = new Temperature(40);
  var range = new util.Scope(tempLower, tempUpper);
  var tempLess = new Temperature(20);
  var tempMore = new Temperature(45);
  var rangeSec = new util.Scope(tempLess, tempMore);
  var result = range.contains(rangeSec);
  ```


### clamp<sup>8+</sup>

X
xdmal 已提交
1436
clamp(value: ScopeType): ScopeType
W
wusongqing 已提交
1437 1438 1439

Limits a value to this **Scope**.

W
wusongqing 已提交
1440 1441 1442
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1443 1444 1445
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | [ScopeType](#scopetype8) | Yes| Value specified.|
W
wusongqing 已提交
1446

W
wusongqing 已提交
1447
**Return value**
W
wusongqing 已提交
1448 1449 1450
| Type| Description|
| -------- | -------- |
| [ScopeType](#scopetype8) | Returns **lowerObj** if the specified value is less than the lower limit; returns **upperObj** if the specified value is greater than the upper limit; returns the specified value if it is within this **Scope**.|
W
wusongqing 已提交
1451

W
wusongqing 已提交
1452
**Example**
1453
  ```js
W
wusongqing 已提交
1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470
  var tempLower = new Temperature(30);
  var tempUpper = new Temperature(40);
  var tempMiDF = new Temperature(35);
  var range = new util.Scope(tempLower, tempUpper);
  var result = range.clamp(tempMiDF);
  ```


## Base64<sup>8+</sup>


### constructor<sup>8+</sup>

constructor()

A constructor used to create a **Base64** object.

W
wusongqing 已提交
1471 1472 1473
**System capability**: SystemCapability.Utils.Lang

**Example**
1474
  ```js
W
wusongqing 已提交
1475 1476 1477 1478 1479 1480
  var base64 = new  util.Base64();
  ```


### encodeSync<sup>8+</sup>

X
xdmal 已提交
1481
encodeSync(src: Uint8Array): Uint8Array
Z
zengyawen 已提交
1482 1483 1484

Encodes the input content.

W
wusongqing 已提交
1485 1486 1487
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1488 1489 1490
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| src | Uint8Array | Yes| Uint8Array to encode.|
W
wusongqing 已提交
1491

W
wusongqing 已提交
1492
**Return value**
W
wusongqing 已提交
1493 1494 1495
| Type| Description|
| -------- | -------- |
| Uint8Array | Uint8Array encoded.|
W
wusongqing 已提交
1496

W
wusongqing 已提交
1497
**Example**
1498
  ```js
W
wusongqing 已提交
1499 1500 1501 1502 1503 1504 1505 1506
  var that = new util.Base64();
  var array = new Uint8Array([115,49,51]);
  var result = that.encodeSync(array);
  ```


### encodeToStringSync<sup>8+</sup>

X
xdmal 已提交
1507
encodeToStringSync(src: Uint8Array): string
W
wusongqing 已提交
1508 1509 1510

Encodes the input content.

W
wusongqing 已提交
1511 1512 1513
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1514 1515 1516
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| src | Uint8Array | Yes| Uint8Array to encode.|
W
wusongqing 已提交
1517

W
wusongqing 已提交
1518
**Return value**
W
wusongqing 已提交
1519 1520 1521
| Type| Description|
| -------- | -------- |
| string | String encoded from the Uint8Array.|
W
wusongqing 已提交
1522

W
wusongqing 已提交
1523
**Example**
1524
  ```js
W
wusongqing 已提交
1525 1526 1527 1528 1529 1530 1531 1532
  var that = new util.Base64();
  var array = new Uint8Array([115,49,51]);
  var result = that.encodeToStringSync(array);
  ```


### decodeSync<sup>8+</sup>

W
wusongqing 已提交
1533
decodeSync(src: Uint8Array | string): Uint8Array
Z
zengyawen 已提交
1534 1535 1536

Decodes the input content.

W
wusongqing 已提交
1537 1538 1539
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1540 1541 1542
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| src | Uint8Array \| string | Yes| Uint8Array or string to decode.|
W
wusongqing 已提交
1543

W
wusongqing 已提交
1544
**Return value**
W
wusongqing 已提交
1545 1546 1547
| Type| Description|
| -------- | -------- |
| Uint8Array | Uint8Array decoded.|
W
wusongqing 已提交
1548

W
wusongqing 已提交
1549
**Example**
1550
  ```js
W
wusongqing 已提交
1551 1552 1553 1554 1555 1556 1557 1558
  var that = new util.Base64();
  var buff = 'czEz';
  var result = that.decodeSync(buff);
  ```


### encode<sup>8+</sup>

X
xdmal 已提交
1559
encode(src: Uint8Array): Promise&lt;Uint8Array&gt;
Z
zengyawen 已提交
1560 1561 1562

Encodes the input content asynchronously.

W
wusongqing 已提交
1563 1564 1565
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1566 1567 1568
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| src | Uint8Array | Yes| Uint8Array to encode asynchronously.|
W
wusongqing 已提交
1569

W
wusongqing 已提交
1570
**Return value**
W
wusongqing 已提交
1571 1572 1573
| Type| Description|
| -------- | -------- |
| Promise&lt;Uint8Array&gt; | Uint8Array obtained after asynchronous encoding.|
W
wusongqing 已提交
1574

W
wusongqing 已提交
1575
**Example**
1576
  ```js
W
wusongqing 已提交
1577 1578 1579 1580 1581
  var that = new util.Base64();
  var array = new Uint8Array([115,49,51]);
  var rarray = new Uint8Array([99,122,69,122]);
  that.encode(array).then(val=>{    
      for (var i = 0; i < rarray.length; i++) {        
S
shikai-123 已提交
1582
          console.log(val[i].toString())
W
wusongqing 已提交
1583 1584 1585 1586 1587 1588 1589
      }
  })
  ```


### encodeToString<sup>8+</sup>

X
xdmal 已提交
1590
encodeToString(src: Uint8Array): Promise&lt;string&gt;
W
wusongqing 已提交
1591 1592 1593

Encodes the input content asynchronously.

W
wusongqing 已提交
1594 1595 1596
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1597 1598 1599
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| src | Uint8Array | Yes| Uint8Array to encode asynchronously.|
W
wusongqing 已提交
1600

W
wusongqing 已提交
1601
**Return value**
W
wusongqing 已提交
1602 1603 1604
| Type| Description|
| -------- | -------- |
| Promise&lt;string&gt; | String obtained after asynchronous encoding.|
W
wusongqing 已提交
1605

W
wusongqing 已提交
1606
**Example**
1607
  ```js
W
wusongqing 已提交
1608 1609 1610 1611 1612 1613 1614 1615 1616 1617
  var that = new util.Base64();
  var array = new Uint8Array([115,49,51]);
  that.encodeToString(array).then(val=>{    
      console.log(val)
  })
  ```


### decode<sup>8+</sup>

W
wusongqing 已提交
1618
decode(src: Uint8Array | string): Promise&lt;Uint8Array&gt;
Z
zengyawen 已提交
1619 1620 1621

Decodes the input content asynchronously.

W
wusongqing 已提交
1622 1623 1624
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1625 1626 1627
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| src | Uint8Array \| string | Yes| Uint8Array or string to decode asynchronously.|
W
wusongqing 已提交
1628

W
wusongqing 已提交
1629
**Return value**
W
wusongqing 已提交
1630 1631 1632
| Type| Description|
| -------- | -------- |
| Promise&lt;Uint8Array&gt; | Uint8Array obtained after asynchronous decoding.|
W
wusongqing 已提交
1633

W
wusongqing 已提交
1634
**Example**
1635
  ```js
W
wusongqing 已提交
1636 1637 1638 1639 1640
  var that = new util.Base64();
  var array = new Uint8Array([99,122,69,122]);
  var rarray = new Uint8Array([115,49,51]);
  that.decode(array).then(val=>{    
      for (var i = 0; i < rarray.length; i++) {        
S
shikai-123 已提交
1641
          console.log(val[i].toString())
W
wusongqing 已提交
1642 1643 1644 1645 1646
      }
  })
  ```


1647
## types<sup>8+</sup>
W
wusongqing 已提交
1648 1649 1650 1651 1652 1653


### constructor<sup>8+</sup>

constructor()

W
wusongqing 已提交
1654
A constructor used to create a **Types** object.
W
wusongqing 已提交
1655

W
wusongqing 已提交
1656 1657 1658
**System capability**: SystemCapability.Utils.Lang

**Example**
1659
  ```js
1660
  var type = new util.types();
W
wusongqing 已提交
1661 1662 1663 1664 1665
  ```


### isAnyArrayBuffer<sup>8+</sup>

X
xdmal 已提交
1666
isAnyArrayBuffer(value: Object): boolean
W
wusongqing 已提交
1667 1668 1669

Checks whether the input value is of the **ArrayBuffer** type.

W
wusongqing 已提交
1670 1671 1672
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1673 1674 1675
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
1676

W
wusongqing 已提交
1677
**Return value**
W
wusongqing 已提交
1678 1679 1680
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise.|
W
wusongqing 已提交
1681

W
wusongqing 已提交
1682
**Example**
1683
  ```js
1684
  var that = new util.types();
S
shikai-123 已提交
1685
  var result = that.isAnyArrayBuffer(new ArrayBuffer(0));
W
wusongqing 已提交
1686 1687 1688 1689 1690
  ```


### isArrayBufferView<sup>8+</sup>

X
xdmal 已提交
1691
isArrayBufferView(value: Object): boolean
W
wusongqing 已提交
1692 1693 1694 1695 1696

Checks whether the input value is of the **ArrayBufferView** type.

**ArrayBufferView** is a helper type representing any of the following: **Int8Array**, **Int16Array**, **Int32Array**, **Uint8Array**, **Uint8ClampedArray**, **Uint32Array**, **Float32Array**, **Float64Array**, and **DataView**.

W
wusongqing 已提交
1697 1698 1699
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1700 1701 1702
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
1703

W
wusongqing 已提交
1704
**Return value**
W
wusongqing 已提交
1705 1706 1707
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **ArrayBufferView** type; returns **false** otherwise.|
W
wusongqing 已提交
1708

W
wusongqing 已提交
1709
**Example**
1710
  ```js
1711
  var that = new util.types();
W
wusongqing 已提交
1712 1713 1714 1715 1716 1717
  var result = that.isArrayBufferView(new Int8Array([]));
  ```


### isArgumentsObject<sup>8+</sup>

X
xdmal 已提交
1718
isArgumentsObject(value: Object): boolean
W
wusongqing 已提交
1719 1720 1721

Checks whether the input value is of the **arguments** type.

W
wusongqing 已提交
1722 1723 1724
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1725 1726 1727
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
1728

W
wusongqing 已提交
1729
**Return value**
W
wusongqing 已提交
1730 1731 1732
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **arguments** type; returns **false** otherwise.|
W
wusongqing 已提交
1733

W
wusongqing 已提交
1734
**Example**
1735
  ```js
1736
  var that = new util.types();
W
wusongqing 已提交
1737 1738 1739 1740 1741 1742 1743 1744 1745
  function foo() {
      var result = that.isArgumentsObject(arguments);
  }
  var f = foo();
  ```


### isArrayBuffer<sup>8+</sup>

X
xdmal 已提交
1746
isArrayBuffer(value: Object): boolean
W
wusongqing 已提交
1747 1748 1749

Checks whether the input value is of the **ArrayBuffer** type.

W
wusongqing 已提交
1750 1751 1752
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1753 1754 1755
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
1756

W
wusongqing 已提交
1757
**Return value**
W
wusongqing 已提交
1758 1759 1760
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise.|
W
wusongqing 已提交
1761

W
wusongqing 已提交
1762
**Example**
1763
  ```js
1764
  var that = new util.types();
S
shikai-123 已提交
1765
  var result = that.isArrayBuffer(new ArrayBuffer(0));
W
wusongqing 已提交
1766 1767 1768 1769 1770
  ```


### isAsyncFunction<sup>8+</sup>

X
xdmal 已提交
1771
isAsyncFunction(value: Object): boolean
Z
zengyawen 已提交
1772 1773 1774

Checks whether the input value is an asynchronous function.

W
wusongqing 已提交
1775 1776 1777
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1778 1779 1780
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
1781

W
wusongqing 已提交
1782
**Return value**
W
wusongqing 已提交
1783 1784 1785
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is an asynchronous function; returns **false** otherwise.|
W
wusongqing 已提交
1786

W
wusongqing 已提交
1787
**Example**
1788
  ```js
1789
  var that = new util.types();
W
wusongqing 已提交
1790 1791 1792 1793 1794 1795
  var result = that.isAsyncFunction(async function foo() {});
  ```


### isBooleanObject<sup>8+</sup>

X
xdmal 已提交
1796
isBooleanObject(value: Object): boolean
W
wusongqing 已提交
1797 1798 1799

Checks whether the input value is of the **Boolean** type.

W
wusongqing 已提交
1800 1801 1802
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1803 1804 1805
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
1806

W
wusongqing 已提交
1807
**Return value**
W
wusongqing 已提交
1808 1809 1810
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Boolean** type; returns **false** otherwise.|
W
wusongqing 已提交
1811

W
wusongqing 已提交
1812
**Example**
1813
  ```js
1814
  var that = new util.types();
W
wusongqing 已提交
1815 1816 1817 1818 1819 1820
  var result = that.isBooleanObject(new Boolean(true));
  ```


### isBoxedPrimitive<sup>8+</sup>

X
xdmal 已提交
1821
isBoxedPrimitive(value: Object): boolean
W
wusongqing 已提交
1822 1823 1824

Checks whether the input value is of the **Boolean**, **Number**, **String**, or **Symbol** type.

W
wusongqing 已提交
1825 1826 1827
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1828 1829 1830
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
1831

W
wusongqing 已提交
1832
**Return value**
W
wusongqing 已提交
1833 1834 1835
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Boolean**, **Number**, **String**, or **Symbol** type; returns **false** otherwise.|
W
wusongqing 已提交
1836

W
wusongqing 已提交
1837
**Example**
1838
  ```js
1839
  var that = new util.types();
W
wusongqing 已提交
1840 1841 1842 1843 1844 1845
  var result = that.isBoxedPrimitive(new Boolean(false));
  ```


### isDataView<sup>8+</sup>

X
xdmal 已提交
1846
isDataView(value: Object): boolean
W
wusongqing 已提交
1847 1848 1849

Checks whether the input value is of the **DataView** type.

W
wusongqing 已提交
1850 1851 1852
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1853 1854 1855
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
1856

W
wusongqing 已提交
1857
**Return value**
W
wusongqing 已提交
1858 1859 1860
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **DataView** type; returns **false** otherwise.|
W
wusongqing 已提交
1861

W
wusongqing 已提交
1862
**Example**
1863
  ```js
1864
  var that = new util.types();
W
wusongqing 已提交
1865 1866 1867 1868 1869 1870 1871
  const ab = new ArrayBuffer(20);
  var result = that.isDataView(new DataView(ab));
  ```


### isDate<sup>8+</sup>

X
xdmal 已提交
1872
isDate(value: Object): boolean
W
wusongqing 已提交
1873 1874 1875

Checks whether the input value is of the **Date** type.

W
wusongqing 已提交
1876 1877 1878
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1879 1880 1881
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
1882

W
wusongqing 已提交
1883
**Return value**
W
wusongqing 已提交
1884 1885 1886
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Date** type; returns **false** otherwise.|
W
wusongqing 已提交
1887

W
wusongqing 已提交
1888
**Example**
1889
  ```js
1890
  var that = new util.types();
W
wusongqing 已提交
1891 1892 1893 1894 1895 1896
  var result = that.isDate(new Date());
  ```


### isExternal<sup>8+</sup>

X
xdmal 已提交
1897
isExternal(value: Object): boolean
W
wusongqing 已提交
1898 1899 1900

Checks whether the input value is of the **native external** type.

W
wusongqing 已提交
1901 1902 1903
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1904 1905 1906
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
1907

W
wusongqing 已提交
1908
**Return value**
W
wusongqing 已提交
1909 1910 1911
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **native external** type; returns **false** otherwise.|
W
wusongqing 已提交
1912

W
wusongqing 已提交
1913
**Example**
1914
  ```js
1915
  var that = new util.types();
W
wusongqing 已提交
1916 1917 1918 1919 1920 1921 1922
  const data = util.createExternalType();
  var result = that.isExternal(data);
  ```


### isFloat32Array<sup>8+</sup>

X
xdmal 已提交
1923
isFloat32Array(value: Object): boolean
W
wusongqing 已提交
1924 1925 1926

Checks whether the input value is of the **Float32Array** type.

W
wusongqing 已提交
1927 1928 1929
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1930 1931 1932
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
1933

W
wusongqing 已提交
1934
**Return value**
W
wusongqing 已提交
1935 1936 1937
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Float32Array** type; returns **false** otherwise.|
W
wusongqing 已提交
1938

W
wusongqing 已提交
1939
**Example**
1940
  ```js
1941
  var that = new util.types();
W
wusongqing 已提交
1942 1943 1944 1945 1946 1947
  var result = that.isFloat32Array(new Float32Array());
  ```


### isFloat64Array<sup>8+</sup>

X
xdmal 已提交
1948
isFloat64Array(value: Object): boolean
W
wusongqing 已提交
1949 1950 1951

Checks whether the input value is of the **Float64Array** type.

W
wusongqing 已提交
1952 1953 1954
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1955 1956 1957
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
1958

W
wusongqing 已提交
1959
**Return value**
W
wusongqing 已提交
1960 1961 1962
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Float64Array** type; returns **false** otherwise.|
W
wusongqing 已提交
1963

W
wusongqing 已提交
1964
**Example**
1965
  ```js
1966
  var that = new util.types();
W
wusongqing 已提交
1967 1968 1969 1970 1971 1972
  var result = that.isFloat64Array(new Float64Array());
  ```


### isGeneratorFunction<sup>8+</sup>

X
xdmal 已提交
1973
isGeneratorFunction(value: Object): boolean
Z
zengyawen 已提交
1974 1975 1976

Checks whether the input value is a generator function.

W
wusongqing 已提交
1977 1978 1979
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1980 1981 1982
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
1983

W
wusongqing 已提交
1984
**Return value**
W
wusongqing 已提交
1985 1986 1987
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is a generator function; returns **false** otherwise.|
W
wusongqing 已提交
1988

W
wusongqing 已提交
1989
**Example**
1990
  ```js
1991
  var that = new util.types();
W
wusongqing 已提交
1992 1993 1994 1995 1996 1997
  var result = that.isGeneratorFunction(function* foo() {});
  ```


### isGeneratorObject<sup>8+</sup>

X
xdmal 已提交
1998
isGeneratorObject(value: Object): boolean
Z
zengyawen 已提交
1999 2000 2001

Checks whether the input value is a generator object.

W
wusongqing 已提交
2002 2003 2004
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2005 2006 2007
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2008

W
wusongqing 已提交
2009
**Return value**
W
wusongqing 已提交
2010 2011 2012
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is a generator object; returns **false** otherwise.|
W
wusongqing 已提交
2013

W
wusongqing 已提交
2014
**Example**
2015
  ```js
2016
  var that = new util.types();
W
wusongqing 已提交
2017 2018 2019 2020 2021 2022 2023 2024
  function* foo() {}
  const generator = foo();
  var result = that.isGeneratorObject(generator);
  ```


### isInt8Array<sup>8+</sup>

X
xdmal 已提交
2025
isInt8Array(value: Object): boolean
W
wusongqing 已提交
2026 2027 2028

Checks whether the input value is of the **Int8Array** type.

W
wusongqing 已提交
2029 2030 2031
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2032 2033 2034
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2035

W
wusongqing 已提交
2036
**Return value**
W
wusongqing 已提交
2037 2038 2039
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Int8Array** type; returns **false** otherwise.|
W
wusongqing 已提交
2040

W
wusongqing 已提交
2041
**Example**
2042
  ```js
2043
  var that = new util.types();
W
wusongqing 已提交
2044 2045 2046 2047 2048 2049
  var result = that.isInt8Array(new Int8Array([]));
  ```


### isInt16Array<sup>8+</sup>

X
xdmal 已提交
2050
isInt16Array(value: Object): boolean
W
wusongqing 已提交
2051 2052 2053

Checks whether the input value is of the **Int16Array** type.

W
wusongqing 已提交
2054 2055 2056
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2057 2058 2059
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2060

W
wusongqing 已提交
2061
**Return value**
W
wusongqing 已提交
2062 2063 2064
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Int16Array** type; returns **false** otherwise.|
W
wusongqing 已提交
2065

W
wusongqing 已提交
2066
**Example**
2067
  ```js
2068
  var that = new util.types();
W
wusongqing 已提交
2069 2070 2071 2072 2073 2074
  var result = that.isInt16Array(new Int16Array([]));
  ```


### isInt32Array<sup>8+</sup>

X
xdmal 已提交
2075
isInt32Array(value: Object): boolean
W
wusongqing 已提交
2076 2077 2078

Checks whether the input value is of the **Int32Array** type.

W
wusongqing 已提交
2079 2080 2081
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2082 2083 2084
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2085

W
wusongqing 已提交
2086
**Return value**
W
wusongqing 已提交
2087 2088 2089
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Int32Array** type; returns **false** otherwise.|
W
wusongqing 已提交
2090

W
wusongqing 已提交
2091
**Example**
2092
  ```js
2093
  var that = new util.types();
W
wusongqing 已提交
2094 2095 2096 2097 2098 2099
  var result = that.isInt32Array(new Int32Array([]));
  ```


### isMap<sup>8+</sup>

X
xdmal 已提交
2100
isMap(value: Object): boolean
W
wusongqing 已提交
2101 2102 2103

Checks whether the input value is of the **Map** type.

W
wusongqing 已提交
2104 2105 2106
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2107 2108 2109
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2110

W
wusongqing 已提交
2111
**Return value**
W
wusongqing 已提交
2112 2113 2114
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Map** type; returns **false** otherwise.|
W
wusongqing 已提交
2115

W
wusongqing 已提交
2116
**Example**
2117
  ```js
2118
  var that = new util.types();
W
wusongqing 已提交
2119 2120 2121 2122 2123 2124
  var result = that.isMap(new Map());
  ```


### isMapIterator<sup>8+</sup>

X
xdmal 已提交
2125
isMapIterator(value: Object): boolean
W
wusongqing 已提交
2126 2127 2128

Checks whether the input value is of the **MapIterator** type.

W
wusongqing 已提交
2129 2130 2131
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2132 2133 2134
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2135

W
wusongqing 已提交
2136
**Return value**
W
wusongqing 已提交
2137 2138 2139
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **MapIterator** type; returns **false** otherwise.|
W
wusongqing 已提交
2140

W
wusongqing 已提交
2141
**Example**
2142
  ```js
2143
  var that = new util.types();
W
wusongqing 已提交
2144 2145 2146 2147 2148 2149 2150
  const map = new Map();
  var result = that.isMapIterator(map.keys());
  ```


### isNativeError<sup>8+</sup>

X
xdmal 已提交
2151
isNativeError(value: Object): boolean
W
wusongqing 已提交
2152 2153 2154

Checks whether the input value is of the **Error** type.

W
wusongqing 已提交
2155 2156 2157
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2158 2159 2160
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2161

W
wusongqing 已提交
2162
**Return value**
W
wusongqing 已提交
2163 2164 2165
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Error** type; returns **false** otherwise.|
W
wusongqing 已提交
2166

W
wusongqing 已提交
2167
**Example**
2168
  ```js
2169
  var that = new util.types();
W
wusongqing 已提交
2170 2171 2172 2173 2174 2175
  var result = that.isNativeError(new TypeError());
  ```


### isNumberObject<sup>8+</sup>

X
xdmal 已提交
2176
isNumberObject(value: Object): boolean
Z
zengyawen 已提交
2177 2178 2179

Checks whether the input value is a number object.

W
wusongqing 已提交
2180 2181 2182
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2183 2184 2185
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2186

W
wusongqing 已提交
2187
**Return value**
W
wusongqing 已提交
2188 2189 2190
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is a number object; returns **false** otherwise.|
W
wusongqing 已提交
2191

W
wusongqing 已提交
2192
**Example**
2193
  ```js
2194
  var that = new util.types();
W
wusongqing 已提交
2195 2196 2197 2198 2199 2200
  var result = that.isNumberObject(new Number(0));
  ```


### isPromise<sup>8+</sup>

X
xdmal 已提交
2201
isPromise(value: Object): boolean
Z
zengyawen 已提交
2202 2203 2204

Checks whether the input value is a promise.

W
wusongqing 已提交
2205 2206 2207
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2208 2209 2210
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2211

W
wusongqing 已提交
2212
**Return value**
W
wusongqing 已提交
2213 2214 2215
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is a promise; returns **false** otherwise.|
W
wusongqing 已提交
2216

W
wusongqing 已提交
2217
**Example**
2218
  ```js
2219
  var that = new util.types();
W
wusongqing 已提交
2220 2221 2222 2223 2224 2225
  var result = that.isPromise(Promise.resolve(1));
  ```


### isProxy<sup>8+</sup>

X
xdmal 已提交
2226
isProxy(value: Object): boolean
Z
zengyawen 已提交
2227 2228 2229

Checks whether the input value is a proxy.

W
wusongqing 已提交
2230 2231 2232
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2233 2234 2235
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2236

W
wusongqing 已提交
2237
**Return value**
W
wusongqing 已提交
2238 2239 2240
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is a proxy; returns **false** otherwise.|
W
wusongqing 已提交
2241

W
wusongqing 已提交
2242
**Example**
2243
  ```js
2244
  var that = new util.types();
W
wusongqing 已提交
2245 2246 2247 2248 2249 2250 2251 2252
  const target = {};
  const proxy = new Proxy(target, {});
  var result = that.isProxy(proxy);
  ```


### isRegExp<sup>8+</sup>

X
xdmal 已提交
2253
isRegExp(value: Object): boolean
W
wusongqing 已提交
2254 2255 2256

Checks whether the input value is of the **RegExp** type.

W
wusongqing 已提交
2257 2258 2259
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2260 2261 2262
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2263

W
wusongqing 已提交
2264
**Return value**
W
wusongqing 已提交
2265 2266 2267
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **RegExp** type; returns **false** otherwise.|
W
wusongqing 已提交
2268

W
wusongqing 已提交
2269
**Example**
2270
  ```js
2271
  var that = new util.types();
W
wusongqing 已提交
2272 2273 2274 2275 2276 2277
  var result = that.isRegExp(new RegExp('abc'));
  ```


### isSet<sup>8+</sup>

X
xdmal 已提交
2278
isSet(value: Object): boolean
W
wusongqing 已提交
2279 2280 2281

Checks whether the input value is of the **Set** type.

W
wusongqing 已提交
2282 2283 2284
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2285 2286 2287
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2288

W
wusongqing 已提交
2289
**Return value**
W
wusongqing 已提交
2290 2291 2292
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Set** type; returns **false** otherwise.|
W
wusongqing 已提交
2293

W
wusongqing 已提交
2294
**Example**
2295
  ```js
2296
  var that = new util.types();
W
wusongqing 已提交
2297 2298 2299 2300 2301 2302
  var result = that.isSet(new Set());
  ```


### isSetIterator<sup>8+</sup>

X
xdmal 已提交
2303
isSetIterator(value: Object): boolean
W
wusongqing 已提交
2304 2305 2306

Checks whether the input value is of the **SetIterator** type.

W
wusongqing 已提交
2307 2308 2309
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2310 2311 2312
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2313

W
wusongqing 已提交
2314
**Return value**
W
wusongqing 已提交
2315 2316 2317
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **SetIterator** type; returns **false** otherwise.|
W
wusongqing 已提交
2318

W
wusongqing 已提交
2319
**Example**
2320
  ```js
2321
  var that = new util.types();
W
wusongqing 已提交
2322 2323 2324 2325 2326 2327 2328
  const set = new Set();
  var result = that.isSetIterator(set.keys());
  ```


### isStringObject<sup>8+</sup>

X
xdmal 已提交
2329
isStringObject(value: Object): boolean
Z
zengyawen 已提交
2330 2331 2332

Checks whether the input value is a string object.

W
wusongqing 已提交
2333 2334 2335
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2336 2337 2338
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2339

W
wusongqing 已提交
2340
**Return value**
W
wusongqing 已提交
2341 2342 2343
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is a string object; returns **false** otherwise.|
W
wusongqing 已提交
2344

W
wusongqing 已提交
2345
**Example**
2346
  ```js
2347
  var that = new util.types();
W
wusongqing 已提交
2348 2349 2350 2351 2352 2353
  var result = that.isStringObject(new String('foo'));
  ```


### isSymbolObjec<sup>8+</sup>

X
xdmal 已提交
2354
isSymbolObject(value: Object): boolean
Z
zengyawen 已提交
2355 2356 2357

Checks whether the input value is a symbol object.

W
wusongqing 已提交
2358 2359 2360
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2361 2362 2363
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2364

W
wusongqing 已提交
2365
**Return value**
W
wusongqing 已提交
2366 2367 2368
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is a symbol object; returns **false** otherwise.|
W
wusongqing 已提交
2369

W
wusongqing 已提交
2370
**Example**
2371
  ```js
2372
  var that = new util.types();
W
wusongqing 已提交
2373 2374 2375 2376 2377 2378 2379
  const symbols = Symbol('foo');
  var result = that.isSymbolObject(Object(symbols));
  ```


### isTypedArray<sup>8+</sup>

X
xdmal 已提交
2380
isTypedArray(value: Object): boolean
W
wusongqing 已提交
2381 2382 2383 2384 2385

Checks whether the input value is of the **TypedArray** type.

**TypedArray** is a helper type representing any of the following: **Int8Array**, **Int16Array**, **Int32Array**, **Uint8Array**, **Uint8ClampedArray**, **Uint16Array**, **Uint32Array**, **Float32Array**, **Float64Array**, and **DataView**.

W
wusongqing 已提交
2386 2387 2388
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2389 2390 2391
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2392

W
wusongqing 已提交
2393
**Return value**
W
wusongqing 已提交
2394 2395 2396
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **TypedArray** type; returns **false** otherwise.|
W
wusongqing 已提交
2397

W
wusongqing 已提交
2398
**Example**
2399
  ```js
2400
  var that = new util.types();
W
wusongqing 已提交
2401 2402 2403 2404 2405 2406
  var result = that.isTypedArray(new Float64Array([]));
  ```


### isUint8Array<sup>8+</sup>

X
xdmal 已提交
2407
isUint8Array(value: Object): boolean
W
wusongqing 已提交
2408 2409 2410

Checks whether the input value is of the **Uint8Array** type.

W
wusongqing 已提交
2411 2412 2413
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2414 2415 2416
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2417

W
wusongqing 已提交
2418
**Return value**
W
wusongqing 已提交
2419 2420 2421
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Uint8Array** type; returns **false** otherwise.|
W
wusongqing 已提交
2422

W
wusongqing 已提交
2423
**Example**
2424
  ```js
2425
  var that = new util.types();
W
wusongqing 已提交
2426 2427 2428 2429 2430 2431
  var result = that.isUint8Array(new Uint8Array([]));
  ```


### isUint8ClampedArray<sup>8+</sup>

X
xdmal 已提交
2432
isUint8ClampedArray(value: Object): boolean
W
wusongqing 已提交
2433 2434 2435

Checks whether the input value is of the **Uint8ClampedArray** type.

W
wusongqing 已提交
2436 2437 2438
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2439 2440 2441
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2442

W
wusongqing 已提交
2443
**Return value**
W
wusongqing 已提交
2444 2445 2446
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Uint8ClampedArray** type; returns **false** otherwise.|
W
wusongqing 已提交
2447

W
wusongqing 已提交
2448
**Example**
2449
  ```js
2450
  var that = new util.types();
W
wusongqing 已提交
2451 2452 2453 2454 2455 2456
  var result = that.isUint8ClampedArray(new Uint8ClampedArray([]));
  ```


### isUint16Array<sup>8+</sup>

X
xdmal 已提交
2457
isUint16Array(value: Object): boolean
W
wusongqing 已提交
2458 2459 2460

Checks whether the input value is of the **Uint16Array** type.

W
wusongqing 已提交
2461 2462 2463
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2464 2465 2466
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2467

W
wusongqing 已提交
2468
**Return value**
W
wusongqing 已提交
2469 2470 2471
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Uint16Array** type; returns **false** otherwise.|
W
wusongqing 已提交
2472

W
wusongqing 已提交
2473
**Example**
2474
  ```js
2475
  var that = new util.types();
W
wusongqing 已提交
2476 2477 2478 2479 2480 2481
  var result = that.isUint16Array(new Uint16Array([]));
  ```


### isUint32Array<sup>8+</sup>

X
xdmal 已提交
2482
isUint32Array(value: Object): boolean
W
wusongqing 已提交
2483 2484 2485

Checks whether the input value is of the **Uint32Array** type.

W
wusongqing 已提交
2486 2487 2488
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2489 2490 2491
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2492

W
wusongqing 已提交
2493
**Return value**
W
wusongqing 已提交
2494 2495 2496
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Uint32Array** type; returns **false** otherwise.|
W
wusongqing 已提交
2497

W
wusongqing 已提交
2498
**Example**
2499
  ```js
2500
  var that = new util.types();
W
wusongqing 已提交
2501 2502 2503 2504 2505 2506
  var result = that.isUint32Array(new Uint32Array([]));
  ```


### isWeakMap<sup>8+</sup>

X
xdmal 已提交
2507
isWeakMap(value: Object): boolean
W
wusongqing 已提交
2508 2509 2510

Checks whether the input value is of the **WeakMap** type.

W
wusongqing 已提交
2511 2512 2513
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2514 2515 2516
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2517

W
wusongqing 已提交
2518
**Return value**
W
wusongqing 已提交
2519 2520 2521
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **WeakMap** type; returns **false** otherwise.|
W
wusongqing 已提交
2522

W
wusongqing 已提交
2523
**Example**
2524
  ```js
2525
  var that = new util.types();
W
wusongqing 已提交
2526 2527 2528 2529 2530 2531
  var result = that.isWeakMap(new WeakMap());
  ```


### isWeakSet<sup>8+</sup>

X
xdmal 已提交
2532
isWeakSet(value: Object): boolean
W
wusongqing 已提交
2533 2534 2535

Checks whether the input value is of the **WeakSet** type.

W
wusongqing 已提交
2536 2537 2538
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2539 2540 2541
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2542

W
wusongqing 已提交
2543
**Return value**
W
wusongqing 已提交
2544 2545 2546
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **WeakSet** type; returns **false** otherwise.|
Z
zengyawen 已提交
2547

W
wusongqing 已提交
2548
**Example**
2549
  ```js
2550
  var that = new util.types();
W
wusongqing 已提交
2551
  var result = that.isWeakSet(new WeakSet());
W
wusongqing 已提交
2552
  ```