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


W
wusongqing 已提交
4 5
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> 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 已提交
6

W
wusongqing 已提交
7 8 9 10 11

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.


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

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

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

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

Prints the input content in a formatted string.

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

**Parameters**
W
wusongqing 已提交
26 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
**Return value**
W
wusongqing 已提交
32 33 34 35
  | Type| Description|
  | -------- | -------- |
  | string | String in the specified format.|

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


## util.getErrorString

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

Obtains detailed information about a system error code.

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

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

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

W
wusongqing 已提交
61
**Example**
W
wusongqing 已提交
62 63 64 65 66 67 68 69 70 71 72 73
  ```
  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 已提交
74

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

**Parameters**

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

W
wusongqing 已提交
83
**Return value**
W
wusongqing 已提交
84 85 86
  | 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 已提交
87

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


## util.promiseWrapper

promiseWrapper(original: (err: Object, value: Object) => void): Object
Z
zengyawen 已提交
104 105 106

Processes an asynchronous function and returns a promise version.

W
wusongqing 已提交
107 108 109
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
110 111
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
W
wusongqing 已提交
112
  | original | Function | Yes| Asynchronous function.|
W
wusongqing 已提交
113

W
wusongqing 已提交
114
**Return value**
W
wusongqing 已提交
115 116 117 118
  | 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 已提交
119
**Example**
W
wusongqing 已提交
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
  ```
  function aysnFun(str1, str2, callback) {
      if (typeof str1 === 'string' && typeof str2 === 'string') {
          callback(null, str1 + str2);
      } else {
          callback('type err');
      }
  }
  let newPromiseObj = util.promiseWrapper(aysnFun)("Hello", 'World');
  newPromiseObj.then(res => {
      console.log(res);
  })
  ```


## TextDecoder

### Attributes

W
wusongqing 已提交
139 140
**System capability**: SystemCapability.Utils.Lang

W
wusongqing 已提交
141 142
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
W
wusongqing 已提交
143
| encoding | string | Yes| No| Encoding format.<br>-&nbsp;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|
W
wusongqing 已提交
144 145 146 147 148 149 150 151 152 153
| 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.|


### constructor

constructor(encoding?:string, options?:{ fatal?:boolean;ignoreBOM?:boolean })

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

W
wusongqing 已提交
154 155 156
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
157 158 159 160 161 162
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | encoding | string | No| Encoding format.|
  | options | Object | No| Encoding-related options, which include **fatal** and **ignoreBOM**.|

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

W
wusongqing 已提交
164 165 166 167 168
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | fatal | boolean | No| Whether to display fatal errors.|
  | ignoreBOM | boolean | No| Whether to ignore the BOM.|

W
wusongqing 已提交
169
**Example**
W
wusongqing 已提交
170 171 172 173 174 175 176
  ```
  var textDecoder = new util.TextDecoder("utf-8",{ignoreBOM:true});
  ```


### decode

X
xdmal 已提交
177
decode(input: Unit8Array, options?:{stream?:false}): string
Z
zengyawen 已提交
178

Z
zengyawen 已提交
179
Decodes the input content.
Z
zengyawen 已提交
180

W
wusongqing 已提交
181 182 183
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
184 185 186 187 188 189
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | input | Unit8Array | Yes| Uint8Array to decode.|
  | options | Object | No| Options related to decoding.|

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

W
wusongqing 已提交
191 192 193
  | 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 已提交
194

W
wusongqing 已提交
195
**Return value**
W
wusongqing 已提交
196 197 198
  | Type| Description|
  | -------- | -------- |
  | string | Data decoded.|
Z
zengyawen 已提交
199

W
wusongqing 已提交
200
**Example**
W
wusongqing 已提交
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
  ```
  var textDecoder = new util.TextDecoder("utf-8",{ignoreBOM:true});
  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:");
  for(var j= 0; j < 6; j++) {
      console.log(result[j]);
  }
  var retStr = textDecoder.decode( result , {stream:false});
  console.log("retStr = " + retStr);
  ```
Z
zengyawen 已提交
217 218


W
wusongqing 已提交
219
## TextEncoder
Z
zengyawen 已提交
220

W
wusongqing 已提交
221
### Attributes
Z
zengyawen 已提交
222

W
wusongqing 已提交
223 224
**System capability**: SystemCapability.Utils.Lang

W
wusongqing 已提交
225 226 227
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| encoding | string | Yes| No| Encoding format. The default format is **utf-8**.|
Z
zengyawen 已提交
228 229


W
wusongqing 已提交
230
### constructor
Z
zengyawen 已提交
231

W
wusongqing 已提交
232
constructor()
Z
zengyawen 已提交
233

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

W
wusongqing 已提交
236 237 238
**System capability**: SystemCapability.Utils.Lang

**Example**
W
wusongqing 已提交
239 240 241 242 243 244 245 246
  ```
  var textEncoder = new util.TextEncoder();
  ```


### encode

encode(input?:string):Uint8Array
Z
zengyawen 已提交
247

Z
zengyawen 已提交
248
Encodes the input content.
Z
zengyawen 已提交
249

W
wusongqing 已提交
250 251 252
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
253 254 255 256
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | input | string | Yes| String to encode.|

W
wusongqing 已提交
257
**Return value**
W
wusongqing 已提交
258 259 260 261
  | Type| Description|
  | -------- | -------- |
  | Uint8Array | Encoded text.|

W
wusongqing 已提交
262
**Example**
W
wusongqing 已提交
263 264 265 266 267 268 269 270 271 272
  ```
  var textEncoder = new util.TextEncoder();
  var result = new Uint8Array(buffer);
  result = textEncoder.encode("\uD800¥¥");
  ```


### encodeInto

encodeInto(input:string, dest:Uint8Array, ):{ read:number; written:number }
Z
zengyawen 已提交
273 274 275

Stores the UTF-8 encoded text.

W
wusongqing 已提交
276 277 278
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
279 280 281 282
  | 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 已提交
283

W
wusongqing 已提交
284
**Return value**
W
wusongqing 已提交
285 286 287
  | Type| Description|
  | -------- | -------- |
  | Uint8Array | Encoded text.|
Z
zengyawen 已提交
288

W
wusongqing 已提交
289
**Example**
W
wusongqing 已提交
290 291 292 293 294 295
  ```
  var that = new util.TextEncoder();
  var buffer = new ArrayBuffer(4);
  this.dest = new Uint8Array(buffer);
  var result = that.encodeInto("abcd", this.dest);
  ```
Z
zengyawen 已提交
296

W
wusongqing 已提交
297
## RationalNumber<sup>8+</sup>
Z
zengyawen 已提交
298 299


W
wusongqing 已提交
300
### constructor<sup>8+</sup>
Z
zengyawen 已提交
301

W
wusongqing 已提交
302
constructor(numerator:number,denominator:number)
Z
zengyawen 已提交
303

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

W
wusongqing 已提交
306 307 308
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
309 310 311 312
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | numerator | number | Yes| Numerator, which is an integer.|
  | denominator | number | Yes| Denominator, which is an integer.|
Z
zengyawen 已提交
313

W
wusongqing 已提交
314
**Example**
W
wusongqing 已提交
315 316 317
  ```
  var rationalNumber = new util.RationalNumber(1,2);
  ```
Z
zengyawen 已提交
318 319


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

W
wusongqing 已提交
322
static createRationalFromString​(rationalString:string):RationalNumber​
Z
zengyawen 已提交
323

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

W
wusongqing 已提交
326 327 328
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
329 330 331
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | rationalString | string | Yes| String used to create the **RationalNumber** object.|
Z
zengyawen 已提交
332

W
wusongqing 已提交
333
**Return value**
W
wusongqing 已提交
334 335 336
  | Type| Description|
  | -------- | -------- |
  | object | **RationalNumber** object created.|
Z
zengyawen 已提交
337

W
wusongqing 已提交
338
**Example**
W
wusongqing 已提交
339 340 341 342
  ```
  var rationalNumber = new util.RationalNumber(1,2);
  var rational = rationalNumer.creatRationalFromString("3/4");
  ```
Z
zengyawen 已提交
343 344


W
wusongqing 已提交
345
### compareTo<sup>8+</sup>
Z
zengyawen 已提交
346

W
wusongqing 已提交
347
compareTo​(another:RationalNumber):number​
Z
zengyawen 已提交
348

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

W
wusongqing 已提交
351 352 353
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
354 355 356
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | another | RationalNumber | Yes| Object used to compare with this **RationalNumber** object.|
Z
zengyawen 已提交
357

W
wusongqing 已提交
358
**Return value**
W
wusongqing 已提交
359 360 361
  | 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 已提交
362

W
wusongqing 已提交
363
**Example**
W
wusongqing 已提交
364 365 366 367 368
  ```
  var rationalNumber = new util.RationalNumber(1,2);
  var rational = rationalNumer.creatRationalFromString("3/4");
  var result = rationalNumber.compareTo(rational);
  ```
Z
zengyawen 已提交
369 370


W
wusongqing 已提交
371
### valueOf<sup>8+</sup>
Z
zengyawen 已提交
372

W
wusongqing 已提交
373
valueOf():number
Z
zengyawen 已提交
374

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

W
wusongqing 已提交
377 378 379
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
380 381 382
  | Type| Description|
  | -------- | -------- |
  | number | An integer or a floating-point number.|
Z
zengyawen 已提交
383

W
wusongqing 已提交
384
**Example**
W
wusongqing 已提交
385 386 387 388
  ```
  var rationalNumber = new util.RationalNumber(1,2);
  var result = rationalNumber.valueOf();
  ```
Z
zengyawen 已提交
389 390


W
wusongqing 已提交
391
### equals<sup>8+</sup>
Z
zengyawen 已提交
392

W
wusongqing 已提交
393
equals​(obj:Object):boolean
Z
zengyawen 已提交
394

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

W
wusongqing 已提交
397 398 399
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
400 401 402
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | object | Object | Yes| Object used to compare with this **RationalNumber** object.|
Z
zengyawen 已提交
403

W
wusongqing 已提交
404
**Return value**
W
wusongqing 已提交
405 406 407
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the two objects are equal; returns **false** otherwise.|
Z
zengyawen 已提交
408

W
wusongqing 已提交
409
**Example**
W
wusongqing 已提交
410 411 412 413 414
  ```
  var rationalNumber = new util.RationalNumber(1,2);
  var rational = rationalNumer.creatRationalFromString("3/4");
  var result = rationalNumber.equals(rational);
  ```
Z
zengyawen 已提交
415 416


W
wusongqing 已提交
417
### getCommonDivisor<sup>8+</sup>
Z
zengyawen 已提交
418

W
wusongqing 已提交
419
static getCommonDivisor​(number1:number,number2:number):number
Z
zengyawen 已提交
420

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

W
wusongqing 已提交
423 424 425
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
426 427 428 429
  | 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 已提交
430

W
wusongqing 已提交
431
**Return value**
W
wusongqing 已提交
432 433 434
  | Type| Description|
  | -------- | -------- |
  | number | Greatest common divisor obtained.|
Z
zengyawen 已提交
435

W
wusongqing 已提交
436
**Example**
W
wusongqing 已提交
437 438 439 440
  ```
  var rationalNumber = new util.RationalNumber(1,2);
  var result = rationalNumber.getCommonDivisor(4,6);
  ```
Z
zengyawen 已提交
441 442


W
wusongqing 已提交
443
### getNumerator<sup>8+</sup>
Z
zengyawen 已提交
444

W
wusongqing 已提交
445
getNumerator​():number
Z
zengyawen 已提交
446

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

W
wusongqing 已提交
449 450 451 452
**System capability**: SystemCapability.Utils.Lang

**Return value**

W
wusongqing 已提交
453 454 455
  | Type| Description|
  | -------- | -------- |
  | number | Numerator of this **RationalNumber** object.|
Z
zengyawen 已提交
456

W
wusongqing 已提交
457
**Example**
W
wusongqing 已提交
458 459 460 461
  ```
  var rationalNumber = new util.RationalNumber(1,2);
  var result = rationalNumber.getNumerator();
  ```
Z
zengyawen 已提交
462 463


W
wusongqing 已提交
464
### getDenominator<sup>8+</sup>
Z
zengyawen 已提交
465

W
wusongqing 已提交
466
getDenominator​():number
Z
zengyawen 已提交
467

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

W
wusongqing 已提交
470 471 472
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
473 474 475
  | Type| Description|
  | -------- | -------- |
  | number | Denominator of this **RationalNumber** object.|
Z
zengyawen 已提交
476

W
wusongqing 已提交
477
**Example**
W
wusongqing 已提交
478 479 480 481
  ```
  var rationalNumber = new util.RationalNumber(1,2);
  var result = rationalNumber.getDenominator();
  ```
Z
zengyawen 已提交
482 483


W
wusongqing 已提交
484
### isZero<sup>8+</sup>
Z
zengyawen 已提交
485

W
wusongqing 已提交
486
isZero​():boolean
Z
zengyawen 已提交
487

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

W
wusongqing 已提交
490 491 492
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
493 494 495
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the value of this **RationalNumber** object is **0**; returns **false** otherwise.|
Z
zengyawen 已提交
496

W
wusongqing 已提交
497
**Example**
W
wusongqing 已提交
498 499 500 501
  ```
  var rationalNumber = new util.RationalNumber(1,2);
  var result = rationalNumber.isZero();
  ```
Z
zengyawen 已提交
502 503


W
wusongqing 已提交
504
### isNaN<sup>8+</sup>
Z
zengyawen 已提交
505

W
wusongqing 已提交
506
isNaN​():boolean
Z
zengyawen 已提交
507

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

W
wusongqing 已提交
510 511 512
**System capability**: SystemCapability.Utils.Lang

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

W
wusongqing 已提交
517
**Example**
W
wusongqing 已提交
518 519 520 521
  ```
  var rationalNumber = new util.RationalNumber(1,2);
  var result = rationalNumber.isNaN();
  ```
Z
zengyawen 已提交
522 523


W
wusongqing 已提交
524
### isFinite<sup>8+</sup>
Z
zengyawen 已提交
525

W
wusongqing 已提交
526
isFinite​():boolean
Z
zengyawen 已提交
527

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

W
wusongqing 已提交
530 531 532
**System capability**: SystemCapability.Utils.Lang

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

W
wusongqing 已提交
537
**Example**
W
wusongqing 已提交
538 539 540 541
  ```
  var rationalNumber = new util.RationalNumber(1,2);
  var result = rationalNumber.isFinite();
  ```
Z
zengyawen 已提交
542 543


W
wusongqing 已提交
544
### toString<sup>8+</sup>
Z
zengyawen 已提交
545

W
wusongqing 已提交
546
toString​():string
Z
zengyawen 已提交
547

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

W
wusongqing 已提交
550 551 552
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
553 554 555
  | 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 已提交
556

W
wusongqing 已提交
557
**Example**
W
wusongqing 已提交
558 559 560 561
  ```
  var rationalNumber = new util.RationalNumber(1,2);
  var result = rationalNumber.toString();
  ```
Z
zengyawen 已提交
562

W
wusongqing 已提交
563
## LruBuffer<sup>8+</sup>
Z
zengyawen 已提交
564

W
wusongqing 已提交
565
### Attributes
Z
zengyawen 已提交
566

W
wusongqing 已提交
567 568
**System capability**: SystemCapability.Utils.Lang

W
wusongqing 已提交
569 570 571
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| length | number | Yes| No| Total number of values in this buffer.|
Z
zengyawen 已提交
572

W
wusongqing 已提交
573
**Example**
W
wusongqing 已提交
574 575 576 577 578 579
  ```
  var pro = new util.LruBuffer();
  pro.put(2,10);
  pro.put(1,8);
  var result = pro.length;
  ```
Z
zengyawen 已提交
580 581


W
wusongqing 已提交
582
### constructor<sup>8+</sup>
Z
zengyawen 已提交
583

W
wusongqing 已提交
584
constructor(capacity?:number)
Z
zengyawen 已提交
585

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

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

**Parameters**
W
wusongqing 已提交
591 592 593
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | capacity | number | No| Capacity of the **LruBuffer** to create.|
Z
zengyawen 已提交
594

W
wusongqing 已提交
595
**Example**
W
wusongqing 已提交
596 597 598
  ```
  var lrubuffer= new util.LruBuffer();
  ```
Z
zengyawen 已提交
599 600


W
wusongqing 已提交
601
### updateCapacity<sup>8+</sup>
Z
zengyawen 已提交
602

W
wusongqing 已提交
603
updateCapacity(newCapacity:number):void
Z
zengyawen 已提交
604

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

W
wusongqing 已提交
607 608 609
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
610 611 612
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | newCapacity | number | Yes| New capacity of the **LruBuffer**.|
Z
zengyawen 已提交
613

W
wusongqing 已提交
614
**Example**
W
wusongqing 已提交
615 616 617 618
  ```
  var pro = new util.LruBuffer();
  var result = pro.updateCapacity(100);
  ```
Z
zengyawen 已提交
619 620


W
wusongqing 已提交
621
### toString<sup>8+</sup>
Z
zengyawen 已提交
622

W
wusongqing 已提交
623
toString():string
Z
zengyawen 已提交
624

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

W
wusongqing 已提交
627 628 629
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
630 631 632 633
  | Type| Description|
  | -------- | -------- |
  | string | String representation of this **LruBuffer** object.|

W
wusongqing 已提交
634
**Example**
W
wusongqing 已提交
635 636 637 638 639 640 641 642 643 644 645 646 647 648 649
  ```
  var pro = new util.LruBuffer();
  pro.put(2,10);
  pro.get(2);
  pro.remove(20);
  var result = pro.toString();
  ```


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

getCapacity():number

Obtains the capacity of this buffer.

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

**Return value**
W
wusongqing 已提交
653 654 655 656
  | Type| Description|
  | -------- | -------- |
  | number | Capacity of this buffer.|

W
wusongqing 已提交
657
**Example**
W
wusongqing 已提交
658 659 660 661
  ```
  var pro = new util.LruBuffer();
  var result = pro.getCapacity();
  ```
Z
zengyawen 已提交
662 663


W
wusongqing 已提交
664
### clear<sup>8+</sup>
Z
zengyawen 已提交
665

W
wusongqing 已提交
666
clear():void
Z
zengyawen 已提交
667

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

W
wusongqing 已提交
670 671 672
**System capability**: SystemCapability.Utils.Lang

**Example**
W
wusongqing 已提交
673 674 675 676 677 678
  ```
  var pro = new util.LruBuffer();
  pro.put(2,10);
  var result = pro.size();
  pro.clear();
  ```
Z
zengyawen 已提交
679 680


W
wusongqing 已提交
681
### getCreateCount<sup>8+</sup>
Z
zengyawen 已提交
682

W
wusongqing 已提交
683 684 685 686
getCreateCount():number

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

W
wusongqing 已提交
687 688 689
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
690 691 692 693
  | Type| Description|
  | -------- | -------- |
  | number | Number of return values for **createDefault()**.|

W
wusongqing 已提交
694
**Example**
W
wusongqing 已提交
695 696 697 698 699 700 701 702 703 704 705 706 707
  ```
  var pro = new util.LruBuffer();
  pro.put(1,8);
  var result = pro.getCreateCount();
  ```


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

getMissCount():number

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

W
wusongqing 已提交
708 709 710
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
711 712 713 714
  | Type| Description|
  | -------- | -------- |
  | number | Number of times that the queried values are mismatched.|

W
wusongqing 已提交
715
**Example**
W
wusongqing 已提交
716 717 718 719 720 721 722 723 724 725 726 727 728 729
  ```
  var pro = new util.LruBuffer();
  pro.put(2,10);
  pro.get(2);
  var result = pro.getMissCount();
  ```


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

getRemovalCount():number

Obtains the number of removals from this buffer.

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

**Return value**
W
wusongqing 已提交
733 734 735 736
  | Type| Description|
  | -------- | -------- |
  | number | Number of removals from the buffer.|

W
wusongqing 已提交
737
**Example**
W
wusongqing 已提交
738 739 740 741 742 743 744 745 746 747 748 749 750 751 752
  ```
  var pro = new util.LruBuffer();
  pro.put(2,10);
  pro.updateCapacity(2);
  pro.put(50,22);
  var result = pro.getRemovalCount();
  ```


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

getMatchCount():number

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

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

**Return value**
W
wusongqing 已提交
756 757 758 759
  | Type| Description|
  | -------- | -------- |
  | number | Number of times that the queried values are matched.|

W
wusongqing 已提交
760
**Example**
W
wusongqing 已提交
761 762 763 764 765 766 767 768 769 770 771 772 773 774
  ```
  var pro = new util.LruBuffer();
  pro.put(2,10);
  pro.get(2);
  var result = pro.getMatchCount();
  ```


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

getPutCount():number

Obtains the number of additions to this buffer.

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

**Return value**
W
wusongqing 已提交
778 779 780 781
  | Type| Description|
  | -------- | -------- |
  | number | Number of additions to the buffer.|

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


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

isEmpty():boolean

Checks whether this buffer is empty.

W
wusongqing 已提交
796 797 798
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
799 800 801 802
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the buffer does not contain any value.|

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


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

get(key:K):V | undefined
Z
zengyawen 已提交
814 815 816

Obtains the value of the specified key.

W
wusongqing 已提交
817 818 819
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
820 821 822 823
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | key | K | Yes| Key based on which the value is queried.|

W
wusongqing 已提交
824
**Return value**
W
wusongqing 已提交
825 826 827 828
  | Type| Description|
  | -------- | -------- |
  | V&nbsp;\|&nbsp;undefind | Returns the value of the key if a match is found in the buffer; returns **undefined** otherwise.|

W
wusongqing 已提交
829
**Example**
W
wusongqing 已提交
830 831 832 833 834 835 836 837 838 839
  ```
  var pro = new util.LruBuffer();
  pro.put(2,10);
  var result  = pro.get(2);
  ```


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

put(key:K,value:V):V
Z
zengyawen 已提交
840 841 842

Adds a key-value pair to this buffer.

W
wusongqing 已提交
843 844 845
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
846 847 848 849
  | 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 已提交
850

W
wusongqing 已提交
851
**Return value**
W
wusongqing 已提交
852 853 854
  | 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 已提交
855

W
wusongqing 已提交
856
**Example**
W
wusongqing 已提交
857 858 859 860
  ```
  var pro = new util.LruBuffer();
  var result = pro.put(2,10);
  ```
Z
zengyawen 已提交
861 862


W
wusongqing 已提交
863
### values<sup>8+</sup>
Z
zengyawen 已提交
864

W
wusongqing 已提交
865 866 867
values():V[]

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

W
wusongqing 已提交
869 870 871
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
872 873 874
  | Type| Description|
  | -------- | -------- |
  | V&nbsp;[] | All values in the buffer, listed from the most to the least recently accessed.|
Z
zengyawen 已提交
875

W
wusongqing 已提交
876
**Example**
W
wusongqing 已提交
877 878 879 880 881 882 883
  ```
  var pro = new util.LruBuffer();
  pro.put(2,10);
  pro.put(2,"anhu");
  pro.put("afaf","grfb");
  var result = pro.values();
  ```
Z
zengyawen 已提交
884 885


W
wusongqing 已提交
886 887 888
### keys<sup>8+</sup>

keys():K[]
Z
zengyawen 已提交
889 890 891

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

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

**Return value**
W
wusongqing 已提交
895 896 897 898
  | Type| Description|
  | -------- | -------- |
  | K&nbsp;[] | All keys in the buffer, listed from the most to the least recently accessed.|

W
wusongqing 已提交
899
**Example**
W
wusongqing 已提交
900 901 902 903 904 905 906 907 908 909 910 911 912
  ```
  var pro = new util.LruBuffer();
  pro.put(2,10);
  var result = pro.keys();
  ```


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

remove(key:K):V | undefined

Removes the specified key and its value from this buffer.

W
wusongqing 已提交
913 914 915
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
916 917 918 919
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | key | K | Yes| Key to remove.|

W
wusongqing 已提交
920
**Return value**
W
wusongqing 已提交
921 922 923 924
  | Type| Description|
  | -------- | -------- |
  | V&nbsp;\|&nbsp;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 已提交
925
**Example**
W
wusongqing 已提交
926 927 928 929 930 931 932 933 934 935 936 937 938
  ```
  var pro = new util.LruBuffer();
  pro.put(2,10);
  var result = pro.remove(20);
  ```


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

afterRemoval(isEvict:boolean,key:K,value:V,newValue:V):void

Performs subsequent operations after a value is removed.

W
wusongqing 已提交
939 940 941
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
942 943 944 945 946 947 948
  | 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 已提交
949
**Example**
W
wusongqing 已提交
950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982
  ```
  var arr = [];
  class ChildLruBuffer extends util.LruBuffer
  {
  	constructor()
  	{
  		super();
  	}
  	static getInstance()
  	{
  		if(this.instance ==  null)
  		{
  			this.instance = new ChildLruBuffer();
  		}
  		return this.instance;  
  	}
  	afterRemoval(isEvict, key, value, newValue)
  	{
  		if (isEvict === false)
  		{
  			arr = [key, value, newValue];
  		}
  	}
  }
  ChildLruBuffer.getInstance().afterRemoval(false,10,30,null);
  ```


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

contains(key:K):boolean

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

W
wusongqing 已提交
984 985 986
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
987 988 989
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | key | K | Yes| Key to check.|
Z
zengyawen 已提交
990

W
wusongqing 已提交
991
**Return value**
W
wusongqing 已提交
992 993 994
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the buffer contains the specified key; returns **false** otherwise.|
Z
zengyawen 已提交
995

W
wusongqing 已提交
996
**Example**
W
wusongqing 已提交
997 998 999 1000 1001
  ```
  var pro = new util.LruBuffer();
  pro.put(2,10);
  var result = pro.contains(20);
  ```
Z
zengyawen 已提交
1002 1003


W
wusongqing 已提交
1004 1005 1006
### createDefault<sup>8+</sup>

createDefault(key:K):V
Z
zengyawen 已提交
1007 1008 1009

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

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

**Parameters**
W
wusongqing 已提交
1013 1014 1015
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | key | K | Yes| Key of which the value is missing.|
Z
zengyawen 已提交
1016

W
wusongqing 已提交
1017
**Return value**
W
wusongqing 已提交
1018 1019 1020
  | Type| Description|
  | -------- | -------- |
  | V | Value of the key.|
Z
zengyawen 已提交
1021

W
wusongqing 已提交
1022
**Example**
W
wusongqing 已提交
1023 1024 1025 1026
  ```
  var pro = new util.LruBuffer();
  var result = pro.createDefault(50);
  ```
Z
zengyawen 已提交
1027 1028


W
wusongqing 已提交
1029
### entries<sup>8+</sup>
Z
zengyawen 已提交
1030

W
wusongqing 已提交
1031
entries():IterableIterator&lt;[K,V]&gt;
Z
zengyawen 已提交
1032

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

W
wusongqing 已提交
1035 1036 1037
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
1038 1039 1040
  | Type| Description|
  | -------- | -------- |
  | [K,&nbsp;V] | Iterable array.|
Z
zengyawen 已提交
1041

W
wusongqing 已提交
1042
**Example**
W
wusongqing 已提交
1043 1044 1045 1046 1047
  ```
  var pro = new util.LruBuffer();
  pro.put(2,10);
  var result = pro.entries();
  ```
Z
zengyawen 已提交
1048 1049


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

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

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

W
wusongqing 已提交
1056 1057 1058
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
1059 1060 1061
  | Type| Description|
  | -------- | -------- |
  | [K,&nbsp;V] | Two-dimensional array in key-value pairs.|
Z
zengyawen 已提交
1062

W
wusongqing 已提交
1063
**Example**
W
wusongqing 已提交
1064 1065 1066 1067 1068
  ```
  var pro = new util.LruBuffer();
  pro.put(2,10);
  var result = pro[symbol.iterator]();
  ```
Z
zengyawen 已提交
1069 1070


W
wusongqing 已提交
1071
## Scope<sup>8+</sup>
Z
zengyawen 已提交
1072 1073


W
wusongqing 已提交
1074
### ScopeType<sup>8+</sup>
Z
zengyawen 已提交
1075

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

W
wusongqing 已提交
1078
The values of the **ScopeComparable** type are used to implement the **compareTo** method. Therefore, ensure that the input parameters are comparable.
Z
zengyawen 已提交
1079 1080 1081 1082 1083 1084 1085 1086
```
interface ScopeComparable{
    compareTo(other:ScopeComparable):boolean;
}
type ScopeType = ScopeComparable | number;
```


W
wusongqing 已提交
1087
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 已提交
1088

W
wusongqing 已提交
1089 1090

Example
Z
zengyawen 已提交
1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108
```
class Temperature{
    constructor(value){
       this._temp = value;
    }
    comapreTo(value){
       return this._temp >= value.getTemp();
    }
    getTemp(){
       return this._temp;
    }
    toString(){
       return this._temp.toString();
    }
}
```


W
wusongqing 已提交
1109 1110 1111 1112 1113 1114
### constructor<sup>8+</sup>

constructor(lowerObj:ScopeType,upperObje:ScopeType)

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

W
wusongqing 已提交
1115 1116 1117
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1118 1119 1120 1121 1122
  | 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 已提交
1123
**Example**
W
wusongqing 已提交
1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136
  ```
  var tempLower = new Temperature(30);
  var tempUpper = new Temperature(40);
  var range = new util.Scope(tempLower, tempUpper);
  ```


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

toString():string

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

W
wusongqing 已提交
1137 1138 1139
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
1140 1141 1142 1143
  | Type| Description|
  | -------- | -------- |
  | string | String representation containing the **Scope**.|

W
wusongqing 已提交
1144
**Example**
W
wusongqing 已提交
1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158
  ```
  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>

intersect(range:Scope):Scope

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

W
wusongqing 已提交
1159 1160 1161
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1162 1163 1164 1165
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | range | [Scope](#scope8) | Yes| **Scope** specified.|

W
wusongqing 已提交
1166
**Return value**
W
wusongqing 已提交
1167 1168 1169 1170
  | Type| Description|
  | -------- | -------- |
  | [Scope](#scope8) | Intersection of this **Scope** and the given **Scope**.|

W
wusongqing 已提交
1171
**Example**
W
wusongqing 已提交
1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188
  ```
  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>

intersect(lowerObj:ScopeType,upperObj:ScopeType):Scope

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

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

**Parameters**
W
wusongqing 已提交
1192 1193 1194 1195 1196
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | lowerObj | [ScopeType](#scopetype8) | Yes| Lower limit.|
  | upperObj | [ScopeType](#scopetype8) | Yes| Upper limit.|

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

W
wusongqing 已提交
1202
**Example**
W
wusongqing 已提交
1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218
  ```
  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>

getUpper():ScopeType

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

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

**Return value**

W
wusongqing 已提交
1223 1224 1225 1226
  | Type| Description|
  | -------- | -------- |
  | [ScopeType](#scopetype8) | Upper limit of this **Scope**.|

W
wusongqing 已提交
1227
**Example**
W
wusongqing 已提交
1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241
  ```
  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>

getLower():ScopeType

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

W
wusongqing 已提交
1242 1243 1244
**System capability**: SystemCapability.Utils.Lang

**Return value**
W
wusongqing 已提交
1245 1246 1247 1248
  | Type| Description|
  | -------- | -------- |
  | [ScopeType](#scopetype8) | Lower limit of this **Scope**.|

W
wusongqing 已提交
1249
**Example**
W
wusongqing 已提交
1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263
  ```
  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>

expand(lowerObj:ScopeType,upperObj:ScopeType):Scope

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

W
wusongqing 已提交
1264 1265 1266
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1267 1268 1269 1270 1271
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | lowerObj | [ScopeType](#scopetype8) | Yes| Lower limit.|
  | upperObj | [ScopeType](#scopetype8) | Yes| Upper limit.|

W
wusongqing 已提交
1272
**Return value**
W
wusongqing 已提交
1273 1274 1275 1276
  | Type| Description|
  | -------- | -------- |
  | [Scope](#scope8) | Union set of this **Scope** and the given lower and upper limits.|

W
wusongqing 已提交
1277
**Example**
W
wusongqing 已提交
1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293
  ```
  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>

expand(range:Scope):Scope

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

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

**Parameters**
W
wusongqing 已提交
1297 1298 1299 1300
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | range | [Scope](#scope8) | Yes| **Scope** specified.|

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

W
wusongqing 已提交
1306
**Example**
W
wusongqing 已提交
1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323
  ```
  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>

expand(value:ScopeType):Scope

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

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

**Parameters**
W
wusongqing 已提交
1327 1328 1329 1330
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | [ScopeType](#scopetype8) | Yes| Value specified.|

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

W
wusongqing 已提交
1336
**Example**
W
wusongqing 已提交
1337 1338 1339 1340 1341 1342 1343
  ```
  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 已提交
1344 1345


W
wusongqing 已提交
1346
### contains<sup>8+</sup>
Z
zengyawen 已提交
1347

W
wusongqing 已提交
1348
contains(value:ScopeType):boolean
Z
zengyawen 已提交
1349

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

W
wusongqing 已提交
1352 1353 1354
**System capability**: SystemCapability.Utils.Lang

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

W
wusongqing 已提交
1359
**Return value**
W
wusongqing 已提交
1360 1361 1362 1363
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the value is within this **Scope**; returns **false** otherwise.|

W
wusongqing 已提交
1364
**Example**
W
wusongqing 已提交
1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379
  ```
  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>

contains(range:Scope):boolean

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

W
wusongqing 已提交
1380 1381 1382
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1383 1384
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
W
wusongqing 已提交
1385
  | range | [Scope](#scope8) | Yes| **Scope** specified.|
W
wusongqing 已提交
1386

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

W
wusongqing 已提交
1392
**Example**
W
wusongqing 已提交
1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409
  ```
  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>

clamp(value:ScopeType):ScopeType

Limits a value to this **Scope**.

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

**Parameters**
W
wusongqing 已提交
1413 1414 1415 1416
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | [ScopeType](#scopetype8) | Yes| Value specified.|

W
wusongqing 已提交
1417
**Return value**
W
wusongqing 已提交
1418 1419 1420 1421
  | 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 已提交
1422
**Example**
W
wusongqing 已提交
1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440
  ```
  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 已提交
1441 1442 1443
**System capability**: SystemCapability.Utils.Lang

**Example**
W
wusongqing 已提交
1444 1445 1446 1447 1448 1449 1450 1451
  ```
  var base64 = new  util.Base64();
  ```


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

encodeSync(src:Uint8Array):Uint8Array
Z
zengyawen 已提交
1452 1453 1454

Encodes the input content.

W
wusongqing 已提交
1455 1456 1457
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1458 1459 1460 1461
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | src | Uint8Array | Yes| Uint8Array to encode.|

W
wusongqing 已提交
1462
**Return value**
W
wusongqing 已提交
1463 1464 1465 1466
  | Type| Description|
  | -------- | -------- |
  | Uint8Array | Uint8Array encoded.|

W
wusongqing 已提交
1467
**Example**
W
wusongqing 已提交
1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480
  ```
  var that = new util.Base64();
  var array = new Uint8Array([115,49,51]);
  var result = that.encodeSync(array);
  ```


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

encodeToStringSync(src:Uint8Array):string

Encodes the input content.

W
wusongqing 已提交
1481 1482 1483
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1484 1485 1486 1487
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | src | Uint8Array | Yes| Uint8Array to encode.|

W
wusongqing 已提交
1488
**Return value**
W
wusongqing 已提交
1489 1490 1491 1492
  | Type| Description|
  | -------- | -------- |
  | string | String encoded from the Uint8Array.|

W
wusongqing 已提交
1493
**Example**
W
wusongqing 已提交
1494 1495 1496 1497 1498 1499 1500 1501 1502 1503
  ```
  var that = new util.Base64();
  var array = new Uint8Array([115,49,51]);
  var result = that.encodeToStringSync(array);
  ```


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

decodeSync(src:Uint8Array | string):Uint8Array
Z
zengyawen 已提交
1504 1505 1506

Decodes the input content.

W
wusongqing 已提交
1507 1508 1509
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1510 1511 1512 1513
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | src | Uint8Array&nbsp;\|&nbsp;string | Yes| Uint8Array or string to decode.|

W
wusongqing 已提交
1514
**Return value**
W
wusongqing 已提交
1515 1516 1517 1518
  | Type| Description|
  | -------- | -------- |
  | Uint8Array | Uint8Array decoded.|

W
wusongqing 已提交
1519
**Example**
W
wusongqing 已提交
1520 1521 1522 1523 1524 1525 1526 1527 1528 1529
  ```
  var that = new util.Base64();
  var buff = 'czEz';
  var result = that.decodeSync(buff);
  ```


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

encode(src:Uint8Array):Promise&lt;Uint8Array&gt;
Z
zengyawen 已提交
1530 1531 1532

Encodes the input content asynchronously.

W
wusongqing 已提交
1533 1534 1535
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1536 1537 1538 1539
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | src | Uint8Array | Yes| Uint8Array to encode asynchronously.|

W
wusongqing 已提交
1540
**Return value**
W
wusongqing 已提交
1541 1542 1543 1544
  | Type| Description|
  | -------- | -------- |
  | Promise&lt;Uint8Array&gt; | Uint8Array obtained after asynchronous encoding.|

W
wusongqing 已提交
1545
**Example**
W
wusongqing 已提交
1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563
  ```
  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++) {        
          console.log(val[i])
      }
  })
  ```


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

encodeToString(src:Uint8Array):Promise&lt;string&gt;

Encodes the input content asynchronously.

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

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

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

W
wusongqing 已提交
1576
**Example**
W
wusongqing 已提交
1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588
  ```
  var that = new util.Base64();
  var array = new Uint8Array([115,49,51]);
  that.encodeToString(array).then(val=>{    
      console.log(val)
  })
  ```


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

decode(src:Uint8Array | string):Promise&lt;Uint8Array&gt;
Z
zengyawen 已提交
1589 1590 1591

Decodes the input content asynchronously.

W
wusongqing 已提交
1592 1593 1594
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1595 1596 1597 1598
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | src | Uint8Array&nbsp;\|&nbsp;string | Yes| Uint8Array or string to decode asynchronously.|

W
wusongqing 已提交
1599
**Return value**
W
wusongqing 已提交
1600 1601 1602 1603
  | Type| Description|
  | -------- | -------- |
  | Promise&lt;Uint8Array&gt; | Uint8Array obtained after asynchronous decoding.|

W
wusongqing 已提交
1604
**Example**
W
wusongqing 已提交
1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625
  ```
  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++) {        
          console.log(val[i])
      }
  })
  ```


## Types<sup>8+</sup>


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

constructor()

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

W
wusongqing 已提交
1626 1627 1628
**System capability**: SystemCapability.Utils.Lang

**Example**
W
wusongqing 已提交
1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639
  ```
  var type = new util.Types();
  ```


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

isAnyArrayBuffer(value: Object):boolean

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

W
wusongqing 已提交
1640 1641 1642
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1643 1644 1645 1646
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
1647
**Return value**
W
wusongqing 已提交
1648 1649 1650 1651
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise.|

W
wusongqing 已提交
1652
**Example**
W
wusongqing 已提交
1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666
  ```
  var that = new util.Types();
  var result = that.isAnyArrayBuffer(new ArrayBuffer([]));
  ```


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

isArrayBufferView(value: Object):boolean

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 已提交
1667 1668 1669
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1670 1671 1672 1673
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
1674
**Return value**
W
wusongqing 已提交
1675 1676 1677 1678
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is of the **ArrayBufferView** type; returns **false** otherwise.|

W
wusongqing 已提交
1679
**Example**
W
wusongqing 已提交
1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691
  ```
  var that = new util.Types();
  var result = that.isArrayBufferView(new Int8Array([]));
  ```


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

isArgumentsObject(value: Object):boolean

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

W
wusongqing 已提交
1692 1693 1694
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1695 1696 1697 1698
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
1699
**Return value**
W
wusongqing 已提交
1700 1701 1702 1703
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is of the **arguments** type; returns **false** otherwise.|

W
wusongqing 已提交
1704
**Example**
W
wusongqing 已提交
1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719
  ```
  var that = new util.Types();
  function foo() {
      var result = that.isArgumentsObject(arguments);
  }
  var f = foo();
  ```


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

isArrayBuffer(value: Object):boolean

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

W
wusongqing 已提交
1720 1721 1722
**System capability**: SystemCapability.Utils.Lang

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

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

W
wusongqing 已提交
1732
**Example**
W
wusongqing 已提交
1733 1734 1735 1736 1737 1738 1739 1740 1741
  ```
  var that = new util.Types();
  var result = that.isArrayBuffer(new ArrayBuffer([]));
  ```


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

isAsyncFunction(value: Object):boolean
Z
zengyawen 已提交
1742 1743 1744

Checks whether the input value is an asynchronous function.

W
wusongqing 已提交
1745 1746 1747
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1748 1749 1750 1751
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
1752
**Return value**
W
wusongqing 已提交
1753 1754 1755 1756
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is an asynchronous function; returns **false** otherwise.|

W
wusongqing 已提交
1757
**Example**
W
wusongqing 已提交
1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769
  ```
  var that = new util.Types();
  var result = that.isAsyncFunction(async function foo() {});
  ```


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

isBooleanObject(value: Object):boolean

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

W
wusongqing 已提交
1770 1771 1772
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1773 1774 1775 1776
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
1777
**Return value**
W
wusongqing 已提交
1778 1779 1780 1781
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is of the **Boolean** type; returns **false** otherwise.|

W
wusongqing 已提交
1782
**Example**
W
wusongqing 已提交
1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794
  ```
  var that = new util.Types();
  var result = that.isBooleanObject(new Boolean(true));
  ```


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

isBoxedPrimitive(value: Object):boolean

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

W
wusongqing 已提交
1795 1796 1797
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1798 1799 1800 1801
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
1802
**Return value**
W
wusongqing 已提交
1803 1804 1805 1806
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is of the **Boolean**, **Number**, **String**, or **Symbol** type; returns **false** otherwise.|

W
wusongqing 已提交
1807
**Example**
W
wusongqing 已提交
1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819
  ```
  var that = new util.Types();
  var result = that.isBoxedPrimitive(new Boolean(false));
  ```


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

isDataView(value: Object):boolean

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

W
wusongqing 已提交
1820 1821 1822
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1823 1824 1825 1826
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
1827
**Return value**
W
wusongqing 已提交
1828 1829 1830 1831
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is of the **DataView** type; returns **false** otherwise.|

W
wusongqing 已提交
1832
**Example**
W
wusongqing 已提交
1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845
  ```
  var that = new util.Types();
  const ab = new ArrayBuffer(20);
  var result = that.isDataView(new DataView(ab));
  ```


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

isDate(value: Object):boolean

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

W
wusongqing 已提交
1846 1847 1848
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1849 1850 1851 1852
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
1853
**Return value**
W
wusongqing 已提交
1854 1855 1856 1857
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is of the **Date** type; returns **false** otherwise.|

W
wusongqing 已提交
1858
**Example**
W
wusongqing 已提交
1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870
  ```
  var that = new util.Types();
  var result = that.isDate(new Date());
  ```


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

isExternal(value: Object):boolean

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

W
wusongqing 已提交
1871 1872 1873
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1874 1875 1876 1877
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
1878
**Return value**
W
wusongqing 已提交
1879 1880 1881 1882
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is of the **native external** type; returns **false** otherwise.|

W
wusongqing 已提交
1883
**Example**
W
wusongqing 已提交
1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896
  ```
  var that = new util.Types();
  const data = util.createExternalType();
  var result = that.isExternal(data);
  ```


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

isFloat32Array(value: Object):boolean

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

W
wusongqing 已提交
1897 1898 1899
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1900 1901 1902 1903
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
1904
**Return value**
W
wusongqing 已提交
1905 1906 1907 1908
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is of the **Float32Array** type; returns **false** otherwise.|

W
wusongqing 已提交
1909
**Example**
W
wusongqing 已提交
1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921
  ```
  var that = new util.Types();
  var result = that.isFloat32Array(new Float32Array());
  ```


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

isFloat64Array(value: Object):boolean

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

W
wusongqing 已提交
1922 1923 1924
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1925 1926 1927 1928
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
1929
**Return value**
W
wusongqing 已提交
1930 1931 1932 1933
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is of the **Float64Array** type; returns **false** otherwise.|

W
wusongqing 已提交
1934
**Example**
W
wusongqing 已提交
1935 1936 1937 1938 1939 1940 1941 1942 1943
  ```
  var that = new util.Types();
  var result = that.isFloat64Array(new Float64Array());
  ```


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

isGeneratorFunction(value: Object):boolean
Z
zengyawen 已提交
1944 1945 1946

Checks whether the input value is a generator function.

W
wusongqing 已提交
1947 1948 1949
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1950 1951 1952 1953
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
1954
**Return value**
W
wusongqing 已提交
1955 1956 1957 1958
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is a generator function; returns **false** otherwise.|

W
wusongqing 已提交
1959
**Example**
W
wusongqing 已提交
1960 1961 1962 1963 1964 1965 1966 1967 1968
  ```
  var that = new util.Types();
  var result = that.isGeneratorFunction(function* foo() {});
  ```


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

isGeneratorObject(value: Object):boolean
Z
zengyawen 已提交
1969 1970 1971

Checks whether the input value is a generator object.

W
wusongqing 已提交
1972 1973 1974
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
1975 1976 1977 1978
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
1979
**Return value**
W
wusongqing 已提交
1980 1981 1982 1983
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is a generator object; returns **false** otherwise.|

W
wusongqing 已提交
1984
**Example**
W
wusongqing 已提交
1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998
  ```
  var that = new util.Types();
  function* foo() {}
  const generator = foo();
  var result = that.isGeneratorObject(generator);
  ```


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

isInt8Array(value: Object):boolean

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

W
wusongqing 已提交
1999 2000 2001
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2002 2003 2004 2005
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
2006
**Return value**
W
wusongqing 已提交
2007 2008 2009 2010
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is of the **Int8Array** type; returns **false** otherwise.|

W
wusongqing 已提交
2011
**Example**
W
wusongqing 已提交
2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023
  ```
  var that = new util.Types();
  var result = that.isInt8Array(new Int8Array([]));
  ```


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

isInt16Array(value: Object):boolean

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

W
wusongqing 已提交
2024 2025 2026
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2027 2028 2029 2030
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
2031
**Return value**
W
wusongqing 已提交
2032 2033 2034 2035
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is of the **Int16Array** type; returns **false** otherwise.|

W
wusongqing 已提交
2036
**Example**
W
wusongqing 已提交
2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048
  ```
  var that = new util.Types();
  var result = that.isInt16Array(new Int16Array([]));
  ```


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

isInt32Array(value: Object):boolean

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

W
wusongqing 已提交
2049 2050 2051
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2052 2053 2054 2055
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
2056
**Return value**
W
wusongqing 已提交
2057 2058 2059 2060
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is of the **Int32Array** type; returns **false** otherwise.|

W
wusongqing 已提交
2061
**Example**
W
wusongqing 已提交
2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073
  ```
  var that = new util.Types();
  var result = that.isInt32Array(new Int32Array([]));
  ```


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

isMap(value: Object):boolean

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

W
wusongqing 已提交
2074 2075 2076
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2077 2078 2079 2080
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
2081
**Return value**
W
wusongqing 已提交
2082 2083 2084 2085
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is of the **Map** type; returns **false** otherwise.|

W
wusongqing 已提交
2086
**Example**
W
wusongqing 已提交
2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098
  ```
  var that = new util.Types();
  var result = that.isMap(new Map());
  ```


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

isMapIterator(value: Object):boolean

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

W
wusongqing 已提交
2099 2100 2101
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2102 2103 2104 2105
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
2106
**Return value**
W
wusongqing 已提交
2107 2108 2109 2110
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is of the **MapIterator** type; returns **false** otherwise.|

W
wusongqing 已提交
2111
**Example**
W
wusongqing 已提交
2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124
  ```
  var that = new util.Types();
  const map = new Map();
  var result = that.isMapIterator(map.keys());
  ```


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

isNativeError(value: Object):boolean

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

W
wusongqing 已提交
2125 2126 2127
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2128 2129 2130 2131
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
2132
**Return value**
W
wusongqing 已提交
2133 2134 2135 2136
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is of the **Error** type; returns **false** otherwise.|

W
wusongqing 已提交
2137
**Example**
W
wusongqing 已提交
2138 2139 2140 2141 2142 2143 2144 2145 2146
  ```
  var that = new util.Types();
  var result = that.isNativeError(new TypeError());
  ```


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

isNumberObject(value: Object):boolean
Z
zengyawen 已提交
2147 2148 2149

Checks whether the input value is a number object.

W
wusongqing 已提交
2150 2151 2152
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2153 2154 2155 2156
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
2157
**Return value**
W
wusongqing 已提交
2158 2159 2160 2161
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is a number object; returns **false** otherwise.|

W
wusongqing 已提交
2162
**Example**
W
wusongqing 已提交
2163 2164 2165 2166 2167 2168 2169 2170 2171
  ```
  var that = new util.Types();
  var result = that.isNumberObject(new Number(0));
  ```


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

isPromise(value: Object):boolean
Z
zengyawen 已提交
2172 2173 2174

Checks whether the input value is a promise.

W
wusongqing 已提交
2175 2176 2177
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2178 2179 2180 2181
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
2182
**Return value**
W
wusongqing 已提交
2183 2184 2185 2186
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is a promise; returns **false** otherwise.|

W
wusongqing 已提交
2187
**Example**
W
wusongqing 已提交
2188 2189 2190 2191 2192 2193 2194 2195 2196
  ```
  var that = new util.Types();
  var result = that.isPromise(Promise.resolve(1));
  ```


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

isProxy(value: Object):boolean
Z
zengyawen 已提交
2197 2198 2199

Checks whether the input value is a proxy.

W
wusongqing 已提交
2200 2201 2202
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2203 2204 2205 2206
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
2207
**Return value**
W
wusongqing 已提交
2208 2209 2210 2211
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is a proxy; returns **false** otherwise.|

W
wusongqing 已提交
2212
**Example**
W
wusongqing 已提交
2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226
  ```
  var that = new util.Types();
  const target = {};
  const proxy = new Proxy(target, {});
  var result = that.isProxy(proxy);
  ```


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

isRegExp(value: Object):boolean

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

W
wusongqing 已提交
2227 2228 2229
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2230 2231 2232 2233
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
2234
**Return value**
W
wusongqing 已提交
2235 2236 2237 2238
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is of the **RegExp** type; returns **false** otherwise.|

W
wusongqing 已提交
2239
**Example**
W
wusongqing 已提交
2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251
  ```
  var that = new util.Types();
  var result = that.isRegExp(new RegExp('abc'));
  ```


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

isSet(value: Object):boolean

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

W
wusongqing 已提交
2252 2253 2254
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2255 2256 2257 2258
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
2259
**Return value**
W
wusongqing 已提交
2260 2261 2262 2263
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is of the **Set** type; returns **false** otherwise.|

W
wusongqing 已提交
2264
**Example**
W
wusongqing 已提交
2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276
  ```
  var that = new util.Types();
  var result = that.isSet(new Set());
  ```


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

isSetIterator(value: Object):boolean

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

W
wusongqing 已提交
2277 2278 2279
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2280 2281 2282 2283
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
2284
**Return value**
W
wusongqing 已提交
2285 2286 2287 2288
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is of the **SetIterator** type; returns **false** otherwise.|

W
wusongqing 已提交
2289
**Example**
W
wusongqing 已提交
2290 2291 2292 2293 2294 2295 2296 2297 2298 2299
  ```
  var that = new util.Types();
  const set = new Set();
  var result = that.isSetIterator(set.keys());
  ```


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

isStringObject(value: Object):boolean
Z
zengyawen 已提交
2300 2301 2302

Checks whether the input value is a string object.

W
wusongqing 已提交
2303 2304 2305
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2306 2307 2308 2309
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
2310
**Return value**
W
wusongqing 已提交
2311 2312 2313 2314
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is a string object; returns **false** otherwise.|

W
wusongqing 已提交
2315
**Example**
W
wusongqing 已提交
2316 2317 2318 2319 2320 2321 2322 2323
  ```
  var that = new util.Types();
  var result = that.isStringObject(new String('foo'));
  ```


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

X
xdmal 已提交
2324
isSymbolObjec(value: Object): boolean
Z
zengyawen 已提交
2325 2326 2327

Checks whether the input value is a symbol object.

W
wusongqing 已提交
2328 2329 2330
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2331 2332 2333 2334
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
2335
**Return value**
W
wusongqing 已提交
2336 2337 2338 2339
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is a symbol object; returns **false** otherwise.|

W
wusongqing 已提交
2340
**Example**
W
wusongqing 已提交
2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355
  ```
  var that = new util.Types();
  const symbols = Symbol('foo');
  var result = that.isSymbolObject(Object(symbols));
  ```


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

isTypedArray(value: Object):boolean

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 已提交
2356 2357 2358
**System capability**: SystemCapability.Utils.Lang

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

W
wusongqing 已提交
2363
**Return value**
W
wusongqing 已提交
2364 2365 2366 2367
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is of the **TypedArray** type; returns **false** otherwise.|

W
wusongqing 已提交
2368
**Example**
W
wusongqing 已提交
2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380
  ```
  var that = new util.Types();
  var result = that.isTypedArray(new Float64Array([]));
  ```


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

isUint8Array(value: Object):boolean

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

W
wusongqing 已提交
2381 2382 2383
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2384 2385 2386 2387
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
2388
**Return value**
W
wusongqing 已提交
2389 2390 2391 2392
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is of the **Uint8Array** type; returns **false** otherwise.|

W
wusongqing 已提交
2393
**Example**
W
wusongqing 已提交
2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405
  ```
  var that = new util.Types();
  var result = that.isUint8Array(new Uint8Array([]));
  ```


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

isUint8ClampedArray(value: Object):boolean

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

W
wusongqing 已提交
2406 2407 2408
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2409 2410 2411 2412
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
2413
**Return value**
W
wusongqing 已提交
2414 2415 2416 2417
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is of the **Uint8ClampedArray** type; returns **false** otherwise.|

W
wusongqing 已提交
2418
**Example**
W
wusongqing 已提交
2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430
  ```
  var that = new util.Types();
  var result = that.isUint8ClampedArray(new Uint8ClampedArray([]));
  ```


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

isUint16Array(value: Object):boolean

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

W
wusongqing 已提交
2431 2432 2433
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2434 2435 2436 2437
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
2438
**Return value**
W
wusongqing 已提交
2439 2440 2441 2442
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is of the **Uint16Array** type; returns **false** otherwise.|

W
wusongqing 已提交
2443
**Example**
W
wusongqing 已提交
2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455
  ```
  var that = new util.Types();
  var result = that.isUint16Array(new Uint16Array([]));
  ```


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

isUint32Array(value: Object):boolean

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

W
wusongqing 已提交
2456 2457 2458
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2459 2460 2461 2462
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
2463
**Return value**
W
wusongqing 已提交
2464 2465 2466 2467
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is of the **Uint32Array** type; returns **false** otherwise.|

W
wusongqing 已提交
2468
**Example**
W
wusongqing 已提交
2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480
  ```
  var that = new util.Types();
  var result = that.isUint32Array(new Uint32Array([]));
  ```


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

isWeakMap(value: Object):boolean

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

W
wusongqing 已提交
2481 2482 2483
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2484 2485 2486 2487
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
2488
**Return value**
W
wusongqing 已提交
2489 2490 2491 2492
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is of the **WeakMap** type; returns **false** otherwise.|

W
wusongqing 已提交
2493
**Example**
W
wusongqing 已提交
2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505
  ```
  var that = new util.Types();
  var result = that.isWeakMap(new WeakMap());
  ```


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

isWeakSet(value: Object):boolean

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

W
wusongqing 已提交
2506 2507 2508
**System capability**: SystemCapability.Utils.Lang

**Parameters**
W
wusongqing 已提交
2509 2510 2511 2512
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | value | Object | Yes| Object to check.|

W
wusongqing 已提交
2513
**Return value**
W
wusongqing 已提交
2514 2515 2516
  | Type| Description|
  | -------- | -------- |
  | boolean | Returns **true** if the input value is of the **WeakSet** type; returns **false** otherwise.|
Z
zengyawen 已提交
2517

W
wusongqing 已提交
2518
**Example**
W
wusongqing 已提交
2519 2520 2521 2522
  ```
  var that = new util.Types();
  var result = that.isWeakSet(new WeakSet());
  ```