js-apis-util.md 60.9 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
  var errnum = 10; // 10 is a system error code.
W
wusongqing 已提交
65 66 67 68 69 70 71 72 73 74
  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

W
wusongqing 已提交
107 108 109
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use **[util.promisify9+](#utilpromisify9)** instead.
S
shikai-123 已提交
110

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

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

**Parameters**
W
wusongqing 已提交
116

W
wusongqing 已提交
117 118 119
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| original | Function | Yes| Asynchronous function.|
W
wusongqing 已提交
120

W
wusongqing 已提交
121
**Return value**
W
wusongqing 已提交
122 123 124
| 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 已提交
125

S
shikai-123 已提交
126
## util.promisify<sup>9+</sup>
S
shikai-123 已提交
127

S
shikai-123 已提交
128
promisify(original: (err: Object, value: Object) =&gt; void): Function
S
shikai-123 已提交
129

W
wusongqing 已提交
130
Processes an asynchronous function and returns a promise.
S
shikai-123 已提交
131 132 133 134 135 136 137 138 139 140 141

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

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

**Return value**
| Type| Description|
| -------- | -------- |
W
wusongqing 已提交
142
| Function | Function in the error-first style (that is, **(err, value) =>...** is called as the last parameter) and the promise.|
S
shikai-123 已提交
143

W
wusongqing 已提交
144
**Example**
145
  ```js
S
shikai-123 已提交
146 147 148 149 150 151
  function aysnFun(str1, str2) {
    if (typeof str1 === 'object' && typeof str2 === 'object') {
      return str2
    } else {
      return str1
    }
W
wusongqing 已提交
152
  }
S
shikai-123 已提交
153
  let newPromiseObj = util.promisify(aysnFun);
S
shikai-123 已提交
154 155
  newPromiseObj({ err: "type error" }, {value:'HelloWorld'}).then(res => {
    console.log(res);
W
wusongqing 已提交
156 157 158 159 160 161 162
  })
  ```

## TextDecoder

### Attributes

W
wusongqing 已提交
163 164
**System capability**: SystemCapability.Utils.Lang

W
wusongqing 已提交
165 166 167 168 169
| 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 已提交
170 171 172 173


### constructor

S
shikai-123 已提交
174
constructor(encoding?: string, options?: { fatal?: boolean; ignoreBOM?: boolean },)
W
wusongqing 已提交
175 176 177

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

W
wusongqing 已提交
178 179 180
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
181 182 183 184
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| encoding | string | No| Encoding format.|
| options | Object | No| Encoding-related options, which include **fatal** and **ignoreBOM**.|
W
wusongqing 已提交
185 186

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

W
wusongqing 已提交
188 189 190 191
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| fatal | boolean | No| Whether to display fatal errors.|
| ignoreBOM | boolean | No| Whether to ignore the BOM.|
W
wusongqing 已提交
192

W
wusongqing 已提交
193
**Example**
194
  ```js
X
xdmal 已提交
195
  var textDecoder = new util.TextDecoder("utf-8",{ignoreBOM: true});
W
wusongqing 已提交
196 197 198 199 200
  ```


### decode

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

Z
zengyawen 已提交
203
Decodes the input content.
Z
zengyawen 已提交
204

W
wusongqing 已提交
205 206 207
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
208 209
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
W
wusongqing 已提交
210
| input | Uint8Array | Yes| Uint8Array to decode.|
W
wusongqing 已提交
211
| options | Object | No| Options related to decoding.|
W
wusongqing 已提交
212 213

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

W
wusongqing 已提交
215 216 217
| 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 已提交
218

W
wusongqing 已提交
219
**Return value**
W
wusongqing 已提交
220 221 222
| Type| Description|
| -------- | -------- |
| string | Data decoded.|
Z
zengyawen 已提交
223

W
wusongqing 已提交
224
**Example**
225
  ```js
X
xdmal 已提交
226
  var textDecoder = new util.TextDecoder("utf-8",{ignoreBOM: true});
W
wusongqing 已提交
227 228 229 230 231 232 233 234
  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 已提交
235
  var retStr = textDecoder.decode( result , {stream: false});
W
wusongqing 已提交
236 237
  console.log("retStr = " + retStr);
  ```
Z
zengyawen 已提交
238 239


W
wusongqing 已提交
240
## TextEncoder
Z
zengyawen 已提交
241

W
wusongqing 已提交
242
### Attributes
Z
zengyawen 已提交
243

W
wusongqing 已提交
244 245
**System capability**: SystemCapability.Utils.Lang

W
wusongqing 已提交
246 247 248
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| encoding | string | Yes| No| Encoding format. The default format is **utf-8**.|
Z
zengyawen 已提交
249 250


W
wusongqing 已提交
251
### constructor
Z
zengyawen 已提交
252

W
wusongqing 已提交
253
constructor()
Z
zengyawen 已提交
254

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

W
wusongqing 已提交
257 258 259
**System capability**: SystemCapability.Utils.Lang

**Example**
260
  ```js
W
wusongqing 已提交
261 262 263 264 265 266
  var textEncoder = new util.TextEncoder();
  ```


### encode

X
xdmal 已提交
267
encode(input?: string): Uint8Array
Z
zengyawen 已提交
268

Z
zengyawen 已提交
269
Encodes the input content.
Z
zengyawen 已提交
270

W
wusongqing 已提交
271 272 273
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
274 275 276
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| input | string | Yes| String to encode.|
W
wusongqing 已提交
277

W
wusongqing 已提交
278
**Return value**
W
wusongqing 已提交
279 280 281
| Type| Description|
| -------- | -------- |
| Uint8Array | Encoded text.|
W
wusongqing 已提交
282

W
wusongqing 已提交
283
**Example**
284
  ```js
W
wusongqing 已提交
285
  var textEncoder = new util.TextEncoder();
286
  var buffer = new ArrayBuffer(20);
W
wusongqing 已提交
287 288 289 290 291 292 293
  var result = new Uint8Array(buffer);
  result = textEncoder.encode("\uD800¥¥");
  ```


### encodeInto

X
xdmal 已提交
294
encodeInto(input: string, dest: Uint8Array, ): { read: number; written: number }
Z
zengyawen 已提交
295 296 297

Stores the UTF-8 encoded text.

W
wusongqing 已提交
298 299 300
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
301 302 303 304
| 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 已提交
305

W
wusongqing 已提交
306
**Return value**
W
wusongqing 已提交
307 308 309
| Type| Description|
| -------- | -------- |
| Uint8Array | Encoded text.|
Z
zengyawen 已提交
310

W
wusongqing 已提交
311
**Example**
312
  ```js
S
shikai-123 已提交
313 314 315 316 317
  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 已提交
318
  ```
Z
zengyawen 已提交
319

W
wusongqing 已提交
320
## RationalNumber<sup>8+</sup>
Z
zengyawen 已提交
321 322


W
wusongqing 已提交
323
### constructor<sup>8+</sup>
Z
zengyawen 已提交
324

X
xdmal 已提交
325
constructor(numerator: number,denominator: number)
Z
zengyawen 已提交
326

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

W
wusongqing 已提交
329 330 331
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
332 333 334 335
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| numerator | number | Yes| Numerator, which is an integer.|
| denominator | number | Yes| Denominator, which is an integer.|
Z
zengyawen 已提交
336

W
wusongqing 已提交
337
**Example**
338
  ```js
W
wusongqing 已提交
339 340
  var rationalNumber = new util.RationalNumber(1,2);
  ```
Z
zengyawen 已提交
341 342


W
wusongqing 已提交
343
### createRationalFromString<sup>8+</sup>
Z
zengyawen 已提交
344

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

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

W
wusongqing 已提交
349 350 351
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
352 353 354
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| rationalString | string | Yes| String used to create the **RationalNumber** object.|
Z
zengyawen 已提交
355

W
wusongqing 已提交
356
**Return value**
W
wusongqing 已提交
357 358 359
| Type| Description|
| -------- | -------- |
| object | **RationalNumber** object created.|
Z
zengyawen 已提交
360

W
wusongqing 已提交
361
**Example**
362
  ```js
W
wusongqing 已提交
363
  var rationalNumber = new util.RationalNumber(1,2);
S
shikai-123 已提交
364
  var rational = util.RationalNumber.createRationalFromString("3/4");
W
wusongqing 已提交
365
  ```
Z
zengyawen 已提交
366 367


W
wusongqing 已提交
368
### compareTo<sup>8+</sup>
Z
zengyawen 已提交
369

X
xdmal 已提交
370
compareTo​(another: RationalNumber): number​
Z
zengyawen 已提交
371

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

W
wusongqing 已提交
374 375 376
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
377 378 379
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| another | RationalNumber | Yes| Object used to compare with this **RationalNumber** object.|
Z
zengyawen 已提交
380

W
wusongqing 已提交
381
**Return value**
W
wusongqing 已提交
382 383 384
| 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 已提交
385

W
wusongqing 已提交
386
**Example**
387
  ```js
W
wusongqing 已提交
388
  var rationalNumber = new util.RationalNumber(1,2);
S
shikai-123 已提交
389
  var rational = util.RationalNumber.createRationalFromString("3/4");
W
wusongqing 已提交
390 391
  var result = rationalNumber.compareTo(rational);
  ```
Z
zengyawen 已提交
392 393


W
wusongqing 已提交
394
### valueOf<sup>8+</sup>
Z
zengyawen 已提交
395

X
xdmal 已提交
396
valueOf(): number
Z
zengyawen 已提交
397

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

W
wusongqing 已提交
400 401 402
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
403 404 405
| Type| Description|
| -------- | -------- |
| number | An integer or a floating-point number.|
Z
zengyawen 已提交
406

W
wusongqing 已提交
407
**Example**
408
  ```js
W
wusongqing 已提交
409 410 411
  var rationalNumber = new util.RationalNumber(1,2);
  var result = rationalNumber.valueOf();
  ```
Z
zengyawen 已提交
412 413


W
wusongqing 已提交
414
### equals<sup>8+</sup>
Z
zengyawen 已提交
415

X
xdmal 已提交
416
equals​(obj: Object): boolean
Z
zengyawen 已提交
417

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

W
wusongqing 已提交
420 421 422
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
423 424 425
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| object | Object | Yes| Object used to compare with this **RationalNumber** object.|
Z
zengyawen 已提交
426

W
wusongqing 已提交
427
**Return value**
W
wusongqing 已提交
428 429 430
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the two objects are equal; returns **false** otherwise.|
Z
zengyawen 已提交
431

W
wusongqing 已提交
432
**Example**
433
  ```js
W
wusongqing 已提交
434
  var rationalNumber = new util.RationalNumber(1,2);
S
shikai-123 已提交
435
  var rational = util.RationalNumber.createRationalFromString("3/4");
W
wusongqing 已提交
436 437
  var result = rationalNumber.equals(rational);
  ```
Z
zengyawen 已提交
438 439


W
wusongqing 已提交
440
### getCommonDivisor<sup>8+</sup>
Z
zengyawen 已提交
441

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

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

W
wusongqing 已提交
446 447 448
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
449 450 451 452
| 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 已提交
453

W
wusongqing 已提交
454
**Return value**
W
wusongqing 已提交
455 456 457
| Type| Description|
| -------- | -------- |
| number | Greatest common divisor obtained.|
Z
zengyawen 已提交
458

W
wusongqing 已提交
459
**Example**
460
  ```js
W
wusongqing 已提交
461
  var rationalNumber = new util.RationalNumber(1,2);
S
shikai-123 已提交
462
  var result = util.RationalNumber.getCommonDivisor(4,6);
W
wusongqing 已提交
463
  ```
Z
zengyawen 已提交
464 465


W
wusongqing 已提交
466
### getNumerator<sup>8+</sup>
Z
zengyawen 已提交
467

X
xdmal 已提交
468
getNumerator​(): number
Z
zengyawen 已提交
469

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

W
wusongqing 已提交
472 473 474 475
**System capability**: SystemCapability.Utils.Lang

**Return value**

W
wusongqing 已提交
476 477 478
| Type| Description|
| -------- | -------- |
| number | Numerator of this **RationalNumber** object.|
Z
zengyawen 已提交
479

W
wusongqing 已提交
480
**Example**
481
  ```js
W
wusongqing 已提交
482 483 484
  var rationalNumber = new util.RationalNumber(1,2);
  var result = rationalNumber.getNumerator();
  ```
Z
zengyawen 已提交
485 486


W
wusongqing 已提交
487
### getDenominator<sup>8+</sup>
Z
zengyawen 已提交
488

X
xdmal 已提交
489
getDenominator​(): number
Z
zengyawen 已提交
490

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

W
wusongqing 已提交
493 494 495
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
496 497 498
| Type| Description|
| -------- | -------- |
| number | Denominator of this **RationalNumber** object.|
Z
zengyawen 已提交
499

W
wusongqing 已提交
500
**Example**
501
  ```js
W
wusongqing 已提交
502 503 504
  var rationalNumber = new util.RationalNumber(1,2);
  var result = rationalNumber.getDenominator();
  ```
Z
zengyawen 已提交
505 506


W
wusongqing 已提交
507
### isZero<sup>8+</sup>
Z
zengyawen 已提交
508

W
wusongqing 已提交
509
isZero​():boolean
Z
zengyawen 已提交
510

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

W
wusongqing 已提交
513 514 515
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
516 517 518
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the value of this **RationalNumber** object is **0**; returns **false** otherwise.|
Z
zengyawen 已提交
519

W
wusongqing 已提交
520
**Example**
521
  ```js
W
wusongqing 已提交
522 523 524
  var rationalNumber = new util.RationalNumber(1,2);
  var result = rationalNumber.isZero();
  ```
Z
zengyawen 已提交
525 526


W
wusongqing 已提交
527
### isNaN<sup>8+</sup>
Z
zengyawen 已提交
528

X
xdmal 已提交
529
isNaN​(): boolean
Z
zengyawen 已提交
530

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

W
wusongqing 已提交
533 534 535
**System capability**: SystemCapability.Utils.Lang

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

W
wusongqing 已提交
540
**Example**
541
  ```js
W
wusongqing 已提交
542 543 544
  var rationalNumber = new util.RationalNumber(1,2);
  var result = rationalNumber.isNaN();
  ```
Z
zengyawen 已提交
545 546


W
wusongqing 已提交
547
### isFinite<sup>8+</sup>
Z
zengyawen 已提交
548

W
wusongqing 已提交
549
isFinite​():boolean
Z
zengyawen 已提交
550

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

W
wusongqing 已提交
553 554 555
**System capability**: SystemCapability.Utils.Lang

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

W
wusongqing 已提交
560
**Example**
561
  ```js
W
wusongqing 已提交
562 563 564
  var rationalNumber = new util.RationalNumber(1,2);
  var result = rationalNumber.isFinite();
  ```
Z
zengyawen 已提交
565 566


W
wusongqing 已提交
567
### toString<sup>8+</sup>
Z
zengyawen 已提交
568

X
xdmal 已提交
569
toString​(): string
Z
zengyawen 已提交
570

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

W
wusongqing 已提交
573 574 575
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
576 577 578
| 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 已提交
579

W
wusongqing 已提交
580
**Example**
581
  ```js
W
wusongqing 已提交
582 583 584
  var rationalNumber = new util.RationalNumber(1,2);
  var result = rationalNumber.toString();
  ```
Z
zengyawen 已提交
585

W
wusongqing 已提交
586
## LruBuffer<sup>8+</sup>
Z
zengyawen 已提交
587

W
wusongqing 已提交
588
### Attributes
Z
zengyawen 已提交
589

W
wusongqing 已提交
590 591
**System capability**: SystemCapability.Utils.Lang

W
wusongqing 已提交
592 593 594
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| length | number | Yes| No| Total number of values in this buffer.|
Z
zengyawen 已提交
595

W
wusongqing 已提交
596
**Example**
597
  ```js
W
wusongqing 已提交
598 599 600 601 602
  var pro = new util.LruBuffer();
  pro.put(2,10);
  pro.put(1,8);
  var result = pro.length;
  ```
Z
zengyawen 已提交
603 604


W
wusongqing 已提交
605
### constructor<sup>8+</sup>
Z
zengyawen 已提交
606

X
xdmal 已提交
607
constructor(capacity?: number)
Z
zengyawen 已提交
608

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

W
wusongqing 已提交
611 612 613
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
614 615 616
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| capacity | number | No| Capacity of the **LruBuffer** to create.|
Z
zengyawen 已提交
617

W
wusongqing 已提交
618
**Example**
619
  ```js
W
wusongqing 已提交
620 621
  var lrubuffer= new util.LruBuffer();
  ```
Z
zengyawen 已提交
622 623


W
wusongqing 已提交
624
### updateCapacity<sup>8+</sup>
Z
zengyawen 已提交
625

X
xdmal 已提交
626
updateCapacity(newCapacity: number): void
Z
zengyawen 已提交
627

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

W
wusongqing 已提交
630 631 632
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
633 634 635
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| newCapacity | number | Yes| New capacity of the **LruBuffer**.|
Z
zengyawen 已提交
636

W
wusongqing 已提交
637
**Example**
638
  ```js
W
wusongqing 已提交
639 640 641
  var pro = new util.LruBuffer();
  var result = pro.updateCapacity(100);
  ```
Z
zengyawen 已提交
642 643


W
wusongqing 已提交
644
### toString<sup>8+</sup>
Z
zengyawen 已提交
645

X
xdmal 已提交
646
toString(): string
Z
zengyawen 已提交
647

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

W
wusongqing 已提交
650 651 652
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
653 654 655
| Type| Description|
| -------- | -------- |
| string | String representation of this **LruBuffer** object.|
W
wusongqing 已提交
656

W
wusongqing 已提交
657
**Example**
658
  ```js
W
wusongqing 已提交
659 660 661 662 663 664 665 666 667 668
  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 已提交
669
getCapacity(): number
W
wusongqing 已提交
670 671 672

Obtains the capacity of this buffer.

W
wusongqing 已提交
673 674 675
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
676 677 678
| Type| Description|
| -------- | -------- |
| number | Capacity of this buffer.|
W
wusongqing 已提交
679

W
wusongqing 已提交
680
**Example**
681
  ```js
W
wusongqing 已提交
682 683 684
  var pro = new util.LruBuffer();
  var result = pro.getCapacity();
  ```
Z
zengyawen 已提交
685 686


W
wusongqing 已提交
687
### clear<sup>8+</sup>
Z
zengyawen 已提交
688

X
xdmal 已提交
689
clear(): void
Z
zengyawen 已提交
690

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

W
wusongqing 已提交
693 694 695
**System capability**: SystemCapability.Utils.Lang

**Example**
696
  ```js
W
wusongqing 已提交
697 698
  var pro = new util.LruBuffer();
  pro.put(2,10);
S
shikai-123 已提交
699
  var result = pro.length;
W
wusongqing 已提交
700 701
  pro.clear();
  ```
Z
zengyawen 已提交
702 703


W
wusongqing 已提交
704
### getCreateCount<sup>8+</sup>
Z
zengyawen 已提交
705

X
xdmal 已提交
706
getCreateCount(): number
W
wusongqing 已提交
707 708 709

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

W
wusongqing 已提交
710 711 712
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
713 714 715
| Type| Description|
| -------- | -------- |
| number | Number of return values for **createDefault()**.|
W
wusongqing 已提交
716

W
wusongqing 已提交
717
**Example**
718
  ```js
W
wusongqing 已提交
719 720 721 722 723 724 725 726
  var pro = new util.LruBuffer();
  pro.put(1,8);
  var result = pro.getCreateCount();
  ```


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

X
xdmal 已提交
727
getMissCount(): number
W
wusongqing 已提交
728 729 730

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

W
wusongqing 已提交
731 732 733
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
734 735 736
| Type| Description|
| -------- | -------- |
| number | Number of times that the queried values are mismatched.|
W
wusongqing 已提交
737

W
wusongqing 已提交
738
**Example**
739
  ```js
W
wusongqing 已提交
740 741 742 743 744 745 746 747 748
  var pro = new util.LruBuffer();
  pro.put(2,10);
  pro.get(2);
  var result = pro.getMissCount();
  ```


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

X
xdmal 已提交
749
getRemovalCount(): number
W
wusongqing 已提交
750 751 752

Obtains the number of removals from this buffer.

W
wusongqing 已提交
753 754 755
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
756 757 758
| Type| Description|
| -------- | -------- |
| number | Number of removals from the buffer.|
W
wusongqing 已提交
759

W
wusongqing 已提交
760
**Example**
761
  ```js
W
wusongqing 已提交
762 763 764 765 766 767 768 769 770 771
  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 已提交
772
getMatchCount(): number
W
wusongqing 已提交
773 774 775

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

W
wusongqing 已提交
776 777 778
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
779 780 781
| Type| Description|
| -------- | -------- |
| number | Number of times that the queried values are matched.|
W
wusongqing 已提交
782

W
wusongqing 已提交
783
**Example**
784
  ```js
W
wusongqing 已提交
785 786 787 788 789 790 791 792 793
  var pro = new util.LruBuffer();
  pro.put(2,10);
  pro.get(2);
  var result = pro.getMatchCount();
  ```


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

X
xdmal 已提交
794
getPutCount(): number
W
wusongqing 已提交
795 796 797

Obtains the number of additions to this buffer.

W
wusongqing 已提交
798 799 800
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
801 802 803
| Type| Description|
| -------- | -------- |
| number | Number of additions to the buffer.|
W
wusongqing 已提交
804

W
wusongqing 已提交
805
**Example**
806
  ```js
W
wusongqing 已提交
807 808 809 810 811 812 813 814
  var pro = new util.LruBuffer();
  pro.put(2,10);
  var result = pro.getPutCount();
  ```


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

X
xdmal 已提交
815
isEmpty(): boolean
W
wusongqing 已提交
816 817 818

Checks whether this buffer is empty.

W
wusongqing 已提交
819 820 821
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
822 823 824
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the buffer does not contain any value.|
W
wusongqing 已提交
825

W
wusongqing 已提交
826
**Example**
827
  ```js
W
wusongqing 已提交
828 829 830 831 832 833 834 835
  var pro = new util.LruBuffer();
  pro.put(2,10);
  var result = pro.isEmpty();
  ```


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

W
wusongqing 已提交
836
get(key: K): V | undefined
Z
zengyawen 已提交
837 838 839

Obtains the value of the specified key.

W
wusongqing 已提交
840 841 842
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
843 844 845
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | K | Yes| Key based on which the value is queried.|
W
wusongqing 已提交
846

W
wusongqing 已提交
847
**Return value**
W
wusongqing 已提交
848 849 850
| Type| Description|
| -------- | -------- |
| V \| undefind | Returns the value of the key if a match is found in the buffer; returns **undefined** otherwise.|
W
wusongqing 已提交
851

W
wusongqing 已提交
852
**Example**
853
  ```js
W
wusongqing 已提交
854 855 856 857 858 859 860 861
  var pro = new util.LruBuffer();
  pro.put(2,10);
  var result  = pro.get(2);
  ```


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

X
xdmal 已提交
862
put(key: K,value: V): V
Z
zengyawen 已提交
863 864 865

Adds a key-value pair to this buffer.

W
wusongqing 已提交
866 867 868
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
869 870 871 872
| 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 已提交
873

W
wusongqing 已提交
874
**Return value**
W
wusongqing 已提交
875 876 877
| 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 已提交
878

W
wusongqing 已提交
879
**Example**
880
  ```js
W
wusongqing 已提交
881 882 883
  var pro = new util.LruBuffer();
  var result = pro.put(2,10);
  ```
Z
zengyawen 已提交
884 885


W
wusongqing 已提交
886
### values<sup>8+</sup>
Z
zengyawen 已提交
887

X
xdmal 已提交
888
values(): V[]
W
wusongqing 已提交
889 890

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

W
wusongqing 已提交
892 893 894
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
895 896 897
| Type| Description|
| -------- | -------- |
| V [] | All values in the buffer, listed from the most to the least recently accessed.|
Z
zengyawen 已提交
898

W
wusongqing 已提交
899
**Example**
900
  ```js
W
wusongqing 已提交
901 902 903 904 905 906
  var pro = new util.LruBuffer();
  pro.put(2,10);
  pro.put(2,"anhu");
  pro.put("afaf","grfb");
  var result = pro.values();
  ```
Z
zengyawen 已提交
907 908


W
wusongqing 已提交
909 910
### keys<sup>8+</sup>

X
xdmal 已提交
911
keys(): K[]
Z
zengyawen 已提交
912 913 914

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

W
wusongqing 已提交
915 916 917
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
918 919 920
| Type| Description|
| -------- | -------- |
| K [] | All keys in the buffer, listed from the most to the least recently accessed.|
W
wusongqing 已提交
921

W
wusongqing 已提交
922
**Example**
923
  ```js
W
wusongqing 已提交
924 925 926 927 928 929 930 931
  var pro = new util.LruBuffer();
  pro.put(2,10);
  var result = pro.keys();
  ```


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

W
wusongqing 已提交
932
remove(key: K): V | undefined
W
wusongqing 已提交
933 934 935

Removes the specified key and its value from this buffer.

W
wusongqing 已提交
936 937 938
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
939 940 941
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | K | Yes| Key to remove.|
W
wusongqing 已提交
942

W
wusongqing 已提交
943
**Return value**
W
wusongqing 已提交
944 945 946
| 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 已提交
947

W
wusongqing 已提交
948
**Example**
949
  ```js
W
wusongqing 已提交
950 951 952 953 954 955 956 957
  var pro = new util.LruBuffer();
  pro.put(2,10);
  var result = pro.remove(20);
  ```


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

X
xdmal 已提交
958
afterRemoval(isEvict: boolean,key: K,value: V,newValue: V): void
W
wusongqing 已提交
959 960 961

Performs subsequent operations after a value is removed.

W
wusongqing 已提交
962 963 964
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
965 966 967 968 969 970
| 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 已提交
971

W
wusongqing 已提交
972
**Example**
973
  ```js
W
wusongqing 已提交
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988
  var arr = [];
  class ChildLruBuffer extends util.LruBuffer
  {
  	constructor()
  	{
  		super();
  	}
  	afterRemoval(isEvict, key, value, newValue)
  	{
  		if (isEvict === false)
  		{
  			arr = [key, value, newValue];
  		}
  	}
  }
S
shikai-123 已提交
989 990
  var lru = new ChildLruBuffer();
  lru.afterRemoval(false,10,30,null);
W
wusongqing 已提交
991 992 993 994 995
  ```


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

X
xdmal 已提交
996
contains(key: K): boolean
W
wusongqing 已提交
997 998

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

W
wusongqing 已提交
1000 1001 1002
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1003 1004 1005
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | K | Yes| Key to check.|
Z
zengyawen 已提交
1006

W
wusongqing 已提交
1007
**Return value**
W
wusongqing 已提交
1008 1009 1010
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the buffer contains the specified key; returns **false** otherwise.|
Z
zengyawen 已提交
1011

W
wusongqing 已提交
1012
**Example**
1013
  ```js
W
wusongqing 已提交
1014 1015 1016 1017
  var pro = new util.LruBuffer();
  pro.put(2,10);
  var result = pro.contains(20);
  ```
Z
zengyawen 已提交
1018 1019


W
wusongqing 已提交
1020 1021
### createDefault<sup>8+</sup>

X
xdmal 已提交
1022
createDefault(key: K): V
Z
zengyawen 已提交
1023 1024 1025

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

W
wusongqing 已提交
1026 1027 1028
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1029 1030 1031
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | K | Yes| Key of which the value is missing.|
Z
zengyawen 已提交
1032

W
wusongqing 已提交
1033
**Return value**
W
wusongqing 已提交
1034 1035 1036
| Type| Description|
| -------- | -------- |
| V | Value of the key.|
Z
zengyawen 已提交
1037

W
wusongqing 已提交
1038
**Example**
1039
  ```js
W
wusongqing 已提交
1040 1041 1042
  var pro = new util.LruBuffer();
  var result = pro.createDefault(50);
  ```
Z
zengyawen 已提交
1043 1044


W
wusongqing 已提交
1045
### entries<sup>8+</sup>
Z
zengyawen 已提交
1046

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

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

W
wusongqing 已提交
1051 1052 1053
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
1054 1055 1056
| Type| Description|
| -------- | -------- |
| [K, V] | Iterable array.|
Z
zengyawen 已提交
1057

W
wusongqing 已提交
1058
**Example**
1059
  ```js
W
wusongqing 已提交
1060 1061 1062 1063
  var pro = new util.LruBuffer();
  pro.put(2,10);
  var result = pro.entries();
  ```
Z
zengyawen 已提交
1064 1065


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

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

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

W
wusongqing 已提交
1072 1073 1074
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
1075 1076 1077
| Type| Description|
| -------- | -------- |
| [K, V] | Two-dimensional array in key-value pairs.|
Z
zengyawen 已提交
1078

W
wusongqing 已提交
1079
**Example**
1080
  ```js
W
wusongqing 已提交
1081 1082
  var pro = new util.LruBuffer();
  pro.put(2,10);
S
shikai-123 已提交
1083
  var result = pro[Symbol.iterator]();
W
wusongqing 已提交
1084
  ```
Z
zengyawen 已提交
1085 1086


W
wusongqing 已提交
1087
## Scope<sup>8+</sup>
Z
zengyawen 已提交
1088 1089


W
wusongqing 已提交
1090
### ScopeType<sup>8+</sup>
Z
zengyawen 已提交
1091

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

W
wusongqing 已提交
1094
The values of the **ScopeComparable** type are used to implement the **compareTo** method. Therefore, ensure that the input parameters are comparable.
1095
```js
Z
zengyawen 已提交
1096
interface ScopeComparable{
X
xdmal 已提交
1097
    compareTo(other: ScopeComparable): boolean;
Z
zengyawen 已提交
1098
}
W
wusongqing 已提交
1099
type ScopeType = ScopeComparable | number;
Z
zengyawen 已提交
1100 1101 1102
```


W
wusongqing 已提交
1103
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 已提交
1104

W
wusongqing 已提交
1105 1106

Example
1107
```js
Z
zengyawen 已提交
1108 1109
class Temperature{
    constructor(value){
W
wusongqing 已提交
1110 1111
       // If TS is used for development, add the following code:
       // private readonly _temp: Temperature;
Z
zengyawen 已提交
1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126
       this._temp = value;
    }
    comapreTo(value){
       return this._temp >= value.getTemp();
    }
    getTemp(){
       return this._temp;
    }
    toString(){
       return this._temp.toString();
    }
}
```


W
wusongqing 已提交
1127 1128
### constructor<sup>8+</sup>

X
xdmal 已提交
1129
constructor(lowerObj: ScopeType, upperObj: ScopeType)
W
wusongqing 已提交
1130 1131 1132

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

W
wusongqing 已提交
1133 1134 1135
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1136 1137 1138 1139
| 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 已提交
1140

W
wusongqing 已提交
1141
**Example**
1142
  ```js
W
wusongqing 已提交
1143 1144 1145 1146 1147 1148 1149 1150
  var tempLower = new Temperature(30);
  var tempUpper = new Temperature(40);
  var range = new util.Scope(tempLower, tempUpper);
  ```


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

X
xdmal 已提交
1151
toString(): string
W
wusongqing 已提交
1152 1153 1154

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

W
wusongqing 已提交
1155 1156 1157
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
1158 1159 1160
| Type| Description|
| -------- | -------- |
| string | String representation containing the **Scope**.|
W
wusongqing 已提交
1161

W
wusongqing 已提交
1162
**Example**
1163
  ```js
W
wusongqing 已提交
1164 1165 1166 1167 1168 1169 1170 1171 1172
  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 已提交
1173
intersect(range: Scope): Scope
W
wusongqing 已提交
1174 1175 1176

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

W
wusongqing 已提交
1177 1178 1179
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1180 1181 1182
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| range | [Scope](#scope8) | Yes| **Scope** specified.|
W
wusongqing 已提交
1183

W
wusongqing 已提交
1184
**Return value**
W
wusongqing 已提交
1185 1186 1187
| Type| Description|
| -------- | -------- |
| [Scope](#scope8) | Intersection of this **Scope** and the given **Scope**.|
W
wusongqing 已提交
1188

W
wusongqing 已提交
1189
**Example**
1190
  ```js
W
wusongqing 已提交
1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202
  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 已提交
1203
intersect(lowerObj:ScopeType,upperObj:ScopeType):Scope
W
wusongqing 已提交
1204 1205 1206

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

W
wusongqing 已提交
1207 1208 1209
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1210 1211 1212 1213
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| lowerObj | [ScopeType](#scopetype8) | Yes| Lower limit.|
| upperObj | [ScopeType](#scopetype8) | Yes| Upper limit.|
W
wusongqing 已提交
1214

W
wusongqing 已提交
1215
**Return value**
W
wusongqing 已提交
1216 1217 1218
| Type| Description|
| -------- | -------- |
| [Scope](#scope8) | Intersection of this **Scope** and the given lower and upper limits.|
W
wusongqing 已提交
1219

W
wusongqing 已提交
1220
**Example**
1221
  ```js
W
wusongqing 已提交
1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232
  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 已提交
1233
getUpper(): ScopeType
W
wusongqing 已提交
1234 1235 1236

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

W
wusongqing 已提交
1237 1238 1239 1240
**System capability**: SystemCapability.Utils.Lang

**Return value**

W
wusongqing 已提交
1241 1242 1243
| Type| Description|
| -------- | -------- |
| [ScopeType](#scopetype8) | Upper limit of this **Scope**.|
W
wusongqing 已提交
1244

W
wusongqing 已提交
1245
**Example**
1246
  ```js
W
wusongqing 已提交
1247 1248 1249 1250 1251 1252 1253 1254 1255
  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 已提交
1256
getLower(): ScopeType
W
wusongqing 已提交
1257 1258 1259

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

W
wusongqing 已提交
1260 1261 1262
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
1263 1264 1265
| Type| Description|
| -------- | -------- |
| [ScopeType](#scopetype8) | Lower limit of this **Scope**.|
W
wusongqing 已提交
1266

W
wusongqing 已提交
1267
**Example**
1268
  ```js
W
wusongqing 已提交
1269 1270 1271 1272 1273 1274 1275 1276 1277
  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 已提交
1278
expand(lowerObj: ScopeType,upperObj: ScopeType): Scope
W
wusongqing 已提交
1279 1280 1281

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

W
wusongqing 已提交
1282 1283 1284
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1285 1286 1287 1288
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| lowerObj | [ScopeType](#scopetype8) | Yes| Lower limit.|
| upperObj | [ScopeType](#scopetype8) | Yes| Upper limit.|
W
wusongqing 已提交
1289

W
wusongqing 已提交
1290
**Return value**
W
wusongqing 已提交
1291 1292 1293
| Type| Description|
| -------- | -------- |
| [Scope](#scope8) | Union set of this **Scope** and the given lower and upper limits.|
W
wusongqing 已提交
1294

W
wusongqing 已提交
1295
**Example**
W
wusongqing 已提交
1296

1297
  ```js
W
wusongqing 已提交
1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308
  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 已提交
1309
expand(range: Scope): Scope
W
wusongqing 已提交
1310 1311 1312

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

W
wusongqing 已提交
1313 1314 1315
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1316 1317 1318
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| range | [Scope](#scope8) | Yes| **Scope** specified.|
W
wusongqing 已提交
1319

W
wusongqing 已提交
1320
**Return value**
W
wusongqing 已提交
1321 1322 1323
| Type| Description|
| -------- | -------- |
| [Scope](#scope8) | Union set of this **Scope** and the given **Scope**.|
W
wusongqing 已提交
1324

W
wusongqing 已提交
1325
**Example**
1326
  ```js
W
wusongqing 已提交
1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338
  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 已提交
1339
expand(value: ScopeType): Scope
W
wusongqing 已提交
1340 1341 1342

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

W
wusongqing 已提交
1343 1344 1345
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1346 1347 1348
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | [ScopeType](#scopetype8) | Yes| Value specified.|
W
wusongqing 已提交
1349

W
wusongqing 已提交
1350
**Return value**
W
wusongqing 已提交
1351 1352 1353
| Type| Description|
| -------- | -------- |
| [Scope](#scope8) | Union set of this **Scope** and the given value.|
Z
zengyawen 已提交
1354

W
wusongqing 已提交
1355
**Example**
1356
  ```js
W
wusongqing 已提交
1357 1358 1359 1360 1361 1362
  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 已提交
1363 1364


W
wusongqing 已提交
1365
### contains<sup>8+</sup>
Z
zengyawen 已提交
1366

X
xdmal 已提交
1367
contains(value: ScopeType): boolean
Z
zengyawen 已提交
1368

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

W
wusongqing 已提交
1371 1372 1373
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1374 1375 1376
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | [ScopeType](#scopetype8) | Yes| Value specified.|
Z
zengyawen 已提交
1377

W
wusongqing 已提交
1378
**Return value**
W
wusongqing 已提交
1379 1380 1381
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the value is within this **Scope**; returns **false** otherwise.|
W
wusongqing 已提交
1382

W
wusongqing 已提交
1383
**Example**
1384
  ```js
W
wusongqing 已提交
1385 1386 1387 1388 1389 1390 1391 1392 1393 1394
  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 已提交
1395
contains(range: Scope): boolean
W
wusongqing 已提交
1396 1397 1398

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

W
wusongqing 已提交
1399 1400 1401
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1402 1403 1404
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| range | [Scope](#scope8) | Yes| **Scope** specified.|
W
wusongqing 已提交
1405

W
wusongqing 已提交
1406
**Return value**
W
wusongqing 已提交
1407 1408 1409
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the range is within this **Scope**; returns **false** otherwise.|
W
wusongqing 已提交
1410

W
wusongqing 已提交
1411
**Example**
1412
  ```js
W
wusongqing 已提交
1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424
  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 已提交
1425
clamp(value: ScopeType): ScopeType
W
wusongqing 已提交
1426 1427 1428

Limits a value to this **Scope**.

W
wusongqing 已提交
1429 1430 1431
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1432 1433 1434
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | [ScopeType](#scopetype8) | Yes| Value specified.|
W
wusongqing 已提交
1435

W
wusongqing 已提交
1436
**Return value**
W
wusongqing 已提交
1437 1438 1439
| 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 已提交
1440

W
wusongqing 已提交
1441
**Example**
1442
  ```js
W
wusongqing 已提交
1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459
  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 已提交
1460 1461 1462
**System capability**: SystemCapability.Utils.Lang

**Example**
1463
  ```js
W
wusongqing 已提交
1464 1465 1466 1467 1468 1469
  var base64 = new  util.Base64();
  ```


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

X
xdmal 已提交
1470
encodeSync(src: Uint8Array): Uint8Array
Z
zengyawen 已提交
1471 1472 1473

Encodes the input content.

W
wusongqing 已提交
1474 1475 1476
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1477 1478 1479
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| src | Uint8Array | Yes| Uint8Array to encode.|
W
wusongqing 已提交
1480

W
wusongqing 已提交
1481
**Return value**
W
wusongqing 已提交
1482 1483 1484
| Type| Description|
| -------- | -------- |
| Uint8Array | Uint8Array encoded.|
W
wusongqing 已提交
1485

W
wusongqing 已提交
1486
**Example**
1487
  ```js
W
wusongqing 已提交
1488 1489 1490 1491 1492 1493 1494 1495
  var that = new util.Base64();
  var array = new Uint8Array([115,49,51]);
  var result = that.encodeSync(array);
  ```


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

X
xdmal 已提交
1496
encodeToStringSync(src: Uint8Array): string
W
wusongqing 已提交
1497 1498 1499

Encodes the input content.

W
wusongqing 已提交
1500 1501 1502
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1503 1504 1505
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| src | Uint8Array | Yes| Uint8Array to encode.|
W
wusongqing 已提交
1506

W
wusongqing 已提交
1507
**Return value**
W
wusongqing 已提交
1508 1509 1510
| Type| Description|
| -------- | -------- |
| string | String encoded from the Uint8Array.|
W
wusongqing 已提交
1511

W
wusongqing 已提交
1512
**Example**
1513
  ```js
W
wusongqing 已提交
1514 1515 1516 1517 1518 1519 1520 1521
  var that = new util.Base64();
  var array = new Uint8Array([115,49,51]);
  var result = that.encodeToStringSync(array);
  ```


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

W
wusongqing 已提交
1522
decodeSync(src: Uint8Array | string): Uint8Array
Z
zengyawen 已提交
1523 1524 1525

Decodes the input content.

W
wusongqing 已提交
1526 1527 1528
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1529 1530 1531
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| src | Uint8Array \| string | Yes| Uint8Array or string to decode.|
W
wusongqing 已提交
1532

W
wusongqing 已提交
1533
**Return value**
W
wusongqing 已提交
1534 1535 1536
| Type| Description|
| -------- | -------- |
| Uint8Array | Uint8Array decoded.|
W
wusongqing 已提交
1537

W
wusongqing 已提交
1538
**Example**
1539
  ```js
W
wusongqing 已提交
1540 1541 1542 1543 1544 1545 1546 1547
  var that = new util.Base64();
  var buff = 'czEz';
  var result = that.decodeSync(buff);
  ```


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

X
xdmal 已提交
1548
encode(src: Uint8Array): Promise&lt;Uint8Array&gt;
Z
zengyawen 已提交
1549 1550 1551

Encodes the input content asynchronously.

W
wusongqing 已提交
1552 1553 1554
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1555 1556 1557
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| src | Uint8Array | Yes| Uint8Array to encode asynchronously.|
W
wusongqing 已提交
1558

W
wusongqing 已提交
1559
**Return value**
W
wusongqing 已提交
1560 1561 1562
| Type| Description|
| -------- | -------- |
| Promise&lt;Uint8Array&gt; | Uint8Array obtained after asynchronous encoding.|
W
wusongqing 已提交
1563

W
wusongqing 已提交
1564
**Example**
1565
  ```js
W
wusongqing 已提交
1566 1567 1568 1569 1570
  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 已提交
1571
          console.log(val[i].toString())
W
wusongqing 已提交
1572 1573 1574 1575 1576 1577 1578
      }
  })
  ```


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

X
xdmal 已提交
1579
encodeToString(src: Uint8Array): Promise&lt;string&gt;
W
wusongqing 已提交
1580 1581 1582

Encodes the input content asynchronously.

W
wusongqing 已提交
1583 1584 1585
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1586 1587 1588
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| src | Uint8Array | Yes| Uint8Array to encode asynchronously.|
W
wusongqing 已提交
1589

W
wusongqing 已提交
1590
**Return value**
W
wusongqing 已提交
1591 1592 1593
| Type| Description|
| -------- | -------- |
| Promise&lt;string&gt; | String obtained after asynchronous encoding.|
W
wusongqing 已提交
1594

W
wusongqing 已提交
1595
**Example**
1596
  ```js
W
wusongqing 已提交
1597 1598 1599 1600 1601 1602 1603 1604 1605 1606
  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 已提交
1607
decode(src: Uint8Array | string): Promise&lt;Uint8Array&gt;
Z
zengyawen 已提交
1608 1609 1610

Decodes the input content asynchronously.

W
wusongqing 已提交
1611 1612 1613
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1614 1615 1616
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| src | Uint8Array \| string | Yes| Uint8Array or string to decode asynchronously.|
W
wusongqing 已提交
1617

W
wusongqing 已提交
1618
**Return value**
W
wusongqing 已提交
1619 1620 1621
| Type| Description|
| -------- | -------- |
| Promise&lt;Uint8Array&gt; | Uint8Array obtained after asynchronous decoding.|
W
wusongqing 已提交
1622

W
wusongqing 已提交
1623
**Example**
1624
  ```js
W
wusongqing 已提交
1625 1626 1627 1628 1629
  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 已提交
1630
          console.log(val[i].toString())
W
wusongqing 已提交
1631 1632 1633 1634 1635
      }
  })
  ```


1636
## types<sup>8+</sup>
W
wusongqing 已提交
1637 1638 1639 1640 1641 1642


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

constructor()

W
wusongqing 已提交
1643
A constructor used to create a **Types** object.
W
wusongqing 已提交
1644

W
wusongqing 已提交
1645 1646 1647
**System capability**: SystemCapability.Utils.Lang

**Example**
1648
  ```js
1649
  var type = new util.types();
W
wusongqing 已提交
1650 1651 1652 1653 1654
  ```


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

X
xdmal 已提交
1655
isAnyArrayBuffer(value: Object): boolean
W
wusongqing 已提交
1656 1657 1658

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

W
wusongqing 已提交
1659 1660 1661
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1662 1663 1664
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
1665

W
wusongqing 已提交
1666
**Return value**
W
wusongqing 已提交
1667 1668 1669
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise.|
W
wusongqing 已提交
1670

W
wusongqing 已提交
1671
**Example**
1672
  ```js
1673
  var that = new util.types();
S
shikai-123 已提交
1674
  var result = that.isAnyArrayBuffer(new ArrayBuffer(0));
W
wusongqing 已提交
1675 1676 1677 1678 1679
  ```


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

X
xdmal 已提交
1680
isArrayBufferView(value: Object): boolean
W
wusongqing 已提交
1681 1682 1683 1684 1685

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 已提交
1686 1687 1688
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1689 1690 1691
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
1692

W
wusongqing 已提交
1693
**Return value**
W
wusongqing 已提交
1694 1695 1696
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **ArrayBufferView** type; returns **false** otherwise.|
W
wusongqing 已提交
1697

W
wusongqing 已提交
1698
**Example**
1699
  ```js
1700
  var that = new util.types();
W
wusongqing 已提交
1701 1702 1703 1704 1705 1706
  var result = that.isArrayBufferView(new Int8Array([]));
  ```


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

X
xdmal 已提交
1707
isArgumentsObject(value: Object): boolean
W
wusongqing 已提交
1708 1709 1710

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

W
wusongqing 已提交
1711 1712 1713
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1714 1715 1716
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
1717

W
wusongqing 已提交
1718
**Return value**
W
wusongqing 已提交
1719 1720 1721
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **arguments** type; returns **false** otherwise.|
W
wusongqing 已提交
1722

W
wusongqing 已提交
1723
**Example**
1724
  ```js
1725
  var that = new util.types();
W
wusongqing 已提交
1726 1727 1728 1729 1730 1731 1732 1733 1734
  function foo() {
      var result = that.isArgumentsObject(arguments);
  }
  var f = foo();
  ```


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

X
xdmal 已提交
1735
isArrayBuffer(value: Object): boolean
W
wusongqing 已提交
1736 1737 1738

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

W
wusongqing 已提交
1739 1740 1741
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1742 1743 1744
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
1745

W
wusongqing 已提交
1746
**Return value**
W
wusongqing 已提交
1747 1748 1749
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise.|
W
wusongqing 已提交
1750

W
wusongqing 已提交
1751
**Example**
1752
  ```js
1753
  var that = new util.types();
S
shikai-123 已提交
1754
  var result = that.isArrayBuffer(new ArrayBuffer(0));
W
wusongqing 已提交
1755 1756 1757 1758 1759
  ```


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

X
xdmal 已提交
1760
isAsyncFunction(value: Object): boolean
Z
zengyawen 已提交
1761 1762 1763

Checks whether the input value is an asynchronous function.

W
wusongqing 已提交
1764 1765 1766
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1767 1768 1769
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
1770

W
wusongqing 已提交
1771
**Return value**
W
wusongqing 已提交
1772 1773 1774
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is an asynchronous function; returns **false** otherwise.|
W
wusongqing 已提交
1775

W
wusongqing 已提交
1776
**Example**
1777
  ```js
1778
  var that = new util.types();
W
wusongqing 已提交
1779 1780 1781 1782 1783 1784
  var result = that.isAsyncFunction(async function foo() {});
  ```


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

X
xdmal 已提交
1785
isBooleanObject(value: Object): boolean
W
wusongqing 已提交
1786 1787 1788

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

W
wusongqing 已提交
1789 1790 1791
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1792 1793 1794
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
1795

W
wusongqing 已提交
1796
**Return value**
W
wusongqing 已提交
1797 1798 1799
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Boolean** type; returns **false** otherwise.|
W
wusongqing 已提交
1800

W
wusongqing 已提交
1801
**Example**
1802
  ```js
1803
  var that = new util.types();
W
wusongqing 已提交
1804 1805 1806 1807 1808 1809
  var result = that.isBooleanObject(new Boolean(true));
  ```


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

X
xdmal 已提交
1810
isBoxedPrimitive(value: Object): boolean
W
wusongqing 已提交
1811 1812 1813

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

W
wusongqing 已提交
1814 1815 1816
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1817 1818 1819
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
1820

W
wusongqing 已提交
1821
**Return value**
W
wusongqing 已提交
1822 1823 1824
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Boolean**, **Number**, **String**, or **Symbol** type; returns **false** otherwise.|
W
wusongqing 已提交
1825

W
wusongqing 已提交
1826
**Example**
1827
  ```js
1828
  var that = new util.types();
W
wusongqing 已提交
1829 1830 1831 1832 1833 1834
  var result = that.isBoxedPrimitive(new Boolean(false));
  ```


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

X
xdmal 已提交
1835
isDataView(value: Object): boolean
W
wusongqing 已提交
1836 1837 1838

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

W
wusongqing 已提交
1839 1840 1841
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1842 1843 1844
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
1845

W
wusongqing 已提交
1846
**Return value**
W
wusongqing 已提交
1847 1848 1849
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **DataView** type; returns **false** otherwise.|
W
wusongqing 已提交
1850

W
wusongqing 已提交
1851
**Example**
1852
  ```js
1853
  var that = new util.types();
W
wusongqing 已提交
1854 1855 1856 1857 1858 1859 1860
  const ab = new ArrayBuffer(20);
  var result = that.isDataView(new DataView(ab));
  ```


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

X
xdmal 已提交
1861
isDate(value: Object): boolean
W
wusongqing 已提交
1862 1863 1864

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

W
wusongqing 已提交
1865 1866 1867
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1868 1869 1870
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
1871

W
wusongqing 已提交
1872
**Return value**
W
wusongqing 已提交
1873 1874 1875
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Date** type; returns **false** otherwise.|
W
wusongqing 已提交
1876

W
wusongqing 已提交
1877
**Example**
1878
  ```js
1879
  var that = new util.types();
W
wusongqing 已提交
1880 1881 1882 1883 1884 1885
  var result = that.isDate(new Date());
  ```


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

X
xdmal 已提交
1886
isExternal(value: Object): boolean
W
wusongqing 已提交
1887 1888 1889

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

W
wusongqing 已提交
1890 1891 1892
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1893 1894 1895
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
1896

W
wusongqing 已提交
1897
**Return value**
W
wusongqing 已提交
1898 1899 1900
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **native external** type; returns **false** otherwise.|
W
wusongqing 已提交
1901

W
wusongqing 已提交
1902
**Example**
1903
  ```js
1904
  var that = new util.types();
S
shikai-123 已提交
1905
  var result = that.isExternal(true);
W
wusongqing 已提交
1906 1907 1908 1909 1910
  ```


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

X
xdmal 已提交
1911
isFloat32Array(value: Object): boolean
W
wusongqing 已提交
1912 1913 1914

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

W
wusongqing 已提交
1915 1916 1917
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1918 1919 1920
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
1921

W
wusongqing 已提交
1922
**Return value**
W
wusongqing 已提交
1923 1924 1925
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Float32Array** type; returns **false** otherwise.|
W
wusongqing 已提交
1926

W
wusongqing 已提交
1927
**Example**
1928
  ```js
1929
  var that = new util.types();
W
wusongqing 已提交
1930 1931 1932 1933 1934 1935
  var result = that.isFloat32Array(new Float32Array());
  ```


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

X
xdmal 已提交
1936
isFloat64Array(value: Object): boolean
W
wusongqing 已提交
1937 1938 1939

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

W
wusongqing 已提交
1940 1941 1942
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1943 1944 1945
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
1946

W
wusongqing 已提交
1947
**Return value**
W
wusongqing 已提交
1948 1949 1950
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Float64Array** type; returns **false** otherwise.|
W
wusongqing 已提交
1951

W
wusongqing 已提交
1952
**Example**
1953
  ```js
1954
  var that = new util.types();
W
wusongqing 已提交
1955 1956 1957 1958 1959 1960
  var result = that.isFloat64Array(new Float64Array());
  ```


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

X
xdmal 已提交
1961
isGeneratorFunction(value: Object): boolean
Z
zengyawen 已提交
1962 1963 1964

Checks whether the input value is a generator function.

W
wusongqing 已提交
1965 1966 1967
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1968 1969 1970
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
1971

W
wusongqing 已提交
1972
**Return value**
W
wusongqing 已提交
1973 1974 1975
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is a generator function; returns **false** otherwise.|
W
wusongqing 已提交
1976

W
wusongqing 已提交
1977
**Example**
1978
  ```js
1979
  var that = new util.types();
W
wusongqing 已提交
1980 1981 1982 1983 1984 1985
  var result = that.isGeneratorFunction(function* foo() {});
  ```


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

X
xdmal 已提交
1986
isGeneratorObject(value: Object): boolean
Z
zengyawen 已提交
1987 1988 1989

Checks whether the input value is a generator object.

W
wusongqing 已提交
1990 1991 1992
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1993 1994 1995
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
1996

W
wusongqing 已提交
1997
**Return value**
W
wusongqing 已提交
1998 1999 2000
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is a generator object; returns **false** otherwise.|
W
wusongqing 已提交
2001

W
wusongqing 已提交
2002
**Example**
2003
  ```js
2004
  var that = new util.types();
W
wusongqing 已提交
2005 2006 2007 2008 2009 2010 2011 2012
  function* foo() {}
  const generator = foo();
  var result = that.isGeneratorObject(generator);
  ```


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

X
xdmal 已提交
2013
isInt8Array(value: Object): boolean
W
wusongqing 已提交
2014 2015 2016

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

W
wusongqing 已提交
2017 2018 2019
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2020 2021 2022
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2023

W
wusongqing 已提交
2024
**Return value**
W
wusongqing 已提交
2025 2026 2027
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Int8Array** type; returns **false** otherwise.|
W
wusongqing 已提交
2028

W
wusongqing 已提交
2029
**Example**
2030
  ```js
2031
  var that = new util.types();
W
wusongqing 已提交
2032 2033 2034 2035 2036 2037
  var result = that.isInt8Array(new Int8Array([]));
  ```


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

X
xdmal 已提交
2038
isInt16Array(value: Object): boolean
W
wusongqing 已提交
2039 2040 2041

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

W
wusongqing 已提交
2042 2043 2044
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2045 2046 2047
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2048

W
wusongqing 已提交
2049
**Return value**
W
wusongqing 已提交
2050 2051 2052
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Int16Array** type; returns **false** otherwise.|
W
wusongqing 已提交
2053

W
wusongqing 已提交
2054
**Example**
2055
  ```js
2056
  var that = new util.types();
W
wusongqing 已提交
2057 2058 2059 2060 2061 2062
  var result = that.isInt16Array(new Int16Array([]));
  ```


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

X
xdmal 已提交
2063
isInt32Array(value: Object): boolean
W
wusongqing 已提交
2064 2065 2066

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

W
wusongqing 已提交
2067 2068 2069
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2070 2071 2072
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2073

W
wusongqing 已提交
2074
**Return value**
W
wusongqing 已提交
2075 2076 2077
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Int32Array** type; returns **false** otherwise.|
W
wusongqing 已提交
2078

W
wusongqing 已提交
2079
**Example**
2080
  ```js
2081
  var that = new util.types();
W
wusongqing 已提交
2082 2083 2084 2085 2086 2087
  var result = that.isInt32Array(new Int32Array([]));
  ```


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

X
xdmal 已提交
2088
isMap(value: Object): boolean
W
wusongqing 已提交
2089 2090 2091

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

W
wusongqing 已提交
2092 2093 2094
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2095 2096 2097
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2098

W
wusongqing 已提交
2099
**Return value**
W
wusongqing 已提交
2100 2101 2102
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Map** type; returns **false** otherwise.|
W
wusongqing 已提交
2103

W
wusongqing 已提交
2104
**Example**
2105
  ```js
2106
  var that = new util.types();
W
wusongqing 已提交
2107 2108 2109 2110 2111 2112
  var result = that.isMap(new Map());
  ```


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

X
xdmal 已提交
2113
isMapIterator(value: Object): boolean
W
wusongqing 已提交
2114 2115 2116

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

W
wusongqing 已提交
2117 2118 2119
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2120 2121 2122
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2123

W
wusongqing 已提交
2124
**Return value**
W
wusongqing 已提交
2125 2126 2127
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **MapIterator** type; returns **false** otherwise.|
W
wusongqing 已提交
2128

W
wusongqing 已提交
2129
**Example**
2130
  ```js
2131
  var that = new util.types();
W
wusongqing 已提交
2132 2133 2134 2135 2136 2137 2138
  const map = new Map();
  var result = that.isMapIterator(map.keys());
  ```


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

X
xdmal 已提交
2139
isNativeError(value: Object): boolean
W
wusongqing 已提交
2140 2141 2142

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

W
wusongqing 已提交
2143 2144 2145
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2146 2147 2148
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2149

W
wusongqing 已提交
2150
**Return value**
W
wusongqing 已提交
2151 2152 2153
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Error** type; returns **false** otherwise.|
W
wusongqing 已提交
2154

W
wusongqing 已提交
2155
**Example**
2156
  ```js
2157
  var that = new util.types();
W
wusongqing 已提交
2158 2159 2160 2161 2162 2163
  var result = that.isNativeError(new TypeError());
  ```


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

X
xdmal 已提交
2164
isNumberObject(value: Object): boolean
Z
zengyawen 已提交
2165 2166 2167

Checks whether the input value is a number object.

W
wusongqing 已提交
2168 2169 2170
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2171 2172 2173
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2174

W
wusongqing 已提交
2175
**Return value**
W
wusongqing 已提交
2176 2177 2178
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is a number object; returns **false** otherwise.|
W
wusongqing 已提交
2179

W
wusongqing 已提交
2180
**Example**
2181
  ```js
2182
  var that = new util.types();
W
wusongqing 已提交
2183 2184 2185 2186 2187 2188
  var result = that.isNumberObject(new Number(0));
  ```


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

X
xdmal 已提交
2189
isPromise(value: Object): boolean
Z
zengyawen 已提交
2190 2191 2192

Checks whether the input value is a promise.

W
wusongqing 已提交
2193 2194 2195
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2196 2197 2198
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2199

W
wusongqing 已提交
2200
**Return value**
W
wusongqing 已提交
2201 2202 2203
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is a promise; returns **false** otherwise.|
W
wusongqing 已提交
2204

W
wusongqing 已提交
2205
**Example**
2206
  ```js
2207
  var that = new util.types();
W
wusongqing 已提交
2208 2209 2210 2211 2212 2213
  var result = that.isPromise(Promise.resolve(1));
  ```


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

X
xdmal 已提交
2214
isProxy(value: Object): boolean
Z
zengyawen 已提交
2215 2216 2217

Checks whether the input value is a proxy.

W
wusongqing 已提交
2218 2219 2220
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2221 2222 2223
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2224

W
wusongqing 已提交
2225
**Return value**
W
wusongqing 已提交
2226 2227 2228
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is a proxy; returns **false** otherwise.|
W
wusongqing 已提交
2229

W
wusongqing 已提交
2230
**Example**
2231
  ```js
2232
  var that = new util.types();
W
wusongqing 已提交
2233 2234 2235 2236 2237 2238 2239 2240
  const target = {};
  const proxy = new Proxy(target, {});
  var result = that.isProxy(proxy);
  ```


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

X
xdmal 已提交
2241
isRegExp(value: Object): boolean
W
wusongqing 已提交
2242 2243 2244

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

W
wusongqing 已提交
2245 2246 2247
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2248 2249 2250
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2251

W
wusongqing 已提交
2252
**Return value**
W
wusongqing 已提交
2253 2254 2255
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **RegExp** type; returns **false** otherwise.|
W
wusongqing 已提交
2256

W
wusongqing 已提交
2257
**Example**
2258
  ```js
2259
  var that = new util.types();
W
wusongqing 已提交
2260 2261 2262 2263 2264 2265
  var result = that.isRegExp(new RegExp('abc'));
  ```


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

X
xdmal 已提交
2266
isSet(value: Object): boolean
W
wusongqing 已提交
2267 2268 2269

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

W
wusongqing 已提交
2270 2271 2272
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2273 2274 2275
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2276

W
wusongqing 已提交
2277
**Return value**
W
wusongqing 已提交
2278 2279 2280
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Set** type; returns **false** otherwise.|
W
wusongqing 已提交
2281

W
wusongqing 已提交
2282
**Example**
2283
  ```js
2284
  var that = new util.types();
W
wusongqing 已提交
2285 2286 2287 2288 2289 2290
  var result = that.isSet(new Set());
  ```


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

X
xdmal 已提交
2291
isSetIterator(value: Object): boolean
W
wusongqing 已提交
2292 2293 2294

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

W
wusongqing 已提交
2295 2296 2297
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2298 2299 2300
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2301

W
wusongqing 已提交
2302
**Return value**
W
wusongqing 已提交
2303 2304 2305
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **SetIterator** type; returns **false** otherwise.|
W
wusongqing 已提交
2306

W
wusongqing 已提交
2307
**Example**
2308
  ```js
2309
  var that = new util.types();
W
wusongqing 已提交
2310 2311 2312 2313 2314 2315 2316
  const set = new Set();
  var result = that.isSetIterator(set.keys());
  ```


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

X
xdmal 已提交
2317
isStringObject(value: Object): boolean
Z
zengyawen 已提交
2318 2319 2320

Checks whether the input value is a string object.

W
wusongqing 已提交
2321 2322 2323
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2324 2325 2326
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2327

W
wusongqing 已提交
2328
**Return value**
W
wusongqing 已提交
2329 2330 2331
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is a string object; returns **false** otherwise.|
W
wusongqing 已提交
2332

W
wusongqing 已提交
2333
**Example**
2334
  ```js
2335
  var that = new util.types();
W
wusongqing 已提交
2336 2337 2338 2339 2340 2341
  var result = that.isStringObject(new String('foo'));
  ```


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

X
xdmal 已提交
2342
isSymbolObject(value: Object): boolean
Z
zengyawen 已提交
2343 2344 2345

Checks whether the input value is a symbol object.

W
wusongqing 已提交
2346 2347 2348
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2349 2350 2351
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2352

W
wusongqing 已提交
2353
**Return value**
W
wusongqing 已提交
2354 2355 2356
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is a symbol object; returns **false** otherwise.|
W
wusongqing 已提交
2357

W
wusongqing 已提交
2358
**Example**
2359
  ```js
2360
  var that = new util.types();
W
wusongqing 已提交
2361 2362 2363 2364 2365 2366 2367
  const symbols = Symbol('foo');
  var result = that.isSymbolObject(Object(symbols));
  ```


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

X
xdmal 已提交
2368
isTypedArray(value: Object): boolean
W
wusongqing 已提交
2369 2370 2371 2372 2373

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 已提交
2374 2375 2376
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2377 2378 2379
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2380

W
wusongqing 已提交
2381
**Return value**
W
wusongqing 已提交
2382 2383 2384
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **TypedArray** type; returns **false** otherwise.|
W
wusongqing 已提交
2385

W
wusongqing 已提交
2386
**Example**
2387
  ```js
2388
  var that = new util.types();
W
wusongqing 已提交
2389 2390 2391 2392 2393 2394
  var result = that.isTypedArray(new Float64Array([]));
  ```


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

X
xdmal 已提交
2395
isUint8Array(value: Object): boolean
W
wusongqing 已提交
2396 2397 2398

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

W
wusongqing 已提交
2399 2400 2401
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2402 2403 2404
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2405

W
wusongqing 已提交
2406
**Return value**
W
wusongqing 已提交
2407 2408 2409
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Uint8Array** type; returns **false** otherwise.|
W
wusongqing 已提交
2410

W
wusongqing 已提交
2411
**Example**
2412
  ```js
2413
  var that = new util.types();
W
wusongqing 已提交
2414 2415 2416 2417 2418 2419
  var result = that.isUint8Array(new Uint8Array([]));
  ```


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

X
xdmal 已提交
2420
isUint8ClampedArray(value: Object): boolean
W
wusongqing 已提交
2421 2422 2423

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

W
wusongqing 已提交
2424 2425 2426
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2427 2428 2429
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2430

W
wusongqing 已提交
2431
**Return value**
W
wusongqing 已提交
2432 2433 2434
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Uint8ClampedArray** type; returns **false** otherwise.|
W
wusongqing 已提交
2435

W
wusongqing 已提交
2436
**Example**
2437
  ```js
2438
  var that = new util.types();
W
wusongqing 已提交
2439 2440 2441 2442 2443 2444
  var result = that.isUint8ClampedArray(new Uint8ClampedArray([]));
  ```


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

X
xdmal 已提交
2445
isUint16Array(value: Object): boolean
W
wusongqing 已提交
2446 2447 2448

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

W
wusongqing 已提交
2449 2450 2451
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2452 2453 2454
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2455

W
wusongqing 已提交
2456
**Return value**
W
wusongqing 已提交
2457 2458 2459
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Uint16Array** type; returns **false** otherwise.|
W
wusongqing 已提交
2460

W
wusongqing 已提交
2461
**Example**
2462
  ```js
2463
  var that = new util.types();
W
wusongqing 已提交
2464 2465 2466 2467 2468 2469
  var result = that.isUint16Array(new Uint16Array([]));
  ```


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

X
xdmal 已提交
2470
isUint32Array(value: Object): boolean
W
wusongqing 已提交
2471 2472 2473

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

W
wusongqing 已提交
2474 2475 2476
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2477 2478 2479
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2480

W
wusongqing 已提交
2481
**Return value**
W
wusongqing 已提交
2482 2483 2484
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **Uint32Array** type; returns **false** otherwise.|
W
wusongqing 已提交
2485

W
wusongqing 已提交
2486
**Example**
2487
  ```js
2488
  var that = new util.types();
W
wusongqing 已提交
2489 2490 2491 2492 2493 2494
  var result = that.isUint32Array(new Uint32Array([]));
  ```


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

X
xdmal 已提交
2495
isWeakMap(value: Object): boolean
W
wusongqing 已提交
2496 2497 2498

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

W
wusongqing 已提交
2499 2500 2501
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2502 2503 2504
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2505

W
wusongqing 已提交
2506
**Return value**
W
wusongqing 已提交
2507 2508 2509
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **WeakMap** type; returns **false** otherwise.|
W
wusongqing 已提交
2510

W
wusongqing 已提交
2511
**Example**
2512
  ```js
2513
  var that = new util.types();
W
wusongqing 已提交
2514 2515 2516 2517 2518 2519
  var result = that.isWeakMap(new WeakMap());
  ```


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

X
xdmal 已提交
2520
isWeakSet(value: Object): boolean
W
wusongqing 已提交
2521 2522 2523

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

W
wusongqing 已提交
2524 2525 2526
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2527 2528 2529
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | Object | Yes| Object to check.|
W
wusongqing 已提交
2530

W
wusongqing 已提交
2531
**Return value**
W
wusongqing 已提交
2532 2533 2534
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input value is of the **WeakSet** type; returns **false** otherwise.|
Z
zengyawen 已提交
2535

W
wusongqing 已提交
2536
**Example**
2537
  ```js
2538
  var that = new util.types();
W
wusongqing 已提交
2539
  var result = that.isWeakSet(new WeakSet());
W
wusongqing 已提交
2540
  ```