• Home
Name Date Size #Lines LOC

..--

js_api_module/12-May-2024-23,24119,352

js_concurrent_module/12-May-2024-10,2507,866

js_sys_module/12-May-2024-6,5064,968

js_util_module/12-May-2024-14,59312,370

platform/12-May-2024-971697

LICENSED12-May-20249.9 KiB178150

README.en.mdD12-May-202489.3 KiB2,4322,241

README.mdD12-May-2024201.2 KiB5,5055,247

bundle.jsonD12-May-20244.3 KiB115114

ets_utils_config.gniD12-May-20241.9 KiB4341

README.en.md

1# ets_utils
2The ets_utils component provides four modules: js_api_module, js_util_module, js_sys_module, and js_concurrent_module. The following provides an introduction to these modules and describes their directory structures, APIs, and involved repositories.
3
4# Modules
5## js_api_module
6### Introduction
7
8The js_api_module provides the following classes:<br>**URL**: provides APIs to parse, construct, standardize, and encode URLs. The constructor of this class creates a **URL** object, where you can call APIs to parse and change the URL. **URLSearchParams**: provides APIs to handle URL query strings.
9
10**URI**: provides APIs to parse URI strings.
11
12**ConvertXml**: provides APIs to convert XML text into JavaScript objects.
13
14**XmlSerializer**: provides APIs to generate an XML file. The constructor of this class creates an **XmlSerializer** object, where you can call the APIs to generate an XML file. **XmlPullParser**: provides APIs to parse an XML file. The constructor of this class creates an **XmlPullParser** object, where you can call the APIs to parse an XML file.
15
16### Directory Structure
17
18```
19commonlibrary/ets_utils/js_api_module/
20├── Class:URL                                                                     # URL class
21│   ├── new URL(input[, base])                                                    # Used to create a URL object
22│   ├── hash                                                                      # hash attribute
23│   ├── host                                                                      # host attribute
24│   ├── hostname                                                                  # hostname attribute
25│   ├── href                                                                      # href attribute
26│   ├── origin                                                                    # origin attribute
27│   ├── password                                                                  # password attribute
28│   ├── pathname                                                                  # pathname attribute
29│   ├── port                                                                      # port attribute
30│   ├── protocol                                                                  # protocol attribute
31│   ├── search                                                                    # search attribute
32│   ├── searchParams                                                              # searchParams attribute
33│   ├── username                                                                  # username attribute
34│   ├── toString()                                                                # toString method
35│   └── toJSON()                                                                  # toJSON method
36├── Class: URLSearchParams                                                        # URLSearchParams class
37│   ├── new URLSearchParams()                                                     # Used to create a URLSearchParams object
38│   ├── new URLSearchParams(string)                                               # Used to create a URLSearchParams object
39│   ├── new URLSearchParams(obj)                                                  # Used to create a URLSearchParams object
40│   ├── new URLSearchParams(iterable)                                             # Used to create a URLSearchParams object
41│   ├── append(name, value)                                                       # append method
42│   ├── delete(name)                                                              # delete method
43│   ├── entries()                                                                 # entries method
44│   ├── forEach(fn[, thisArg])                                                    # forEach method
45│   ├── get(name)                                                                 # get method
46│   ├── getAll(name)                                                              # getAll method
47│   ├── has(name)                                                                 # has method
48│   ├── keys()                                                                    # keys method
49│   ├── set(name, value)                                                          # set method
50│   ├── sort()                                                                    # sort method
51│   ├── toString()                                                                # toString method
52│   ├── values()                                                                  # values method
53│   └── urlSearchParams[Symbol.iterator]()                                        # Used to create a URLSearchParams object
54├── Class:URI                                                                     # URI class
55│   ├── URI(str: string)                                                          # Used to create a URI object
56│   ├── scheme                                                                    # scheme attribute
57│   ├── authority                                                                 # authority attribute
58│   ├── ssp                                                                       # ssp attribute
59│   ├── userinfo                                                                  # userinfo attribute
60│   ├── host                                                                      # host attribute
61│   ├── port                                                                      # port attribute
62│   ├── query                                                                     # query attribute
63│   ├── fragment                                                                  # fragment attribute
64│   ├── path                                                                      # path attribute
65│   ├── equals(ob: Object)                                                        # equals attribute
66│   ├── normalize()                                                               # normalize attribute
67│   ├── checkIsAbsolute()                                                         # checkIsAbsolute attribute
68│   ├── normalize()                                                               # normalize method
69│   └── toString()                                                                # toString method
70├── Class:ConvertXml                                                              # ConvertXml class
71│   ├── ConvertXml()                                                              # Used to create a ConvertXml object
72│   └── convert(xml: string, options: Object)                                     # convert method
73├── Class:XmlSerializer                                                           # XmlSerializer class
74│   ├── new XmlSerializer(buffer: ArrayBuffer | DataView, encoding?: string)      # Used to create an XmlSerializer object
75│   ├── setAttributes(name: string, value: string)                                # setAttributes method
76│   ├── addEmptyElement(name: string)                                             # addEmptyElement method
77│   ├── setDeclaration()                                                          # setDeclaration method
78│   ├── startElement(name: string)                                                # startElement method
79│   ├── endElement()                                                              # endElement method
80│   ├── setNamespace(prefix: string, namespace: string)                           # setNamespace method
81│   ├── setComment(text: string)                                                  # setComment method
82│   ├── setCData(text: string)                                                    # setCData method
83│   ├── setText(text: string)                                                     # setText method
84│   └── setDocType(text: string)                                                  # setDocType method
85└── Class: XmlPullParser                                                          # XmlPullParser class
86    ├── new (buffer: ArrayBuffer | DataView, encoding?: string)                   # Used to create an XmlPullParser object
87    └── parse(option: ParseOptions)                                               # parse method
88```
89
90### Usage
91
92#### Available APIs
93
94
95| API| Description|
96| -------- | -------- |
97| URL(url: string,base?:string \| URL) | Creates a **URL** object that references a URL specified using an absolute URL string, a relative URL string, and a base URL string.|
98| tostring():string | Converts the parsed URL into a string. Its function is the same as that of read-only **URL.href**.|
99| toJSON():string | Converts the parsed URL into a JSON string.|
100| new URLSearchParams() | No-argument constructor that creates a **URLSearchParams** object. The question mark (?) at the beginning of the query string will be ignored.|
101| new URLSearchParams(string) | Constructor that creates a **URLSearchParams** object with the string type specified. The question mark (?) at the beginning of the query string will be ignored.|
102| new URLSearchParams(obj) | Constructor that creates a **URLSearchParams** object with the object type specified. The question mark (?) at the beginning of the query string will be ignored.|
103| new URLSearchParams(iterable) | Constructor that creates a **URLSearchParams** object with the iterable type specified. The question mark (?) at the beginning of the query string will be ignored.|
104| has(name: string): boolean | Checks whether a key in this **URLSearchParams** object has a value. It returns **true** if the key has a value and returns **false** otherwise.|
105| set(name: string, value string): void |  Sets the value for a key in this **URLSearchParams** object. If key-value pairs matching the specified key exist, the value of the first occurrence of the key-value pair will be changed to the specified value and other key-value pairs will be deleted. Otherwise, the key-value pair will be appended to the query string.|
106| sort(): void | Sorts all key-value pairs in this **URLSearchParams** object based on the Unicode code points of the keys and returns **undefined**. |
107| toString(): string | Obtains strings that can be used for URL query based on this **URLSearchParams** object.|
108| keys(): iterableIterator\<string> | Obtains an iterator that contains the keys of all the key-value pairs in this **URLSearchParams** object.|
109| values(): iterableIterator\<string> | Obtains an iterator that contains the values of all the key-value pairs in this **URLSearchParams** object.|
110| append(name: string, value: string): void | Appends a key-value pair into this **URLSearchParams** object.|
111| delete(name: string): void | Deletes key-value pairs of the specified key from this **URLSearchParams** object.|
112| get(name: string): string | Obtains the value of the first key-value pair with the specified key in this **URLSearchParams** object.|
113| getAll(name: string): string[] | Obtains all the key-value pairs with the specified key in this **URLSearchParams** object.|
114| entries(): iterableIterator<[string, string]> | Obtains an iterator that contains all the key-value pairs of this **URLSearchParams** object.|
115| forEach(): void | Traverses the key-value pairs in this **URLSearchParams** object by using a callback.|
116| urlSearchParams\[Symbol.iterator]() | Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and each array contains a key and value.|
117| URI​(str: string) | Constructs a URI by parsing the given input parameter according to the syntax specified in Appendix A of RFC 2396.|
118| scheme​ | Obtains the scheme component of this URI; returns **null** if **scheme** is not defined.|
119| authority​ | Obtains the decoded authority component of this URI; returns **null** if **authority** is not defined.|
120| ssp​ |  Obtains the decoded scheme-specific component of this URI.|
121| userinfo​ | Obtains the decoded userinfo component of this URI. The return value contains password and username.|
122| host​ | Obtains the host component of this URI; returns **null** if **host** is not defined.|
123| port​ | Obtains the port component of this URI; returns **-1** if **port** is not defined. The return value is a non-negative integer.|
124| query​ | Obtains the query component of this URI; returns **null** if **query** is not defined.|
125| fragment​ | Obtains the decoded fragment component of this URI; returns **null** if **fragment** is not defined.|
126| path​ | Obtains the decoded path component of this URI; returns **null** if **path** is not defined.|
127| equals(ob: Object) | Checks whether this URI is the same as another URI object. It immediately returns **false** if the given object is not a URI.|
128| normalize​() | Normalizes the path of this URI. It constructs a new URI object if the path of the URI is not standard.|
129| checkIsAbsolute​() | Checks whether this URI is an absolute URI (whether the scheme component is defined). It returns **true** if the URI is an absolute URI; otherwise, it returns **false**.|
130| ConvertXml() | A no-argument constructor that creates a **ConvertXml** object.  |
131| convert(xml: string, options: Object)  | Converts an XML text into a JavaScript object.|
132| XmlSerializer(buffer: ArrayBuffer \| DataView, encoding?: string) | Creates and returns an **XmlSerializer** object. The **XmlSerializer** object passes two parameters. The first parameter is the memory of the **ArrayBuffer** or **DataView** type, and the second parameter is the file format (UTF-8 by default).|
133| setAttributes(name: string, value: string): void | Sets attributes for the XML file.|
134| addEmptyElement(name: string): void | Adds an empty element.|
135| setDeclaration(): void | Sets a declaration for the XML file. Example: <? xml version="1.0"encoding="utf-8">|
136| startElement(name: string): void | Writes the start tag based on the given element name.|
137| endElement(): void | Writes the end tag of the element.|
138| setNamespace(prefix: string, namespace: string): void | Sets the namespace for an element tag.|
139| setComment(text: string): void | Sets the comment.|
140| setCData(text: string): void | Sets the **CData** attribute.|
141| setText(text: string): void | Sets the **Text** attribute.|
142| setDocType(text: string): void | Sets the **DocType** attribute.|
143| XmlPullParser(buffer: ArrayBuffer \| DataView, encoding?: string) | Creates and returns an **XmlPullParser** object. The **XmlPullParser** object passes two parameters. The first parameter is the memory of the **ArrayBuffer** or **DataView** type, and the second parameter is the file format (UTF-8 by default).|
144| parse(option: ParseOptions): void | Parses XML information. **ParseOptions** contains five optional parameters: {supportDoctype?: boolean ignoreNameSpace?: boolean tagValueCallbackFunction?: (name: string, value: string) => boolean attributeValueCallbackFunction?: (name: string, value: string) => boolean) tokenValueCallbackFunction?: (eventType: EventType, value: ParseInfo) => boolean }. For **tokenValueCallbackFunction**, the first input parameter indicates the event type, and the second input parameter indicates the **info** interface that contains getters such as **getColumnNumber** and **getDepth**. You can use methods such as **info.getDepth()** to obtain information during the parsing.|
145#### How to Use
146
147Use the APIs as follows:
148
149
1501. new URL(url: string,base?:string|URL)
151```
152let b = new URL('https://developer.mozilla.org'); // => 'https://developer.mozilla.org/'
153
154let a = new URL( 'sca/./path/path/../scasa/text', 'http://www.example.com');
155// => 'http://www.example.com/sca/path/scasa/text'
156```
1572. tostring():string
158```
159const url = new URL('http://10.0xFF.O400.235:8080/directory/file?query#fragment');
160url.toString() // => 'http://10.0xff.o400.235:8080/directory/file?query#fragment'
161
162const url = new URL("http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html");
163url.toString() // => 'http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/index.html'
164
165const url = new URL("http://username:password@host:8080/directory/file?query#fragment");
166url.toString() // => 'http://username:password@host:8080/directory/file?query#fragment'
167```
1683. toJSON():string
169```
170const url = new URL("https://developer.mozilla.org/en-US/docs/Web/API/URL/toString");
171url.toJSON(); // =>  'https://developer.mozilla.org/en-US/docs/Web/API/URL/toString'
172```
1734. new URLSearchParams()
174```
175let params = new URLSearchParams('foo=1&bar=2');
176```
1775. new URLSearchParams(string)
178```
179params = new URLSearchParams('user=abc&query=xyz');
180console.log(params.get('user'));
181// Prints 'abc'
182```
1836. new URLSearchParams(obj)
184```
185const params = new URLSearchParams({
186    user: 'abc',
187    query: ['first', 'second']
188});
189console.log(params.getAll('query'));
190// Prints [ 'first,second' ]
191```
1927. new URLSearchParams(iterable)
193```
194let params;
195
196// Using an array
197params = new URLSearchParams([
198    ['user', 'abc'],
199    ['query', 'first'],
200    ['query', 'second'],
201]);
202console.log(params.toString());
203// Prints 'user = abc & query = first&query = second'
204```
2058. has(name: string): boolean
206```
207console.log(params.has('bar')); // =>true
208```
2099. set(name: string, value string): void
210```
211params.set('baz', 3);
212```
21310. sort(): void
214```
215params .sort();
216```
21711. toString(): string
218```
219console.log(params .toString()); // =>bar=2&baz=3&foo=1'
220```
22112. keys(): iterableIterator\<string>
222```
223for(var key of params.keys()) {
224  console.log(key);
225} // =>bar  baz  foo
226```
22713. values(): iterableIterator\<string>
228```
229for(var value of params.values()) {
230  console.log(value);
231} // =>2  3  1
232```
23314. append(name: string, value: string): void
234```
235params.append('foo', 3); // =>bar=2&baz=3&foo=1&foo=3
236```
23715. delete(name: string): void
238```
239params.delete('baz'); // => bar=2&foo=1&foo=3
240```
24116. get(name: string): string
242```
243params.get('foo'); // => 1
244```
24517. getAll(name: string): string[]
246```
247params.getAll('foo'); // =>[ '1', '3' ]
248```
24918. entries(): iterableIterator<[string, string]>
250```
251for(var pair of searchParams.entries()) {
252   console.log(pair[0]+ ', '+ pair[1]);
253} // => bar, 2   foo, 1  foo, 3
254```
25519. forEach(): void
256```
257url.searchParams.forEach((value, name, searchParams) => {
258  console.log(name, value, url.searchParams === searchParams);
259});
260// => foo 1 true
261// => bar 2 true
262```
26320. urlSearchParams[Symbol.iterator]()
264```
265const params = new URLSearchParams('foo=bar&xyz=baz');
266for (const [name, value] of params) {
267    console.log(name, value);
268}
269// Prints:
270// foo bar
271// xyz bar
272```
273
274
27521. URI(str: string)
276```
277let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
278```
27922. scheme
280```
281let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
282gaogao.scheme        // => "http";
283```
28423. authority
285```
286let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
287gaogao.authority     // => "gg:gaogao@www.baidu.com:99";
288```
28924. ssp
290```
291let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
292gaogao.ssp "         // => gg:gaogao@www.baidu.com:99/path/path?query";
293```
29425. userinfo
295```
296let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
297gaogao.userinfo      // => "gg:gaogao";
298```
29926. host
300```
301let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
302gaogao.host          // => "www.baidu.com";
303```
30427. port
305```
306let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
307gaogao.port          // => "99";
308```
30928. query
310```
311let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
312gaogao.query         // => "query";
313```
31429. fragment
315```
316let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
317gaogao.fragment      // => "fagment";
318```
31930. path
320```
321let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
322gaogao.path          // => "/path/path";
323```
32431. equals(ob: Object)
325```
326let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment');
327let gaogao1 = gaogao;
328let res = gaogao.equals(gaogao1);
329console.log(res);      // => true;
330```
33132. normalize()
332```
333let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/66./../././mm/.././path1?query#fagment');
334let res = gaogao.normalize();
335console.log(res.path);        // => "/path/path1"
336console.log(res.toString());  // => "http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/path1?query#fagment"
337```
33833. checkIsAbsolute()
339```
340let gaogao = new Uri.URI('f/tp://username:password@www.baidu.com:88/path?query#fagment');
341let res = gaogao.checkIsAbsolute();
342console.log(res);              //=> false;
343```
34434. toString()
345```
346let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path/.././../aa/bb/cc?query#fagment');
347let res = gaogao.toString();
348console.log(res.toString());     // => 'http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path/.././../aa/bb/cc?query#fagment';
349```
350
351
35235. ConvertXml()
353```
354var convertml = new convertXml.ConvertXml();
355```
35636. convert(xml: string, options: Object)
357```
358var result = convertml.convert(xml, {compact: false, spaces: 4});
359```
36037. new XmlSerializer(buffer: ArrayBuffer | DataView, encoding?: string)
361```
362
363var arrayBuffer = new ArrayBuffer(1024);
364var bufView = new DataView(arrayBuffer);
365var thatSer = new xml.XmlSerializer(bufView);
366```
36738. setDeclaration(): void
368```
369var thatSer = new xml.XmlSerializer(bufView);
370thatSer.setDeclaration() // => <?xml version="1.0" encoding="utf-8"?>;
371```
37239. setComment(text: string):void
373```
374var thatSer = new xml.XmlSerializer(bufView);
375thatSer.setCommnet("Hello, World!"); // => <!--Hello, World!-->;
376```
37740. setCData(text: string) :void
378```
379var thatSer = new xml.XmlSerializer(bufView);
380thatSer.setDocType('root SYSTEM "http://www.test.org/test.dtd"'); // => <![CDATA[root SYSTEM \"http://www.test.org/test.dtd\"]]>
381```
38241. setDocType(text: string):void
383```
384var thatSer = new xml.XmlSerializer(bufView);
385thatSer.setDocType("foo"); // => <!DOCTYPE foo>
386```
38742. setNamespace(prefix: string, namespace: string): void
38843. startElement(name: string): void
38944. setAttributes(name: string, value: string): void
39045. endElement(): void
39146. setText(text: string): void
392```
393var thatSer = new xml.XmlSerializer(bufView);
394thatSer.setNamespace("h", "http://www.w3.org/TR/html4/");
395thatSer.startElement("table");
396thatSer.setAttributes("importance", "high");
397thatSer.setText("Happy");
398endElement(); // => <h:table importance="high" xmlns:h="http://www.w3.org/TR/html4/">Happy</h:table>
399```
40047. addEmptyElement(name: string): void
401```
402var thatSer = new xml.XmlSerializer(bufView);
403thatSer.addEmptyElement("b"); // => <b/>
404```
40548. new (buffer: ArrayBuffer | DataView, encoding?: string)
406```
407var strXml =
408            '<?xml version="1.0" encoding="utf-8"?>' +
409            '<note importance="high" logged="true">' +
410            '    <title>Happy</title>' +
411            '</note>';
412var arrayBuffer = new ArrayBuffer(strXml.length*2);
413var bufView = new Uint8Array(arrayBuffer);
414var strLen = strXml.length;
415for (var i = 0; i < strLen; ++i) {
416    bufView[i] = strXml.charCodeAt(i); // Set the ArrayBuffer mode.
417}
418var that = new xml.XmlPullParser(arrayBuffer);
419
420```
42149. parse(option: ParseOptions): void
422```
423var strXml =
424            '<?xml version="1.0" encoding="utf-8"?>' +
425            '<note importance="high" logged="true">' +
426            '    <title>Happy</title>' +
427            '</note>';
428var arrayBuffer = new ArrayBuffer(strXml.length*2);
429var bufView = new Uint8Array(arrayBuffer);
430var strLen = strXml.length;
431for (var i = 0; i < strLen; ++i) {
432    bufView[i] = strXml.charCodeAt(i);
433}
434var that = new xml.XmlPullParser(arrayBuffer);
435var arrTag = {};
436arrTag[0] = '132';
437var i = 1;
438function func(key, value){
439    arrTag[i] = 'key:'+key+' value:'+ value.getDepth();
440    i++;
441    return true;
442}
443var options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func}
444that.parse(options);
445```
446
447## js_util_module
448### Introduction
449
450The js_util_module provides the following classes:<br> **TextEncoder**: provides APIs to encode a string into a UTF-8 byte stream. **TextDecoder**: provides APIs to decode a byte stream into a string. **HelpFunction**: provides APIs to perform the callback and promise processing on functions, compile and output error codes, and format class strings. **encode**: provides APIs to use the Base64 encoding scheme to encode all bytes in a Unit8Array typed array into a new Unit8Array typed array or encode a byte array into a string. **decode**: provides APIs to use the Base64 encoding scheme to decode a Base64-encoded string or a Unit8Array typed array into a new Unit8Array typed array. **RationalNumber**: provides APIs to compare rational numbers and obtain numerators and denominators. **LruBuffer**: provides APIs to discard the least recently used data to make rooms for new elements when the buffer is full. The Least Recently Used (LRU) algorithm believes that the recently used data may be accessed again in the near future and the least accessed data is the least valuable data and should be removed from the buffer. **Scope**: provides APIs to define the valid range of a field. The constructor of this class creates comparable objects with lower and upper limits.
451### Directory Structure
452
453```
454commonlibrary/ets_utils/js_util_module/
455├── Class:TextEncoder                   # TextEncoder class
456│   ├──  new TextEncoder()              # Used to create a TextEncoder object
457│   ├──  encode()                       # encode method
458│   ├──  encoding                       # encoding attribute
459│   └──  encodeInto()                   # encodeInto method
460├── Class:TextDecoder                   # TextDecoder class
461│   ├──  new TextDecoder()              # Used to create a TextDecoder object
462│   ├──  decode()                       # decode method
463|   ├──  decodeWithStream()             # decodeWithStream method
464│   ├──  encoding                       # encoding attribute
465│   ├──  fatal                          # fatal attribute
466│   └──  ignoreBOM                      # ignoreBOM attribute
467├── printf()                            # printf method
468├── getErrorString()                    # getErrorString method
469├── callbackWrapper()                   # callbackWrapper method
470├── promiseWrapper()                    # promiseWrapper method
471├── Class:Base64                        # Base64 class
472│   ├──  new Base64()                   # Used to create a Base64 object
473│   ├──  encodeSync()                   # encodeSync method
474│   ├──  encodeToStringSync()           # encodeToStringSync method
475│   ├──  decodeSync()                   # decodeSync method
476│   ├──  encode()                       # encode method
477│   ├──  encodeToString()               # encodeToString method
478│   └──  decode()                       # decode method
479├── Class:RationalNumber                # RationalNumber class
480│   ├──  new RationalNumber()           # Used to create a RationalNumber object
481│   ├──  createRationalFromString()     # createRationalFromString method
482│   ├──  compareTo()                    # compareTo method
483│   ├──  equals()                       # equals method
484│   ├──  valueOf()                      # valueOf method
485│   ├──  getCommonDivisor()             # getCommonDivisor method
486│   ├──  getDenominator()               # getDenominator method
487│   ├──  getNumerator()                 # getNumerator method
488│   ├──  isFinite()                     # isFinite method
489│   ├──  isNaN()                        # isNaN method
490│   ├──  isZero()                       # isZero method
491│   └──  toString()                     # toString method
492├── Class:LruBuffer                     # LruBuffer class
493│   ├──  new LruBuffer()                # Used to create a LruBuffer object
494│   ├──  updateCapacity()               # updateCapacity method
495│   ├──  toString()                     # toString method
496│   ├──  values()                       # values method
497│   ├──  length                         # length attribute
498│   ├──  getCapacity()                  # getCapacity method
499│   ├──  clear()                        # clear method
500│   ├──  getCreateCount()               # getCreateCount method
501│   ├──  getMissCount()                 # getMissCount method
502│   ├──  getRemovalCount()              # getRemovalCount method
503│   ├──  getMatchCount()                # getMatchCount method
504│   ├──  getPutCount()                  # getPutCount method
505│   ├──  isEmpty()                      # isEmpty method
506│   ├──  get()                          # get method
507│   ├──  put()                          # put method
508│   ├──  keys()                         # keys method
509│   ├──  remove()                       # remove method
510│   ├──  afterRemoval()                 # afterRemoval method
511│   ├──  contains()                     # contains method
512│   ├──  createDefault()                # createDefault method
513│   ├──  entries()                      # entries method
514│   └──  [Symbol.iterator]()            # Symboliterator method
515|—— Class:Scope                         # Scope class
516|   ├── constructor()                   # Used to create a Scope object
517|   ├── toString()                      # toString method
518|   ├── intersect()                     # intersect method
519|   ├── intersect()                     # intersect method
520|   ├── getUpper()                      # getUpper method
521|   ├── getLower()                      # getLower method
522|   ├── expand()                        # expand method
523|   ├── expand()                        # expand method
524|   ├── expand()                        # expand method
525|   ├── contains()                      # contains method
526|   ├── contains()                      # contains method
527|   └── clamp()                         # clamp method
528└── Class:Types                         # Types class
529    ├── isAnyArrayBuffer()              # isAnyArrayBuffer method
530    ├── isArrayBufferView()             # isArrayBufferView method
531    ├── isArgumentsObject()             # isArgumentsObject method
532    ├── isArrayBuffer()                 # isArrayBuffer method
533    ├── isAsyncFunction()               # isAsyncFunction method
534    ├── isBigInt64Array()               # isBigInt64Array method
535    ├── isBigUint64Array()              # isBigUint64Array method
536    ├── isBooleanObject()               # isBooleanObject method
537    ├── isBoxedPrimitive()              # isBoxedPrimitive method
538    ├── isDataView()                    # isDataView method
539    ├── isDate()                        # isDate method
540    ├── isExternal()                    # isExternal method
541    ├── isFloat32Array()                # isFloat32Array method
542    ├── isFloat64Array()                # isFloat64Array method
543    ├── isGeneratorFunction()           # isGeneratorFunction method
544    ├── isGeneratorObject()             # isGeneratorObject method
545    ├── isInt8Array()                   # isInt8Array method
546    ├── isInt16Array()                  # isInt16Array method
547    ├── isInt32Array()                  # isInt32Array method
548    ├── isMap()                         # isMap method
549    ├── isMapIterator()                 # isMapIterator method
550    ├── isModuleNamespaceObject()       # isModuleNamespaceObject method
551    ├── isNativeError()                 # isNativeError method
552    ├── isNumberObject()                # isNumberObject method
553    ├── isPromise()                     # isPromise method
554    ├── isProxy()                       # isProxy method
555    ├── isRegExp()                      # isRegExp method
556    ├── isSet()                         # isSet method
557    ├── isSetIterator()                 # isSetIterator method
558    ├── isSharedArrayBuffer()           # isSharedArrayBuffer method
559    ├── isStringObject()                # isStringObject method
560    ├── isSymbolObject()                # isSymbolObject method
561    ├── isTypedArray()                  # isTypedArray method
562    ├── isUint8Array()                  # isUint8Array method
563    ├── isUint8ClampedArray()           # isUint8ClampedArray method
564    ├── isUint16Array()                 # isUint16Array method
565    ├── isUint32Array()                 # isUint32Array method
566    ├── isWeakMap()                     # isWeakMap method
567    └── isWeakSet()                     # isWeakSet method
568```
569### Usage
570
571#### Available APIs
572
573
574| API| Description|
575| -------- | -------- |
576| constructor(encoding? : string) | A constructor used to create a **TextDecoder** object. **encoding** indicates the encoding format. The default value is **UTF-8**, and the values **gb18030**, **gbk**, and **gb2312** are supported.|
577| readonly encoding : string | Obtains the encoding format. Only **UTF-8** is supported.|
578| encode(input : string) : Uint8Array | Encodes a string into a Uint8Array typed array.|
579| encodeInto(input : string, dest : Uint8Array) : {read : number, written : number} | Encodes a string into a Unit8Array typed array, and stores the array. **dest** indicates the storage location, **read** indicates the number of encoded characters, and **written** indicates the number of bytes occupied by the encoded characters.|
580| constructor(encoding? : string, options? : {fatal? : boolean, ignoreBOM? : boolean}) | A constructor used to create a **TextDecoder** object. **encoding** indicates the decoding format. **options** indicates certain attributes, where **fatal** specifies whether to throw an exception, and **ignoreBOM** specifies whether to ignore the BOM flag.|
581| readonly encoding : string | Obtains the decoding format.|
582| readonly fatal : boolean | Obtains the setting of whether to throw an exception.|
583| readonly ignoreBOM : boolean | Obtains the setting of whether to ignore the BOM flag.|
584| decode(input : Uint8Array, options?: { stream?: false }) : string | Decodes a Unit8Array typed array into a string. **input** indicates the data to decode, and **options** specifies whether additional data will be followed, with the default value **false**.|
585| decodeWithStream(input : Uint8Array, options?: { stream?: false }) : string | Decodes a Unit8Array typed array into a string. **input** indicates the data to decode, and **options** specifies whether additional data will be followed, with the default value **false**.|
586| encodeSync(src: Uint8Array): Uint8Array; | Uses the Base64 encoding scheme to synchronously encode all bytes in a Unit8Array typed array into a new Unit8Array typed array.|
587| encodeToStringSync(src: Uint8Array): string; | Uses the Base64 encoding scheme to synchronously encode a Unit8Array typed array into a string.|
588| decodeSync(src: Uint8Array \| string): Uint8Array; | Uses the Base64 encoding scheme to synchronously decode a Base64-encoded string or a Unit8Array typed array into a new Unit8Array typed array.|
589| encode(src: Uint8Array): Promise\<Uint8Array\>; | Uses the Base64 encoding scheme to asynchronously encode all bytes in a Unit8Array typed array into a new Unit8Array typed array.|
590| encodeToString(src: Uint8Array): Promise\<string\>; | Uses the Base64 encoding scheme to asynchronously encode a Unit8Array typed array into a string. It uses a promise to return the result.|
591| decode(src: Uint8Array \| string): Promise\<Uint8Array\>; | Uses the Base64 encoding scheme to asynchronously decode a Base64-encoded string or a Unit8Array typed array into a new Unit8Array typed array.|
592| static createRationalFromString(rationalString: string): RationalNumber | Creates a **RationalNumber** object based on the given string.|
593| compareTo(another: RationalNumber): number | Compares this **RationalNumber** object with the given object.|
594| equals(obj: object): number | Checks whether this **RationalNumber** object equals the given object.|
595| valueOf(): number | Rounds the value of this **RationalNumber** object as an integer or a floating-point number.|
596| static getCommonDivisor(number1: number, number2: number,): number | Obtains the greatest common divisor of two specified integers.|
597| getDenominator(): number | Obtains the denominator of this **RationalNumber** object.|
598| getNumerator(): number | Obtains the numerator of this **RationalNumber** object.|
599| isFinite(): boolean | Checks whether this **RationalNumber** object represents a finite value.|
600| isNaN(): boolean | Checks whether this **RationalNumber** object is a Not a Number (NaN).|
601| isZero(): boolean | Checks whether this **RationalNumber** object is **0**.|
602| toString(): string | Obtains the string representation of this **RationalNumber** object.|
603| constructor(capacity?: number) | Default constructor used to create an **LruBuffer** instance. The default capacity of the buffer is 64.|
604| updateCapacity(newCapacity: number): void | Changes the **LruBuffer** capacity. If the new capacity is less than or equal to **0**, an exception will be thrown.|
605| toString(): string | Obtains the string representation of this **LruBuffer** object. |
606| values(): V[] | Obtains all values in this buffer, listed from the most to the least recently used.|
607| length: number | Obtains the total number of values in this buffer.|
608| getCapacity(): number | Obtains the capacity of this buffer.|
609| clear(): void | Clears key-value pairs from this buffer. **afterRemoval()** will be called to perform subsequent operations.|
610| getCreateCount(): number | Obtains the number of return values for **createDefault()**.|
611| getMissCount(): number | Obtains the number of times that the queried values are mismatched.|
612| getRemovalCount(): number | Obtains the number of removals from this buffer.|
613| getMatchCount​(): number | Obtains the number of times that the queried values are matched.|
614| getPutCount(): number | Obtains the number of additions to this buffer.|
615| isEmpty(): boolean | Checks whether this buffer is empty. This API returns **true** if the buffer does not contain any value.|
616| get(key: K) : V \| undefined | Obtains the value of the specified key. This API returns the value of the key if a match is found in the buffer; otherwise, it returns **undefined**.|
617| put(key: K , value: V): V | Adds a key-value pair to the buffer and outputs the value associated with the key. This API returns the existing value if the key already exists; otherwise, it returns the value added. If the key or value is null, an exception will be thrown.|
618| keys(): K[ ] | Obtains all keys in this buffer, listed from the most to the least recently used.|
619| remove​(key: K): V \| undefined |  Removes the specified key and its value from this buffer.|
620| afterRemoval(isEvict: boolean, key: K, value : V, newValue : V):void | Performs subsequent operations after a value is removed.|
621| contains(key: K): boolean | Checks whether this buffer contains the specified key. This API returns **true** if the buffer contains the specified key.|
622| createDefault(key: K): V | Creates a value if the value of the specified key is not available.|
623| entries(): [K,V] | Obtains a new iterator object that contains all key-value pairs in this buffer. The key and value of each pair are objects.|
624| \[Symbol.iterator\](): [K,V] | Obtains a two-dimensional array in key-value pairs.|
625| constructor(lowerObj: ScopeType, upperObj : ScopeType) | A constructor used to create a **Scope** object with the specified upper and lower limits.|
626| toString(): string | Obtains a string representation that contains this **Scope**.|
627| intersect(range: Scope): Scope | Obtains the intersection of this **Scope** and the given **Scope**.|
628| intersect(lowerObj: ScopeType, upperObj: ScopeType): Scope | Obtains the intersection of this **Scope** and the given lower and upper limits.|
629| getUpper(): ScopeType | Obtains the upper limit of this **Scope**.|
630| getLower(): ScopeType | Obtains the lower limit of this **Scope**.|
631| expand(lowerObj: ScopeType, upperObj:  ScopeType): Scope | Obtains the union set of this **Scope** and the given lower and upper limits.|
632| expand(range: Scope): Scope | Obtains the union set of this **Scope** and the given **Scope**.|
633| expand(value: ScopeType): Scope | Obtains the union set of this **Scope** and the given value.|
634| contains(value: ScopeType): boolean | Checks whether a value is within this **Scope**.|
635| contains(range: Scope): boolean | Checks whether a range is within this **Scope**.|
636| clamp(value: ScopeType): ScopeType | Limits a value to this **Scope**.|
637| function printf(format: string, ...args: Object[]): string | Prints the input content in a formatted string. **format** can contain zero or more format specifiers.|
638| function getErrorString(errno: number): string | Obtains detailed information about a system error code.|
639| function callbackWrapper(original: Function): (err: Object, value: Object) => void | Wraps an asynchronous function (or a function that returns a promise) into an error-first callback, which means that **(err, value) => ...** is used as the last parameter of the callback. 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.|
640| function promiseWrapper(original: (err: Object, value: Object) => void): Object | Wraps a function that follows the error-first callback paradigm into a promise.|
641| isAnyArrayBuffer(value: Object): boolean | Checks whether the input value is of the **ArrayBuffer** or **SharedArrayBuffer** type.|
642| isArrayBufferView(value: Object): boolean | Checks whether the input value is of the **ArrayBufferView** type, which is a helper type representing any of the following: napi_int8_array, napi_uint8_array, napi_uint8_clamped_array, napi_int16_array, napi_uint16_array, napi_int32_array, napi_uint32_array, napi_float32_array, napi_float64_array, and DataView.|
643| isArgumentsObject(value: Object): boolean | Checks whether the input value is of the **arguments** type.|
644| isArrayBuffer(value: Object): boolean | Checks whether the input value is of the **ArrayBuffer** type.|
645| isAsyncFunction(value: Object): boolean | Checks whether the input value is an asynchronous function.|
646| isBigInt64Array(value: Object): boolean | Checks whether the input value is of the **BigInt64Array** type.|
647| isBigUint64Array(value: Object): boolean | Checks whether the input value is of the **BigUint64Array** type.|
648| isBooleanObject(value: Object): boolean | Checks whether the input value is of the **Boolean** type.|
649| isBoxedPrimitive(value: Object): boolean | Checks whether the input value is of the **Boolean**, **Number**, **String**, or **Symbol** type.|
650| isDataView(value: Object): boolean | Checks whether the input value is of the **DataView** type.|
651| isDate(value: Object): boolean | Checks whether the input value is of the **Date** type.|
652| isExternal(value: Object): boolean | Checks whether the input value is of the **native external** type.|
653| isFloat32Array(value: Object): boolean | Checks whether the input value is of the **Float32Array** type.|
654| isFloat64Array(value: Object): boolean | Checks whether the input value is of the **Float64Array** type.|
655| isGeneratorFunction(value: Object): boolean | Checks whether the input value is a generator function.|
656| isGeneratorObject(value: Object): boolean | Checks whether the input value is a generator object.|
657| isInt8Array(value: Object): boolean | Checks whether the input value is of the **Int8Array** type.|
658| isInt16Array(value: Object): boolean | Checks whether the input value is of the **Int16Array** type.|
659| isInt32Array(value: Object): boolean | Checks whether the input value is of the **Int32Array** type.|
660| isMap(value: Object): boolean | Checks whether the input value is of the **Map** type.|
661| isMapIterator(value: Object): boolean | Checks whether the input value is of the **MapIterator** type.|
662| isModuleNamespaceObject(value: Object): boolean | Checks whether the input value is a module namespace object.|
663| isNativeError(value: Object): boolean | Checks whether the input value is of the **Error** type.|
664| isNumberObject(value: Object): boolean | Checks whether the input value is a number object.|
665| isPromise(value: Object): boolean | Checks whether the input value is a promise.|
666| isProxy(value: Object): boolean | Checks whether the input value is a proxy.|
667| isRegExp(value: Object): boolean | Checks whether the input value is a regular expression.|
668| isSet(value: Object): boolean | Checks whether the input value is of the **Set** type.|
669| isSetIterator(value: Object): boolean | Checks whether the input value is of the **SetIterator** type.|
670| isSharedArrayBuffer(value: Object): boolean | Checks whether the input value is of the **SharedArrayBuffer** type.|
671| isStringObject(value: Object): boolean | Checks whether the input value is a string object.|
672| isSymbolObject(value: Object): boolean | Checks whether the input value is a symbol object.|
673| isTypedArray(value: Object): boolean | Checks whether the input value is of the **TypedArray** type.|
674| isUint8Array(value: Object): boolean | Checks whether the input value is of the **Uint8Array** type.|
675| isUint8ClampedArray(value: Object): boolean | Checks whether the input value is of the **Uint8ClampedArray** type.|
676| isUint16Array(value: Object): boolean | Checks whether the input value is of the **Uint16Array** type.|
677| isUint32Array(value: Object): boolean | Checks whether the input value is of the **Uint32Array** type.|
678| isWeakMap(value: Object): boolean | Checks whether the input value is of the **WeakMap** type.|
679| isWeakSet(value: Object): boolean | Checks whether the input value is of the **WeakSet** type.|
680
681Each format specifier in **printf()** is replaced with the converted value of the corresponding parameter. The following format specifiers are supported:
682| Format Specifier| Description|
683| -------- | -------- |
684|    %s:  | String. It is used to convert all values except **BigInt**, **Object**, and **-0**.|
685|    %d:  | Number. It is used to convert all values except **BigInt** and **Symbol**.|
686|    %i:  | **parseInt(value, 10)**. It used to convert all values except **BigInt** and **Symbol**.|
687|    %f:  | **parseFloat(value)**. It is used to convert all values except **Symbol**.|
688|    %j:  | JSON. A circular reference in the parameter will be replaced with the string **'[Circular]'**.|
689|    %o:  | A common JavaScript object represented in a string. It is similar to **util.inspect()** with the option **{ showHidden: true, showProxy: true }**. This will display a complete object, including innumerable properties and proxies.|
690|    %O:  | Object. A string representation of an object with a common JavaScript object format. It is similar to **util.inspect()** without options. This will display a complete object, excluding innumerable properties and proxies.|
691|    %c:  | This specifier is ignored and will jump any incoming CSS.|
692|    %%:  | Single percent sign ('%'). This does not consume to-be-sampled parameters.|
693
694#### How to Use
695Use the APIs as follows:
696
6971. readonly encoding()
698
699```
700import util from '@ohos.util'
701var textEncoder = new util.TextEncoder();
702var getEncoding = textEncoder.encoding();
703```
7042. encode()
705```
706import util from '@ohos.util'
707var textEncoder = new util.TextEncoder();
708var result = textEncoder.encode('abc');
709```
7103. encodeInto()
711```
712import util from '@ohos.util'
713var textEncoder = new util.TextEncoder();
714var obj = textEncoder.encodeInto('abc', dest);
715```
7164. textDecoder()
717```
718import util from '@ohos.util'
719var textDecoder = new util.textDecoder("utf-16be", {fatal : true, ignoreBOM : false});
720```
7215. readonly encoding()
722```
723import util from '@ohos.util'
724var textDecoder = new util.textDecoder("utf-16be", {fatal : true, ignoreBOM : false});
725var getEncoding = textDecoder.encoding();
726```
7276. readonly fatal()
728```
729import util from '@ohos.util'
730var textDecoder = new util.textDecoder("utf-16be", {fatal : true, ignoreBOM : false});
731var fatalStr = textDecoder.fatal();
732```
7337. readonly ignoreBOM()
734```
735import util from '@ohos.util'
736var textDecoder = new util.textDecoder("utf-16be", {fatal : true, ignoreBOM : false});
737var ignoreBom = textDecoder.ignoreBOM();
738```
7398. decode()
740```
741import util from '@ohos.util'
742var textDecoder = new util.textDecoder("utf-16be", {fatal : true, ignoreBOM : false});
743var result = textDecoder.decode(input, {stream : true});
744```
7459. decodeWithStream()
746```
747import util from '@ohos.util'
748var textDecoder = new util.textDecoder("utf-16be", {fatal : true, ignoreBOM : false});
749var result = textDecoder.decodeWithStream(input, {stream : true});
750```
75110. printf()
752```
753import util from '@ohos.util'
754var format = "%%%o%%%i%s";
755var value =  function aa(){};
756var value1 = 1.5;
757var value2 = "qwer";
758var result = util.printf(format,value,value1,value2);
759```
76011. getErrorString()
761```
762import util from '@ohos.util'
763var errnum = 13;
764var result = util.getErrorString(errnum);
765```
76612. callbackWrapper()
767```
768import util from '@ohos.util'
769async function promiseFn() {
770    return Promise.resolve('value');
771};
772var cb = util.callbackWrapper(promiseFn);
773cb((err, ret) => {
774    expect(err).strictEqual(null);
775    expect(ret).strictEqual('value');
776})
777```
77813. promiseWrapper()
779```
780import util from '@ohos.util'
781function aysnFun(str1, str2, callback) {
782    if (typeof str1 === 'string' && typeof str1 === 'string') {
783        callback(null, str1 + str2);
784    } else {
785        callback('type err');
786    }
787}
788let newPromiseObj = util.promiseWrapper(aysnFun)("Hello", 'World');
789newPromiseObj.then(res => {
790    expect(res).strictEqual('HelloWorld');
791})
792```
79314. encodeSync()
794```
795import util from '@ohos.util'
796var that = new util.Base64();
797var array = new Uint8Array([115,49,51]);
798var result = that.encodeSync(array);
799```
80015. encodeToStringSync()
801```
802import util from '@ohos.util'
803var that = new util.Base64();
804var array = new Uint8Array([115,49,51]);
805var result = that.encodeToStringSync(array);
806```
80716. decodeSync()
808```
809import util from '@ohos.util'
810var that = new util.Base64()
811var buff = 'czEz';
812var result = that.decodeSync(buff);
813
814```
81517. encode()
816```
817import util from '@ohos.util'
818var that = new util.Base64()
819var array = new Uint8Array([115,49,51]);
820await that.encode(array).then(val=>{
821})
822done()
823```
82418. encodeToString()
825```
826import util from '@ohos.util'
827var that = new util.Base64()
828var array = new Uint8Array([115,49,51]);
829await that.encodeToString(array).then(val=>{
830})
831done()
832```
83319. decode()
834```
835import util from '@ohos.util'
836var that = new util.Base64()
837var buff = 'czEz';
838await that.decode(buff).then(val=>{
839})
840done()
841```
84220. createRationalFromString()
843```
844import util from '@ohos.util'
845var pro = new util.RationalNumber(0, 0);
846var res = pro.createRationalFromString("-1:2");
847var result1 = res.valueOf();
848```
84921. compareTo()
850```
851import util from '@ohos.util'
852var pro = new util.RationalNumber(2, 1);
853var proc = new util.RationalNumber(3, 4);
854var res = pro.compareTo(proc);
855```
85622. equals()
857```
858import util from '@ohos.util'
859var pro = new util.RationalNumber(2, 1);
860var proc = new util.RationalNumber(3, 4);
861var res = pro.equals(proc);
862```
86323. valueOf()
864```
865import util from '@ohos.util'
866var pro = new util.RationalNumber(2, 1);
867var res = pro.valueOf();
868```
86924. getCommonDivisor()
870```
871import util from '@ohos.util'
872var pro = new util.RationalNumber(0, 0);
873var res = pro.getCommonDivisor(4, 8);
874```
87525. getDenominator()
876```
877import util from '@ohos.util'
878var pro = new util.RationalNumber(2, 1);
879var res = pro.getDenominator();
880```
88126. getNumerator()
882```
883import util from '@ohos.util'
884var pro = new util.RationalNumber(-2, 1);
885var res = pro.getNumerator();
886```
88727. isFinite()
888```
889import util from '@ohos.util'
890var pro = new util.RationalNumber(-2, 1);
891var res = pro.isFinite();
892```
89328. isNaN()
894```
895import util from '@ohos.util'
896var pro = new util.RationalNumber(-2, 1);
897var res = pro.isNaN();
898```
89929. isZero()
900```
901import util from '@ohos.util'
902var pro = new util.RationalNumber(-2, 1);
903var res = pro.isZero();
904```
90530. toString()
906```
907import util from '@ohos.util'
908var pro = new util.RationalNumber(-2, 1);
909var res = pro.toString();
910```
91131. updateCapacity()
912```
913import util from '@ohos.util'
914var pro = new util.LruBuffer();
915var result = pro.updateCapacity(100);
916```
91732. toString()
918```
919import util from '@ohos.util'
920var pro = new util.LruBuffer();
921pro.put(2,10);
922pro.get(2);
923pro.remove(20);
924var result = pro.toString();
925```
92633. values()
927```
928import util from '@ohos.util'
929var pro = new util.LruBuffer();
930pro.put(2,10);
931pro.put(2,"anhu");
932pro.put("afaf","grfb");
933var result = pro.values();
934```
93534. length
936```
937import util from '@ohos.util'
938var pro = new util.LruBuffer();
939pro.put(2,10);
940pro.put(1,8);
941var result = pro.length;
942```
94335. getCapacity()
944```
945import util from '@ohos.util'
946var pro = new util.LruBuffer();
947var result = pro.getCapacity();
948```
94936. clear()
950```
951import util from '@ohos.util'
952var pro = new util.LruBuffer();
953pro.put(2,10);
954pro.clear();
955```
95637. getCreateCount()
957```
958import util from '@ohos.util'
959var pro = new util.LruBuffer();
960pro.put(1,8);
961var result = pro.getCreateCount();
962```
96338. getMissCount()
964```
965import util from '@ohos.util'
966var pro = new util.LruBuffer();
967pro.put(2,10);
968pro.get(2)
969var result = pro.getMissCount();
970```
97139. getRemovalCount()
972```
973
974import util from '@ohos.util'
975var pro = new util.LruBuffer();
976pro.put(2,10);
977pro.updateCapacity(2);
978pro.put(50,22);
979var result = pro.getRemovalCount();
980
981```
98240. getMatchCount()
983```
984import util from '@ohos.util'
985var pro = new util.LruBuffer();
986pro.put(2,10);
987pro.get(2);
988var result = pro.getMatchCount();
989```
99041. getPutCount()
991```
992import util from '@ohos.util'
993var pro = new util.LruBuffer();
994pro.put(2,10);
995var result = pro.getPutCount();
996```
99742. isEmpty()
998```
999import util from '@ohos.util'
1000var pro = new util.LruBuffer();
1001pro.put(2,10);
1002var result = pro.isEmpty();
1003```
100443. get()
1005
1006```
1007import util from '@ohos.util'
1008var pro = new util.LruBuffer();
1009pro.put(2,10);
1010var result = pro.get(2);
1011```
101244. put()
1013```
1014import util from '@ohos.util'
1015var pro = new util.LruBuffer();
1016var result = pro.put(2,10);
1017```
101845. keys()
1019```
1020import util from '@ohos.util'
1021var pro = new util.LruBuffer();
1022pro.put(2,10);
1023var result = pro.keys();
1024```
102546. remove()
1026```
1027import util from '@ohos.util'
1028var pro = new util.LruBuffer();
1029pro.put(2,10);
1030var result = pro.remove(20);
1031```
103247. contains()
1033```
1034import util from '@ohos.util'
1035var pro = new util.LruBuffer();
1036pro.put(2,10);
1037var result = pro.contains(20);
1038```
103948. createDefault()
1040```
1041import util from '@ohos.util'
1042var pro = new util.LruBuffer();
1043var result = pro.createDefault(50);
1044```
104549. entries()
1046```
1047import util from '@ohos.util'
1048var pro = new util.LruBuffer();
1049pro.put(2,10);
1050var result = pro.entries();
1051```
105250. \[Symbol.iterator\]()
1053```
1054import util from '@ohos.util'
1055var pro = new util.LruBuffer();
1056pro .put(2,10);
1057var result = pro[symbol.iterator]();
1058```
105951. afterRemoval()
1060```
1061import util from '@ohos.util'
1062var arr = [ ];
1063class ChildLruBuffer extends util.LruBuffer
1064{
1065    constructor()
1066    {
1067        super();
1068    }
1069    static getInstance()
1070    {
1071        if(this.instance ==  null)
1072        {
1073            this.instance = new ChildLruBuffer();
1074        }
1075        return this.instance;
1076    }
1077    afterRemoval(isEvict, key, value, newValue)
1078    {
1079        if (isEvict === false)
1080        {
1081            arr = [key, value, newValue];
1082        }
1083    }
1084}
1085ChildLruBuffer.getInstance().afterRemoval(false,10,30,null)
1086```
1087A new constructor of **Scope** to implement the **compareTo** method.
1088
1089```
1090class Temperature {
1091    constructor(value) {
1092        this._temp = value;
1093    }
1094    compareTo(value) {
1095        return this._temp >= value.getTemp();
1096    }
1097    getTemp() {
1098        return this._temp;
1099    }
1100    toString() {
1101        return this._temp.toString();
1102    }
1103}
1104```
1105
110652. constructor()
1107
1108```
1109var tempLower = new Temperature(30);
1110var tempUpper = new Temperature(40);
1111var range = new Scope(tempLower, tempUpper);
1112```
1113
111453. toString()
1115
1116```
1117var tempLower = new Temperature(30);
1118var tempUpper = new Temperature(40);
1119var range = new Scope(tempLower, tempUpper);
1120var result = range.toString() // => [30,40]
1121```
1122
112354. intersect()
1124
1125```
1126var tempLower = new Temperature(30);
1127var tempUpper = new Temperature(40);
1128var range = new Scope(tempLower, tempUpper);
1129var tempMiDF = new Temperature(35);
1130var tempMidS = new Temperature(39);
1131var rangeFir = new Scope(tempMiDF, tempMidS);
1132var result = range.intersect(rangeFir)  // => [35,39]
1133```
1134
113555. intersect()
1136
1137```
1138var tempLower = new Temperature(30);
1139var tempUpper = new Temperature(40);
1140var tempMiDF = new Temperature(35);
1141var tempMidS = new Temperature(39);
1142var range = new Scope(tempLower, tempUpper);
1143var result = range.intersect(tempMiDF, tempMidS)  // => [35,39]
1144```
1145
114656. getUpper()
1147
1148```
1149var tempLower = new Temperature(30);
1150var tempUpper = new Temperature(40);
1151var range = new Scope(tempLower, tempUpper);
1152var result = range.getUpper() // => 40
1153```
1154
115557. getLower()
1156
1157```
1158var tempLower = new Temperature(30);
1159var tempUpper = new Temperature(40);
1160var range = new Scope(tempLower, tempUpper);
1161var result = range.getLower() // => 30
1162```
1163
116458. expand()
1165
1166```
1167var tempLower = new Temperature(30);
1168var tempUpper = new Temperature(40);
1169var tempMiDF = new Temperature(35);
1170var tempMidS = new Temperature(39);
1171var range = new Scope(tempLower, tempUpper);
1172var result = range.expand(tempMiDF, tempMidS)  // => [30,40]
1173```
1174
117559. expand()
1176
1177```
1178var tempLower = new Temperature(30);
1179var tempUpper = new Temperature(40);
1180var tempMiDF = new Temperature(35);
1181var tempMidS = new Temperature(39);
1182var range = new Scope(tempLower, tempUpper);
1183var rangeFir = new Scope(tempMiDF, tempMidS);
1184var result = range.expand(rangeFir) // => [30,40]
1185```
1186
118760. expand()
1188
1189```
1190var tempLower = new Temperature(30);
1191var tempUpper = new Temperature(40);
1192var tempMiDF = new Temperature(35);
1193var range = new Scope(tempLower, tempUpper);
1194var result = range.expand(tempMiDF)  // => [30,40]
1195```
1196
119761. contains()
1198
1199```
1200var tempLower = new Temperature(30);
1201var tempUpper = new Temperature(40);
1202var tempMiDF = new Temperature(35);
1203var range = new Scope(tempLower, tempUpper);
1204var result = range.contains(tempMiDF) // => true
1205```
1206
120762. contains()
1208
1209```
1210var tempLower = new Temperature(30);
1211var tempUpper = new Temperature(40);
1212var range = new Scope(tempLower, tempUpper);
1213var tempLess = new Temperature(20);
1214var tempMore = new Temperature(45);
1215var rangeSec = new Scope(tempLess, tempMore);
1216var result = range.contains(rangeSec) // => true
1217```
1218
121963. clamp()
1220
1221```
1222var tempLower = new Temperature(30);
1223var tempUpper = new Temperature(40);
1224var tempMiDF = new Temperature(35);
1225var range = new Scope(tempLower, tempUpper);
1226var result = range.clamp(tempMiDF) // => 35
1227```
122864. isAnyArrayBuffer()
1229```
1230import util from '@ohos.util'
1231var proc = new util.Types();
1232var result = proc.isAnyArrayBuffer(new ArrayBuffer([]))
1233```
123465. isArrayBufferView()
1235```
1236import util from '@ohos.util'
1237var proc = new util.Types();
1238var result = proc.isArrayBufferView(new DataView(new ArrayBuffer(16)));
1239```
124066. isArgumentsObject()
1241```
1242import util from '@ohos.util'
1243function foo() {
1244        var result = proc.isArgumentsObject(arguments);
1245    }
1246var f = foo();
1247```
124867. isArrayBuffer()
1249```
1250import util from '@ohos.util'
1251var proc = new util.Types();
1252var result = proc.isArrayBuffer(new ArrayBuffer([]));
1253```
125468. isAsyncFunction()
1255```
1256import util from '@ohos.util'
1257var proc = new util.Types();
1258var result = proc.isAsyncFunction(async function foo() {});
1259```
126069. isBigInt64Array()
1261```
1262import util from '@ohos.util'
1263var proc = new util.Types();
1264var result = proc.isBigInt64Array(new Int16Array([]));
1265```
126670. isBigUint64Array()
1267```
1268import util from '@ohos.util'
1269var proc = new util.Types();
1270var result = proc.isBigUint64Array(new Int16Array([]));
1271```
127271. isBooleanObject()
1273```
1274import util from '@ohos.util'
1275var proc = new util.Types();
1276var result = proc.isBooleanObject(new Boolean(false));
1277```
127872. isBoxedPrimitive()
1279```
1280import util from '@ohos.util'
1281var proc = new util.Types();
1282var result = proc.isBoxedPrimitive(new Boolean(false));
1283```
128473. isDataView()
1285```
1286import util from '@ohos.util'
1287var proc = new util.Types();
1288const ab = new ArrayBuffer(20);
1289var result = proc.isDataView(new DataView(ab));
1290```
129174. isDate()
1292```
1293import util from '@ohos.util'
1294var proc = new util.Types();
1295var result = proc.isDate(new Date());
1296```
129775. isExternal()
1298```
1299import util from '@ohos.util'
1300const data = util.createExternalType();
1301var reult13 = proc.isExternal(data);
1302```
130376. isFloat32Array()
1304```
1305import util from '@ohos.util'
1306var proc = new util.Types();
1307var result = proc.isFloat32Array(new Float32Array([]));
1308```
130977. isFloat64Array()
1310```
1311import util from '@ohos.util'
1312var proc = new util.Types();
1313var result = proc.isFloat64Array(new Float64Array([]));
1314```
131578. isGeneratorFunction()
1316```
1317import util from '@ohos.util'
1318var proc = new util.Types();
1319var result = proc.isGeneratorFunction(function* foo() {});
1320```
132179. isGeneratorObject()
1322```
1323import util from '@ohos.util'
1324var proc = new util.Types();
1325function* foo() {}
1326const generator = foo();
1327var result = proc.isGeneratorObject(generator);
1328```
132980. isInt8Array()
1330```
1331import util from '@ohos.util'
1332var proc = new util.Types();
1333var result = proc.isInt8Array(new Int8Array([]));
1334```
133581. isInt16Array()
1336```
1337import util from '@ohos.util'
1338var proc = new util.Types();
1339var result = proc.isInt16Array(new Int16Array([]));
1340```
134182. isInt32Array()
1342```
1343import util from '@ohos.util'
1344var proc = new util.Types();
1345var result = proc.isInt32Array(new Int32Array([]));
1346```
134783. isMap()
1348```
1349import util from '@ohos.util'
1350var proc = new util.Types();
1351var result = proc.isMap(new Map());
1352```
135384. isMapIterator()
1354```
1355import util from '@ohos.util'
1356var proc = new util.Types();
1357var result = proc.isMapIterator(map.keys());
1358```
135985. isModuleNamespaceObject()
1360```
1361import util from '@ohos.util'
1362var proc = new util.Types();
1363var result = proc.isModuleNamespaceObject(util);
1364```
136586. isNativeError()
1366```
1367import util from '@ohos.util'
1368var proc = new util.Types();
1369var result = proc.isNativeError(new TypeError());
1370```
137187. isNumberObject()
1372```
1373import util from '@ohos.util'
1374var proc = new util.Types();
1375var result = proc.isNumberObject(new Number(0));
1376```
137788. isPromise()
1378```
1379import util from '@ohos.util'
1380var proc = new util.Types();
1381var result = proc.isPromise(Promise.resolve(42));
1382```
138389. isProxy()
1384```
1385import util from '@ohos.util'
1386var proc = new util.Types();
1387const target = {};
1388const proxy = new Proxy(target, {});
1389var result = proc.isProxy(proxy);
1390```
139190. isRegExp()
1392```
1393import util from '@ohos.util'
1394var proc = new util.Types();
1395var result = proc.isRegExp(new RegExp('abc'));
1396```
139791. isSet()
1398```
1399import util from '@ohos.util'
1400var proc = new util.Types();
1401var result = proc.isSet(new Set());
1402```
140392. isSetIterator()
1404```
1405import util from '@ohos.util'
1406var proc = new util.Types();
1407const set = new Set();
1408var result = proc.isSetIterator(set.keys());
1409```
141093. isSharedArrayBuffer()
1411```
1412import util from '@ohos.util'
1413var proc = new util.Types();
1414var result = proc.isSharedArrayBuffer(new ArrayBuffer([]));
1415```
141694. isStringObject()
1417```
1418import util from '@ohos.util'
1419var proc = new util.Types();
1420var result = proc.isStringObject(new String('foo'));
1421```
142295. isSymbolObject()
1423```
1424import util from '@ohos.util'
1425var proc = new util.Types();
1426const symbols = Symbol('foo');
1427var result = proc.isSymbolObject(Object(symbols));
1428```
142996. isTypedArray()
1430```
1431import util from '@ohos.util'
1432var proc = new util.Types();
1433var result = proc.isTypedArray(new Float64Array([]));
1434```
143597. isUint8Array()
1436```
1437import util from '@ohos.util'
1438var proc = new util.Types();
1439var result = proc.isUint8Array(new Uint8Array([]));
1440```
144198. isUint8ClampedArray()
1442```
1443import util from '@ohos.util'
1444var proc = new util.Types();
1445var result = proc.isUint8ClampedArray(new Uint8ClampedArray([]));
1446```
144799. isUint16Array()
1448```
1449import util from '@ohos.util'
1450var proc = new util.Types();
1451var result = proc.isUint16Array(new Uint16Array([]));
1452```
1453100. isUint32Array()
1454```
1455import util from '@ohos.util'
1456var proc = new util.Types();
1457var result = proc.isUint32Array(new Uint32Array([]));
1458```
1459101. isWeakMap()
1460```
1461import util from '@ohos.util'
1462var proc = new util.Types();
1463var result = proc.isWeakMap(new WeakMap());
1464```
1465102. isWeakSet()
1466```
1467import util from '@ohos.util'
1468var proc = new util.Types();
1469var result = proc.isWeakSet(new WeakSet());
1470```
1471
1472## js_sys_module
1473###  Introduction
1474js_sys_module provides the following classes:<br>**Process**: provides APIs to obtain multiple IDs of a process, obtain and modify the working directory of a process, and exit and stop a process. **childprocess**:  provides APIs for a process to obtain the standard input and output of its child processes, send signals, and close its child processes.
1475### Directory Structure
1476
1477```
1478commonlibrary/ets_utils/js_sys_module/
1479├── Class:PROCESS                   # Process class
1480├── Uid                             # UID attribute
1481├── Gid                             # GID attribute
1482├── EUid                            # EUID attribute
1483├── EGid                            # EGID attribute
1484├── Groups                          # Groups attribute
1485├── Pid                             # PID attribute
1486├── Ppid                            # PPID attribute
1487├── chdir()                         # chdir method
1488├── uptime()                        # uptime method
1489├── kill()                          # kill method
1490├── abort()                         # abort method
1491├── on()                            # on method
1492├── tid                             # tid method
1493├── getStartRealtime()              # getStartRealtime method
1494├── getAvailableCores()             # getAvailableCores method
1495├── getPastCputime()                # getPastCputime method
1496├── isIsolatedProcess()             # isIsolatedProcess method
1497├── is64Bit()                       # is64Bit method
1498├── isAppUid()                      # isAppUid method
1499├── getUidForName()                 # getUidForName method
1500├── getThreadPriority()             # getThreadPriority method
1501├── getSystemConfig()               # getSystemConfig method
1502├── getEnvironmentVar()             # getEnvironmentVar method
1503├── exit()                          # exit method
1504├── cwd()                           # cwd method
1505├── off()                           # off method
1506├── runCmd()                        # runCmd method
1507└─── Class:CHILDPROCESS             # ChildProcess class
1508    ├── close()                     # close method
1509    ├── kill()                      # kill method
1510    ├── getOutput()                 # getOutput method
1511    ├── getErrorOutput()            # getErrorOutput method
1512    ├── wait()                      # wait method
1513    ├── killed                      # killed attribute
1514    ├── pid                         # PID attribute
1515    ├── ppid                        # PPID attribute
1516    └── exitCode                    # exitCode attribute
1517|—— Class:CONSOLE
1518    ├── debug()                     # debug method
1519    ├── log()                       # log method
1520    ├── info()                      # info method
1521    ├── warn()                      # warn method
1522    ├── error()                     # error method
1523    ├── assert()                    # assert method
1524    ├── count()                     # count method
1525    ├── countReset()                # countReset method
1526    ├── dir()                       # dir method
1527    ├── dirxml()                    # dirxml method
1528    ├── group()                     # group method
1529    ├── groupCollapsed()            # groupCollapsed method
1530    ├── groupEnd()                  # groupEnd method
1531    ├── table()                     # table method
1532    ├── time()                      # time method
1533    ├── timeEnd()                   # timeEnd method
1534    ├── timeLog()                   # timeLog method
1535    ├── trace()                     # trace method
1536|—— Class:TIMER
1537    ├── setInterval()               # setInterval method
1538    ├── setTimeout()                # setTimeout method
1539    ├── clearInterval()             # clearInterval method
1540    ├── clearTimeout()              # clearTimeout method
1541```
1542
1543### How to Use
1544
1545#### Available APIs
1546| API| Description|
1547| -------- | -------- |
1548| const uid :number | Obtains the user identifier (UID) of this process.|
1549| const gid :number | Obtains the group identifier (GID) of this process.|
1550| const euid :number | Obtains the effective user identifier (EUID) of this process.|
1551| const egid :number | Obtains the effective group identifier (EGID) of this process.|
1552| const groups :number[] |  Obtains an array with supplementary group IDs.|
1553| const pid :number | Obtains the process ID (PID) of this process.|
1554| const ppid :number |  Obtains the parent process ID (PPID) of this process.|
1555| chdir(dir:string) :void | Changes the working directory of this process.|
1556| uptime() :number |  Obtains the running time of this process, in seconds.|
1557| Kill(pid:number, signal:number) :boolean | Sends a signal to the specified process to terminate it. The value **true** means that the signal is sent.|
1558| abort() :void | Aborts a process and generates a core file. It will cause the process to exit immediately.|
1559| on(type:string ,listener:EventListener) :void | Stores the events triggered by the user.|
1560| exit(code:number):void | Terminates this process.|
1561| cwd():string |  Obtains the working directory of this process.|
1562| off(type: string): boolean | Deletes the event stored by the user. The value **true** means that the event is deleted.|
1563| runCmd(command: string, options?: { timeout : number, killSignal : number \| string, maxBuffer : number }): ChildProcess |Forks a new process to run a shell command and returns the **ChildProcess** object. **command** indicates the shell command to run, and **options** indicates certain running parameters, such as **timeout**, **killsignal**, and **maxbuffer**, of the child process. If **timeout** is set, the child process sends the **kill** signal after the specified timeout reaches. **maxbuffer** is used to limit the maximum size of **stdout** and **stderr** that can be received.|
1564| wait(): Promise\<number>| Waits until the child process ends. It uses a promise to return the exit code of the child process.|
1565| getOutput(): Promise\<Uint8Array> |  Obtains the standard output of the child process.|
1566| getErrorOutput(): Promise\<Uint8Array> | Obtains the standard error output of the child process.|
1567| const tid:number | Obtains the TID of the process.|
1568| getStartRealtime() :number | Obtains the duration (in milliseconds) from the time the system starts to the time the process starts.|
1569| getAvailableCores() :number[] | Obtains the number of CPU cores available for the process on a multi-core device.|
1570| getPastCputime() :number | Obtains the CPU time (in milliseconds) from the time the process starts to the current time.|
1571| isIsolatedProcess(): boolean | Checks whether this process is isolated.|
1572| is64Bit(): boolean | Checks whether this process is running in a 64-bit environment.|
1573| isAppUid(v:number): boolean | Checks whether a UID belongs to the current app.|
1574| getUidForName(v:string): number | Obtains the process UID based on the process name.|
1575| getThreadPriority(v:number): number | Obtains the thread priority based on the TID.|
1576| getSystemConfig(name:number): number | Obtains the system configuration based on the configuration name.|
1577| getEnvironmentVar(name:string): string | Obtains the value of an environment variable.|
1578| close(): void | Closes the child process in running.|
1579| kill(signal: number \| string): void |  Sends a signal to the specified child process to terminate it.|
1580| readonly killed: boolean | Specifies whether the signal is sent. The value **true** means that the signal is sent.|
1581| readonly exitCode: number | Indicates the exit code of the child process.|
1582| readonly pid: number | Indicates the PID of the child process.|
1583| readonly ppid: number | Indicates the PPID of the process.|
1584| debug(message: string, ...arguments: any[]): void | print debug information. |
1585| log(message: string, ...arguments: any[]): void | print log information. |
1586| info(message: string, ...arguments: any[]): void | print info information. |
1587| warn(message: string, ...arguments: any[]): void | print warn information. |
1588| error(message: string, ...arguments: any[]): void | print error information. |
1589| assert(value?: Object, ...arguments: Object[]): void | if value is false,print arguments information. |
1590| count(label?: string): void | Counts the label name. |
1591| countReset(label?: string): void | Clear the count of label names. |
1592| dir(dir?: Object): void | Print the object content. |
1593| dirxml(...arguments: Object[]): void | print log information. |
1594| group(...arguments: Object[]): void | Indent one group |
1595| groupCollapsed(...arguments: Object[]): void | Indent one group |
1596| groupEnd(): void | Unindent one group. |
1597| table(tableData?: Object): void | Print data in tabular form. |
1598| time(label?: string): void | Start the clock. |
1599| timeEnd(label?: string): void | End the timer. |
1600| timeLog(label?: string, ...arguments: Object[]): void | Print current timing. |
1601| trace(...arguments: Object[]): void | Print current stack. |
1602|  setInterval(handler: Function \| string, delay: number, ...arguments: any[]): number | Timing to call callback function. |
1603|  setTimeout(handler: Function \| string, delay?: number, ...arguments: any[]): number | Call the callback function when the timing ends. |
1604|  clearInterval(intervalID?: number): void | Clear the timing callback. |
1605|  clearTimeout(timeoutID?: number): void |Clear the timing callback. |
1606
1607#### How to Use
1608
1609Use the APIs as follows:
16101. uid()
1611```
1612uid(){
1613    var res =  Process.uid;
1614}
1615```
16162. gid()
1617```
1618gid(){
1619    var result = Process.gid;
1620}
1621```
16223. euid()
1623```
1624euid(){
1625    var and = Process.euid;
1626}
1627```
16284. egid()
1629```
1630egid(){
1631    var resb = Process.egid;
1632}
1633```
16345. groups()
1635```
1636groups(){
1637    var answer = Process.groups;
1638}
1639```
16406. pid()
1641```
1642pid(){
1643    var result = Process.pid;
1644}
1645```
16467. ppid()
1647```
1648ppid(){
1649    var result = Process.ppid;
1650}
1651```
16528. chdir()
1653```
1654chdir(){
1655    Process.chdir("123456");
1656}
1657```
16589. uptime()
1659```
1660uptime(){
1661    var num = Process.uptime();
1662}
1663```
166410. kill()
1665```
1666kill(){
1667    var ansu = Process.kill(5,23);
1668}
1669```
167011. abort()
1671```
1672abort(){
1673    Process.abort();
1674}
1675```
167612. on()
1677```
1678on(){
1679    function add(num){
1680        var value = num + 5;
1681        return value;
1682    }
1683    Process.on("add",add);
1684}
1685```
168613. exit()
1687```
1688exit(){
1689    Process.exit(15);
1690}
1691```
169214. Cwd()
1693```
1694Cwd(){
1695    var result = Process.cwd();
1696}
1697```
169815. off()
1699
1700```
1701off(){
1702    var result =  Process.off("add");
1703}
1704```
170516. runCmd()
1706```
1707runCmd(){
1708    var child = process.runCmd('echo abc')
1709    // killSignal can be a number or string.
1710    var child = process.runCmd('echo abc;', {killSignal : 'SIGKILL'});
1711    var child = process.runCmd('sleep 5; echo abc;', {timeout : 1, killSignal : 9, maxBuffer : 2})
1712}
1713```
171417. wait()
1715```
1716wait()
1717{
1718    var child = process.runCmd('ls')
1719    var status = child.wait();
1720    status.then(val => {
1721        console.log(val);
1722    })
1723}
1724```
172518. getOutput()
1726```
1727getOutput(){
1728    var child = process.runCmd('echo bcd;');
1729    var res = child.getOutput();
1730    child.wait();
1731    res.then(val => {
1732        console.log(val);
1733    })
1734}
1735```
173619. getErrorOutput()
1737```
1738getErrorOutput(){
1739    var child = process.runCmd('makdir 1.txt'); // execute an error command
1740    var res = child.getErrorOutput();
1741    child.wait();
1742    res.then(val => {
1743        console.log(val);
1744    })
1745}
1746```
174720. close()
1748```
1749close(){
1750    var child =  process.runCmd('ls; sleep 5s;')
1751    var result = child.close()
1752}
1753```
175421. kill()
1755```
1756kill(){
1757    var child =  process.runCmd('ls; sleep 5s;')
1758    var result = child.kill('SIGHUP');
1759    child.wait();
1760    var temp = child.killed;
1761}
1762```
176322. killed
1764```
1765{
1766    var child = process.runCmd('ls; sleep 5;')
1767    child.kill(3);
1768    var killed_ = child.killed;
1769    child.wait();
1770}
1771```
177223. exitCode
1773```
1774{
1775    var child = process.runCmd('ls; sleep 5;')
1776    child.kill(9);
1777    child.wait();
1778    var exitCode_ = child.exitCode;
1779}
1780```
178124. pid
1782```
1783pid
1784{
1785    var child = process.runCmd('ls; sleep 5;')
1786    var pid_ = child.pid;
1787    child.wait();
1788}
1789```
179025. ppid
1791```
1792ppid
1793{
1794    var child = process.runCmd('ls; sleep 5;')
1795    var ppid_ = child.ppid;
1796    child.wait();
1797}
1798```
179926. tid
1800```
1801tid(){
1802    var ansu = Process.tid;
1803}
1804```
180527. isIsolatedProcess()
1806```
1807isIsolatedProcess(){
1808    var ansu = Process.isIsolatedProcess()();
1809}
1810```
181128. isAppUid()
1812```
1813isAppUid(){
1814    var ansu = Process.isAppUid(10000);
1815}
1816```
181729. is64Bit()
1818```
1819is64Bit(){
1820    var ansu = Process.is64Bit();
1821}
1822```
182330. getUidForName()
1824```
1825getUidForName(){
1826    var buf = "root";
1827    var ansu = Process.getUidForName(buf);
1828}
1829```
183031. getEnvironmentVar()
1831```
1832getEnvironmentVar(){
1833    var ansu = Process.getEnvironmentVar('USER');
1834}
1835```
183632. getAvailableCores()
1837```
1838getAvailableCores(){
1839    var ansu = Process.getAvailableCores();
1840}
1841```
184233. getThreadPriority()
1843```
1844getThreadPriority(){
1845    var result = Process.getTid();
1846    var ansu = getThreadPriority(result);
1847}
1848```
184934. getStartRealtime()
1850```
1851getStartRealtime(){
1852    var ansu = Process.getStartRealtime();
1853}
1854```
185535. getPastCputime()
1856```
1857getPastCputime(){
1858    var ansu = Process.getPastCputime();
1859}
1860```
186136. getSystemConfig()
1862```
1863getSystemConfig(){
1864    var _SC_ARG_MAX = 0;
1865    var ansu = Process.getSystemConfig(_SC_ARG_MAX)
1866}
1867```
186837.console.debug()
1869```
1870console.debug("print debug log");
1871}
1872```
187338.console.log()
1874```
1875console.debug("print log");
1876}
1877```
187839.console.info()
1879```
1880console.debug("print info log");
1881}
1882```
188340.console.warn()
1884```
1885console.debug("print warn log");
1886}
1887```
188841.console.error()
1889```
1890console.debug("print error log");
1891}
1892```
189342.console.assert()
1894```
1895for (let number = 2; number <= 5; number++) {
1896    console.assert(number % 2 === 0, "error");
1897}
1898```
189943.console.count()
1900```
1901console.count("myObj");
1902```
190344.console.countReset()
1904```
1905console.count("myObj");
1906console.countReset("myObj");
1907```
190845.console.dir()
1909```
1910function cat(name, age, score){
1911  this.name = name;
1912  this.age = age;
1913  this.score = score;
1914}
1915var c = new cat("ohos", 2, [6,8,7]);
1916console.dir(c);
1917```
191846.console.dirxml()
1919```
1920console.xml("print log");
1921```
192247.console.group()
1923```
1924console.group();
1925```
192648.console.groupCollapsed()
1927```
1928console.groupCollapsed();
1929```
193049.console.groupEnd()
1931```
1932console.groupEnd();
1933```
193450.console.table()
1935```
1936var languages = {
1937  csharp: { name: "C#", paradigm: "undefined" },
1938  fsharp: { name: "F#", paradigm: "functional" }
1939};
1940console.table(languages);
1941```
194251.console.time()
1943```
1944console.time("timer1");
1945```
194652.console.timeEnd()
1947```
1948console.time("timer1");
1949console.timeEnd("timer1");
1950```
195153.console.timeLog()
1952```
1953console.time("timer1");
1954console.timeLog("timer1");
1955```
195654.console.trace()
1957```
1958console.trace();
1959```
196055.setInterval()
1961```
1962function callback() {
1963  console.log("setInterval");
1964};
1965setInterval(callback, 100);
1966```
196755.setTimeout()
1968```
1969function callback() {
1970  console.log("setTimeout");
1971};
1972setTimeout(callback, 100);
1973```
197455.clearInterval()
1975```
1976function callback() {
1977  console.log("clearInterval");
1978};
1979var myVar = setInterval(callback, 1000);
1980clearInterval(myVar);
1981```
198256.clearTimeout()
1983```
1984function callback() {
1985  console.log("clearTimeout");
1986};
1987var myVar = setTimeout(callback, 1000);
1988clearTimeout(myVar);
1989```
1990
1991## js_concurrent_module
1992
1993### Introduction
1994
1995The js_concurrent_module provides the worker thread, which communicates with the host thread through **postMessage**.
1996
1997### Available APIs
1998For details about the API implementation, see js_worker_module/worker.
1999
2000#### Worker Object
2001
2002Object used by the host thread to communicate with the worker thread.
2003
2004##### APIs
2005
20061.
2007
2008- API
2009
2010|constructor(scriptURL:string, options?:WorkerOptions) | Constructor used to create a worker object.|
2011|---|---|
2012
2013- Example
2014
2015You can use any of the following methods to create a worker thread, depending on whether the **workers** directory that stores the **worker.ts** file is at the same level as the **pages** directory and whether the FA or stage model is in use:
2016
2017(1) In the FA model, the **workers** and **pages** directories are at the same level.
2018```
2019import worker from "@ohos.worker";
2020const workerInstance = new worker.Worker("workers/worker.js", {name:"first worker"});
2021```
2022(2) In the FA model, the **workers** and **pages** directories are at different levels.
2023```
2024import worker from "@ohos.worker";
2025const workerInstance = new worker.Worker("../workers/worker.js", {name:"first worker"});
2026```
2027(3) In the stage model, the **workers** and **pages** directories are at the same level.
2028```
2029import worker from "@ohos.worker";
2030const workerInstance = new worker.Worker('entry/ets/workers/worker.ts');
2031```
2032(4) In the stage model, the **workers** and **pages** directories are at different levels.
2033```
2034import worker from "@ohos.worker";
2035const workerInstance = new worker.Worker('entry/ets/pages/workers/worker.ts');
2036```
2037scriptURL in the stage model — Description of "entry/ets/workers/worker.ts".
2038- **entry**: value of the **name** attribute under **module** in the **module.json5** file.
2039- **ets**: programming language in use.
2040- **worker.ts**: file for the module. You can also use a **worker.js** file.
2041
2042Depending on whether the **workers** and **pages** directories are at the same level, you may need to configure the **buildOption** attribute in the **build-profile.json5** file.
2043
2044(1) If the **workers** and **pages** directories are at the same level, the configuration is optional.
2045
2046In the FA model:
2047```
2048  "buildOption": {
2049    "sourceOption": {
2050      "workers": [
2051        "./src/main/ets/MainAbility/workers/worker.js"
2052      ]
2053    }
2054  }
2055```
2056In the stage model:
2057```
2058  "buildOption": {
2059    "sourceOption": {
2060      "workers": [
2061        "./src/main/ets/workers/worker.ts"
2062      ]
2063    }
2064  }
2065```
2066(2) If the **workers** and **pages** directories are at different levels, the configuration is mandatory.
2067
2068In the FA model:
2069```
2070  "buildOption": {
2071    "sourceOption": {
2072      "workers": [
2073        "./src/main/ets/workers/worker.js"
2074      ]
2075    }
2076  }
2077```
2078In the stage model (the following assumes that the **workers** directory is under the **pages** directory):
2079```
2080  "buildOption": {
2081    "sourceOption": {
2082      "workers": [
2083        "./src/main/ets/pages/workers/worker.ts"
2084      ]
2085    }
2086  }
2087```
20882.
2089
2090- API
2091
2092| postMessage(message:Object, options?:PostMessageOptions)  | Sends a message to the worker thread. |
2093|---|---|
2094| postMessage(message:Object, transfer:ArrayBuffer[])  | Sends a message to the worker thread. |
2095
2096- Examples
2097
2098```
2099// Example 1
2100import worker from "@ohos.worker"
2101const worker = new worker.Worker("workers/worker.js");
2102worker.postMessage("hello world");
2103
2104// Example 2
2105import worker from "@ohos.worker"
2106const worker = new worker.Worker("workers/worker.js");
2107var buffer = new ArrayBuffer(8);
2108worker.postMessage(buffer, [buffer]);
2109```
2110
21113.
2112
2113- API
2114
2115| on(type:string, listener:EventListener)  | Adds an event listener to the worker. |
2116|---|---|
2117
2118- Examples
2119
2120```
2121import worker from "@ohos.worker"
2122const worker = new worker.Worker("workers/worker.js");
2123worker.on("alert", (e)=>{
2124     console.log("worker on...");
2125});
2126```
2127
21284.
2129
2130- API
2131
2132| once(type:string, listener:EventListener)  | Adds an event listener to the worker and removes the event listener automatically after it is invoked once. |
2133|---|---|
2134
2135- Examples
2136
2137```
2138import worker from "@ohos.worker"
2139const worker = new worker.Worker("workers/worker.js");
2140worker.once("alert", (e)=>{
2141    console.log("worker once...");
2142});
2143```
2144
21455.
2146
2147- API
2148
2149| off(type:string, listener?:EventListener)  | Removes an event listener for the worker. |
2150|---|---|
2151
2152- Examples
2153
2154```
2155import worker from "@ohos.worker"
2156const worker = new worker.Worker("workers/worker.js");
2157worker.off("alert");
2158```
2159
21606.
2161
2162- API
2163
2164| terminate()  | Terminates the worker thread to stop the worker from receiving messages. |
2165|---|---|
2166
2167- Example
2168
2169```
2170import worker from "@ohos.worker"
2171const worker = new worker.Worker("workers/worker.js");
2172worker.terminate();
2173```
2174
21757.
2176
2177- API
2178
2179| removeEventListener(type:string, listener?:EventListener)  | Removes an event listener for the worker. |
2180|---|---|
2181
2182- Example
2183
2184```
2185import worker from "@ohos.worker"
2186const worker = new worker.Worker("workers/worker.js");
2187worker.removeEventListener("alert", (e)=>{
2188    console.log("worker removeEventListener...");
2189});
2190```
2191
21928.
2193
2194- API
2195
2196| dispatchEvent(event: Event)  | Dispatches the event defined for the worker. |
2197|---|---|
2198
2199- Example
2200
2201```
2202import worker from "@ohos.worker"
2203const worker = new worker.Worker("workers/worker.js");
2204worker.dispatchEvent({type:"alert"});
2205```
2206
22079.
2208
2209- API
2210
2211| removeAllListener()  | Removes all event listeners for the worker. |
2212|---|---|
2213
2214- Example
2215
2216```
2217import worker from "@ohos.worker"
2218const worker = new worker.Worker("workers/worker.js");
2219worker.removeAllListener();
2220```
2221
2222##### Attributes
2223
22241.
2225
2226- Attribute
2227
2228| onexit?:(code:number)=>void  | Event handler to be called when the worker thread exits. The handler is executed in the host thread. |
2229|---|---|
2230
2231- Example
2232
2233```
2234import worker from "@ohos.worker"
2235const worker = new worker.Worker("workers/worker.js");
2236worker.onexit = function(e) {
2237    console.log("onexit...");
2238}
2239```
2240
22412.
2242
2243- Attribute
2244
2245| onerror?:(ev:ErrorEvent)=>void  | Event handler to be called when an exception occurs during worker execution. The event handler is executed in the host thread. |
2246|---|---|
2247
2248- Example
2249
2250```
2251import worker from "@ohos.worker"
2252const worker = new worker.Worker("workers/worker.js");
2253worker.onerror = function(e) {
2254    console.log("onerror...");
2255}
2256```
2257
22583.
2259
2260- Attribute
2261
2262| onmessage?:(ev:MessageEvent)=>void  | Event handler to be called when the host thread receives a message sent by the worker thread through **parentPort.postMessage**. The event handler is executed in the host thread.|
2263|---|---|
2264
2265- Example
2266
2267```
2268import worker from "@ohos.worker"
2269const worker = new worker.Worker("workers/worker.js");
2270worker.onmessage = function(e) {
2271    console.log("onmessage...");
2272}
2273```
2274
22754.
2276
2277- Attribute
2278
2279| onmessageerror?:(event:MessageEvent)=>void  | Event handler to be called when the worker thread receives a message that cannot be serialized. The event handler is executed in the host thread.|
2280|---|---|
2281
2282- Example
2283
2284```
2285import worker from "@ohos.worker"
2286const worker = new worker.Worker("workers/worker.js");
2287worker.onmessageerror = function(e) {
2288    console.log("onmessageerror...");
2289}
2290```
2291
2292#### parentPort Object
2293
2294Object of the worker thread used to communicate with the host thread.
2295
2296##### APIs
2297
22981.
2299
2300- API
2301
2302| postMessage(message:Object, options?:PostMessageOptions)  | Sends a message to the host thread from the worker thread.|
2303|---|---|
2304| postMessage(message:Object, transfer:ArrayBuffer[])  | Sends a message to the host thread from the worker thread. |
2305
2306- Example
2307
2308```
2309// main.js
2310import worker from "@ohos.worker"
2311const worker = new worker.Worker("workers/worker.js");
2312worker.postMessage("hello world");
2313
2314// worker.js
2315import worker from "@ohos.worker"
2316const parentPort = worker.parentPort;
2317parentPort.onmessage = function(e) {
2318    parentPort.postMessage("hello world from worker.js");
2319}
2320```
2321
23222.
2323
2324- API
2325
2326| close()  | Terminates the worker thread to stop the worker from receiving messages. |
2327|---|---|
2328
2329- Example
2330
2331```
2332// main.js
2333import worker from "@ohos.worker"
2334const worker = new worker.Worker("workers/worker.js");
2335worker.postMessage("hello world");
2336
2337// worker.js
2338import worker from "@ohos.worker"
2339const parentPort = worker.parentPort;
2340parentPort.onmessage = function(e) {
2341    parentPort.close();
2342}
2343```
2344
2345##### Attributes
2346
23471.
2348
2349- Attribute
2350
2351| onmessage?:(event:MessageEvent)=>void  | Event handler to be called when the host thread receives a message sent by the worker thread through **parentPort.postMessage**. The event handler is executed in the worker thread. |
2352|---|---|
2353
2354- Example
2355
2356```
2357// main.js
2358import worker from "@ohos.worker"
2359const worker = new worker.Worker("workers/worker.js");
2360worker.postMessage("hello world");
2361
2362// worker.js
2363import worker from "@ohos.worker"
2364const parentPort = worker.parentPort;
2365parentPort.onmessage = function(e) {
2366    console.log("receive main.js message");
2367}
2368```
2369
23702.
2371
2372- Attribute
2373
2374| onerror?:(ev: ErrorEvent)=>void  | Event handler to be called when an exception occurs during worker execution. The event handler is executed in the worker thread. |
2375|---|---|
2376
2377- Example
2378
2379```
2380// main.js
2381import worker from "@ohos.worker"
2382const worker = new worker.Worker("workers/worker.js");
2383worker.postMessage("hello world");
2384
2385// worker.js
2386import worker from "@ohos.worker"
2387const parentPort = worker.parentPort;
2388parentPort.onerror = function(e) {
2389    console.log("onerror...");
2390}
2391
2392```
2393
23943.
2395
2396- Attribute
2397
2398| onmessageerror?:(event: MessageEvent)=>void  | Event handler to be called when the worker thread receives a message that cannot be deserialized. The event handler is executed in the worker thread. |
2399|---|---|
2400
2401- Example
2402
2403```
2404// main.js
2405import worker from "@ohos.worker"
2406const worker = new worker.Worker("workers/worker.js");
2407worker.postMessage("hello world");
2408
2409// worker.js
2410import worker from "@ohos.worker"
2411const parentPort = worker.parentPort;
2412parentPort.onmessageerror = function(e) {
2413    console.log("onmessageerror...");
2414}
2415```
2416
2417
2418# Repositories Involved
2419
2420[arkcompiler_ets_runtime](https://gitee.com/openharmony/arkcompiler_ets_runtime/blob/master/README_zh.md)
2421[arkui_ace_engine](https://gitee.com/openharmony/arkui_ace_engine/blob/master/README_zh.md)
2422[arkui_napi](https://gitee.com/openharmony/arkui_napi/blob/master/README_zh.md)
2423
2424# Licenses
2425
2426**js_api_module** can be used under the [Mozilla Public License](https://www.mozilla.org/en-US/MPL/). For the complete license text, see [License](https://gitee.com/openharmony/commonlibrary_ets_utils/blob/master/js_api_module/mozilla_docs.txt).
2427
2428**js_util_module** can be used under the [Mozilla Public License](https://www.mozilla.org/en-US/MPL/). For the complete license text, see [License](https://gitee.com/openharmony/commonlibrary_ets_utils/blob/master/js_util_module/mozilla_docs.txt).
2429
2430**js_concurrent_module** can be used under the [Mozilla Public License](https://www.mozilla.org/en-US/MPL/). For the complete license text, see [License](https://gitee.com/openharmony/commonlibrary_ets_utils/blob/master/js_concurrent_module/mozilla_docs.txt).
2431
2432**js_sys_module** can be used under the [Mozilla Public License](https://www.mozilla.org/en-US/MPL/). For the complete license text, see [License](https://gitee.com/openharmony/commonlibrary_ets_utils/blob/master/js_sys_module/mozilla_docs.txt).

README.md

1# ets_utils组件
2ets_utils组件共提供四个子模块,分别是:js_api_module、js_util_module、js_sys_module和js_concurrent_module,以下内容将详细介绍各个子模块的简介、目录、说明和涉及仓等相关内容。
3
4# 子模块
5## 1. js_api_module子模块
6### 1.1. 简介
7
8URL接口用于解析,构造,规范化和编码 URLs。 URL的构造函数创建新的URL对象。 以便对URL的已解析组成部分或对URL进行更改。URLSearchParams 接口定义了一些实用的方法来处理 URL 的查询字符串。
9
10URI表示统一资源标识符引用。
11
12xml表示指可扩展标记语言。
13
14XmlSerializer接口用于生成一个xml文件。 XmlSerializer的构造函数创建新的XmlSerializer对象,调用XmlSerializer对象的方法生成一个xml文件。XmlPullParser 接口用于解析已有的xml文件,XmlPullParser的构造函数创建新的XmlPullParser对象,调用XmlPullParser对象的方法解析xml。
15
16### 1.2. 目录
17
18```
19commonlibrary/ets_utils/js_api_module/
20├── Class:URL                                                                     # URL类
21│   ├── new URL(input[, base])                                                    # 创建URL对象
22│   ├── hash                                                                      # hash属性
23│   ├── host                                                                      # host属性
24│   ├── hostname                                                                  # hostname属性
25│   ├── href                                                                      # href属性
26│   ├── origin                                                                    # origin属性
27│   ├── password                                                                  # password属性
28│   ├── pathname                                                                  # pathname属性
29│   ├── port                                                                      # port属性
30│   ├── protocol                                                                  # protocol属性
31│   ├── search                                                                    # search属性
32│   ├── searchParams                                                              # searchParams属性
33│   ├── username                                                                  # username属性
34│   ├── toString()                                                                # toString方法
35│   └── toJSON()                                                                  # toJSON方法
36├── Class: URLSearchParams                                                        # URLSearchParams类
37│   ├── new URLSearchParams()                                                     # 创建URLSearchParams对象
38│   ├── new URLSearchParams(string)                                               # 创建URLSearchParams对象
39│   ├── new URLSearchParams(obj)                                                  # 创建URLSearchParams对象
40│   ├── new URLSearchParams(iterable)                                             # 创建URLSearchParams对象
41│   ├── append(name, value)                                                       # append方法
42│   ├── delete(name)                                                              # delete方法
43│   ├── entries()                                                                 # entries方法
44│   ├── forEach(fn[, thisArg])                                                    # forEach方法
45│   ├── get(name)                                                                 # get方法
46│   ├── getAll(name)                                                              # getAll方法
47│   ├── has(name)                                                                 # has方法
48│   ├── keys()                                                                    # keys方法
49│   ├── set(name, value)                                                          # set方法
50│   ├── sort()                                                                    # sort方法
51│   ├── toString()                                                                # toString方法
52│   ├── values()                                                                  # values方法
53│   └── urlSearchParams[Symbol.iterator]()                                        # 创建URLSearchParams对象
54├── Class:URI                                                                     # URI类
55│   ├── URI(str: string)                                                          # 创建URI对象
56│   ├── scheme                                                                    # scheme属性
57│   ├── authority                                                                 # authority属性
58│   ├── ssp                                                                       # ssp属性
59│   ├── userinfo                                                                  # userinfo属性
60│   ├── host                                                                      # host属性
61│   ├── port                                                                      # port属性
62│   ├── query                                                                     # query属性
63│   ├── fragment                                                                  # fragment属性
64│   ├── path                                                                      # path属性
65│   ├── equals(ob: Object)                                                        # equals方法
66│   ├── normalize()                                                               # normalize方法
67│   ├── checkIsAbsolute()                                                         # checkIsAbsolute方法
68│   ├── normalize()                                                               # normalize方法
69│   └── toString()                                                                # toString方法
70├── Class:ConvertXml                                                              # ConvertXml类
71│   ├── ConvertXml()                                                              # 创建ConvertXml类对象
72│   └── convert(xml: string, options: Object)                                     # convert方法
73├── Class:XmlSerializer                                                           # XmlSerializer类
74│   ├── new XmlSerializer(buffer: ArrayBuffer | DataView, encoding?: string)      # 创建XmlSerializer类对象
75│   ├── setAttributes(name: string, value: string)                                # 设置Attributes方法
76│   ├── addEmptyElement(name: string)                                             # 添加一个空元素方法
77│   ├── setDeclaration()                                                          # 设置Declaration方法
78│   ├── startElement(name: string)                                                # 设置开始元素方法
79│   ├── endElement()                                                              # 设置结束元素方法
80│   ├── setNamespace(prefix: string, namespace: string)                           # 设置命名空间方法
81│   ├── setCommnet(text: string)                                                  # 设置Commnet方法
82│   ├── setCData(text: string)                                                    # 设置CData方法
83│   ├── setText(text: string)                                                     # 设置Text方法
84│   └── setDocType(text: string)                                                  # 设置DocType方法
85├── Class: XmlPullParser                                                          # XmlPullParser类
86│   ├── new (buffer: ArrayBuffer | DataView, encoding?: string)                   # 创建XmlPullParser对象
87│   └── parse(option: ParseOptions)                                               # parse方法
88├── alloc()                                                                       # 创建Buffer实例并初始化
89├── allocUninitializedFromPool()                                                  # 在池中创建Buffer实例
90├── allocUninitialized()                                                          # 创建Buffer实例
91├── byteLength()                                                                  # 按编码返回字节数
92├── compare()                                                                     # Buffer数据比较
93├── concat()                                                                      # 粘接Buffer数组
94├── from()                                                                        # 创建Buffer实例
95├── isBuffer()                                                                    # 判断是否为Buffer
96├── isEncoding()                                                                  # 创建Buffer实例
97├── transcode()                                                                   # 转码
98├── Class: Buffer                                                                 # Buffer类
99│   ├── length                                                                    # length属性
100│   ├── buffer                                                                    # buffer属性
101│   ├── byteOffset                                                                # byteOffset属性
102│   ├── fill()                                                                    # 填充数据
103│   ├── compare()                                                                 # Buffer数据比较
104│   ├── copy()                                                                    # 复制数据
105│   ├── equals()                                                                  # 比较实例是否相等
106│   ├── includes()                                                                # 检查对象是否包含值
107│   ├── indexOf()                                                                 # 查找索引
108│   ├── keys()                                                                    # 返回包含key值的迭代器
109│   ├── values()                                                                  # 返回包含value值的迭代器
110│   ├── entries()                                                                 # 返回包含key和value的迭代器
111│   ├── lastIndexOf()                                                             # 反向查找索引
112│   ├── readBigInt64BE()                                                          # 读取有符号的大端序64位整数
113│   ├── readBigInt64LE()                                                          # 读取有符号的小端序64位整数
114│   ├── readBigUInt64BE()                                                         # 读取无符号的大端序64位整数
115│   ├── readBigUInt64LE()                                                         # 读取无符号的小端序64位整数
116│   ├── readDoubleBE()                                                            # 读取64位大端序双精度值
117│   ├── readDoubleLE()                                                            # 读取64位小端序双精度值
118│   ├── readFloatBE()                                                             # 读取32位大端序浮点数
119│   ├── readFloatLE()                                                             # 读取32位小端序浮点数
120│   ├── readInt8()                                                                # 读取有符号的8位整数
121│   ├── readInt16BE()                                                             # 读取有符号的大端序16位整数
122│   ├── readInt16LE()                                                             # 读取有符号的小端序16位整数
123│   ├── readInt32BE()                                                             # 读取有符号的大端序32位整数
124│   ├── readInt32LE()                                                             # 读取有符号的小端序32位整数
125│   ├── readIntBE()                                                               # 读取有符号的大端序整数
126│   ├── readIntLE()                                                               # 读取有符号的小端序整数
127│   ├── readUInt8()                                                               # 读取8位无符号整数
128│   ├── readUInt16BE()                                                            # 读取无符号的大端序16位整数
129│   ├── readUInt16LE()                                                            # 读取无符号的小端序16位整数
130│   ├── readUInt32BE()                                                            # 读取无符号的大端序32位整数
131│   ├── readUInt32LE()                                                            # 读取无符号的小端序32位整数
132│   ├── readUIntBE()                                                              # 读取无符号的大端序整数
133│   ├── readUIntLE()                                                              # 读取无符号的小端序整数
134│   ├── subarray()                                                                # 子Buffer
135│   ├── swap16()                                                                  # 以16位为基础交换字节顺序
136│   ├── swap32()                                                                  # 以32位为基础交换字节顺序
137│   ├── swap64()                                                                  # 以64位为基础交换字节顺序
138│   ├── toJSON()                                                                  # 转为JSON格式对象
139│   ├── toString()                                                                # 转成字符串
140│   ├── write()                                                                   # 写入字符串
141│   ├── writeBigInt64BE()                                                         # 写入有符号的大端序64位整数
142│   ├── writeBigInt64LE()                                                         # 写入有符号的小端序64位整数
143│   ├── writeBigUInt64BE()                                                        # 写入无符号的大端序64位整数
144│   ├── writeBigUInt64LE()                                                        # 写入无符号的小端序64位整数
145│   ├── writeDoubleBE()                                                           # 写入64位大端序双浮点型数据
146│   ├── writeDoubleLE()                                                           # 写入64位小端序双浮点型数据
147│   ├── writeFloatBE()                                                            # 写入32位大端序浮点型数据
148│   ├── writeFloatLE()                                                            # 写入32位小端序浮点型数据
149│   ├── writeInt8()                                                               # 写入8位有符号整数
150│   ├── writeInt16BE()                                                            # 写入有符号的大端序16位整数
151│   ├── writeInt16LE()                                                            # 写入有符号的小端序16位整数
152│   ├── writeInt32BE()                                                            # 写入有符号的大端序32位整数
153│   ├── writeInt32LE()                                                            # 写入有符号的大端序16位整数
154│   ├── writeIntBE()                                                              # 写入有符号的大端序整数
155│   ├── writeIntLE()                                                              # 写入有符号的小端序整数
156│   ├── writeUInt8()                                                              # 写入8位无符号整数
157│   ├── writeUInt16BE()                                                           # 写入无符号的大端序16位整数
158│   ├── writeUInt16LE()                                                           # 写入无符号的小端序16位整数
159│   ├── writeUInt32BE()                                                           # 写入无符号的大端序32位整数
160│   ├── writeUInt32LE()                                                           # 写入无符号的小端序32位整数
161│   ├── writeUIntBE()                                                             # 写入无符号的大端序整数
162│   └── writeUIntLE()                                                             # 写入无符号的小端序整数
163└── Class: Blob                                                                   # Blob类
164    ├── constructor()                                                             # 构造函数
165    ├── size                                                                      # size属性
166    ├── type                                                                      # type属性
167    ├── arrayBuffer()                                                             # 获取ArrayBuffer对象
168    ├── slice()                                                                   # 返回切割后的对象
169    └── text()                                                                    # 返回文本
170```
171
172### 1.3. 说明
173
174#### 1.3.1. 接口说明
175
176
177| 接口名 | 说明 |
178| -------- | -------- |
179| URL(url: string,base?:string \| URL) | 创建并返回一个URL对象,该URL对象引用使用绝对URL字符串,相对URL字符串和基本URL字符串指定的URL。 |
180| tostring():string | 该字符串化方法返回一个包含完整 URL 的 USVString。它的作用等同于只读的 URL.href。 |
181| toJSON():string | 该方法返回一个USVString,其中包含一个序列化的URL版本。 |
182| new URLSearchParams() | URLSearchParams() 构造器无入参,该方法创建并返回一个新的URLSearchParams 对象。 开头的'?' 字符会被忽略。 |
183| new URLSearchParams(string) | URLSearchParams(string) 构造器的入参为string数据类型,该方法创建并返回一个新的URLSearchParams 对象。 开头的'?' 字符会被忽略。 |
184| new URLSearchParams(obj) | URLSearchParams(obj) 构造器的入参为obj数据类型,该方法创建并返回一个新的URLSearchParams 对象。 开头的'?' 字符会被忽略。 |
185| new URLSearchParams(iterable) | URLSearchParams(iterable) 构造器的入参为iterable数据类型,该方法创建并返回一个新的URLSearchParams 对象。 开头的'?' 字符会被忽略。 |
186| has(name: string): boolean | 检索searchParams对象中是否含有name。有则返回true,否则返回false。 |
187| set(name: string, value string): void |  检索searchParams对象中是否含有key为name的键值对。没有的话则添加该键值对,有的话则修改对象中第一个key所对应的value,并删除键为name的其余键值对。 |
188| sort(): void | 根据键的Unicode代码点,对包含在此对象中的所有键/值对进行排序,并返回undefined。 |
189| toString(): string | 根据searchParams对象,返回适用在URL中的查询字符串。 |
190| keys(): iterableIterator\<string> | 返回一个iterator,遍历器允许遍历对象中包含的所有key值。 |
191| values(): iterableIterator\<string> | 返回一个iterator,遍历器允许遍历对象中包含的所有value值。 |
192| append(name: string, value: string): void | 在searchParams对象中插入name, value键值对。 |
193| delete(name: string): void | 遍历searchParams对象,查找所有的name,删除对应的键值对。 |
194| get(name: string): string | 检索searchParams对象中第一个name,返回name键对应的值。 |
195| getAll(name: string): string[] | 检索searchParams对象中所有name,返回name键对应的所有值。 |
196| entries(): iterableIterator<[string, string]> | 返回一个iterator,允许遍历searchParams对象中包含的所有键/值对。 |
197| forEach(): void | 通过回调函数来遍历URLSearchParams实例对象上的键值对。 |
198| urlSearchParams\[Symbol.iterator]() | 返回查询字符串中每个名称-值对的ES6迭代器。迭代器的每个项都是一个JavaScript数组。 |
199| URI​(str: string) | 通过解析给定入参(String str)来构造URI。此构造函数严格按照RFC 2396附录A中的语法规定解析给定字符串。 |
200| scheme​ | 返回此 URI 的scheme部分,如果scheme未定义,则返回 null |
201| authority​ | 返回此 URI 的解码authority部分,如果authority未定义,则返回 null。 |
202| ssp​ |  返回此 URI 的解码scheme-specific部分。 |
203| userinfo​ | 返回此 URI 的解码userinfo部分。包含passworld和username。 |
204| host​ | 返回此 URI 的host部分,如果host未定义,则返回 null。 |
205| port​ | 返回此 URI 的port部分,如果port未定义,则返回 -1。URI 的port组件(如果已定义)是一个非负整数。 |
206| query​ | 返回此 URI 的query部分,如果query未定义,则返回 null。 |
207| fragment​ | 返回此 URI 的解码fragment组件,如果fragment未定义,则返回 null。|
208| path​ | 返回此 URI 的解码path组件,如果path未定义,则返回 null。 |
209| equals(ob: Object) | 测试此 URI 是否与另一个对象相等。如果给定的对象不是 URI,则此方法立即返回 false。 |
210| normalize​() | 规范化这个 URI 的路径。如果这个 URI 的path不规范,将规范后构造一个新 URI对象返回。 |
211| checkIsAbsolute​() | 判断这个 URI 是否是绝对的。当且仅当它具有scheme部分时,URI 是绝对的,返回值为true,否则返回值为false。 |
212| ConvertXml() | 用于构造ConvertXml类对象的构造函数。此构造函数无需传入参数。 |
213| convert(xml: string, options: Object)  | 返回按选项要求转化xml字符串的JavaScrip对象。 |
214| XmlSerializer(buffer: ArrayBuffer \| DataView, encoding?: string) | 创建并返回一个XmlSerializer对象,该XmlSerializer对象传参两个第一参数是ArrayBuffer或DataView一段内存,第二个参数为文件格式(默认为UTF-8)。 |
215| setAttributes(name: string, value: string): void | 给xml文件中写入属性Attributes属性。 |
216| addEmptyElement(name: string): void | 写入一个空元素。 |
217| setDeclaration(): void | 设置Declaration使用编码写入xml声明。例如:<?xml version=“1.0”encoding=“utf-8”> |
218| startElement(name: string): void | 写入具有给定名称的elemnet开始标记。|
219| endElement(): void | 写入元素的结束标记。 |
220| setNamespace(prefix: string, namespace: string): void | 写入当前元素标记的命名空间。 |
221| setCommnet(text: string): void | 写入comment属性。 |
222| setCData(text: string): void | 写入CData属性。 |
223| setText(text: string): void | 写入Text属性。 |
224| setDocType(text: string): void | 写入DocType属性。 |
225| XmlPullParser(buffer: ArrayBuffer \| DataView, encoding?: string) | 创建并返回一个XmlPullParser对象,该XmlPullParser对象传参两个第一参数是ArrayBuffer或DataView一段内存,第二个参数为文件格式(默认为UTF-8)。 |
226| parse(option: ParseOptions): void | 该接口用于解析xml,ParseOptions参数为一个接口包含五个可选参{supportDoctype?: boolea ignoreNameSpace?: boolean tagValueCallbackFunction?: (name: string, value: string) => boolean attributeValueCallbackFunction?: (name: string, value: string) => boolean) tokenValueCallbackFunction?: (eventType: EventType, value: ParseInfo) => boolean }。其中tokenValueCallbackFunction回调函数的入参1是事件类型,入参2是包含getColumnNumber、getDepth等get属性的info接口,用户可通过info.getDepth()等方法来获取当前解析过程中的depth等信息。 |
227| alloc(size: number, fill?: string \| Buffer \| number, encoding?: BufferEncoding): Buffer | 创建size个字节长度的Buffer实例,并初始化。 |
228| allocUninitializedFromPool(size: number): Buffer | 创建指定大小的未被初始化Buffer实例。内存从缓冲池分配。 创建的Buffer的内容未知,需要使用fill()函数来初始化Buffer实例。 |
229| allocUninitialized(size: number): Buffer | 创建指定大小的未被初始化Buffer实例。内存不从缓冲池分配。 |
230| byteLength(string: string \| Buffer \| TypedArray \| DataView \| ArrayBuffer \| SharedArrayBuffer, encoding?: BufferEncoding): number | 根据不同的编码方法,返回字符串的字节数。 |
231| compare(buf1: Buffer \| Uint8Array, buf2: Buffer \| Uint8Array): -1 \| 0 \| 1 | 返回比较buf1和buf2的结果, 通常用于对Buffer实例的数组进行排序。 |
232| concat(list: Buffer[] \| Uint8Array[], totalLength?: number): Buffer | 将list中的实例内容复制totalLength字节长度到新的Buffer实例中并返回。 |
233| from(array: number[]): Buffer | 根据指定数组创建新的Buffer实例。 |
234| from(arrayBuffer: ArrayBuffer \| SharedArrayBuffer, byteOffset?: number, length?: number): Buffer | 创建指定长度的与arrayBuffer共享内存的Buffer实例 |
235| from(buffer: Buffer \| Uint8Array): Buffer | 创建并复制buffer数据到新的Buffer实例并返回。 |
236| from(object: Object, offsetOrEncoding: number \| string, length: number): Buffer | 根据指定的object类型数据,创建新的Buffer实例。 |
237| from(string: String, encoding?: BufferEncoding): Buffer | 根据指定编码格式的字符串,创建新的Buffer实例。 |
238| isBuffer(obj: Object): boolean | 判断obj是否为Buffer。 |
239| isEncoding(encoding: string):boolean | 判断encoding是否为支持的编码格式。 |
240| transcode(source: Buffer \| Uint8Array, fromEnc: string, toEnc: string): Buffer | 将给定的Buffer或Uint8Array实例从一种字符编码重新编码为另一种。 |
241| length: number | buffer的字节长度。 |
242| buffer: ArrayBuffer | ArrayBuffer对象。 |
243| byteOffset: number | 当前buffer所在内存池的偏移量。 |
244| fill(value: string \| Buffer \| Uint8Array \| number, offset?: number, end?: number, encoding?: BufferEncoding): Buffer | 用value填充this实例指定位置的数据,默认为循环填充,并返回填充后的Buffer实例。 |
245| compare(target: Buffer \| Uint8Array, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): -1 \| 0 \| 1 | this实例对象与target实例对象进行比较,返回buf在排序中的顺序,-1:前排序,0:与buf相同,1:后排序。 |
246| copy(target: Buffer \| Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number | 将this实例中指定位置的数据复制到target的指定位置上,并返回复制的字节总长度。 |
247| equals(otherBuffer: Uint8Array \| Buffer): boolean | 比较this实例和otherBuffer实例是否相等。 |
248| includes(value: string \| number \| Buffer \| Uint8Array, byteOffset?: number, encoding?: BufferEncoding): boolean | 检查Buffer对象是否包含value值。 |
249| indexOf(value: string \| number \| Buffer \| Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number | 查找this实例中第一次出现value的索引,如果不包含value,则为-1。 |
250| keys(): IterableIterator<number> | 返回一个包含key值的迭代器。 |
251| values(): IterableIterator<number> | 返回一个包含value的迭代器。 |
252| entries(): IterableIterator<[number, number]> | 返回一个包含key和value的迭代器。 |
253| lastIndexOf(value: string | number | Buffer | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number | 返回this实例中最后一次出现value的索引,如果对象不包含,则为-1。 |
254| readBigInt64BE(offset?: number): bigint | 从指定的offset处读取有符号的大端序64位整数。 |
255| readBigInt64LE(offset?: number): bigint | 从指定的offset处读取有符号的小端序64位整数。 |
256| readBigUInt64BE(offset?: number): bigint | 从指定的offset处读取无符号的大端序64位整数。 |
257| readBigUInt64LE(offset?: number): bigint | 从指定的offset处读取无符号的小端序64位整数。 |
258| readDoubleBE(offset?: number): number | 从指定offset处读取64位大端序双精度值。 |
259| readDoubleLE(offset?: number): number | 从指定offset处读取64位小端序双精度值。 |
260| readFloatBE(offset?: number): number | 从指定offset处读取32位大端序浮点数。 |
261| readFloatLE(offset?: number): number | 从指定offset处读取32位小端序浮点数。 |
262| readInt8(offset?: number): number | 从指定的offset处读取有符号的8位整数。 |
263| readInt16BE(offset?: number): number | 从指定的offset处读取有符号的大端序16位整数。 |
264| readInt16LE(offset?: number): number | 从指定的offset处读取有符号的小端序16位整数。 |
265| readInt32BE(offset?: number): number | 从指定的offset处读取有符号的大端序32位整数。 |
266| readInt32LE(offset?: number): number | 从指定的offset处读取有符号的小端序32位整数。 |
267| readIntBE(offset: number, byteLength: number): number | 从指定的offset处的buf读取byteLength个字节,并将结果解释为支持最高48位精度的大端序、二进制补码有符号值。 |
268| readIntLE(offset: number, byteLength: number): number | 从指定的offset处的buf读取byteLength个字节,并将结果解释为支持最高48位精度的小端序、二进制补码有符号值。 |
269| readUInt8(offset?: number): number | 从offset处读取8位无符号整型数。 |
270| readUInt16BE(offset?: number): number | 从指定的`offset`处的buf读取无符号的大端序16位整数。 |
271| readUInt16LE(offset?: number): number | 从指定的`offset`处的buf读取无符号的小端序16位整数。 |
272| readUInt32BE(offset?: number): number | 从指定的`offset`处的buf读取无符号的大端序32位整数。 |
273| readUInt32LE(offset?: number): number | 从指定的`offset`处的buf读取无符号的小端序32位整数。 |
274| readUIntBE(offset: number, byteLength: number): number | 从指定的`offset`处的buf读取`byteLength`个字节,并将结果解释为支持最高48位精度的无符号大端序整数。 |
275| readUIntLE(offset: number, byteLength: number): number | 从指定的`offset`处的buf读取`byteLength`个字节,并将结果解释为支持最高48位精度的无符号小端序整数。 |
276| subarray(start?: number, end?: number): Buffer | 截取指定位置的`this`实例并返回。 |
277| swap16(): Buffer | 将`this`实例解释为无符号的16位整数数组,并就地交换字节顺序。 |
278| swap32(): Buffer | 将`this`实例解释为无符号的32位整数数组,并就地交换字节顺序。 |
279| swap64(): Buffer | 将`this`实例解释为无符号的64位整数数组,并就地交换字节顺序。 |
280| toJSON(): Object | 将buf转为JSON并返回。 |
281| toString(encoding?: string, start?: number, end?: number): string | 将`this`实例中指定位置数据转成指定编码格式字符串并返回。 |
282| write(str: string, offset?: number, length?: number, encoding?: string): number | 从buf的offset偏移写入指定编码的字符串str,写入的字节长度为length。 |
283| writeBigInt64BE(value: bigint, offset?: number): number | 从buf的offset偏移写入有符号的大端序64位BigInt型数据value。 |
284| writeBigInt64LE(value: bigint, offset?: number): number | 从buf的offset偏移写入有符号的小端序64位BigInt型数据value。 |
285| writeBigUInt64BE(value: bigint, offset?: number): number | 从buf的offset偏移写入无符号的大端序64位BigUInt型数据value。 |
286| writeBigUInt64LE(value: bigint, offset?: number): number | 从buf的offset偏移写入无符号的小端序64位BigUInt型数据value。 |
287| writeDoubleBE(value: number, offset?: number): number | 从buf的offset偏移写入大端序的64位双浮点型数据value。 |
288| writeDoubleLE(value: number, offset?: number): number | 从buf的offset偏移写入小端序的64位双浮点型数据value。 |
289| writeFloatBE(value: number, offset?: number): number | 从buf的offset偏移写入大端序的32位浮点型数据value。 |
290| writeFloatLE(value: number, offset?: number): number | 从buf的offset偏移写入小端序的32位浮点型数据value。 |
291| writeInt8(value: number, offset?: number): number | 从buf的offset偏移写入8位有符号整型数据value。 |
292| writeInt16BE(value: number, offset?: number): number | 从buf的offset偏移写入大端序的16位有符号整型数据value。 |
293| writeInt16LE(value: number, offset?: number): number | 从buf的offset偏移写入小端序的16位有符号整型数据value。 |
294| writeInt32BE(value: number, offset?: number): number | 从buf的offset偏移写入大端序的32位有符号整型数据value。 |
295| writeInt32LE(value: number, offset?: number): number | 从buf的offset偏移写入小端序的32位有符号整型数据value。 |
296| writeIntBE(value: number, offset: number, byteLength: number): number | 从buf的offset偏移写入大端序的有符号value数据,value字节长度为byteLength。 |
297| writeIntLE(value: number, offset: number, byteLength: number): number | 从buf的offset偏移写入小端序的有符号value数据,value字节长度为byteLength。 |
298| writeUInt8(value: number, offset?: number): number | 从buf的offset偏移写入8位无符号整型数据value。 |
299| writeUInt16BE(value: number, offset?: number): number | 从buf的offset偏移写入大端序的16位无符号整型数据value。 |
300| writeUInt16LE(value: number, offset?: number): number | 从buf的offset偏移写入小端序的16位无符号整型数据value。 |
301| writeUInt32BE(value: number, offset?: number): number | 从buf的offset偏移写入大端序的32位无符号整型数据value。 |
302| writeUInt32LE(value: number, offset?: number): number | 从buf的offset偏移写入小端序的32位无符号整型数据value。 |
303| writeUIntBE(value: number, offset: number, byteLength: number): number | 从buf的offset偏移写入大端序的无符号value数据,value字节长度为byteLength。 |
304| writeUIntLE(value: number, offset: number, byteLength: number): number | 从buf的offset偏移写入小端序的无符号value数据,value字节长度为byteLength。 |
305| new Blob(sources: string[] \| ArrayBuffer[] \| TypedArray[] \| DataView[] \| Blob[] , options?: Object) | Blob的构造函数,返回一个Blob的实例对象。 |
306| size | Blob实例的总字节大小。 |
307| type | Blob实例的内容类型。 |
308| arrayBuffer(): Promise&lt;ArrayBuffer&gt; | 将Blob中的数据放入到ArrayBuffer中,并返回一个Promise。 |
309| slice(start?: number, end?: number, type?: string): Blob | 创建并返回一个复制原blob对象中start到end位置数据的新blob实例对象。 |
310| text(): Promise&lt;string&gt; | 返回一个Promise,该Promise中的值为UTF8编码类型的文本。 |
311#### 1.3.2. 使用说明 |
312
313各接口使用方法如下:
314
315
3161、new URL(url: string,base?:string|URL)
317```
318let b = new URL('https://developer.mozilla.org'); // => 'https://developer.mozilla.org/'
319
320let a = new URL( 'sca/./path/path/../scasa/text', 'http://www.example.com');
321// => 'http://www.example.com/sca/path/scasa/text'
322```
3232、tostring():string
324```
325const url = new URL('http://10.0xFF.O400.235:8080/directory/file?query#fragment');
326url.toString() // => 'http://10.0xff.o400.235:8080/directory/file?query#fragment'
327
328const url = new URL("http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html");
329url.toString() // => 'http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/index.html'
330
331const url = new URL("http://username:password@host:8080/directory/file?query#fragment");
332url.toString() // => 'http://username:password@host:8080/directory/file?query#fragment'
333```
3343、toJSON():string
335```
336const url = new URL("https://developer.mozilla.org/en-US/docs/Web/API/URL/toString");
337url.toJSON(); // =>  'https://developer.mozilla.org/en-US/docs/Web/API/URL/toString'
338```
3394、new URLSearchParams()
340```
341let params = new URLSearchParams('foo=1&bar=2');
342```
3435、new URLSearchParams(string)
344```
345params = new URLSearchParams('user=abc&query=xyz');
346console.log(params.get('user'));
347// Prints 'abc'
348```
3496、new URLSearchParams(obj)
350```
351const params = new URLSearchParams({
352    user: 'abc',
353    query: ['first', 'second']
354});
355console.log(params.getAll('query'));
356// Prints [ 'first,second' ]
357```
3587、new URLSearchParams(iterable)
359```
360let params;
361
362// Using an array
363params = new URLSearchParams([
364    ['user', 'abc'],
365    ['query', 'first'],
366    ['query', 'second'],
367]);
368console.log(params.toString());
369// Prints 'user = abc & query = first&query = second'
370```
3718、has(name: string): boolean
372```
373console.log(params.has('bar')); // =>true
374```
3759、set(name: string, value string): void
376```
377params.set('baz', 3);
378```
37910、sort(): void
380```
381params .sort();
382```
38311、toString(): string
384```
385console.log(params .toString()); // =>bar=2&baz=3&foo=1'
386```
38712、keys(): iterableIterator\<string>
388```
389for(var key of params.keys()) {
390  console.log(key);
391} // =>bar  baz  foo
392```
39313、values(): iterableIterator\<string>
394```
395for(var value of params.values()) {
396  console.log(value);
397} // =>2  3  1
398```
39914、append(name: string, value: string): void
400```
401params.append('foo', 3); // =>bar=2&baz=3&foo=1&foo=3
402```
40315、delete(name: string): void
404```
405params.delete('baz'); // => bar=2&foo=1&foo=3
406```
40716、get(name: string): string
408```
409params.get('foo'); // => 1
410```
41117、getAll(name: string): string[]
412```
413params.getAll('foo'); // =>[ '1', '3' ]
414```
41518、entries(): iterableIterator<[string, string]>
416```
417for(var pair of searchParams.entries()) {
418   console.log(pair[0]+ ', '+ pair[1]);
419} // => bar, 2   foo, 1  foo, 3
420```
42119、forEach(): void
422```
423url.searchParams.forEach((value, name, searchParams) => {
424  console.log(name, value, url.searchParams === searchParams);
425});
426// => foo 1 true
427// => bar 2 true
428```
42920、urlSearchParams[Symbol.iterator] ()
430```
431const params = new URLSearchParams('foo=bar&xyz=baz');
432for (const [name, value] of params) {
433    console.log(name, value);
434}
435// Prints:
436// foo bar
437// xyz bar
438```
439
440
44121、URI​(str: string)
442```
443let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
444```
44522、scheme
446```
447let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
448gaogao.scheme        // => "http";
449```
45023、authority
451```
452let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
453gaogao.authority     // => "gg:gaogao@www.baidu.com:99";
454```
45524、ssp
456```
457let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
458gaogao.ssp "         // => gg:gaogao@www.baidu.com:99/path/path?query";
459```
46025、userinfo
461```
462let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
463gaogao.userinfo      // => "gg:gaogao";
464```
46526、host
466```
467let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
468gaogao.host          // => "www.baidu.com";
469```
47027、port
471```
472let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
473gaogao.port          // => "99";
474```
47528、query
476```
477let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
478gaogao.query         // => "query";
479```
48029、fragment
481```
482let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
483gaogao.fragment      // => "fagment";
484```
48530、path
486```
487let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
488gaogao.path          // => "/path/path";
489```
49031、equals(ob: Object)
491```
492let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment');
493let gaogao1 = gaogao;
494let res = gaogao.equals(gaogao1);
495console.log(res);      // => true;
496```
49732、normalize​()
498```
499let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/66./../././mm/.././path1?query#fagment');
500let res = gaogao.normalize();
501console.log(res.path);        // => "/path/path1"
502console.log(res.toString());  // => "http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/path1?query#fagment"
503```
50433、checkIsAbsolute​()
505```
506let gaogao = new Uri.URI('f/tp://username:password@www.baidu.com:88/path?query#fagment');
507let res = gaogao.checkIsAbsolute();
508console.log(res);              //=> false;
509```
51034、toString()
511```
512let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path/.././../aa/bb/cc?query#fagment');
513let res = gaogao.toString();
514console.log(res.toString());     // => 'http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path/.././../aa/bb/cc?query#fagment';
515```
516
517
51835、ConvertXml()
519```
520var convertml = new convertXml.ConvertXml();
521```
52236、convert(xml: string, options: Object)
523```
524var result = convertml.convert(xml, {compact: false, spaces: 4});
525```
52637、new XmlSerializer(buffer: ArrayBuffer | DataView, encoding?: string)
527```
528
529var arrayBuffer = new ArrayBuffer(1024);
530var bufView = new DataView(arrayBuffer);
531var thatSer = new xml.XmlSerializer(bufView);
532```
53338、setDeclaration():void
534```
535var thatSer = new xml.XmlSerializer(bufView);
536thatSer.setDeclaration() // => <?xml version="1.0" encoding="utf-8"?>;
537```
53839、setCommnet(text: string):void
539```
540var thatSer = new xml.XmlSerializer(bufView);
541thatSer.setCommnet("Hello, World!"); // => <!--Hello, World!-->;
542```
54340、setCData(text: string) :void
544```
545var thatSer = new xml.XmlSerializer(bufView);
546thatSer.setDocType('root SYSTEM "http://www.test.org/test.dtd"'); // => <![CDATA[root SYSTEM \“http://www.test.org/test.dtd\”]]>
547```
54841、setDocType(text: string):void
549```
550var thatSer = new xml.XmlSerializer(bufView);
551thatSer.setDocType("foo"); // => <!DOCTYPE foo>
552```
55342、setNamespace(prefix: string, namespace: string): void
55443、startElement(name: string): void
55544、setAttributes(name: string, value: string): void
55645、endElement(): void
55746、setText(text: string): void
558```
559var thatSer = new xml.XmlSerializer(bufView);
560thatSer.setNamespace("h", "http://www.w3.org/TR/html4/");
561thatSer.startElement("table");
562thatSer.setAttributes("importance", "high");
563thatSer.setText("Happy");
564endElement(); // => <h:table importance="high" xmlns:h="http://www.w3.org/TR/html4/">Happy</h:table>
565```
56647、addEmptyElement(name: string): void
567```
568var thatSer = new xml.XmlSerializer(bufView);
569thatSer.addEmptyElement("b"); // => <b/>
570```
57148、new (buffer: ArrayBuffer | DataView, encoding?: string)
572```
573var strXml =
574            '<?xml version="1.0" encoding="utf-8"?>' +
575            '<note importance="high" logged="true">' +
576            '    <title>Happy</title>' +
577            '</note>';
578var arrayBuffer = new ArrayBuffer(strXml.length*2);
579var bufView = new Uint8Array(arrayBuffer);
580var strLen = strXml.length;
581for (var i = 0; i < strLen; ++i) {
582    bufView[i] = strXml.charCodeAt(i);//设置arraybuffer 方式
583}
584var that = new xml.XmlPullParser(arrayBuffer);
585
586```
58749、parse(option: ParseOptions): void
588```
589var strXml =
590            '<?xml version="1.0" encoding="utf-8"?>' +
591            '<note importance="high" logged="true">' +
592            '    <title>Happy</title>' +
593            '</note>';
594var arrayBuffer = new ArrayBuffer(strXml.length*2);
595var bufView = new Uint8Array(arrayBuffer);
596var strLen = strXml.length;
597for (var i = 0; i < strLen; ++i) {
598    bufView[i] = strXml.charCodeAt(i);
599}
600var that = new xml.XmlPullParser(arrayBuffer);
601var arrTag = {};
602arrTag[0] = '132';
603var i = 1;
604function func(key, value){
605    arrTag[i] = 'key:'+key+' value:'+ value.getDepth();
606    i++;
607    return true;
608}
609var options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func}
610that.parse(options);
611```
61250、alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): Buffer
613```
614import buffer from '@ohos.buffer';
615
616let buf1 = buffer.alloc(5);
617let buf2 = buffer.alloc(5, 'a');
618let buf3 = buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');
619```
62051、allocUninitializedFromPool(size: number): Buffer
621```
622import buffer from '@ohos.buffer';
623
624let buf = buffer.allocUninitializedFromPool(10);
625buf.fill(0);
626```
62752、allocUninitialized(size: number): Buffer
628```
629import buffer from '@ohos.buffer';
630
631let buf = buffer.allocUninitialized(10);
632buf.fill(0);
633```
63453、byteLength(string: string | Buffer | TypedArray | DataView | ArrayBuffer | SharedArrayBuffer, encoding?: BufferEncoding): number
635```
636import buffer from '@ohos.buffer';
637
638let str = '\u00bd + \u00bc = \u00be';
639console.log(`${str}: ${str.length} characters, ${buffer.byteLength(str, 'utf-8')} bytes`);
640// 打印: ½ + ¼ = ¾: 9 characters, 12 bytes
641```
64254、compare(buf1: Buffer | Uint8Array, buf2: Buffer | Uint8Array): -1 | 0 | 1
643```
644import buffer from '@ohos.buffer';
645
646let buf1 = buffer.from('1234');
647let buf2 = buffer.from('0123');
648let res = buf1.compare(buf2);
649
650console.log(Number(res).toString()); // 打印 1
651```
65255、concat(list: Buffer[] | Uint8Array[], totalLength?: number): Buffer
653```
654import buffer from '@ohos.buffer';
655
656let buf1 = buffer.from("1234");
657let buf2 = buffer.from("abcd");
658let buf = buffer.concat([buf1, buf2]);
659console.log(buf.toString('hex')); // 3132333461626364
660```
66156、from(array: number[]): Buffer
662```
663import buffer from '@ohos.buffer';
664
665let buf = buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
666console.log(buf.toString('hex')); // 627566666572
667```
66857、from(arrayBuffer: ArrayBuffer | SharedArrayBuffer, byteOffset?: number, length?: number): Buffer
669```
670let ab = new ArrayBuffer(10);
671let buf = buffer.from(ab, 0, 2);
672```
67358、from(buffer: Buffer | Uint8Array): Buffer
674```
675import buffer from '@ohos.buffer';
676
677let buf1 = buffer.from('buffer');
678let buf2 = buffer.from(buf1);
679```
68059、from(object: Object, offsetOrEncoding: number | string, length: number): Buffer
681```
682import buffer from '@ohos.buffer';
683
684let buf = buffer.from(new String('this is a test'));
685```
68660、from(string: String, encoding?: BufferEncoding): Buffer
687```
688import buffer from '@ohos.buffer';
689
690let buf1 = buffer.from('this is a test');
691let buf2 = buffer.from('7468697320697320612074c3a97374', 'hex');
692
693console.log(buf1.toString());	// 打印: this is a test
694console.log(buf2.toString());
695```
69661、isBuffer(obj: Object): boolean
697```
698import buffer from '@ohos.buffer';
699
700buffer.isBuffer(buffer.alloc(10)); // true
701buffer.isBuffer(buffer.from('foo')); // true
702buffer.isBuffer('a string'); // false
703buffer.isBuffer([]); // false
704buffer.isBuffer(new Uint8Array(1024)); // false
705```
70662、isEncoding(encoding: string):boolean
707```
708import buffer from '@ohos.buffer';
709
710console.log(buffer.isEncoding('utf-8').toString());	// 打印: true
711console.log(buffer.isEncoding('hex').toString());	// 打印: true
712console.log(buffer.isEncoding('utf/8').toString());	// 打印: false
713console.log(buffer.isEncoding('').toString());	// 打印: false
714```
71563、transcode(source: Buffer | Uint8Array, fromEnc: string, toEnc: string): Buffer
716```
717import buffer from '@ohos.buffer';
718
719let buf = buffer.alloc(50);
720let newBuf = buffer.transcode(buffer.from('€'), 'utf-8', 'ascii');
721console.log(newBuf.toString('ascii'));
722```
72364、length: number
724```
725import buffer from '@ohos.buffer';
726
727let buf = buffer.from("1236");
728console.log(JSON.stringify(buf.length));
729```
73065、buffer: ArrayBuffer
731```
732import buffer from '@ohos.buffer';
733
734let buf = buffer.from("1236");
735let arrayBuffer = buf.buffer;
736console.log(JSON.stringify(new Uint8Array(arrayBuffer)));
737```
73866、byteOffset: number
739```
740import buffer from '@ohos.buffer';
741
742let buf = buffer.from("1236");
743console.log(JSON.stringify(buf.byteOffset));
744```
74567、fill(value: string | Buffer | Uint8Array | number, offset?: number, end?: number, encoding?: BufferEncoding): Buffer
746```
747import buffer from '@ohos.buffer';
748
749let b = buffer.allocUninitializedFromPool(50).fill('h');
750console.log(b.toString());
751```
75268、compare(target: Buffer | Uint8Array, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): -1 | 0 | 1
753```
754import buffer from '@ohos.buffer';
755
756let buf1 = buffer.from([1, 2, 3, 4, 5, 6, 7, 8, 9]);
757let buf2 = buffer.from([5, 6, 7, 8, 9, 1, 2, 3, 4]);
758
759console.log(buf1.compare(buf2, 5, 9, 0, 4).toString());	// 打印: 0
760console.log(buf1.compare(buf2, 0, 6, 4).toString());	// 打印: -1
761console.log(buf1.compare(buf2, 5, 6, 5).toString());	// 打印: 1
762```
76369、copy(target: Buffer | Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number
764```
765import buffer from '@ohos.buffer';
766
767let buf1 = buffer.allocUninitializedFromPool(26);
768let buf2 = buffer.allocUninitializedFromPool(26).fill('!');
769
770for (let i = 0; i < 26; i++) {
771  buf1[i] = i + 97;
772}
773
774buf1.copy(buf2, 8, 16, 20);
775console.log(buf2.toString('ascii', 0, 25));
776// 打印: !!!!!!!!qrst!!!!!!!!!!!!!
777```
77870、equals(otherBuffer: Uint8Array | Buffer): boolean
779```
780import buffer from '@ohos.buffer';
781
782let buf1 = buffer.from('ABC');
783let buf2 = buffer.from('414243', 'hex');
784let buf3 = buffer.from('ABCD');
785
786console.log(buf1.equals(buf2).toString());	// 打印: true
787console.log(buf1.equals(buf3).toString());	// 打印: false
788```
78971、includes(value: string | number | Buffer | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): boolean
790```
791import buffer from '@ohos.buffer';
792
793let buf = buffer.from('this is a buffer');
794console.log(buf.includes('this').toString());	// 打印: true
795console.log(buf.includes('be').toString());	// 打印: false
796```
79772、indexOf(value: string | number | Buffer | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number
798```
799import buffer from '@ohos.buffer';
800
801let buf = buffer.from('this is a buffer');
802console.log(buf.indexOf('this').toString());	// 打印: 0
803console.log(buf.indexOf('is').toString());		// 打印: 2
804```
80573、keys(): IterableIterator\<number>
806```
807import buffer from '@ohos.buffer';
808
809let buf = buffer.from('buffer');
810for (const key of buf.keys()) {
811  console.log(key.toString());
812}
813```
81474、values(): IterableIterator\<number>
815```
816import buffer from '@ohos.buffer';
817
818let buf1 = buffer.from('buffer');
819for (let value of buf1.values()) {
820  console.log(value.toString());
821}
822```
82375、entries(): IterableIterator<[number, number]>
824```
825import buffer from '@ohos.buffer';
826
827let buf = buffer.from('buffer');
828for (let pair of buf.entries()) {
829  console.log(pair.toString());
830}
831```
83276、lastIndexOf(value: string | number | Buffer | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number
833```
834import buffer from '@ohos.buffer';
835
836let buf = buffer.from('this buffer is a buffer');
837console.log(buf.lastIndexOf('this').toString());	// 打印: 0
838console.log(buf.lastIndexOf('buffer').toString());	// 打印: 17
839```
84077、readBigInt64BE(offset?: number): bigint
841```
842import buffer from '@ohos.buffer';
843
844let buf = buffer.from([0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70,
845        0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78]);
846console.log(buf.readBigInt64BE(0).toString());
847
848let buf1 = buffer.allocUninitializedFromPool(8);
849buf1.writeBigInt64BE(0x0102030405060708n, 0);
850```
85178、readBigInt64LE(offset?: number): bigint
852```
853import buffer from '@ohos.buffer';
854
855let buf = buffer.from([0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70,
856        0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78]);
857console.log(buf.readBigInt64LE(0).toString());
858
859let buf1 = buffer.allocUninitializedFromPool(8);
860buf1.writeBigInt64BE(0x0102030405060708n, 0);
861```
86279、readBigUInt64BE(offset?: number): bigint
863```
864import buffer from '@ohos.buffer';
865
866let buf = buffer.from([0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70,
867        0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78]);
868console.log(buf.readBigUInt64BE(0).toString());
869
870let buf1 = buffer.allocUninitializedFromPool(8);
871buf1.writeBigUInt64BE(0xdecafafecacefaden, 0);
872```
87380、readBigUInt64LE(offset?: number): bigint
874```
875import buffer from '@ohos.buffer';
876
877let buf = buffer.from([0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70,
878        0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78]);
879console.log(buf.readBigUInt64LE(0).toString());
880
881let buf1 = buffer.allocUninitializedFromPool(8);
882buf1.writeBigUInt64BE(0xdecafafecacefaden, 0);
883```
88481、readDoubleBE(offset?: number): number
885```
886import buffer from '@ohos.buffer';
887
888let buf = buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
889console.log(buf.readDoubleBE(0).toString());
890
891let buf1 = buffer.allocUninitializedFromPool(8);
892buf1.writeDoubleBE(123.456, 0);
893```
89482、readDoubleLE(offset?: number): number
895```
896import buffer from '@ohos.buffer';
897
898let buf = buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
899console.log(buf.readDoubleLE(0).toString());
900
901let buf1 = buffer.allocUninitializedFromPool(8);
902buf1.writeDoubleLE(123.456, 0);
903```
90483、readFloatBE(offset?: number): number
905```
906import buffer from '@ohos.buffer';
907
908let buf = buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
909console.log(buf.readFloatBE(0).toString());
910
911let buf1 = buffer.allocUninitializedFromPool(4);
912buf1.writeFloatBE(0xcabcbcbc, 0);
913```
91484、readFloatLE(offset?: number): number
915```
916import buffer from '@ohos.buffer';
917
918let buf = buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
919console.log(buf.readFloatLE(0).toString());
920
921let buf1 = buffer.allocUninitializedFromPool(4);
922buf1.writeFloatLE(0xcabcbcbc, 0);
923```
92485、readInt8(offset?: number): number
925```
926import buffer from '@ohos.buffer';
927
928let buf = buffer.from([-1, 5]);
929console.log(buf.readInt8(0).toString());	// 打印: -1
930console.log(buf.readInt8(1).toString());	// 打印: 5
931
932let buf1 = buffer.allocUninitializedFromPool(2);
933buf1.writeInt8(0x12);
934```
93586、readInt16BE(offset?: number): number
936```
937import buffer from '@ohos.buffer';
938
939let buf = buffer.from([0, 5]);
940console.log(buf.readInt16BE(0).toString());	// 打印: 5
941
942let buf1 = buffer.alloc(2);
943buf1.writeInt16BE(0x1234, 0);
944```
94587、readInt16LE(offset?: number): number
946```
947import buffer from '@ohos.buffer';
948
949let buf = buffer.from([0, 5]);
950console.log(buf.readInt16LE(0).toString());	// 打印: 1280
951
952let buf1 = buffer.alloc(2);
953buf1.writeInt16BE(0x1234, 0);
954```
95588、readInt32BE(offset?: number): number
956```
957import buffer from '@ohos.buffer';
958
959let buf = buffer.from([0, 0, 0, 5]);
960console.log(buf.readInt32BE(0).toString());	// 打印: 5
961
962let buf1 = buffer.alloc(4);
963buf1.writeInt32BE(0x12345678, 0);
964```
96589、readInt32LE(offset?: number): number
966```
967import buffer from '@ohos.buffer';
968
969let buf = buffer.from([0, 0, 0, 5]);
970console.log(buf.readInt32LE(0).toString());	// 打印: 83886080
971
972let buf1 = buffer.alloc(4);
973buf1.writeInt32BE(0x12345678, 0);
974```
97590、readIntBE(offset: number, byteLength: number): number
976```
977import buffer from '@ohos.buffer';
978
979let buf = buffer.from("ab");
980let num = buf.readIntBE(0, 1);
981console.log(num.toString()); // 97
982
983let buf1 = buffer.allocUninitializedFromPool(6);
984buf1.writeIntBE(0x123456789011, 0, 6);
985```
98691、readIntLE(offset: number, byteLength: number): number
987```
988import buffer from '@ohos.buffer';
989
990let buf = buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
991console.log(buf.readIntLE(0, 6).toString(16));
992
993let buf1 = buffer.allocUninitializedFromPool(6);
994buf1.writeIntLE(0x123456789011, 0, 6);
995```
99692、readUInt8(offset?: number): number
997```
998import buffer from '@ohos.buffer';
999
1000let buf = buffer.from([1, -2]);
1001console.log(buf.readUInt8(0).toString());
1002console.log(buf.readUInt8(1).toString());
1003
1004let buf1 = buffer.allocUninitializedFromPool(4);
1005buf1.writeUInt8(0x42);
1006```
100793、readUInt16BE(offset?: number): number
1008```
1009import buffer from '@ohos.buffer';
1010let buf = buffer.from([0x12, 0x34, 0x56]);
1011console.log(buf.readUInt16BE(0).toString(16));
1012console.log(buf.readUInt16BE(1).toString(16));
1013```
101494、readUInt16LE(offset?: number): number
1015```
1016import buffer from '@ohos.buffer';
1017let buf = buffer.from([0x12, 0x34, 0x56]);
1018console.log(buf.readUInt16LE(0).toString(16));
1019console.log(buf.readUInt16LE(1).toString(16));
1020```
102195、readUInt32BE(offset?: number): number
1022```
1023import buffer from '@ohos.buffer';
1024let buf = buffer.from([0x12, 0x34, 0x56, 0x78]);
1025console.log(buf.readUInt32BE(0).toString(16));
1026```
102796、readUInt32LE(offset?: number): number
1028```
1029import buffer from '@ohos.buffer';
1030let buf = buffer.from([0x12, 0x34, 0x56, 0x78]);
1031console.log(buf.readUInt32LE(0).toString(16));
1032```
103397、readUIntBE(offset: number, byteLength: number): number
1034```
1035import buffer from '@ohos.buffer';
1036let buf = buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
1037console.log(buf.readUIntBE(0, 6).toString(16));
1038```
103998、readUIntLE(offset: number, byteLength: number): number
1040```
1041import buffer from '@ohos.buffer';
1042let buf = buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
1043console.log(buf.readUIntLE(0, 6).toString(16));
1044```
104599、subarray(start?: number, end?: number): Buffer
1046```
1047import buffer from '@ohos.buffer';
1048let buf1 = buffer.allocUninitializedFromPool(26);
1049for (let i = 0; i < 26; i++) {
1050  buf1[i] = i + 97;
1051}
1052const buf2 = buf1.subarray(0, 3);
1053console.log(buf2.toString('ascii', 0, buf2.length));
1054```
1055100、swap16(): Buffer
1056```
1057import buffer from '@ohos.buffer';
1058let buf1 = buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
1059console.log(buf1.toString('hex'));
1060buf1.swap16();
1061console.log(buf1.toString('hex'));
1062```
1063101、swap32(): Buffer
1064```
1065import buffer from '@ohos.buffer';
1066let buf1 = buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
1067console.log(buf1.toString('hex'));
1068buf1.swap32();
1069console.log(buf1.toString('hex'));
1070```
1071102、swap64(): Buffer
1072```
1073import buffer from '@ohos.buffer';
1074let buf1 = buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
1075console.log(buf1.toString('hex'));
1076buf1.swap64();
1077console.log(buf1.toString('hex'));
1078```
1079103、toJSON(): Object
1080```
1081import buffer from '@ohos.buffer';
1082let buf1 = buffer.from([0x1, 0x2, 0x3, 0x4, 0x5]);
1083let obj = buf1.toJSON();
1084console.log(JSON.stringify(obj))
1085```
1086104、toString(encoding?: string, start?: number, end?: number): string
1087```
1088import buffer from '@ohos.buffer';
1089let buf1 = buffer.allocUninitializedFromPool(26);
1090for (let i = 0; i < 26; i++) {
1091  buf1[i] = i + 97;
1092}
1093console.log(buf1.toString('utf-8'));
1094```
1095105、write(str: string, offset?: number, length?: number, encoding?: string): number
1096```
1097import buffer from '@ohos.buffer';
1098let buf = buffer.alloc(256);
1099let len = buf.write('\u00bd + \u00bc = \u00be', 0);
1100console.log(`${len} bytes: ${buf.toString('utf-8', 0, len)}`);
1101let buffer1 = buffer.alloc(10);
1102let length = buffer1.write('abcd', 8);
1103```
1104106、writeBigInt64BE(value: bigint, offset?: number): number
1105```
1106import buffer from '@ohos.buffer';
1107let buf = buffer.allocUninitializedFromPool(8);
1108buf.writeBigInt64BE(0x0102030405060708n, 0);
1109```
1110107、writeBigInt64LE(value: bigint, offset?: number): number
1111```
1112import buffer from '@ohos.buffer';
1113let buf = buffer.allocUninitializedFromPool(8);
1114buf.writeBigInt64LE(0x0102030405060708n, 0);
1115```
1116108、writeBigUInt64BE(value: bigint, offset?: number): number
1117```
1118import buffer from '@ohos.buffer';
1119let buf = buffer.allocUninitializedFromPool(8);
1120buf.writeBigUInt64BE(0xdecafafecacefaden, 0);
1121```
1122109、writeBigUInt64LE(value: bigint, offset?: number): number
1123```
1124import buffer from '@ohos.buffer';
1125let buf = buffer.allocUninitializedFromPool(8);
1126buf.writeBigUInt64LE(0xdecafafecacefaden, 0);
1127```
1128110、writeDoubleBE(value: number, offset?: number): number
1129```
1130import buffer from '@ohos.buffer';
1131let buf = buffer.allocUninitializedFromPool(8);
1132buf.writeDoubleBE(123.456, 0);
1133```
1134111、writeDoubleLE(value: number, offset?: number): number
1135```
1136import buffer from '@ohos.buffer';
1137let buf = buffer.allocUninitializedFromPool(8);
1138buf.writeDoubleLE(123.456, 0);
1139```
1140112、writeFloatBE(value: number, offset?: number): number
1141```
1142import buffer from '@ohos.buffer';
1143let buf = buffer.allocUninitializedFromPool(8);
1144buf.writeFloatBE(0xcafebabe, 0);
1145```
1146113、writeFloatLE(value: number, offset?: number): number
1147```
1148import buffer from '@ohos.buffer';
1149let buf = buffer.allocUninitializedFromPool(8);
1150buf.writeFloatLE(0xcafebabe, 0);
1151```
1152114、writeInt8(value: number, offset?: number): number
1153```
1154import buffer from '@ohos.buffer';
1155let buf = buffer.allocUninitializedFromPool(2);
1156buf.writeInt8(2, 0);
1157buf.writeInt8(-2, 1);
1158```
1159115、writeInt16BE(value: number, offset?: number): number
1160```
1161import buffer from '@ohos.buffer';
1162let buf = buffer.allocUninitializedFromPool(2);
1163buf.writeInt16BE(0x0102, 0);
1164```
1165116、writeInt16LE(value: number, offset?: number): number
1166```
1167import buffer from '@ohos.buffer';
1168let buf = buffer.allocUninitializedFromPool(2);
1169buf.writeInt16LE(0x0304, 0);
1170```
1171117、writeInt32BE(value: number, offset?: number): number
1172```
1173import buffer from '@ohos.buffer';
1174let buf = buffer.allocUninitializedFromPool(4);
1175buf.writeInt32BE(0x01020304, 0);
1176```
1177118、writeInt32LE(value: number, offset?: number): number
1178```
1179import buffer from '@ohos.buffer';
1180let buf = buffer.allocUninitializedFromPool(4);
1181buf.writeInt32LE(0x05060708, 0);
1182```
1183119、writeIntBE(value: number, offset: number, byteLength: number): number
1184```
1185import buffer from '@ohos.buffer';
1186let buf = buffer.allocUninitializedFromPool(6);
1187buf.writeIntBE(0x1234567890ab, 0, 6);
1188```
1189120、writeIntLE(value: number, offset: number, byteLength: number): number
1190```
1191import buffer from '@ohos.buffer';
1192let buf = buffer.allocUninitializedFromPool(6);
1193buf.writeIntLE(0x1234567890ab, 0, 6);
1194```
1195121、writeUInt8(value: number, offset?: number): number
1196```
1197import buffer from '@ohos.buffer';
1198let buf = buffer.allocUninitializedFromPool(4);
1199buf.writeUInt8(0x3, 0);
1200buf.writeUInt8(0x4, 1);
1201buf.writeUInt8(0x23, 2);
1202buf.writeUInt8(0x42, 3);
1203```
1204122、writeUInt16BE(value: number, offset?: number): number
1205```
1206import buffer from '@ohos.buffer';
1207let buf = buffer.allocUninitializedFromPool(4);
1208buf.writeUInt16BE(0xdead, 0);
1209buf.writeUInt16BE(0xbeef, 2);
1210```
1211123、writeUInt16LE(value: number, offset?: number): number
1212```
1213import buffer from '@ohos.buffer';
1214let buf = buffer.allocUninitializedFromPool(4);
1215buf.writeUInt16LE(0xdead, 0);
1216buf.writeUInt16LE(0xbeef, 2);
1217```
1218124、writeUInt32BE(value: number, offset?: number): number
1219```
1220import buffer from '@ohos.buffer';
1221let buf = buffer.allocUninitializedFromPool(4);
1222buf.writeUInt32BE(0xfeedface, 0);
1223```
1224125、writeUInt32LE(value: number, offset?: number): number
1225```
1226import buffer from '@ohos.buffer';
1227let buf = buffer.allocUninitializedFromPool(4);
1228buf.writeUInt32LE(0xfeedface, 0);
1229```
1230126、writeUIntBE(value: number, offset: number, byteLength: number): number
1231```
1232import buffer from '@ohos.buffer';
1233let buf = buffer.allocUninitializedFromPool(6);
1234buf.writeUIntBE(0x1234567890ab, 0, 6);
1235```
1236127、writeUIntLE(value: number, offset: number, byteLength: number): number
1237```
1238import buffer from '@ohos.buffer';
1239let buf = buffer.allocUninitializedFromPool(6);
1240buf.writeUIntLE(0x1234567890ab, 0, 6);
1241```
1242128、new Blob(sources: string[] | ArrayBuffer[] | TypedArray[] | DataView[] | Blob[] , options?: Object)
1243```
1244import buffer from '@ohos.buffer';
1245let blob = new buffer.Blob(['a', 'b', 'c']);
1246let blob1 = new buffer.Blob(['a', 'b', 'c'], {endings:'native', type: 'MIME'});
1247```
1248129、size
1249```
1250import buffer from '@ohos.buffer';
1251let blob = new buffer.Blob(['a', 'b', 'c']);
1252blob.size
1253```
1254130、type
1255```
1256import buffer from '@ohos.buffer';
1257let blob = new buffer.Blob(['a', 'b', 'c'], {endings:'native', type: 'MIME'});
1258blob.type
1259```
1260131、arrayBuffer(): Promise&lt;ArrayBuffer&gt;
1261```
1262let blob = new buffer.Blob(['a', 'b', 'c']);
1263let pro = blob.arrayBuffer();
1264pro.then(val => {
1265  let uintarr = new Uint8Array(val);
1266  console.log(uintarr.toString());
1267});
1268```
1269132、slice(start?: number, end?: number, type?: string): Blob
1270```
1271let blob = new buffer.Blob(['a', 'b', 'c']);
1272let blob2 = blob.slice(0, 2);
1273let blob3 = blob.slice(0, 2, "MIME");
1274```
1275133、text(): Promise&lt;string&gt;
1276```
1277let blob = new buffer.Blob(['a', 'b', 'c']);
1278let pro = blob.text();
1279pro.then(val => {
1280    console.log(val)
1281});
1282```
1283
1284## 2. js_util_module子模块
1285### 2.1. 简介
1286
1287UTIL接口用于字符编码TextEncoder、解码TextDecoder、帮助函数HelpFunction、基于Base64的字节编码encode和解码decode、有理数RationalNumber。TextEncoder表示一个文本编码器,接受字符串作为输入,以UTF-8格式进行编码,输出UTF-8字节流。TextDecoder接口表示一个文本解码器,解码器将字节流作为输入,输出stirng字符串。HelpFunction主要是对函数做callback化、promise化以及对错误码进行编写输出,及类字符串的格式化输出。encode接口使用Base64编码方案将指定u8数组中的所有字节编码到新分配的u8数组中或者使用Base64编码方案将指定的字节数组编码为String。decode接口使用Base64编码方案将Base64编码的字符串或输入u8数组解码为新分配的u8数组。RationalNumber有理数主要是对有理数进行比较,获取分子分母等方法。LruBuffer该算法在缓存空间不够的时候,将近期最少使用的数据替换为新数据。该算法源自这样一种访问资源的需求:近期访问的数据,可能在不久的将来会再次访问。于是最少访问的数据就是价值最小的,是最应该踢出缓存空间的数据。Scope接口用于描述一个字段的有效范围。 Scope实例的构造函数用于创建具有指定下限和上限的对象,并要求这些对象必须具有可比性。
1288### 2.2. 目录
1289
1290```
1291commomlibrary/ets_utils/js_util_module/
1292├── Class:TextEncoder                   # TextEncoder类
1293│   ├──  new TextEncoder()              # 创建TextEncoder对象
1294│   ├──  encode()                       # encode方法
1295│   ├──  encoding                       # encoding属性
1296│   └──  encodeInto()                   # encodeInto方法
1297├── Class:TextDecoder                   # TextDecoder类
1298│   ├──  new TextDecoder()              # 创建TextDecoder对象
1299│   ├──  decode()                       # decode方法
1300|   ├──  decodeWithStream()             # decodeWithStream方法
1301│   ├──  encoding                       # encoding属性
1302│   ├──  fatal                          # fatal属性
1303│   └──  ignoreBOM                      # ignoreBOM属性
1304├── printf()                            # printf方法
1305├── getErrorString()                    # getErrorString方法
1306├── callbackWrapper()                   # callbackWrapper方法
1307├── promiseWrapper()                    # promiseWrapper方法
1308├── Class:Base64                        # Base64类
1309│   ├──  new Base64()                   # 创建Base64对象
1310│   ├──  encodeSync()                   # encodeSync方法
1311│   ├──  encodeToStringSync()           # encodeToStringSync方法
1312│   ├──  decodeSync()                   # decodeSync方法
1313│   ├──  encode()                       # encode方法
1314│   ├──  encodeToString()               # encodeToString方法
1315│   └──  decode()                       # decode方法
1316├── Class:RationalNumber                # RationalNumber类
1317│   ├──  new RationalNumber()           # 创建RationalNumber对象
1318│   ├──  createRationalFromString()     # createRationalFromString方法
1319│   ├──  compareTo()                    # compareTo方法
1320│   ├──  equals()                       # equals方法
1321│   ├──  valueOf()                      # valueOf方法
1322│   ├──  getCommonDivisor()             # getCommonDivisor方法
1323│   ├──  getDenominator()               # getDenominator方法
1324│   ├──  getNumerator()                 # getNumerator方法
1325│   ├──  isFinite()                     # isFinite方法
1326│   ├──  isNaN()                        # isNaN方法
1327│   ├──  isZero()                       # isZero方法
1328│   └──  toString()                     # toString方法
1329├── Class:LruBuffer                     # LruBuffer类
1330│   ├──  new LruBuffer()                # 创建LruBuffer对象
1331│   ├──  updateCapacity()               # updateCapacity方法
1332│   ├──  toString()                     # toString方法
1333│   ├──  values()                       # values方法
1334│   ├──  length                         # length属性
1335│   ├──  getCapacity()                  # getCapacity方法
1336│   ├──  clear()                        # clear方法
1337│   ├──  getCreateCount()               # getCreateCount方法
1338│   ├──  getMissCount()                 # getMissCount方法
1339│   ├──  getRemovalCount()              # getRemovalCount方法
1340│   ├──  getMatchCount()                # getMatchCount方法
1341│   ├──  getPutCount()                  # getPutCount方法
1342│   ├──  isEmpty()                      # isEmpty方法
1343│   ├──  get()                          # get方法
1344│   ├──  put()                          # put方法
1345│   ├──  keys()                         # keys方法
1346│   ├──  remove()                       # remove方法
1347│   ├──  afterRemoval()                 # afterRemoval方法
1348│   ├──  contains()                     # contains方法
1349│   ├──  createDefault()                # createDefault方法
1350│   ├──  entries()                      # entries方法
1351│   └──  [Symbol.iterator]()            # Symboliterator方法
1352|—— Class:Scope                         # Scope类
1353|   ├── constructor()                   # 创建Scope对象
1354|   ├── toString()                      # toString方法
1355|   ├── intersect()                     # intersect方法
1356|   ├── intersect()                     # intersect方法
1357|   ├── getUpper()                      # getUpper方法
1358|   ├── getLower()                      # getLower方法
1359|   ├── expand()                        # expand方法
1360|   ├── expand()                        # expand方法
1361|   ├── expand()                        # expand法
1362|   ├── contains()                      # contains方法
1363|   ├── contains()                      # contains方法
1364|   └── clamp()                         # clamp方法
1365|—— Class:Types                         # Types类
1366|   ├── isAnyArrayBuffer()              # isAnyArrayBuffer方法
1367|   ├── isArrayBufferView()             # isArrayBufferView方法
1368|   ├── isArgumentsObject()             # isArgumentsObject方法
1369|   ├── isArrayBuffer()                 # isArrayBuffer方法
1370|   ├── isAsyncFunction()               # isAsyncFunction方法
1371|   ├── isBigInt64Array()               # isBigInt64Array方法
1372|   ├── isBigUint64Array()              # isBigUint64Array方法
1373|   ├── isBooleanObject()               # isBooleanObject方法
1374|   ├── isBoxedPrimitive()              # isBoxedPrimitive方法
1375|   ├── isDataView()                    # isDataView方法
1376|   ├── isDate()                        # isDate方法
1377|   ├── isExternal()                    # isExternal方法
1378|   ├── isFloat32Array()                # isFloat32Array方法
1379|   ├── isFloat64Array()                # isFloat64Array方法
1380|   ├── isGeneratorFunction()           # isGeneratorFunction方法
1381|   ├── isGeneratorObject()             # isGeneratorObject方法
1382|   ├── isInt8Array()                   # isInt8Array方法
1383|   ├── isInt16Array()                  # isInt16Array方法
1384|   ├── isInt32Array()                  # isInt32Array方法
1385|   ├── isMap()                         # isMap方法
1386|   ├── isMapIterator()                 # isMapIterator方法
1387|   ├── isModuleNamespaceObject()       # isModuleNamespaceObject方法
1388|   ├── isNativeError()                 # isNativeError方法
1389|   ├── isNumberObject()                # isNumberObject方法
1390|   ├── isPromise()                     # isPromise方法
1391|   ├── isProxy()                       # isProxy方法
1392|   ├── isRegExp()                      # isRegExp方法
1393|   ├── isSet()                         # isSet方法
1394|   ├── isSetIterator()                 # isSetIterator方法
1395|   ├── isSharedArrayBuffer()           # isSharedArrayBuffer方法
1396|   ├── isStringObject()                # isStringObject方法
1397|   ├── isSymbolObject()                # isSymbolObject方法
1398|   ├── isTypedArray()                  # isTypedArray方法
1399|   ├── isUint8Array()                  # isUint8Array方法
1400|   ├── isUint8ClampedArray()           # isUint8ClampedArray方法
1401|   ├── isUint16Array()                 # isUint16Array方法
1402|   ├── isUint32Array()                 # isUint32Array方法
1403|   ├── isWeakMap()                     # isWeakMap方法
1404|   └── isWeakSet()                     # isWeakSet方法
1405|—— Class:ArrayList
1406|   ├── new ArrayList()                 # 创建ArrayList对象
1407|   ├── length                          # length属性
1408|   ├── add()                           # add方法
1409|   ├── insert()                        # insert方法
1410|   ├── has()                           # has方法
1411|   ├── getIndexOf()                    # getIndexOf方法
1412|   ├── removeByIndex()                 # removeByIndex方法
1413|   ├── remove()                        # remove方法
1414|   ├── getLastIndexOf()                # getLastIndexOf方法
1415|   ├── removeByRange()                 # removeByRange方法
1416|   ├── replaceAllElements()            # replaceAllElements方法
1417|   ├── forEach()                       # forEach方法
1418|   ├── sort()                          # sort方法
1419|   ├── subArrayList()                  # subArrayList方法
1420|   ├── clear()                         # clear方法
1421|   ├── clone()                         # clone方法
1422|   ├── getCapacity()                   # getCapacity方法
1423|   ├── convertToArray()                # convertToArray方法
1424|   ├── isEmpty()                       # isEmpty方法
1425|   ├── increaseCapacityTo()            # increaseCapacityTo方法
1426|   ├── trimToCurrentLength()           # trimToCurrentLength方法
1427|   └── isEmpty()                       # isEmpty方法
1428|—— Class:Deque
1429|   ├── new Deque()                     # 创建Deque对象
1430|   ├── length                          # length属性
1431|   ├── add()                           # add方法
1432|   ├── insertFront()                   # insertFront方法
1433|   ├── insertEnd()                     # insertEnd方法
1434|   ├── has()                           # has方法
1435|   ├── getFirst()                      # getFirst方法
1436|   ├── getLast()                       # getLast方法
1437|   ├── popFirst()                      # popFirst方法
1438|   ├── popLast()                       # popLast方法
1439|   └── forEach()                       # forEach方法
1440|—— Class:HashMap
1441|   ├── new HashMap()                   # 创建HashMap对象
1442|   ├── length                          # length属性
1443|   ├── isEmpty()                       # isEmpty方法
1444|   ├── hasKey()                        # hasKey方法
1445|   ├── hasValue()                      # hasValue方法
1446|   ├── setAll()                        # setAll方法
1447|   ├── set()                           # set方法
1448|   ├── remove()                        # remove方法
1449|   ├── clear()                         # clear方法
1450|   ├── keys()                          # keys方法
1451|   ├── values()                        # values方法
1452|   ├── replace()                       # replace方法
1453|   ├── forEach()                       # forEach方法
1454|   └── entries()                       # entries方法
1455|—— Class:HashSet
1456|   ├── new HashSet()                   # 创建HashSet对象
1457|   ├── length                          # length属性
1458|   ├── isEmpty()                       # isEmpty方法
1459|   ├── has()                           # has方法
1460|   ├── add()                           # add方法
1461|   ├── remove()                        # remove方法
1462|   ├── clear()                         # clear方法
1463|   ├── forEach()                       # forEach方法
1464|   ├── values()                        # values方法
1465|   └── entries()                       # entries方法
1466|—— Class:LightWeightMap
1467|   ├── new LightWeightMap()            # 创建LightWeightMap对象
1468|   ├── length                          # length属性
1469|   ├── hasAll()                        # hasAll方法
1470|   ├── hasKey()                        # hasKey方法
1471|   ├── hasValue()                      # hasValue方法
1472|   ├── increaseCapacityTo()            # increaseCapacityTo方法
1473|   ├── entries()                       # entries方法
1474|   ├── get()                           # get方法
1475|   ├── getIndexOfKey()                 # getIndexOfKey方法
1476|   ├── getIndexOfValue()               # getIndexOfValue方法
1477|   ├── isEmpty()                       # isEmpty方法
1478|   ├── getKeyAt()                      # getKeyAt方法
1479|   ├── keys()                          # keys方法
1480|   ├── setAll()                        # setAll方法
1481|   ├── set()                           # set方法
1482|   ├── remove()                        # remove方法
1483|   ├── removeAt()                      # removeAt方法
1484|   ├── clear()                         # clear方法
1485|   ├── setValueAt()                    # setValueAt方法
1486|   ├── forEach()                       # forEach方法
1487|   ├── toString()                      # toString方法
1488|   ├── getValueAt()                    # getValueAt方法
1489|   ├── values()                        # values方法
1490|   └── [Symbol.iterator]()             # [Symbol.iterator]方法
1491|—— Class:LightWeightSet
1492|   ├── new LightWeightSet()            # 创建LightWeightSet对象
1493|   ├── length                          # length属性
1494|   ├── add()                           # add方法
1495|   ├── addAll()                        # addAll方法
1496|   ├── hasAll()                        # hasAll方法
1497|   ├── has()                           # has方法
1498|   ├── equal()                         # equal方法
1499|   ├── increaseCapacityTo()            # increaseCapacityTo方法
1500|   ├── getIndexOf()                    # getIndexOf方法
1501|   ├── remove()                        # remove方法
1502|   ├── removeAt()                      # removeAt方法
1503|   ├── clear()                         # clear方法
1504|   ├── forEach()                       # forEach方法
1505|   ├── [Symbol.iterator]()             # [Symbol.iterator]方法
1506|   ├── toString()                      # toString方法
1507|   ├── toArray()                       # toArray方法
1508|   ├── getValueAt()                    # getValueAt方法
1509|   ├── values()                        # values方法
1510|   ├── entries()                       # entries方法
1511|   └── isEmpty()                       # isEmpty方法
1512|—— Class:LinkedList
1513|   ├── new LinkedList()                # 创建LinkedList对象
1514|   ├── length                          # length属性
1515|   ├── add()                           # add方法
1516|   ├── insert()                        # insert方法
1517|   ├── get()                           # get方法
1518|   ├── addFirst()                      # addFirst方法
1519|   ├── removeFirst()                   # removeFirst方法
1520|   ├── removeLast()                    # removeLast方法
1521|   ├── has()                           # has方法
1522|   ├── getIndexOf()                    # getIndexOf方法
1523|   ├── removeByIndex()                 # removeByIndex方法
1524|   ├── remove()                        # remove方法
1525|   ├── removeFirstFound()              # removeFirstFound方法
1526|   ├── removeLastFound()               # removeLastFound方法
1527|   ├── getLastIndexOf()                # getLastIndexOf方法
1528|   ├── getFirst()                      # getFirst方法
1529|   ├── getLast()                       # getLast方法
1530|   ├── set()                           # set方法
1531|   ├── forEach()                       # forEach方法
1532|   ├── clear()                         # clear方法
1533|   ├── clone()                         # clone方法
1534|   ├── convertToArray()                # convertToArray方法
1535|   └── [Symbol.iterator]()             # [Symbol.iterator]方法
1536|—— Class:List
1537|   ├── new List()                      # 创建List对象
1538|   ├── length                          # length属性
1539|   ├── add()                           # add方法
1540|   ├── insert()                        # insert方法
1541|   ├── get()                           # get方法
1542|   ├── has()                           # has方法
1543|   ├── getIndexOf()                    # getIndexOf方法
1544|   ├── removeByIndex()                 # removeByIndex方法
1545|   ├── remove()                        # remove方法
1546|   ├── getLastIndexOf()                # getLastIndexOf方法
1547|   ├── getFirst()                      # getFirst方法
1548|   ├── getLast()                       # getLast方法
1549|   ├── set()                           # set方法
1550|   ├── equal()                         # equal方法
1551|   ├── forEach()                       # forEach方法
1552|   ├── sort()                          # sort方法
1553|   ├── clear()                         # clear方法
1554|   ├── getSubList()                    # getSubList方法
1555|   ├── replaceAllElements()            # replaceAllElements方法
1556|   ├── convertToArray()                # convertToArray方法
1557|   ├── isEmpty()                       # isEmpty方法
1558|   └── [Symbol.iterator]()             # [Symbol.iterator]方法
1559|—— Class:PlainArray
1560|   ├── new PlainArray()                # 创建PlainArray对象
1561|   ├── length                          # length属性
1562|   ├── add()                           # add方法
1563|   ├── clear()                         # clear方法
1564|   ├── clone()                         # clone方法
1565|   ├── has()                           # has方法
1566|   ├── get()                           # get方法
1567|   ├── getIndexOfKey()                 # getIndexOfKey方法
1568|   ├── getIndexOfValue()               # getIndexOfValue方法
1569|   ├── isEmpty()                       # isEmpty方法
1570|   ├── getKeyAt()                      # getKeyAt方法
1571|   ├── remove()                        # remove方法
1572|   ├── removeAt()                      # removeAt方法
1573|   ├── removeRangeFrom()               # removeRangeFrom方法
1574|   ├── setValueAt()                    # setValueAt方法
1575|   ├── toString()                      # toString方法
1576|   ├── getValueAt()                    # getValueAt方法
1577|   ├── forEach()                       # forEach方法
1578|   └── [Symbol.iterator]()             # [Symbol.iterator]方法
1579|—— Class:Queue
1580|   ├── new Queue()                     # 创建Queue对象
1581|   ├── length                          # length属性
1582|   ├── add()                           # add方法
1583|   ├── getFirst()                      # getFirst方法
1584|   ├── pop()                           # pop方法
1585|   ├── forEach()                       # forEach方法
1586|   └── [Symbol.iterator]()             # [Symbol.iterator]方法
1587|—— Class:Stack
1588|   ├── new Stack()                     # 创建Stack对象
1589|   ├── length                          # length属性
1590|   ├── isEmpty()                       # isEmpty方法
1591|   ├── peek()                          # peek方法
1592|   ├── pop()                           # pop方法
1593|   ├── push()                          # push方法
1594|   ├── locate()                        # locate方法
1595|   ├── forEach()                       # forEach方法
1596|   └── [Symbol.iterator]()             # [Symbol.iterator]方法
1597|—— Class:TreeMap
1598|   ├── new TreeMap()                   # 创建TreeMap对象
1599|   ├── length                          # length属性
1600|   ├── isEmpty()                       # isEmpty方法
1601|   ├── hasKey()                        # hasKey方法
1602|   ├── hasValue()                      # hasValue方法
1603|   ├── get()                           # get方法
1604|   ├── getFirstKey()                   # getFirstKey方法
1605|   ├── getLastKey()                    # getLastKey方法
1606|   ├── setAll()                        # setAll方法
1607|   ├── set()                           # set方法
1608|   ├── remove()                        # remove方法
1609|   ├── clear()                         # clear方法
1610|   ├── getLowerKey()                   # getLowerKey方法
1611|   ├── getHigherKey()                  # getHigherKey方法
1612|   ├── keys()                          # keys方法
1613|   ├── values()                        # values方法
1614|   ├── replace()                       # replace方法
1615|   ├── forEach()                       # forEach方法
1616|   ├── entries()                       # entries方法
1617|   └── [Symbol.iterator]()             # [Symbol.iterator]方法
1618└── Class:TreeSet
1619    ├── new TreeSet()                   # 创建TreeSet对象
1620    ├── length                          # length属性
1621    ├── isEmpty()                       # isEmpty方法
1622    ├── has()                           # has方法
1623    ├── add()                           # add方法
1624    ├── remove()                        # remove方法
1625    ├── clear()                         # clear方法
1626    ├── getFirstValue()                 # getFirstValue方法
1627    ├── getLastValue()                  # getLastValue方法
1628    ├── getLowerValue()                 # getLowerValue方法
1629    ├── getHigherValue()                # getHigherValue方法
1630    ├── popFirst()                      # popFirst方法
1631    ├── popLast()                       # popLast方法
1632    ├── forEach()                       # forEach方法
1633    ├── values()                        # values方法
1634    ├── entries()                       # entries方法
1635    └── [Symbol.iterator]()             # [Symbol.iterator]方法
1636```
1637
1638### 2.3. 说明
1639
1640#### 2.3.1. 接口说明
1641
1642
1643| 接口名 | 说明 |
1644| -------- | -------- |
1645| constructor(encoding? : string) | 构造函数,参数encoding表示编码的格式。默认utf-8, 支持gb18030, gbk, gb2312. |
1646| readonly encoding : string | 在TextEncoder类中,获取编码的格式,只支持UTF-8。 |
1647| encode(input : string) : Uint8Array | 输入stirng字符串,根据encodeing编码并输出uint8字节流。 |
1648| encodeInto(input : string, dest : Uint8Array) : {read : number, written : number} | 输入stirng字符串,dest表示编码后存放位置,返回一个对象,read表示已经编码的字符的个数,written表示已编码字符所占字节的大小。 |
1649| constructor(encoding? : string, options? : {fatal? : boolean, ignoreBOM? : boolean}) | 构造函数,第一个参数encoding表示解码的格式。第二个参数表示一些属性。属性中fatal表示是否抛出异常,ignoreBOM表示是否忽略bom标志。 |
1650| readonly encoding : string | 在TextDecoder类中,获取设置的解码格式。 |
1651| readonly fatal : boolean | 获取抛出异常的设置。 |
1652| readonly ignoreBOM : boolean | 获取是否忽略bom标志的设置。 |
1653| decode(input : Uint8Array, options?: { stream?: false }) : string | 输入要解码的数据,解出对应的string字符串。第一个参数input表示要解码的数据,第二个参数options表示一个bool标志,表示将跟随附加数据,默认为false。 |
1654| decodeWithStream(input : Uint8Array, options?: { stream?: false }) : string | 输入要解码的数据,解出对应的string字符串。第一个参数input表示要解码的数据,第二个参数options表示一个bool标志,表示将跟随附加数据,默认为false。 |
1655| encodeSync(src: Uint8Array): Uint8Array; | 使用Base64编码方案将指定u8数组中的所有字节编码到新分配的u8数组中。 |
1656| encodeToStringSync(src: Uint8Array): string; | 使用Base64编码方案将指定的字节数组编码为String。 |
1657| decodeSync(src: Uint8Array \| string): Uint8Array; | 使用Base64编码方案将Base64编码的字符串或输入u8数组解码为新分配的u8数组。 |
1658| encode(src: Uint8Array): Promise\<Uint8Array\>; | 使用Base64编码方案将指定u8数组中的所有字节异步编码到新分配的u8数组中。 |
1659| encodeToString(src: Uint8Array): Promise\<string\>; | 使用Base64编码方案将指定的字节数组异步编码为String。 |
1660| decode(src: Uint8Array \| string): Promise\<Uint8Array\>; | 使用Base64编码方案将Base64编码的字符串或输入u8数组异步解码为新分配的u8数组。 |
1661| static createRationalFromString(rationalString: string): RationalNumber | 基于给定的字符串创建一个RationalNumber对象。 |
1662| compareTo(another: RationalNumber): number | 将当前的RationalNumber对象与给定的对象进行比较。 |
1663| equals(obj: object): number | 检查给定对象是否与当前 RationalNumber 对象相同。 |
1664| valueOf(): number | 将当前的RationalNumber对象进行取整数值或者浮点数值。 |
1665| static getCommonDivisor(number1: number, number2: number,): number | 获得两个指定数的最大公约数。 |
1666| getDenominator(): number | 获取当前的RationalNumber对象的分母。 |
1667| getNumerator(): number | 获取当前的RationalNumber对象的分子。 |
1668| isFinite(): boolean | 检查当前的RationalNumber对象是有限的。 |
1669| isNaN(): boolean | 检查当前RationalNumber对象是否表示非数字(NaN)值。 |
1670| isZero(): boolean | 检查当前RationalNumber对象是否表示零值。 |
1671| toString(): string | 获取当前RationalNumber对象的字符串表示形式。 |
1672| constructor(capacity?: number) | 创建默认构造函数用于创建一个新的LruBuffer实例,默认容量为64。 |
1673| updateCapacity(newCapacity: number): void | 将缓冲区容量更新为指定容量,如果 newCapacity 小于或等于 0,则抛出此异常。 |
1674| toString(): string | 返回对象的字符串表示形式,输出对象的字符串表示  |
1675| values(): V[] | 获取当前缓冲区中所有值的列表,输出按升序返回当前缓冲区中所有值的列表,从最近访问到最近最少访问。 |
1676| length: number | 代表当前缓冲区中值的总数,输出返回当前缓冲区中值的总数。 |
1677| getCapacity(): number | 获取当前缓冲区的容量,输出返回当前缓冲区的容量。 |
1678| clear(): void | 从当前缓冲区清除键值对,清除键值对后,调用afterRemoval()方法依次对其执行后续操作。 |
1679| getCreateCount(): number | 获取createDefault()返回值的次数,输出返回createDefault()返回值的次数。 |
1680| getMissCount(): number | 获取查询值不匹配的次数,输出返回查询值不匹配的次数。 |
1681| getRemovalCount(): number | 获取从缓冲区中逐出值的次数,输出从缓冲区中驱逐的次数。 |
1682| getMatchCount​(): number | 获取查询值匹配成功的次数,输出返回查询值匹配成功的次数。 |
1683| getPutCount(): number | 获取将值添加到缓冲区的次数,输出返回将值添加到缓冲区的次数。 |
1684| isEmpty(): boolean | 检查当前缓冲区是否为空,输出如果当前缓冲区不包含任何值,则返回 true 。 |
1685| get(key: K) : V \| undefined | 表示要查询的键,输出如果指定的键存在于缓冲区中,则返回与键关联的值;否则返回undefined。 |
1686| put(key: K , value: V): V | 将键值对添加到缓冲区,输出与添加的键关联的值;如果要添加的键已经存在,则返回原始值,如果键或值为空,则抛出此异常。 |
1687| keys(): K[ ] | 获取当前缓冲区中值的键列表,输出返回从最近访问到最近最少访问排序的键列表。 |
1688| remove​(key: K): V \| undefined |  从当前缓冲区中删除指定的键及其关联的值。 |
1689| afterRemoval(isEvict: boolean, key: K, value : V, newValue : V):void | 删除值后执行后续操作。 |
1690| contains(key: K): boolean | 检查当前缓冲区是否包含指定的键,输出如果缓冲区包含指定的键,则返回 true 。 |
1691| createDefault(key: K): V | 如果未计算特定键的值,则执行后续操作,参数表示丢失的键,输出返回与键关联的值。 |
1692| entries(): [K,V] | 允许迭代包含在这个对象中的所有键值对。每对的键和值都是对象。 |
1693| \[Symbol.iterator\](): [K,V] | 返回以键值对得形式得一个二维数组。 |
1694| constructor(lowerObj: ScopeType, upperObj : ScopeType) | 创建并返回一个Scope对象,用于创建指定下限和上限的作用域实例的构造函数。 |
1695| toString(): string | 该字符串化方法返回一个包含当前范围的字符串表示形式。 |
1696| intersect(range: Scope): Scope | 获取给定范围和当前范围的交集。 |
1697| intersect(lowerObj: ScopeType, upperObj: ScopeType): Scope | 获取当前范围与给定下限和上限范围的交集。 |
1698| getUpper(): ScopeType | 获取当前范围的上限。 |
1699| getLower(): ScopeType | 获取当前范围的下限。 |
1700| expand(lowerObj: ScopeType, upperObj:  ScopeType): Scope | 创建并返回包括当前范围和给定下限和上限的并集。 |
1701| expand(range: Scope): Scope | 创建并返回包括当前范围和给定范围的并集。 |
1702| expand(value: ScopeType): Scope | 创建并返回包括当前范围和给定值的并集。 |
1703| contains(value: ScopeType): boolean | 检查给定value是否包含在当前范围内。 |
1704| contains(range: Scope): boolean | 检查给定range是否在当前范围内。 |
1705| clamp(value: ScopeType): ScopeType | 将给定value限定到当前范围内。 |
1706| function printf(format: string, ...args: Object[]): string | printf()方法使用第一个参数作为格式字符串(其可以包含零个或多个格式说明符)来返回格式化的字符串。 |
1707| function getErrorString(errno: number): string | getErrorString()方法使用一个系统的错误数字作为参数,用来返回系统的错误信息。 |
1708| function callbackWrapper(original: Function): (err: Object, value: Object) => void | 参数为一个采用 async 函数(或返回 Promise 的函数)并返回遵循错误优先回调风格的函数,即将 (err, value) => ... 回调作为最后一个参数。 在回调中,第一个参数将是拒绝原因(如果 Promise 已解决,则为 null),第二个参数将是已解决的值。 |
1709| function promiseWrapper(original: (err: Object, value: Object) => void): Object | 参数为采用遵循常见的错误优先的回调风格的函数(也就是将 (err, value) => ... 回调作为最后一个参数),并返回一个返回 promise 的版本。 |
1710| isAnyArrayBuffer(value: Object): boolean | 检查输入的value是否是ArrayBuffer或SharedArrayBuffer类型。 |
1711| isArrayBufferView(value: Object): boolean | 检查输入的value是否是napi_int8_array或napi_uint8_array或napi_uint8_clamped_array或napi_int16_array或napi_uint16_array或napi_int32_array或napi_uint32_array或napi_float32_array或napi_float64_array数组或DataView类型。 |
1712| isArgumentsObject(value: Object): boolean | 检查输入的value是否是一个arguments对象类型。 |
1713| isArrayBuffer(value: Object): boolean | 检查输入的value是否是ArrayBuffer类型。 |
1714| isAsyncFunction(value: Object): boolean | 检查输入的value是否是异步函数类型。 |
1715| isBigInt64Array(value: Object): boolean | 检查输入的value是否是BigInt64Array数组类型。 |
1716| isBigUint64Array(value: Object): boolean | 检查输入的value是否是BigUint64Array数组类型。 |
1717| isBooleanObject(value: Object): boolean | 检查输入的value是否是一个布尔对象类型。 |
1718| isBoxedPrimitive(value: Object): boolean | 检查输入的value是否是Boolean或Number或String或Symbol对象类型。 |
1719| isDataView(value: Object): boolean | 检查输入的value是否是DataView类型。 |
1720| isDate(value: Object): boolean | 检查输入的value是否是Date类型。 |
1721| isExternal(value: Object): boolean | 检查输入的value是否是一个native External值类型。 |
1722| isFloat32Array(value: Object): boolean | 检查输入的value是否是Float32Array数组类型。 |
1723| isFloat64Array(value: Object): boolean | 检查输入的value是否是Float64Array数组类型。 |
1724| isGeneratorFunction(value: Object): boolean | 检查输入的value是否是一个generator函数类型。 |
1725| isGeneratorObject(value: Object): boolean | 检查输入的value是否是一个generator对象类型。 |
1726| isInt8Array(value: Object): boolean | 检查输入的value是否是Int8Array数组类型。 |
1727| isInt16Array(value: Object): boolean | 检查输入的value是否是Int16Array数组类型。 |
1728| isInt32Array(value: Object): boolean | 检查输入的value是否是Int32Array数组类型。 |
1729| isMap(value: Object): boolean | 检查输入的value是否是Map类型。 |
1730| isMapIterator(value: Object): boolean | 检查输入的value是否是Map的iterator类型。 |
1731| isModuleNamespaceObject(value: Object): boolean | 检查输入的value是否是Module Namespace Object对象类型。 |
1732| isNativeError(value: Object): boolean | 检查输入的value是否是Error类型。 |
1733| isNumberObject(value: Object): boolean | 检查输入的value是否是Number对象类型。 |
1734| isPromise(value: Object): boolean | 检查输入的value是否是Promise类型。 |
1735| isProxy(value: Object): boolean | 检查输入的value是否是Proxy类型。 |
1736| isRegExp(value: Object): boolean | 检查输入的value是否是RegExp类型。 |
1737| isSet(value: Object): boolean | 检查输入的value是否是Set类型。 |
1738| isSetIterator(value: Object): boolean | 检查输入的value是否是Set的iterator类型。 |
1739| isSharedArrayBuffer(value: Object): boolean | 检查输入的value是否是SharedArrayBuffer类型。 |
1740| isStringObject(value: Object): boolean | 检查输入的value是否是一个String对象类型。 |
1741| isSymbolObject(value: Object): boolean | 检查输入的value是否是一个Symbol对象类型。 |
1742| isTypedArray(value: Object): boolean | 检查输入的value是否是TypedArray包含的类型。 |
1743| isUint8Array(value: Object): boolean | 检查输入的value是否是Uint8Array数组类型。 |
1744| isUint8ClampedArray(value: Object): boolean | 检查输入的value是否是Uint8ClampedArray数组类型。 |
1745| isUint16Array(value: Object): boolean | 检查输入的value是否是Uint16Array数组类型。 |
1746| isUint32Array(value: Object): boolean | 检查输入的value是否是Uint32Array数组类型。 |
1747| isWeakMap(value: Object): boolean | 检查输入的value是否是WeakMap类型。 |
1748| isWeakSet(value: Object): boolean | 检查输入的value是否是WeakSet类型。 |
1749| add(element: T): boolean | 在ArrayList尾部插入元素。 |
1750| insert(element: T, index: number): void | 在长度范围内任意位置插入指定元素。 |
1751| has(element: T): boolean | 判断此ArrayList中是否含有该指定元素。 |
1752| getIndexOf(element: T): number | 返回指定元素第一次出现时的下标值,查找失败返回-1。 |
1753| removeByIndex(index: number): T | 根据元素的下标值查找元素,返回元素后将其删除。 |
1754| remove(element: T): boolean | 删除查找到的第一个指定的元素。 |
1755| getLastIndexOf(element: T): number | 返回指定元素最后一次出现时的下标值,查找失败返回-1。 |
1756| removeByRange(fromIndex: number, toIndex: number): void | 从一段范围内删除元素,包括起始值但不包括终止值。 |
1757| replaceAllElements(callbackFn: (value: T, index?: number, arrlist?: ArrayList<T>) => T,
1758thisArg?: Object): void | 用户操作ArrayList中的元素,用操作后的元素替换原元素并返回操作后的元素。 |
1759| forEach(callbackFn: (value: T, index?: number, arrlist?: ArrayList<T>) => void,
1760  thisArg?: Object): void | 通过回调函数来遍历ArrayList实例对象上的元素以及元素对应的下标。 |
1761| sort(comparator?: (firstValue: T, secondValue: T) => number): void | 对ArrayList中的元素排序。 |
1762| subArrayList(fromIndex: number, toIndex: number): ArrayList<T> | 根据下标截取ArrayList中的一段元素,并返回这一段ArrayList实例,包括起始值但不包括终止值。 |
1763| clear(): void | 清除ArrayList中的所有元素,并把length置为0。 |
1764| clone(): ArrayList<T> | 克隆一个与ArrayList相同的实例,并返回克隆后的实例。修改克隆后的实例并不会影响原实例。 |
1765| getCapacity(): number | 获取当前实例的容量大小。 |
1766| convertToArray(): Array<T> | 把当前ArrayList实例转换成数组,并返回转换后的数组。 |
1767| isEmpty(): boolean | 判断该ArrayList是否为空。 |
1768| increaseCapacityTo(newCapacity: number): void | 如果传入的新容量大于或等于ArrayList中的元素个数,将容量变更为新容量。 |
1769| trimToCurrentLength(): void | 把容量限制为当前的length大小。 |
1770| insertFront(element: T): void | 在deque头部插入元素。 |
1771| insertEnd(element: T): void | 在deque尾部插入元素。 |
1772| has(element: T): boolean | 判断此Deque中是否含有该指定元素。 |
1773| getFirst(): T | 获取Deque实例中的头元素。 |
1774| getLast(): T | 获取Deque实例中的尾元素。 |
1775| popFirst(): T | 删除并返回双端队列的首元素。 |
1776| popLast(): T | 删除并返回双端队列的尾元素。 |
1777| forEach(callbackFn: (value: T, index?: number, deque?: Deque<T>) => void,thisArg?: Object): void |
1778通过回调函数来遍历Deque实例对象上的元素以及元素对应的下标。 |
1779| isEmpty(): boolean | 判断该HashMap是否为空。 |
1780| hasKey(key: K): boolean | 判断此HashMap中是否含有该指定key。 |
1781| hasValue(value: V): boolean | 判断此HashMap中是否含有该指定value。 |
1782| get(key: K): V | 获取指定key所对应的value。 |
1783| setAll(map: HashMap<K, V>): void | 将一个HashMap中的所有元素组添加到另一个hashMap中。 |
1784| set(key: K, value: V): Object | 向HashMap中添加一组数据。 |
1785| remove(key: K): V | 删除指定key所对应元素。 |
1786| clear(): void | 清除HashMap中的所有元素,并把length置为0。 |
1787| keys(): IterableIterator<K> | 返回包含此映射中包含的键名的新迭代器对象。 |
1788| values(): IterableIterator<V> | 返回包含此映射中包含的键值的新迭代器对象。 |
1789| replace(key: K, newValue: V): boolean | 对HashMap中一组数据进行更新(替换)。 |
1790| forEach(callbackFn: (value?: V, key?: K, map?: HashMap<K, V>) => void,thisArg?: Object): void |
1791通过回调函数来遍历HashMap实例对象上的元素以及元素对应的下标。 |
1792| entries(): IterableIterator<[K, V]> | 返回包含此映射中包含的键值对的新迭代器对象。 |
1793| isEmpty(): boolean | 判断该HashSet是否为空。 |
1794| has(value: T): boolean | 判断此HashSet中是否含有该指定元素。 |
1795| add(value: T): boolean | 向HashSet中添加数据。 |
1796| remove(value: T): boolean | 删除指定的元素。 |
1797| clear(): void | 清除HashSet中的所有元素,并把length置为0。 |
1798| forEach(callbackFn: (value?: T, key?: T, set?: HashSet<T>) => void,thisArg?: Object): void |
1799通过回调函数来遍历实例对象上的元素以及元素对应的下标。 |
1800| values(): IterableIterator<T> | 返回包含此映射中包含的键值的新迭代器对象。 |
1801| entries(): IterableIterator<[T, T]> | 返回包含此映射中包含的键值对的新迭代器对象。 |
1802| hasAll(map: LightWeightMap<K, V>): boolean | 判断此LightWeightMap中是否含有该指定map中的所有元素。 |
1803| hasKey(key: K): boolean | 判断此LightWeightMap中是否含有该指定key。 |
1804| hasValue(value: V): boolean | 判断此LightWeightMap中是否含有该指定value。 |
1805| increaseCapacityTo(minimumCapacity: number): void | 将当前LightWeightMap扩容至可以容纳指定数量元素。 |
1806| entries(): IterableIterator<[K, V]> | 返回包含此映射中包含的键值对的新迭代器对象。 |
1807| get(key: K): V | 获取指定key所对应的value。 |
1808| getIndexOfKey(key: K): number | 查找key元素第一次出现的下标值,如果没有找到该元素返回-1。 |
1809| getIndexOfValue(value: V): number | 查找value元素第一次出现的下标值,如果没有找到该元素返回-1。 |
1810| isEmpty(): boolean | 判断该LightWeightMap是否为空。 |
1811| getKeyAt(index: number): K | 查找指定下标的元素键值对中key值,否则返回undefined。 |
1812| keys(): IterableIterator<K> | 返回包含此映射中包含的键的新迭代器对象。 |
1813| setAll(map: LightWeightMap<K, V>): void | 将一个LightWeightMap中的所有元素组添加到另一个lightWeightMap中。 |
1814| set(key: K, value: V): Object | 向LightWeightMap中添加一组数据。 |
1815| remove(key: K): V | 删除并返回指定key映射的元素。 |
1816| removeAt(index: number): boolean | 删除指定下标对应的元素。 |
1817| clear(): void | 清除LightWeightMap中的所有元素,并把length置为0。 |
1818| setValueAt(index: number, newValue: V): boolean | 替换指定下标对应键值对中的元素。 |
1819| forEach(callbackFn: (value?: V, key?: K, map?: LightWeightMap<K, V>) => void,thisArg?: Object): void |
1820通过回调函数来遍历实例对象上的元素以及元素对应的下标。 |
1821| [Symbol.iterator](): IterableIterator<[K, V]> | 返回一个迭代器,迭代器的每一项都是一个 JavaScript 对象,并返回该对象。 |
1822| toString(): String | 将此映射中包含的键值对拼接成字符串,并返回字符串类型。 |
1823| getValueAt(index: number): V | 获取指定下标对应键值对中的元素。 |
1824| values(): IterableIterator<V> | 返回包含此映射中包含的键值的新迭代器对象。 |
1825| add(obj: T): boolean | 向此容器中添加数据。 |
1826| addAll(set: LightWeightSet<T>): boolean | 将另一个容器中的所有元素组添加到当前容器中。 |
1827| hasAll(set: LightWeightSet<T>): boolean | 判断此容器中是否含有该指定set中的所有元素。 |
1828| has(key: T): boolean | 判断此容器中是否含有该指定key。 |
1829| equal(obj: Object): boolean | 判断此容器中是否含有该指定obj同类型的对象。 |
1830| increaseCapacityTo(minimumCapacity: number): void | 将当前容器扩容至可以容纳指定数量元素。 |
1831| getIndexOf(key: T): number | 获取指定key所对应的下标。 |
1832| remove(key: T): T | 删除并返回指定key对应的元素。 |
1833| removeAt(index: number): boolean | 删除指定下标所对应的元素。 |
1834| clear(): void | 清除容器中的所有元素,并把length置为0。 |
1835| forEach(callbackFn: (value?: T, key?: T, set?: LightWeightSet<T>) => void,thisArg?: Object): void |
1836通过回调函数来遍历LightWeightSet实例对象上的元素以及元素对应的下标。 |
1837| [Symbol.iterator](): IterableIterator<T> | 返回一个迭代器,迭代器的每一项都是一个 JavaScript 对象,并返回该对象。 |
1838| toString(): String | 获取包含容器中所有键和值的字符串。 |
1839| toArray(): Array<T> | 获取包含此容器中所有对象的数组。 |
1840| getValueAt(index: number): T | 获取此容器中指定下标对应的元素。 |
1841| values(): IterableIterator<T> | 返回包含此映射中包含的键值的新迭代器对象。 |
1842| entries(): IterableIterator<[T, T]> | 返回包含此映射中包含的键值对的新迭代器对象。 |
1843| isEmpty(): boolean | 判断该容器是否为空。 |
1844| add(element: T): boolean | 在LinkedList尾部插入元素。 |
1845| insert(index: number, element: T): void | 在长度范围内任意插入指定元素。 |
1846| get(index: number): T | 根据下标获取LinkedList中的元素。 |
1847| addFirst(element: T): void | 在LinkedList头部插入元素。 |
1848| removeFirst(): T | 删除并返回LinkedList的第一个元素。 |
1849| removeLast(): T | 删除并返回LinkedList的最后一个元素。 |
1850| has(element: T): boolean | 判断此LinkedList中是否含有该指定元素。 |
1851| getIndexOf(element: T): number | 返回指定元素第一次出现时的下标值,查找失败返回-1。 |
1852| removeByIndex(index: number): T | 根据元素的下标值查找元素,返回元素后将其删除。 |
1853| remove(element: T): boolean | 删除查找到的第一个指定的元素。 |
1854| removeFirstFound(element: T): boolean | 删除第一次出现的指定元素。 |
1855| removeLastFound(element: T): boolean | 删除最后一次出现的指定元素。 |
1856| getLastIndexOf(element: T): number | 返回指定元素最后一次出现时的下标值,查找失败返回-1。 |
1857| getFirst(): T | 获取LinkedList实例中的第一个元素。 |
1858| getLast(): T | 获取LinkedList实例中的最后一个元素。 |
1859| set(index: number, element: T): T | 将此LinkedList中指定位置的元素替换为指定元素。 |
1860| forEach(callbackFn: (value: T, index?: number, LinkedList?: LinkedList<T>) => void,thisArg?: Object): void |
1861通过回调函数来遍历LinkedList实例对象上的元素以及元素对应的下标。 |
1862| clear(): void | 清除LinkedList中的所有元素,并把length置为0。 |
1863| clone(): LinkedList<T> | 克隆一个与LinkedList相同的实例,并返回克隆后的实例。修改克隆后的实例并不会影响原实例。 |
1864| convertToArray(): Array<T> | 把当前LinkedList实例转换成数组,并返回转换后的数组。 |
1865| [Symbol.iterator](): IterableIterator<T> | 返回一个迭代器,迭代器的每一项都是一个 JavaScript 对象,并返回该对象。 |
1866| add(element: T): boolean | 在List尾部插入元素。 |
1867| insert(element: T, index: number): void | 在长度范围内任意位置插入指定元素。 |
1868| get(index: number): T | 根据下标获取List中的元素。 |
1869| has(element: T): boolean | 判断此List中是否含有该指定元素。 |
1870| getIndexOf(element: T): number | 查找指定元素第一次出现的下标值,查找失败返回-1。 |
1871| removeByIndex(index: number): T | 根据元素的下标值查找元素,返回元素后将其删除。 |
1872| remove(element: T): boolean | 删除查找到的第一个指定的元素。 |
1873| getLastIndexOf(element: T): number | 查找指定元素最后一次出现的下标值,查找失败返回-1。 |
1874| getFirst(): T | 获取List实例中的第一个元素。 |
1875| getLast(): T | 获取List实例中的最后一个元素。 |
1876| set(index: number, element: T): T | 将此 List 中指定位置的元素替换为指定元素。 |
1877| equal(obj: Object): boolean | 比较指定对象与此List是否相等。 |
1878| forEach(callbackFn: (value: T, index?: number, List?: List<T>) => void,thisArg?: Object): void |
1879通过回调函数来遍历List实例对象上的元素以及元素对应的下标。 |
1880| sort(comparator: (firstValue: T, secondValue: T) => number): void | 对List中的元素进行一个排序操作。 |
1881| clear(): void | 清除List中的所有元素,并把length置为0。 |
1882| getSubList(fromIndex: number, toIndex: number): List<T> |
1883根据下标截取List中的一段元素,并返回这一段List实例,包括起始值但不包括终止值。 |
1884| replaceAllElements(callbackFn: (value: T, index?: number, list?: List<T>) => T,thisArg?: Object): void;T |
1885用户操作List中的元素,用操作后的元素替换原元素并返回操作后的元素。 |
1886| convertToArray(): Array<T> | 把当前List实例转换成数组,并返回转换后的数组。 |
1887| isEmpty(): boolean | 判断该List是否为空。 |
1888| [Symbol.iterator](): IterableIterator<T> | 返回一个迭代器,迭代器的每一项都是一个 JavaScript 对象,并返回该对象。 |
1889| add(key: number, value: T): void | 向容器中添加一组数据。 |
1890| clear(): void | 清除容器中的所有元素,并把length置为0。 |
1891| clone(): PlainArray<T> | 克隆一个实例,并返回克隆后的实例。修改克隆后的实例并不会影响原实例。 |
1892| has(key: number): boolean | 判断此容器中是否含有该指定key。 |
1893| get(key: number): T | 获取指定key所对应的value。 |
1894| getIndexOfKey(key: number): number | 查找指定key第一次出现的下标值,如果没有找到该key返回-1。 |
1895| getIndexOfValue(value: T): number | 查找指定value元素第一次出现的下标值,如果没有找到该value元素返回-1。 |
1896| isEmpty(): boolean | 判断该容器是否为空。 |
1897| getKeyAt(index: number): number | 查找指定下标元素键值对中的key值。 |
1898| remove(key: number): T | 删除指定key对应元素。 |
1899| removeAt(index: number): T | 删除指定下标对应的元素。 |
1900| removeRangeFrom(index: number, size: number): number | 删除一定范围内的元素。 |
1901| setValueAt(index: number, value: T): void | 替换容器中指定下标对应键值对中的键值。 |
1902| toString(): String | 获取包含容器中所有键和值的字符串。 |
1903| getValueAt(index: number): T | 查找指定下标元素键值对中的Value值,失败返回undefined。 |
1904| forEach(callbackFn: (value: T, index?: number, PlainArray?: PlainArray<T>) => void,thisArg?: Object): void |
1905通过回调函数来遍历实例对象上的元素以及元素对应的下标。 |
1906| [Symbol.iterator](): IterableIterator<[number, T]> | 返回一个包含key-value键值对的迭代器对象,其中key是number类型。 |
1907| add(element: T): boolean | 在队列尾部插入元素。 |
1908| getFirst(): T | 获取队列的头元素。 |
1909| pop(): T | 删除头元素并返回该删除元素。 |
1910| forEach(callbackFn: (value: T, index?: number, Queue?: Queue<T>) => void, thisArg?: Object): void; |
1911通过回调函数来遍历Queue实例对象上的元素以及元素对应的下标。 |
1912| [Symbol.iterator](): IterableIterator<T> | 返回一个迭代器,迭代器的每一项都是一个 JavaScript 对象,并返回该对象。 |
1913| isEmpty(): boolean | 判断该栈是否为空。 |
1914| peek(): T | 获取并返回栈顶元素。 |
1915| pop(): T | 删除栈顶元素并返回该删除元素。 |
1916| push(item: T): T | 在栈顶插入元素,并返回该元素。 |
1917| locate(element: T): number | 返回指定元素第一次出现时的下标值,查找失败返回-1。 |
1918| forEach(callbackFn: (value: T, index?: number, stack?: Stack<T>) => void,thisArg?: Object): void |
1919通过回调函数来遍历Stack实例对象上的元素以及元素对应的下标。 |
1920| [Symbol.iterator](): IterableIterator<T> | 返回一个迭代器,迭代器的每一项都是一个 JavaScript 对象,并返回该对象。 |
1921| isEmpty(): boolean | 判断该容器是否为空。 |
1922| hasKey(key: K): boolean | 判断此容器中是否含有该指定key。 |
1923| hasValue(value: V): boolean | 判断此容器中是否含有该指定value。 |
1924| get(key: K): V | 获取指定key所对应的value。 |
1925| getFirstKey(): K | 获取容器中排序第一的key。 |
1926| getLastKey(): K | 获取容器中排序最后的key。 |
1927| setAll(map: TreeMap<K, V>): void | 将一个TreeMap中的所有元素组添加到另一个TreeMap中。 |
1928| set(key: K, value: V): Object | 向容器中添加一组数据。 |
1929| remove(key: K): V | 删除指定key对应的元素。 |
1930| clear(): void | 清除容器中的所有元素,并把length置为0。 |
1931| getLowerKey(key: K): K | 获取容器中比传入key排序靠前一位的key。 |
1932| getHigherKey(key: K): K | 获取容器中比传入key排序靠后一位的key。 |
1933| keys(): IterableIterator<K> | 返回包含此映射中包含的键的新迭代器对象。 |
1934| values(): IterableIterator<V> | 返回包含此映射中键值对的新迭代器对象。 |
1935| replace(key: K, newValue: V): boolean | 对容器中一组数据进行更新(替换)。 |
1936| forEach(callbackFn: (value?: V, key?: K, map?: TreeMap<K, V>) => void, thisArg?: Object): void; |
1937通过回调函数来遍历实例对象上的元素以及元素对应的下标。 |
1938| entries(): IterableIterator<[K, V]> | 返回包含此映射中键值对的新迭代器对象。 |
1939| [Symbol.iterator](): IterableIterator<[K, V]> | 返回一个迭代器,迭代器的每一项都是一个JavaScript对象,并返回该对象。 |
1940| isEmpty(): boolean | 判断该容器是否为空。 |
1941| has(value: T): boolean | 判断此容器中是否含有该指定元素。 |
1942| add(value: T): boolean | 向容器中添加一组数据。 |
1943| remove(value: T): boolean | 删除指定的元素。 |
1944| clear(): void | 清除容器中的所有元素,并把length置为0。 |
1945| getFirstValue(): T | 获取容器中排序第一的数据。 |
1946| getLastValue(): T | 获取容器中排序最后的数据。 |
1947| getLowerValue(key: T): T | 获取容器中比传入元素排序靠前一位的元素。 |
1948| getHigherValue(key: T): T | 获取容器中比传入元素排序靠后一位的元素。 |
1949| popFirst(): T | 删除容器中排序最前的数据。 |
1950| popLast(): T | 删除容器中排序最后的数据。 |
1951| forEach(callbackFn: (value?: T, key?: T, set?: TreeSet<T>) => void, thisArg?: Object): void; |
1952通过回调函数来遍历实例对象上的元素以及元素对应的下标。 |
1953| values(): IterableIterator<T> | 返回包含此映射中键值对的新迭代器对象。 |
1954| entries(): IterableIterator<[T, T]> | 返回包含此映射中键值对的新迭代器对象。 |
1955| [Symbol.iterator](): IterableIterator<T> | 返回一个迭代器,迭代器的每一项都是一个JavaScript对象,并返回该对象。 |
1956
1957printf中每个说明符都替换为来自相应参数的转换后的值。 支持的说明符有:
1958| 式样化字符 | 式样要求 |
1959| -------- | -------- |
1960|    %s:  | String 将用于转换除 BigInt、Object 和 -0 之外的所有值。|
1961|    %d:  | Number 将用于转换除 BigInt 和 Symbol 之外的所有值。|
1962|    %i:  | parseInt(value, 10) 用于除 BigInt 和 Symbol 之外的所有值。|
1963|    %f:  | parseFloat(value) 用于除 Symbol 之外的所有值。|
1964|    %j:  | JSON。 如果参数包含循环引用,则替换为字符串 '[Circular]'。|
1965|    %o:  | Object. 具有通用 JavaScript 对象格式的对象的字符串表示形式。类似于具有选项 { showHidden: true, showProxy: true } 的 util.inspect()。这将显示完整的对象,包括不可枚举的属性和代理。|
1966|    %O:  | Object. 具有通用 JavaScript 对象格式的对象的字符串表示形式。类似于没有选项的 util.inspect()。 这将显示完整的对象,但不包括不可枚举的属性和代理。|
1967|    %c:  | 此说明符被忽略,将跳过任何传入的 CSS 。|
1968|    %%:  | 单个百分号 ('%')。 这不消耗待式样化参数。|
1969
1970#### 2.3.2. 使用说明
1971各接口使用方法如下:
1972
19731.readonly encoding()
1974
1975```
1976import util from '@ohos.util'
1977var textEncoder = new util.TextEncoder();
1978var getEncoding = textEncoder.encoding();
1979```
19802.encode()
1981```
1982import util from '@ohos.util'
1983var textEncoder = new util.TextEncoder();
1984var result = textEncoder.encode('abc');
1985```
19863.encodeInto()
1987```
1988import util from '@ohos.util'
1989var textEncoder = new util.TextEncoder();
1990var obj = textEncoder.encodeInto('abc', dest);
1991```
19924.textDecoder()
1993```
1994import util from '@ohos.util'
1995var textDecoder = new util.textDecoder("utf-16be", {fatal : true, ignoreBOM : false});
1996```
19975.readonly encoding()
1998```
1999import util from '@ohos.util'
2000var textDecoder = new util.textDecoder("utf-16be", {fatal : true, ignoreBOM : false});
2001var getEncoding = textDecoder.encoding();
2002```
20036.readonly fatal()
2004```
2005import util from '@ohos.util'
2006var textDecoder = new util.textDecoder("utf-16be", {fatal : true, ignoreBOM : false});
2007var fatalStr = textDecoder.fatal();
2008```
20097.readonly ignoreBOM()
2010```
2011import util from '@ohos.util'
2012var textDecoder = new util.textDecoder("utf-16be", {fatal : true, ignoreBOM : false});
2013var ignoreBom = textDecoder.ignoreBOM();
2014```
20158.decode()
2016```
2017import util from '@ohos.util'
2018var textDecoder = new util.textDecoder("utf-16be", {fatal : true, ignoreBOM : false});
2019var result = textDecoder.decode(input, {stream : true});
2020```
20219.decodeWithStream()
2022```
2023import util from '@ohos.util'
2024var textDecoder = new util.textDecoder("utf-16be", {fatal : true, ignoreBOM : false});
2025var result = textDecoder.decodeWithStream(input, {stream : true});
2026```
202710.printf()
2028```
2029import util from '@ohos.util'
2030var format = "%%%o%%%i%s";
2031var value =  function aa(){};
2032var value1 = 1.5;
2033var value2 = "qwer";
2034var result = util.printf(format,value,value1,value2);
2035```
203611.getErrorString()
2037```
2038import util from '@ohos.util'
2039var errnum = 13;
2040var result = util.getErrorString(errnum);
2041```
204212.callbackWrapper()
2043```
2044import util from '@ohos.util'
2045async function promiseFn() {
2046    return Promise.resolve('value');
2047};
2048var cb = util.callbackWrapper(promiseFn);
2049cb((err, ret) => {
2050    expect(err).strictEqual(null);
2051    expect(ret).strictEqual('value');
2052})
2053```
205413.promiseWrapper()
2055```
2056import util from '@ohos.util'
2057function aysnFun(str1, str2, callback) {
2058    if (typeof str1 === 'string' && typeof str1 === 'string') {
2059        callback(null, str1 + str2);
2060    } else {
2061        callback('type err');
2062    }
2063}
2064let newPromiseObj = util.promiseWrapper(aysnFun)("Hello", 'World');
2065newPromiseObj.then(res => {
2066    expect(res).strictEqual('HelloWorld');
2067})
2068```
206914.encodeSync()
2070```
2071import util from '@ohos.util'
2072var that = new util.Base64();
2073var array = new Uint8Array([115,49,51]);
2074var result = that.encodeSync(array);
2075```
207615.encodeToStringSync()
2077```
2078import util from '@ohos.util'
2079var that = new util.Base64();
2080var array = new Uint8Array([115,49,51]);
2081var result = that.encodeToStringSync(array);
2082```
208316.decodeSync()
2084```
2085import util from '@ohos.util'
2086var that = new util.Base64()
2087var buff = 'czEz';
2088var result = that.decodeSync(buff);
2089
2090```
209117.encode()
2092```
2093import util from '@ohos.util'
2094var that = new util.Base64()
2095var array = new Uint8Array([115,49,51]);
2096await that.encode(array).then(val=>{
2097})
2098done()
2099```
210018.encodeToString()
2101```
2102import util from '@ohos.util'
2103var that = new util.Base64()
2104var array = new Uint8Array([115,49,51]);
2105await that.encodeToString(array).then(val=>{
2106})
2107done()
2108```
210919.decode()
2110```
2111import util from '@ohos.util'
2112var that = new util.Base64()
2113var buff = 'czEz';
2114await that.decode(buff).then(val=>{
2115})
2116done()
2117```
211820.createRationalFromString()
2119```
2120import util from '@ohos.util'
2121var pro = new util.RationalNumber(0, 0);
2122var res = pro.createRationalFromString("-1:2");
2123var result1 = res.valueOf();
2124```
212521.compareTo()
2126```
2127import util from '@ohos.util'
2128var pro = new util.RationalNumber(2, 1);
2129var proc = new util.RationalNumber(3, 4);
2130var res = pro.compareTo(proc);
2131```
213222.equals()
2133```
2134import util from '@ohos.util'
2135var pro = new util.RationalNumber(2, 1);
2136var proc = new util.RationalNumber(3, 4);
2137var res = pro.equals(proc);
2138```
213923.valueOf()
2140```
2141import util from '@ohos.util'
2142var pro = new util.RationalNumber(2, 1);
2143var res = pro.valueOf();
2144```
214524.getCommonDivisor()
2146```
2147import util from '@ohos.util'
2148var pro = new util.RationalNumber(0, 0);
2149var res = pro.getCommonDivisor(4, 8);
2150```
215125.getDenominator()
2152```
2153import util from '@ohos.util'
2154var pro = new util.RationalNumber(2, 1);
2155var res = pro.getDenominator();
2156```
215726.getNumerator()
2158```
2159import util from '@ohos.util'
2160var pro = new util.RationalNumber(-2, 1);
2161var res = pro.getNumerator();
2162```
216327.isFinite()
2164```
2165import util from '@ohos.util'
2166var pro = new util.RationalNumber(-2, 1);
2167var res = pro.isFinite();
2168```
216928.isNaN()
2170```
2171import util from '@ohos.util'
2172var pro = new util.RationalNumber(-2, 1);
2173var res = pro.isNaN();
2174```
217529.isZero()
2176```
2177import util from '@ohos.util'
2178var pro = new util.RationalNumber(-2, 1);
2179var res = pro.isZero();
2180```
218130.toString()
2182```
2183import util from '@ohos.util'
2184var pro = new util.RationalNumber(-2, 1);
2185var res = pro.toString();
2186```
218731.updateCapacity()
2188```
2189import util from '@ohos.util'
2190var pro = new util.LruBuffer();
2191var result = pro.updateCapacity(100);
2192```
219332.toString()
2194```
2195import util from '@ohos.util'
2196var pro = new util.LruBuffer();
2197pro.put(2,10);
2198pro.get(2);
2199pro.remove(20);
2200var result = pro.toString();
2201```
220233.values()
2203```
2204import util from '@ohos.util'
2205var pro = new util.LruBuffer();
2206pro.put(2,10);
2207pro.put(2,"anhu");
2208pro.put("afaf","grfb");
2209var result = pro.values();
2210```
221134.length
2212```
2213import util from '@ohos.util'
2214var pro = new util.LruBuffer();
2215pro.put(2,10);
2216pro.put(1,8);
2217var result = pro.length;
2218```
221935.getCapacity()
2220```
2221import util from '@ohos.util'
2222var pro = new util.LruBuffer();
2223var result = pro.getCapacity();
2224```
222536.clear()
2226```
2227import util from '@ohos.util'
2228var pro = new util.LruBuffer();
2229pro.put(2,10);
2230pro.clear();
2231```
223237.getCreateCount()
2233```
2234import util from '@ohos.util'
2235var pro = new util.LruBuffer();
2236pro.put(1,8);
2237var result = pro.getCreateCount();
2238```
223938.getMissCount()
2240```
2241import util from '@ohos.util'
2242var pro = new util.LruBuffer();
2243pro.put(2,10);
2244pro.get(2)
2245var result = pro.getMissCount();
2246```
224739.getRemovalCount()
2248```
2249
2250import util from '@ohos.util'
2251var pro = new util.LruBuffer();
2252pro.put(2,10);
2253pro.updateCapacity(2);
2254pro.put(50,22);
2255var result = pro.getRemovalCount();
2256
2257```
225840.getMatchCount()
2259```
2260import util from '@ohos.util'
2261var pro = new util.LruBuffer();
2262pro.put(2,10);
2263pro.get(2);
2264var result = pro.getMatchCount();
2265```
226641.getPutCount()
2267```
2268import util from '@ohos.util'
2269var pro = new util.LruBuffer();
2270pro.put(2,10);
2271var result = pro.getPutCount();
2272```
227342.isEmpty()
2274```
2275import util from '@ohos.util'
2276var pro = new util.LruBuffer();
2277pro.put(2,10);
2278var result = pro.isEmpty();
2279```
228043.get()
2281
2282```
2283import util from '@ohos.util'
2284var pro = new util.LruBuffer();
2285pro.put(2,10);
2286var result = pro.get(2);
2287```
228844.put()
2289```
2290import util from '@ohos.util'
2291var pro = new util.LruBuffer();
2292var result = pro.put(2,10);
2293```
229445.keys()
2295```
2296import util from '@ohos.util'
2297var pro = new util.LruBuffer();
2298pro.put(2,10);
2299var result = pro.keys();
2300```
230146.remove()
2302```
2303import util from '@ohos.util'
2304var pro = new util.LruBuffer();
2305pro.put(2,10);
2306var result = pro.remove(20);
2307```
230847.contains()
2309```
2310import util from '@ohos.util'
2311var pro = new util.LruBuffer();
2312pro.put(2,10);
2313var result = pro.contains(20);
2314```
231548.createDefault()
2316```
2317import util from '@ohos.util'
2318var pro = new util.LruBuffer();
2319var result = pro.createDefault(50);
2320```
232149.entries()
2322```
2323import util from '@ohos.util'
2324var pro = new util.LruBuffer();
2325pro.put(2,10);
2326var result = pro.entries();
2327```
232850.\[Symbol.iterator\]()
2329```
2330import util from '@ohos.util'
2331var pro = new util.LruBuffer();
2332pro .put(2,10);
2333var result = pro[symbol.iterator]();
2334```
233551.afterRemoval()
2336```
2337import util from '@ohos.util'
2338var arr = [ ];
2339class ChildLruBuffer extends util.LruBuffer
2340{
2341    constructor()
2342    {
2343        super();
2344    }
2345    static getInstance()
2346    {
2347        if(this.instance ==  null)
2348        {
2349            this.instance = new ChildLruBuffer();
2350        }
2351        return this.instance;
2352    }
2353    afterRemoval(isEvict, key, value, newValue)
2354    {
2355        if (isEvict === false)
2356        {
2357            arr = [key, value, newValue];
2358        }
2359    }
2360}
2361ChildLruBuffer.getInstance().afterRemoval(false,10,30,null)
2362```
2363Scope接口中构造新类,实现compareTo方法。
2364
2365```
2366class Temperature {
2367    constructor(value) {
2368        this._temp = value;
2369    }
2370    compareTo(value) {
2371        return this._temp >= value.getTemp();
2372    }
2373    getTemp() {
2374        return this._temp;
2375    }
2376    toString() {
2377        return this._temp.toString();
2378    }
2379}
2380```
2381
238252.constructor()
2383
2384```
2385var tempLower = new Temperature(30);
2386var tempUpper = new Temperature(40);
2387var range = new Scope(tempLower, tempUpper);
2388```
2389
239053.toString()
2391
2392```
2393var tempLower = new Temperature(30);
2394var tempUpper = new Temperature(40);
2395var range = new Scope(tempLower, tempUpper);
2396var result = range.toString() // => [30,40]
2397```
2398
239954.intersect()
2400
2401```
2402var tempLower = new Temperature(30);
2403var tempUpper = new Temperature(40);
2404var range = new Scope(tempLower, tempUpper);
2405var tempMiDF = new Temperature(35);
2406var tempMidS = new Temperature(39);
2407var rangeFir = new Scope(tempMiDF, tempMidS);
2408var result = range.intersect(rangeFir)  // => [35,39]
2409```
2410
241155.intersect()
2412
2413```
2414var tempLower = new Temperature(30);
2415var tempUpper = new Temperature(40);
2416var tempMiDF = new Temperature(35);
2417var tempMidS = new Temperature(39);
2418var range = new Scope(tempLower, tempUpper);
2419var result = range.intersect(tempMiDF, tempMidS)  // => [35,39]
2420```
2421
242256.getUpper()
2423
2424```
2425var tempLower = new Temperature(30);
2426var tempUpper = new Temperature(40);
2427var range = new Scope(tempLower, tempUpper);
2428var result = range.getUpper() // => 40
2429```
2430
243157.getLower()
2432
2433```
2434var tempLower = new Temperature(30);
2435var tempUpper = new Temperature(40);
2436var range = new Scope(tempLower, tempUpper);
2437var result = range.getLower() // => 30
2438```
2439
244058.expand()
2441
2442```
2443var tempLower = new Temperature(30);
2444var tempUpper = new Temperature(40);
2445var tempMiDF = new Temperature(35);
2446var tempMidS = new Temperature(39);
2447var range = new Scope(tempLower, tempUpper);
2448var result = range.expand(tempMiDF, tempMidS)  // => [30,40]
2449```
2450
245159.expand()
2452
2453```
2454var tempLower = new Temperature(30);
2455var tempUpper = new Temperature(40);
2456var tempMiDF = new Temperature(35);
2457var tempMidS = new Temperature(39);
2458var range = new Scope(tempLower, tempUpper);
2459var rangeFir = new Scope(tempMiDF, tempMidS);
2460var result = range.expand(rangeFir) // => [30,40]
2461```
2462
246360.expand()
2464
2465```
2466var tempLower = new Temperature(30);
2467var tempUpper = new Temperature(40);
2468var tempMiDF = new Temperature(35);
2469var range = new Scope(tempLower, tempUpper);
2470var result = range.expand(tempMiDF)  // => [30,40]
2471```
2472
247361.contains()
2474
2475```
2476var tempLower = new Temperature(30);
2477var tempUpper = new Temperature(40);
2478var tempMiDF = new Temperature(35);
2479var range = new Scope(tempLower, tempUpper);
2480var result = range.contains(tempMiDF) // => true
2481```
2482
248362.contains()
2484
2485```
2486var tempLower = new Temperature(30);
2487var tempUpper = new Temperature(40);
2488var range = new Scope(tempLower, tempUpper);
2489var tempLess = new Temperature(20);
2490var tempMore = new Temperature(45);
2491var rangeSec = new Scope(tempLess, tempMore);
2492var result = range.contains(rangeSec) // => true
2493```
2494
249563.clamp()
2496
2497```
2498var tempLower = new Temperature(30);
2499var tempUpper = new Temperature(40);
2500var tempMiDF = new Temperature(35);
2501var range = new Scope(tempLower, tempUpper);
2502var result = range.clamp(tempMiDF) // => 35
2503```
250464.isAnyArrayBuffer()
2505```
2506import util from '@ohos.util'
2507var proc = new util.Types();
2508var result = proc.isAnyArrayBuffer(new ArrayBuffer([]))
2509```
251065.isArrayBufferView()
2511```
2512import util from '@ohos.util'
2513var proc = new util.Types();
2514var result = proc.isArrayBufferView(new DataView(new ArrayBuffer(16)));
2515```
251666.isArgumentsObject()
2517```
2518import util from '@ohos.util'
2519function foo() {
2520        var result = proc.isArgumentsObject(arguments);
2521    }
2522var f = foo();
2523```
252467.isArrayBuffer()
2525```
2526import util from '@ohos.util'
2527var proc = new util.Types();
2528var result = proc.isArrayBuffer(new ArrayBuffer([]));
2529```
253068.isAsyncFunction()
2531```
2532import util from '@ohos.util'
2533var proc = new util.Types();
2534var result = proc.isAsyncFunction(async function foo() {});
2535```
253669.isBigInt64Array()
2537```
2538import util from '@ohos.util'
2539var proc = new util.Types();
2540var result = proc.isBigInt64Array(new Int16Array([]));
2541```
254270.isBigUint64Array()
2543```
2544import util from '@ohos.util'
2545var proc = new util.Types();
2546var result = proc.isBigUint64Array(new Int16Array([]));
2547```
254871.isBooleanObject()
2549```
2550import util from '@ohos.util'
2551var proc = new util.Types();
2552var result = proc.isBooleanObject(new Boolean(false));
2553```
255472.isBoxedPrimitive()
2555```
2556import util from '@ohos.util'
2557var proc = new util.Types();
2558var result = proc.isBoxedPrimitive(new Boolean(false));
2559```
256073.isDataView()
2561```
2562import util from '@ohos.util'
2563var proc = new util.Types();
2564const ab = new ArrayBuffer(20);
2565var result = proc.isDataView(new DataView(ab));
2566```
256774.isDate()
2568```
2569import util from '@ohos.util'
2570var proc = new util.Types();
2571var result = proc.isDate(new Date());
2572```
257375.isExternal()
2574```
2575import util from '@ohos.util'
2576const data = util.createExternalType();
2577var reult13 = proc.isExternal(data);
2578```
257976.isFloat32Array()
2580```
2581import util from '@ohos.util'
2582var proc = new util.Types();
2583var result = proc.isFloat32Array(new Float32Array([]));
2584```
258577.isFloat64Array()
2586```
2587import util from '@ohos.util'
2588var proc = new util.Types();
2589var result = proc.isFloat64Array(new Float64Array([]));
2590```
259178.isGeneratorFunction()
2592```
2593import util from '@ohos.util'
2594var proc = new util.Types();
2595var result = proc.isGeneratorFunction(function* foo() {});
2596```
259779.isGeneratorObject()
2598```
2599import util from '@ohos.util'
2600var proc = new util.Types();
2601function* foo() {}
2602const generator = foo();
2603var result = proc.isGeneratorObject(generator);
2604```
260580.isInt8Array()
2606```
2607import util from '@ohos.util'
2608var proc = new util.Types();
2609var result = proc.isInt8Array(new Int8Array([]));
2610```
261181.isInt16Array()
2612```
2613import util from '@ohos.util'
2614var proc = new util.Types();
2615var result = proc.isInt16Array(new Int16Array([]));
2616```
261782.isInt32Array()
2618```
2619import util from '@ohos.util'
2620var proc = new util.Types();
2621var result = proc.isInt32Array(new Int32Array([]));
2622```
262383.isMap()
2624```
2625import util from '@ohos.util'
2626var proc = new util.Types();
2627var result = proc.isMap(new Map());
2628```
262984.isMapIterator()
2630```
2631import util from '@ohos.util'
2632var proc = new util.Types();
2633var result = proc.isMapIterator(map.keys());
2634```
263585.isModuleNamespaceObject()
2636```
2637import util from '@ohos.util'
2638var proc = new util.Types();
2639var result = proc.isModuleNamespaceObject(util);
2640```
264186.isNativeError()
2642```
2643import util from '@ohos.util'
2644var proc = new util.Types();
2645var result = proc.isNativeError(new TypeError());
2646```
264787.isNumberObject()
2648```
2649import util from '@ohos.util'
2650var proc = new util.Types();
2651var result = proc.isNumberObject(new Number(0));
2652```
265388.isPromise()
2654```
2655import util from '@ohos.util'
2656var proc = new util.Types();
2657var result = proc.isPromise(Promise.resolve(42));
2658```
265989.isProxy()
2660```
2661import util from '@ohos.util'
2662var proc = new util.Types();
2663const target = {};
2664const proxy = new Proxy(target, {});
2665var result = proc.isProxy(proxy);
2666```
266790.isRegExp()
2668```
2669import util from '@ohos.util'
2670var proc = new util.Types();
2671var result = proc.isRegExp(new RegExp('abc'));
2672```
267391.isSet()
2674```
2675import util from '@ohos.util'
2676var proc = new util.Types();
2677var result = proc.isSet(new Set());
2678```
267992.isSetIterator()
2680```
2681import util from '@ohos.util'
2682var proc = new util.Types();
2683const set = new Set();
2684var result = proc.isSetIterator(set.keys());
2685```
268693.isSharedArrayBuffer()
2687```
2688import util from '@ohos.util'
2689var proc = new util.Types();
2690var result = proc.isSharedArrayBuffer(new ArrayBuffer([]));
2691```
269294.isStringObject()
2693```
2694import util from '@ohos.util'
2695var proc = new util.Types();
2696var result = proc.isStringObject(new String('foo'));
2697```
269895.isSymbolObject()
2699```
2700import util from '@ohos.util'
2701var proc = new util.Types();
2702const symbols = Symbol('foo');
2703var result = proc.isSymbolObject(Object(symbols));
2704```
270596.isTypedArray()
2706```
2707import util from '@ohos.util'
2708var proc = new util.Types();
2709var result = proc.isTypedArray(new Float64Array([]));
2710```
271197.isUint8Array()
2712```
2713import util from '@ohos.util'
2714var proc = new util.Types();
2715var result = proc.isUint8Array(new Uint8Array([]));
2716```
271798.isUint8ClampedArray()
2718```
2719import util from '@ohos.util'
2720var proc = new util.Types();
2721var result = proc.isUint8ClampedArray(new Uint8ClampedArray([]));
2722```
272399.isUint16Array()
2724```
2725import util from '@ohos.util'
2726var proc = new util.Types();
2727var result = proc.isUint16Array(new Uint16Array([]));
2728```
2729100.isUint32Array()
2730```
2731import util from '@ohos.util'
2732var proc = new util.Types();
2733var result = proc.isUint32Array(new Uint32Array([]));
2734```
2735101.isWeakMap()
2736```
2737import util from '@ohos.util'
2738var proc = new util.Types();
2739var result = proc.isWeakMap(new WeakMap());
2740```
2741102.isWeakSet()
2742```
2743import util from '@ohos.util'
2744var proc = new util.Types();
2745var result = proc.isWeakSet(new WeakSet());
2746```
2747103.add()
2748```
2749import ArrayList from "@ohos.util.ArrayList"
2750let arrayList = new ArrayList();
2751let result = arrayList.add(8);
2752```
2753104.insert()
2754```
2755import ArrayList from "@ohos.util.ArrayList"
2756let arrayList = new ArrayList();
2757arrayList.add("四");
2758arrayList.add("三");
2759arrayList.add(1);
2760arrayList.add("a");
2761arrayList.insert(8, 2);
2762```
2763105.add()
2764```
2765import ArrayList from "@ohos.util.ArrayList"
2766let arrayList = new ArrayList();
2767arrayList.add("四");
2768arrayList.add("三");
2769arrayList.add(1);
2770arrayList.add("a");
2771arrayList.insert(8, 2);
2772let result = arrayList.has(8);
2773```
2774106.getIndexOf()
2775```
2776import ArrayList from "@ohos.util.ArrayList"
2777let arrayList = new ArrayList();
2778arrayList.add(1);
2779arrayList.add("三");
2780arrayList.add(1);
2781arrayList.add("a");
2782arrayList.insert(1, 2);
2783let result = arrayList.getIndexOf(1);
2784```
2785107.removeByIndex()
2786```
2787import ArrayList from "@ohos.util.ArrayList"
2788let arrayList = new ArrayList();
2789arrayList.add(1);
2790arrayList.add("三");
2791arrayList.add(1);
2792arrayList.add("a");
2793let result = arrayList.removeByIndex(2);
2794```
2795108.remove()
2796```
2797import ArrayList from "@ohos.util.ArrayList"
2798let arrayList = new ArrayList();
2799arrayList.add("四");
2800arrayList.add("三");
2801arrayList.add(1);
2802arrayList.add("a");
2803let result = arrayList.remove("三");
2804```
2805109.getLastIndexOf()
2806```
2807import ArrayList from "@ohos.util.ArrayList"
2808let arrayList = new ArrayList();
2809arrayList.add("四");
2810arrayList.add("三");
2811arrayList.add(1);
2812arrayList.add("a");
2813arrayList.add(1);
2814arrayList.add("b");
2815let result = arrayList.getLastIndexOf(1);
2816```
2817110.removeByRange()
2818```
2819import ArrayList from "@ohos.util.ArrayList"
2820let arrayList = new ArrayList();
2821arrayList.add("四");
2822arrayList.add("三");
2823arrayList.add("a");
2824arrayList.add("b");
2825arrayList.add("c");
2826arrayList.removeByRange(1, 3);
2827```
2828111.replaceAllElements()
2829```
2830import ArrayList from "@ohos.util.ArrayList"
2831let arrayList = new ArrayList();
2832arrayList.add(4);
2833arrayList.add(3);
2834arrayList.add(1);
2835arrayList.add(2);
2836arrayList.add(14);
2837arrayList.replaceAllElements((item, index) => {
2838    return (item = 2 * item);
2839});
2840```
2841112.forEach()
2842```
2843import ArrayList from "@ohos.util.ArrayList"
2844let arrayList = new ArrayList();
2845arrayList.add(4);
2846arrayList.add(3);
2847arrayList.add(1);
2848arrayList.add(2);
2849arrayList.add(14);
2850let arr = [];
2851arrayList.forEach((item, index) => {
2852    arr.push(item);
2853});
2854```
2855113.sort()
2856```
2857import ArrayList from "@ohos.util.ArrayList"
2858let arrayList = new ArrayList();
2859arrayList.add(4);
2860arrayList.add(3);
2861arrayList.add(1);
2862arrayList.add(2);
2863arrayList.add(14);
2864arrayList.sort((a, b) => a - b);
2865```
2866114.subArrayList()
2867```
2868import ArrayList from "@ohos.util.ArrayList"
2869let arrayList = new ArrayList();
2870arrayList.add(4);
2871arrayList.add(3);
2872arrayList.add(1);
2873arrayList.add(2);
2874arrayList.add(14);
2875let result = arrayList.subArrayList(0, 5);
2876```
2877115.clear()
2878```
2879import ArrayList from "@ohos.util.ArrayList"
2880let arrayList = new ArrayList();
2881arrayList.add(4);
2882arrayList.add(3);
2883arrayList.add(1);
2884arrayList.add(2);
2885arrayList.add(14);
2886arrayList.clear();
2887```
2888116.clone()
2889```
2890import ArrayList from "@ohos.util.ArrayList"
2891let arrayList = new ArrayList();
2892arrayList.add(4);
2893arrayList.add(3);
2894arrayList.add(1);
2895arrayList.add(2);
2896arrayList.add(14);
2897let res = arrayList.clone();
2898```
2899117.getCapacity()
2900```
2901import ArrayList from "@ohos.util.ArrayList"
2902let arrayList = new ArrayList();
2903arrayList.add(4);
2904arrayList.add(3);
2905arrayList.add(1);
2906arrayList.add(2);
2907arrayList.add(14);
2908let result = arrayList.getCapacity();
2909```
2910118.convertToArray()
2911```
2912import ArrayList from "@ohos.util.ArrayList"
2913let arrayList = new ArrayList();
2914arrayList.add(4);
2915arrayList.add(3);
2916arrayList.add(1);
2917arrayList.add(2);
2918arrayList.add(14);
2919let arr = arrayList.convertToArray();
2920```
2921119.isEmpty()
2922```
2923import ArrayList from "@ohos.util.ArrayList"
2924let arrayList = new ArrayList();
2925arrayList.add(4);
2926arrayList.add(3);
2927arrayList.add(1);
2928arrayList.clear();
2929let result = arrayList.isEmpty();
2930```
2931120.increaseCapacityTo()
2932```
2933import ArrayList from "@ohos.util.ArrayList"
2934let arrayList = new ArrayList();
2935arrayList.add(4);
2936arrayList.add(3);
2937arrayList.add(1);
2938arrayList.add(2);
2939arrayList.add(14);
2940arrayList.increaseCapacityTo(-1);
2941```
2942121.trimToCurrentLength()
2943```
2944import ArrayList from "@ohos.util.ArrayList"
2945let arrayList = new ArrayList();
2946arrayList.add(4);
2947arrayList.add(3);
2948arrayList.add(1);
2949arrayList.add(2);
2950arrayList.add(14);
2951arrayList.trimToCurrentLength();
2952```
2953122.insertFront()
2954```
2955import Deque from "@ohos.util.Deque"
2956let deque = new Deque();
2957deque.insertFront("一");
2958```
2959123.insertEnd()
2960```
2961import Deque from "@ohos.util.Deque"
2962let deque = new Deque();
2963let a = ["a", "b", "c"];
2964deque.insertEnd(a);
2965```
2966124.has()
2967```
2968import Deque from "@ohos.util.Deque"
2969let deque = new Deque();
2970deque.insertEnd(6);
2971let result = deque.has(6);
2972```
2973125.getFirst()
2974```
2975import Deque from "@ohos.util.Deque"
2976let deque = new Deque();
2977deque.insertFront("$");
2978let result = deque.getFirst();
2979```
2980126.getLast()
2981```
2982import Deque from "@ohos.util.Deque"
2983let deque = new Deque();
2984deque.insertFront("$");
2985let result = deque.getLast();
2986```
2987127.popFirst()
2988```
2989import Deque from "@ohos.util.Deque"
2990let deque = new Deque();
2991deque.insertFront(6);
2992let result = deque.popFirst();
2993```
2994128.popLast()
2995```
2996import Deque from "@ohos.util.Deque"
2997let deque = new Deque();
2998deque.insertFront(11);
2999let result = deque.popLast();
3000```
3001129.forEach()
3002```
3003import Deque from "@ohos.util.Deque"
3004let deque = new Deque();
3005deque.insertEnd(1);
3006deque.insertEnd(2);
3007deque.insertEnd(3);
3008let arr = [];
3009deque.forEach((item, index) => {
3010    arr.push(item);
3011});
3012```
3013130.isEmpty()
3014```
3015import HashMap from "@ohos.util.HashMap"
3016let hashMap = new HashMap();
3017hashMap.set(1, "A");
3018hashMap.set(2, "B");
3019let result = hashMap.isEmpty();
3020```
3021131.hasKey()
3022```
3023import HashMap from "@ohos.util.HashMap"
3024let hashMap = new HashMap();
3025hashMap.set(1, "A");
3026hashMap.set(2, "B");
3027hashMap.set(3, "C");
3028let result = hashMap.hasKey(3);
3029```
3030132.hasValue()
3031```
3032import HashMap from "@ohos.util.HashMap"
3033let hashMap = new HashMap();
3034hashMap.set(1, "A");
3035hashMap.set(2, "B");
3036hashMap.set(3, "C");
3037let result = hashMap.hasValue("C");
3038```
3039133.get()
3040```
3041import HashMap from "@ohos.util.HashMap"
3042let hashMap = new HashMap();
3043hashMap.set(1, "A");
3044hashMap.set(2, "B");
3045hashMap.set(3, "C");
3046let result = hashMap.get(3);
3047```
3048134.setAll()
3049```
3050import HashMap from "@ohos.util.HashMap"
3051let hashMap = new HashMap();
3052hashMap.set(1, "A");
3053hashMap.set(2, "B");
3054hashMap.set(3, "C");
3055let hashMap1 = new HashMap();
3056hashMap1.set(1, 1);
3057hashMap1.set(2, 2);
3058hashMap.setAll(hashMap1);
3059```
3060135.set()
3061```
3062import HashMap from "@ohos.util.HashMap"
3063let hashMap = new HashMap();
3064hashMap.set(1, "A");
3065hashMap.set(2, "B");
3066hashMap.set(3, "C");
3067```
3068136.remove()
3069```
3070import HashMap from "@ohos.util.HashMap"
3071let hashMap = new HashMap();
3072hashMap.set(1, "A");
3073hashMap.set(2, "B");
3074hashMap.set(3, "C");
3075let result = hashMap.remove(3);
3076```
3077137.clear()
3078```
3079import HashMap from "@ohos.util.HashMap"
3080let hashMap = new HashMap();
3081hashMap.set(1, "A");
3082hashMap.set(2, "B");
3083hashMap.set(3, "C");
3084hashMap.clear();
3085```
3086138.keys()
3087```
3088import HashMap from "@ohos.util.HashMap"
3089let hashMap = new HashMap();
3090hashMap.set(1, "A");
3091hashMap.set(2, "B");
3092hashMap.set(3, "C");
3093hashMap.set(4, "D");
3094hashMap.set(5, "E");
3095let result = hashMap.keys();
3096```
3097139.values()
3098```
3099import HashMap from "@ohos.util.HashMap"
3100let hashMap = new HashMap();
3101hashMap.set(1, "A");
3102hashMap.set(2, "B");
3103hashMap.set(3, "C");
3104hashMap.set(4, "D");
3105hashMap.set(5, "E");
3106let result = hashMap.values();
3107```
3108140.replace()
3109```
3110import HashMap from "@ohos.util.HashMap"
3111let hashMap = new HashMap();
3112hashMap.set(1, "A");
3113hashMap.set(2, "B");
3114hashMap.set(3, "C");
3115hashMap.set(4, "D");
3116hashMap.set(5, "E");
3117let result = hashMap.replace(2, "G");
3118```
3119141.forEach()
3120```
3121import HashMap from "@ohos.util.HashMap"
3122let hashMap = new HashMap();
3123hashMap.set(1, "A");
3124hashMap.set(2, "B");
3125hashMap.set(3, "C");
3126hashMap.set(4, "D");
3127hashMap.set(5, "E");
3128let vals = [];
3129let keys = [];
3130hashMap.forEach((value, key) => {
3131    keys.push(key);
3132    vals.push(value);
3133});
3134```
3135142.entries()
3136```
3137import HashMap from "@ohos.util.HashMap"
3138let hashMap = new HashMap();
3139hashMap.set(1, "A");
3140hashMap.set(2, "B");
3141hashMap.set(3, "C");
3142hashMap.set(4, "D");
3143hashMap.set(5, "E");
3144let result = hashMap.entries();
3145```
3146143.isEmpty()
3147```
3148import HashSet from "@ohos.util.HashSet"
3149let hashSet = new HashSet();
3150hashSet.add(1);
3151hashSet.add(2);
3152let result = hashSet.isEmpty();
3153```
3154144.has()
3155```
3156import HashSet from "@ohos.util.HashSet"
3157let hashSet = new HashSet();
3158hashSet.add(1);
3159hashSet.add(2);
3160let result = hashSet.has(1);
3161```
3162145.add()
3163```
3164import HashSet from "@ohos.util.HashSet"
3165let hashSet = new HashSet();
3166hashSet.add(1);
3167hashSet.add(2);
3168```
3169146.remove()
3170```
3171import HashSet from "@ohos.util.HashSet"
3172let hashSet = new HashSet();
3173hashSet.add(1);
3174hashSet.add(2);
3175let hashSet = hashSet.remove(1);
3176```
3177147.clear()
3178```
3179import HashSet from "@ohos.util.HashSet"
3180let hashSet = new HashSet();
3181hashSet.add(1);
3182hashSet.add(2);
3183hashSet.clear();
3184```
3185148.forEach()
3186```
3187import HashSet from "@ohos.util.HashSet"
3188let hashSet = new HashSet();
3189hashSet.add(1);
3190hashSet.add(2);
3191hashSet.add(3);
3192hashSet.add(4);
3193hashSet.add(5);
3194let arr = [];
3195hashSet.forEach((value, index) => {
3196    arr.push(value);
3197});
3198```
3199149.values()
3200```
3201import HashSet from "@ohos.util.HashSet"
3202let hashSet = new HashSet();
3203hashSet.add("A");
3204hashSet.add("B");
3205hashSet.add("C");
3206hashSet.add("D");
3207hashSet.add("E");
3208let res = hashSet.values();
3209```
3210150.entries()
3211```
3212import HashSet from "@ohos.util.HashSet"
3213let hashSet = new HashSet();
3214hashSet.add(1);
3215hashSet.add(2);
3216hashSet.add(3);
3217let res = hashSet.entries();
3218```
3219151.hasAll()
3220```
3221import LightWeightMap from "@ohos.util.LightWeightMap"
3222let lightWeightMap = new LightWeightMap();
3223lightWeightMap.set("a", "A");
3224lightWeightMap.set("b", "B");
3225lightWeightMap.set("c", "C");
3226lightWeightMap.set("d", "D");
3227lightWeightMap.set("e", "E");
3228let lightWeightMap1 = new LightWeightMap();
3229lightWeightMap1.set("a", "A");
3230lightWeightMap1.set("d", "D");
3231let res = lightWeightMap.hasAll(lightWeightMap1);
3232```
3233152.hasKey()
3234```
3235import LightWeightMap from "@ohos.util.LightWeightMap"
3236let lightWeightMap = new LightWeightMap();
3237lightWeightMap.set("a", "A");
3238lightWeightMap.set("b", "B");
3239lightWeightMap.set("c", "C");
3240let res = lightWeightMap.hasKey("a");
3241```
3242153.hasValue()
3243```
3244import LightWeightMap from "@ohos.util.LightWeightMap"
3245let lightWeightMap = new LightWeightMap();
3246lightWeightMap.set("a", "A");
3247lightWeightMap.set("b", "B");
3248lightWeightMap.set("c", "C");
3249let res = lightWeightMap.hasValue("A");
3250```
3251154.increaseCapacityTo()
3252```
3253import LightWeightMap from "@ohos.util.LightWeightMap"
3254let lightWeightMap = new LightWeightMap();
3255lightWeightMap.set("a", "A");
3256lightWeightMap.set("b", "B");
3257lightWeightMap.set("c", "C");
3258lightWeightMap.increaseCapacityTo(3);
3259```
3260155.entries()
3261```
3262import LightWeightMap from "@ohos.util.LightWeightMap"
3263let lightWeightMap = new LightWeightMap();
3264lightWeightMap.set(1, "A");
3265lightWeightMap.set(2, "B");
3266lightWeightMap.set(3, "C");
3267let res = lightWeightMap.entries();
3268```
3269156.get()
3270```
3271import LightWeightMap from "@ohos.util.LightWeightMap"
3272let lightWeightMap = new LightWeightMap();
3273lightWeightMap.set(1, "A");
3274lightWeightMap.set(2, "B");
3275lightWeightMap.set(3, "C");
3276let res = lightWeightMap.get(1);
3277```
3278157.getIndexOfKey()
3279```
3280import LightWeightMap from "@ohos.util.LightWeightMap"
3281let lightWeightMap = new LightWeightMap();
3282lightWeightMap.set(1, "A");
3283lightWeightMap.set(2, "B");
3284lightWeightMap.set(3, "C");
3285let res = lightWeightMap.getIndexOfKey(2);
3286```
3287158.getIndexOfValue()
3288```
3289import LightWeightMap from "@ohos.util.LightWeightMap"
3290let lightWeightMap = new LightWeightMap();
3291lightWeightMap.set(1, "A");
3292lightWeightMap.set(2, "B");
3293lightWeightMap.set(3, "C");
3294lightWeightMap.set(4, "D");
3295lightWeightMap.set(5, "E");
3296lightWeightMap.setValueAt(4, "F");
3297let res = lightWeightMap.getIndexOfValue("F");
3298```
3299159.isEmpty()
3300```
3301import LightWeightMap from "@ohos.util.LightWeightMap"
3302let lightWeightMap = new LightWeightMap();
3303lightWeightMap.set(1, "A");
3304lightWeightMap.set(2, "B");
3305let res = lightWeightMap.isEmpty();
3306```
3307160.getKeyAt()
3308```
3309import LightWeightMap from "@ohos.util.LightWeightMap"
3310let lightWeightMap = new LightWeightMap();
3311lightWeightMap.set(1, "A");
3312lightWeightMap.set(2, "B");
3313lightWeightMap.set(3, "C");
3314let res = lightWeightMap.getKeyAt(1);
3315```
3316161.keys()
3317```
3318import LightWeightMap from "@ohos.util.LightWeightMap"
3319let lightWeightMap = new LightWeightMap();
3320lightWeightMap.set(1, "A");
3321lightWeightMap.set(2, "B");
3322lightWeightMap.set(3, "C");
3323let res = lightWeightMap.keys();
3324```
3325161.setAll()
3326```
3327import LightWeightMap from "@ohos.util.LightWeightMap"
3328let lightWeightMap = new LightWeightMap();
3329lightWeightMap.set(1, "A");
3330lightWeightMap.set(2, "B");
3331lightWeightMap.set(3, "C");
3332lightWeightMap.set(4, "D");
3333lightWeightMap.set(5, "E");
3334let lightWeightMap1 = new LightWeightMap();
3335lightWeightMap1.set(6, "A");
3336lightWeightMap1.set(7, "B");
3337lightWeightMap.setAll(lightWeightMap1);
3338```
3339162.set()
3340```
3341import LightWeightMap from "@ohos.util.LightWeightMap"
3342let lightWeightMap = new LightWeightMap();
3343lightWeightMap.set(1, "A");
3344lightWeightMap.set(2, "B");
3345```
3346163.remove()
3347```
3348import LightWeightMap from "@ohos.util.LightWeightMap"
3349let lightWeightMap = new LightWeightMap();
3350lightWeightMap.set(1, "A");
3351lightWeightMap.set(2, "B");
3352let res = lightWeightMap.remove(2);
3353```
3354164.removeAt()
3355```
3356import LightWeightMap from "@ohos.util.LightWeightMap"
3357let lightWeightMap = new LightWeightMap();
3358lightWeightMap.set(1, "A");
3359lightWeightMap.set(2, "B");
3360let res = lightWeightMap.removeAt(1);
3361```
3362165.clear()
3363```
3364import LightWeightMap from "@ohos.util.LightWeightMap"
3365let lightWeightMap = new LightWeightMap();
3366lightWeightMap.set(1, "A");
3367lightWeightMap.set(2, "B");
3368lightWeightMap.clear();
3369```
3370166.setValueAt()
3371```
3372import LightWeightMap from "@ohos.util.LightWeightMap"
3373let lightWeightMap = new LightWeightMap();
3374lightWeightMap.set(1, "A");
3375lightWeightMap.set(2, "B");
3376lightWeightMap.setValueAt(0, "a");
3377```
3378167.forEach()
3379```
3380import LightWeightMap from "@ohos.util.LightWeightMap"
3381let lightWeightMap = new LightWeightMap();
3382lightWeightMap.set(1, "A");
3383lightWeightMap.set(2, "B");
3384lightWeightMap.set(3, "C");
3385lightWeightMap.set(4, "D");
3386lightWeightMap.set(5, "E");
3387let arr = [];
3388lightWeightMap.forEach((value, index) => {
3389    arr.push(value);
3390});
3391```
3392168.[Symbol.iterator]()
3393```
3394import LightWeightMap from "@ohos.util.LightWeightMap"
3395let lightWeightMap = new LightWeightMap();
3396lightWeightMap.set(1, "A");
3397lightWeightMap.set(2, "B");
3398lightWeightMap.set(3, "C");
3399lightWeightMap.set(4, "D");
3400lightWeightMap.set(5, "E");
3401let iters = lightWeightMap[Symbol.iterator]();
3402```
3403169.toString()
3404```
3405import LightWeightMap from "@ohos.util.LightWeightMap"
3406let lightWeightMap = new LightWeightMap();
3407lightWeightMap.set(1, "A");
3408lightWeightMap.set(2, "B");
3409lightWeightMap.set(3, "C");
3410let res = lightWeightMap.toString();
3411```
3412170.getValueAt()
3413```
3414import LightWeightMap from "@ohos.util.LightWeightMap"
3415let lightWeightMap = new LightWeightMap();
3416lightWeightMap.set(1, "A");
3417lightWeightMap.set(2, "B");
3418lightWeightMap.set(3, "C");
3419let res = lightWeightMap.getValueAt(1);
3420```
3421171.values()
3422```
3423import LightWeightMap from "@ohos.util.LightWeightMap"
3424let lightWeightMap = new LightWeightMap();
3425lightWeightMap.set(1, "A");
3426lightWeightMap.set(2, "B");
3427lightWeightMap.set(3, "C");
3428let res = lightWeightMap.values();
3429```
3430172.add()
3431```
3432import LightWeightSet from "@ohos.util.LightWeightSet"
3433let lightWeightSet = new LightWeightSet();
3434lightWeightSet.add(1);
3435```
3436173.addAll()
3437```
3438import LightWeightSet from "@ohos.util.LightWeightSet"
3439let lightWeightSet = new LightWeightSet();
3440lightWeightSet.add(1);
3441lightWeightSet.add(2);
3442lightWeightSet.add(3);
3443lightWeightSet.add(4);
3444lightWeightSet.add(5);
3445let lightWeightSet1 = new LightWeightSet();
3446lightWeightSet1.add(6);
3447lightWeightSet1.add(7);
3448let res1 = lightWeightSet.addAll(lightWeightSet1);
3449```
3450174.hasAll()
3451```
3452import LightWeightSet from "@ohos.util.LightWeightSet"
3453let lightWeightSet = new LightWeightSet();
3454lightWeightSet.add("a");
3455lightWeightSet.add("b");
3456lightWeightSet.add("c");
3457lightWeightSet.add("e");
3458let lightWeightSet1 = new LightWeightSet();
3459lightWeightSet1.add("a");
3460lightWeightSet1.add("d");
3461let res = lightWeightSet.hasAll(lightWeightSet1);
3462```
3463175.has()
3464```
3465import LightWeightSet from "@ohos.util.LightWeightSet"
3466let lightWeightSet = new LightWeightSet();
3467lightWeightSet.add("a");
3468lightWeightSet.add("b");
3469lightWeightSet.add("c");
3470let res = lightWeightSet.has("a");
3471```
3472176.equal()
3473```
3474import LightWeightSet from "@ohos.util.LightWeightSet"
3475let lightWeightSet = new LightWeightSet();
3476lightWeightSet.add(1);
3477lightWeightSet.add(2);
3478lightWeightSet.add(3);
3479let obj = [1,2,3];
3480let res = lightWeightSet.equal(obj);
3481```
3482177.increaseCapacityTo()
3483```
3484import LightWeightSet from "@ohos.util.LightWeightSet"
3485let lightWeightSet = new LightWeightSet();
3486lightWeightSet.add(1);
3487lightWeightSet.add(2);
3488lightWeightSet.add(3);
3489let res = lightWeightSet.increaseCapacityTo(20);
3490```
3491178.getIndexOf()
3492```
3493import LightWeightSet from "@ohos.util.LightWeightSet"
3494let lightWeightSet = new LightWeightSet();
3495lightWeightSet.add(1);
3496lightWeightSet.add(2);
3497lightWeightSet.add(3);
3498let res = lightWeightSet.getIndexOf(2);
3499```
3500179.remove()
3501```
3502import LightWeightSet from "@ohos.util.LightWeightSet"
3503let lightWeightSet = new LightWeightSet();
3504lightWeightSet.add(1);
3505lightWeightSet.add(2);
3506lightWeightSet.add(3);
3507let res = lightWeightSet.remove(1);
3508```
3509180.removeAt()
3510```
3511import LightWeightSet from "@ohos.util.LightWeightSet"
3512let lightWeightSet = new LightWeightSet();
3513lightWeightSet.add(1);
3514lightWeightSet.add(2);
3515lightWeightSet.add(3);
3516let res = lightWeightSet.removeAt(1);
3517```
3518181.clear()
3519```
3520import LightWeightSet from "@ohos.util.LightWeightSet"
3521let lightWeightSet = new LightWeightSet();
3522lightWeightSet.add(1);
3523lightWeightSet.add(2);
3524lightWeightSet.add(3);
3525lightWeightSet.clear();
3526```
3527182.forEach()
3528```
3529import LightWeightSet from "@ohos.util.LightWeightSet"
3530let lightWeightSet = new LightWeightSet();
3531lightWeightSet.add(1);
3532lightWeightSet.add(2);
3533lightWeightSet.add(3);
3534lightWeightSet.add(4);
3535lightWeightSet.add(5);
3536let arr = [];
3537lightWeightSet.forEach((value, index) => {
3538    arr.push(value);
3539});
3540```
3541183.[Symbol.iterator]()
3542```
3543import LightWeightSet from "@ohos.util.LightWeightSet"
3544let lightWeightSet = new LightWeightSet();
3545lightWeightSet.add(1);
3546lightWeightSet.add(2);
3547lightWeightSet.add(3);
3548let res = lightWeightSet[Symbol.iterator]();
3549```
3550184.toString()
3551```
3552import LightWeightSet from "@ohos.util.LightWeightSet"
3553let lightWeightSet = new LightWeightSet();
3554lightWeightSet.add(1);
3555lightWeightSet.add(2);
3556lightWeightSet.add(3);
3557let res = lightWeightSet.toString();
3558```
3559185.toArray()
3560```
3561import LightWeightSet from "@ohos.util.LightWeightSet"
3562let lightWeightSet = new LightWeightSet();
3563lightWeightSet.add(1);
3564lightWeightSet.add(2);
3565lightWeightSet.add(3);
3566let res = lightWeightSet.toArray();
3567```
3568186.getValueAt()
3569```
3570import LightWeightSet from "@ohos.util.LightWeightSet"
3571let lightWeightSet = new LightWeightSet();
3572lightWeightSet.add(1);
3573lightWeightSet.add(2);
3574lightWeightSet.add(3);
3575let res = lightWeightSet.getValueAt(1);
3576```
3577187.values()
3578```
3579import LightWeightSet from "@ohos.util.LightWeightSet"
3580let lightWeightSet = new LightWeightSet();
3581lightWeightSet.add(1);
3582lightWeightSet.add(2);
3583lightWeightSet.add(3);
3584let res = lightWeightSet.values();
3585```
3586188.entries()
3587```
3588import LightWeightSet from "@ohos.util.LightWeightSet"
3589let lightWeightSet = new LightWeightSet();
3590lightWeightSet.add(1);
3591lightWeightSet.add(2);
3592lightWeightSet.add(3);
3593let res = lightWeightSet.entries();
3594```
3595189.isEmpty()
3596```
3597import LightWeightSet from "@ohos.util.LightWeightSet"
3598let lightWeightSet = new LightWeightSet();
3599lightWeightSet.add(1);
3600lightWeightSet.add(2);
3601lightWeightSet.add(3);
3602let res = lightWeightSet.isEmpty();
3603```
3604190.add()
3605```
3606import LinkedList from "@ohos.util.LinkedList"
3607let linkedList = new LinkedList();
3608linkedList.add("四");
3609```
3610191.insert()
3611```
3612import LinkedList from "@ohos.util.LinkedList"
3613let linkedList = new LinkedList();
3614linkedList.add("a");
3615linkedList.add("b");
3616linkedList.add("c");
3617linkedList.add("a");
3618linkedList.add("b");
3619let res = linkedList.insert(3, "d");
3620```
3621192.get()
3622```
3623import LinkedList from "@ohos.util.LinkedList"
3624let linkedList = new LinkedList();
3625linkedList.add("a");
3626linkedList.add("b");
3627linkedList.add("c");
3628let res1 = linkedList.get(2);
3629```
3630193.addFirst()
3631```
3632import LinkedList from "@ohos.util.LinkedList"
3633let linkedList = new LinkedList();
3634linkedList.add("a");
3635linkedList.add("b");
3636linkedList.add("c");
3637linkedList.addFirst("e");
3638```
3639194.removeFirst()
3640```
3641import LinkedList from "@ohos.util.LinkedList"
3642let linkedList = new LinkedList();
3643linkedList.add("a");
3644linkedList.add("b");
3645linkedList.add("c");
3646let res = linkedList.removeFirst();
3647```
3648195.removeLast()
3649```
3650import LinkedList from "@ohos.util.LinkedList"
3651let linkedList = new LinkedList();
3652linkedList.add("a");
3653linkedList.add("b");
3654linkedList.add("c");
3655let res = linkedList.removeLast();
3656```
3657196.has()
3658```
3659import LinkedList from "@ohos.util.LinkedList"
3660let linkedList = new LinkedList();
3661linkedList.add("a");
3662linkedList.add("b");
3663linkedList.add("c");
3664let res = linkedList.has(1);
3665```
3666197.getIndexOf()
3667```
3668import LinkedList from "@ohos.util.LinkedList"
3669let linkedList = new LinkedList();
3670linkedList.add("a");
3671linkedList.add("b");
3672linkedList.add("c");
3673let res = linkedList.getIndexOf("b");
3674```
3675198.removeByIndex()
3676```
3677import LinkedList from "@ohos.util.LinkedList"
3678let linkedList = new LinkedList();
3679linkedList.add("a");
3680linkedList.add("b");
3681linkedList.add("c");
3682let res = linkedList.removeByIndex(2);
3683```
3684199.remove()
3685```
3686import LinkedList from "@ohos.util.LinkedList"
3687let linkedList = new LinkedList();
3688linkedList.add("a");
3689linkedList.add("b");
3690linkedList.add("c");
3691let res = linkedList.remove("a");
3692```
3693200.removeFirstFound()
3694```
3695import LinkedList from "@ohos.util.LinkedList"
3696let linkedList = new LinkedList();
3697linkedList.add("a");
3698linkedList.add("b");
3699linkedList.add("c");
3700let res = linkedList.removeFirstFound("b");
3701```
3702201.removeLastFound()
3703```
3704import LinkedList from "@ohos.util.LinkedList"
3705let linkedList = new LinkedList();
3706linkedList.add("a");
3707linkedList.add("b");
3708linkedList.add("c");
3709let res = linkedList.removeLastFound("b");
3710```
3711202.getLastIndexOf()
3712```
3713import LinkedList from "@ohos.util.LinkedList"
3714let linkedList = new LinkedList();
3715linkedList.add("a");
3716linkedList.add("b");
3717linkedList.add("c");
3718linkedList.add("a");
3719linkedList.add("b");
3720linkedList.add("b");
3721let res = linkedList.getLastIndexOf("a");
3722```
3723203.getFirst()
3724```
3725import LinkedList from "@ohos.util.LinkedList"
3726let linkedList = new LinkedList();
3727linkedList.add("a");
3728linkedList.add("b");
3729linkedList.add("c");
3730linkedList.add("a");
3731linkedList.add("b");
3732linkedList.add("b");
3733let res = linkedList.getFirst();
3734```
3735204.getLast()
3736```
3737import LinkedList from "@ohos.util.LinkedList"
3738let linkedList = new LinkedList();
3739linkedList.add("a");
3740linkedList.add("b");
3741linkedList.add("c");
3742linkedList.add("a");
3743linkedList.add("b");
3744linkedList.add("b");
3745let res = linkedList.getLast();
3746```
3747205.set()
3748```
3749import LinkedList from "@ohos.util.LinkedList"
3750let linkedList = new LinkedList();
3751linkedList.add("a");
3752linkedList.add("b");
3753linkedList.add("c");
3754let res = linkedList.set(2, "d");
3755```
3756206.forEach()
3757```
3758import LinkedList from "@ohos.util.LinkedList"
3759let linkedList = new LinkedList();
3760linkedList.add(8);
3761linkedList.add("一");
3762linkedList.add("二");
3763linkedList.add(5);
3764let c = [1, 2, 3, 4];
3765linkedList.add(c);
3766linkedList.add(6);
3767linkedList.add("三");
3768linkedList.add("四");
3769let arr = [];
3770linkedList.forEach((item, index) => {
3771    arr.push(item);
3772});
3773```
3774207.clear()
3775```
3776import LinkedList from "@ohos.util.LinkedList"
3777let linkedList = new LinkedList();
3778linkedList.add("a");
3779linkedList.add("b");
3780linkedList.add("c");
3781let res = linkedList.clear();
3782```
3783208.clone()
3784```
3785import LinkedList from "@ohos.util.LinkedList"
3786let linkedList = new LinkedList();
3787linkedList.add("a");
3788linkedList.add("b");
3789linkedList.add("c");
3790let linkedList1 = linkedList.clone();
3791```
3792209.convertToArray()
3793```
3794import LinkedList from "@ohos.util.LinkedList"
3795let linkedList = new LinkedList();
3796linkedList.add(4);
3797linkedList.add(3);
3798linkedList.add(1);
3799linkedList.add(2);
3800linkedList.add(14);
3801let res = linkedList.convertToArray();
3802```
3803210.[Symbol.iterator]()
3804```
3805import LinkedList from "@ohos.util.LinkedList"
3806let linkedList = new LinkedList();
3807linkedList.add("a");
3808linkedList.add("b");
3809linkedList.add("c");
3810linkedList.addFirst("e");
3811let itr = linkedList[Symbol.iterator]();
3812```
3813211.add()
3814```
3815import List from "@ohos.util.List"
3816let list = new List();
3817list.add("四");
3818```
3819212.insert()
3820```
3821import List from "@ohos.util.List"
3822let list = new List();
3823list.add("a");
3824list.add("b");
3825list.add("c");
3826list.add("a");
3827list.add("b");
3828let res = list.insert("d", 3);
3829```
3830213.get()
3831```
3832import List from "@ohos.util.List"
3833let list = new List();
3834list.add("a");
3835list.add("b");
3836list.add("c");
3837list.add("a");
3838let res = list.set(2, "d");
3839let res1 = list.get(2);
3840```
3841214.has()
3842```
3843import List from "@ohos.util.List"
3844let list = new List();
3845list.add("a");
3846list.add("b");
3847let res = list.has(1);
3848```
3849215.getIndexOf()
3850```
3851import List from "@ohos.util.List"
3852let list = new List();
3853list.add("a");
3854list.add("b");
3855list.add("c");
3856list.add("b");
3857let res = list.getIndexOf("b");
3858```
3859216.removeByIndex()
3860```
3861import List from "@ohos.util.List"
3862let list = new List();
3863list.add("a");
3864list.add("b");
3865list.add("c");
3866list.add("b");
3867let res = list.removeByIndex(2);
3868```
3869217.remove()
3870```
3871import List from "@ohos.util.List"
3872let list = new List();
3873list.add("a");
3874list.add("b");
3875list.add("c");
3876list.add("b");
3877let res = list.remove("a");
3878```
3879218.getLastIndexOf()
3880```
3881import List from "@ohos.util.List"
3882let list = new List();
3883list.add("a");
3884list.add("b");
3885list.add("c");
3886list.add("b");
3887let res = list.getLastIndexOf("F");
3888```
3889219.getFirst()
3890```
3891import List from "@ohos.util.List"
3892let list = new List();
3893list.add("a");
3894list.add("b");
3895list.add("c");
3896list.add("b");
3897let res = list.getFirst();
3898```
3899220.getLast()
3900```
3901import List from "@ohos.util.List"
3902let list = new List();
3903list.add("a");
3904list.add("b");
3905list.add("c");
3906list.add("b");
3907let res = list.getLast();
3908```
3909221.set()
3910```
3911import List from "@ohos.util.List"
3912let list = new List();
3913list.add("a");
3914list.add("b");
3915list.add("c");
3916list.add("a");
3917let res = list.set(2, "d");
3918```
3919222.equal()
3920```
3921import List from "@ohos.util.List"
3922let list = new List();
3923let list1 = new List();
3924let res = list.equal(list1);
3925```
3926223.forEach()
3927```
3928import List from "@ohos.util.List"
3929let list = new List();
3930let num = 0;
3931list.forEach((item, index) => {
3932    num++;
3933});
3934```
3935224.sort()
3936```
3937import List from "@ohos.util.List"
3938let list = new List();
3939list.add(4);
3940list.add(3);
3941list.add(1);
3942list.sort((a, b) => a - b);
3943```
3944225.clear()
3945```
3946import List from "@ohos.util.List"
3947let list = new List();
3948list.add(4);
3949list.add(3);
3950list.add(1);
3951list.clear();
3952```
3953226.getSubList()
3954```
3955import List from "@ohos.util.List"
3956let list = new List();
3957list.add(4);
3958list.add(3);
3959list.add(1);
3960list.add(2);
3961list.add(14);
3962let res = list.getSubList(2, 4);
3963```
3964227.replaceAllElements()
3965```
3966import List from "@ohos.util.List"
3967let list = new List();
3968let num = 0;
3969list.replaceAllElements((item, index) => {
3970    num++;
3971});
3972```
3973228.convertToArray()
3974```
3975import List from "@ohos.util.List"
3976let list = new List();
3977const res = list.convertToArray();
3978```
3979229.isEmpty()
3980```
3981import List from "@ohos.util.List"
3982let list = new List();
3983let res = list.isEmpty();
3984```
3985230.[Symbol.iterator]()
3986```
3987import List from "@ohos.util.List"
3988let list = new List();
3989list.add("a");
3990list.add("b");
3991list.add("c");
3992let itr = list[Symbol.iterator]();
3993```
3994231.add()
3995```
3996import PlainArray from "@ohos.util.PlainArray"
3997let plainArray = new PlainArray();
3998plainArray.add(1, "A");
3999```
4000232.clear()
4001```
4002import PlainArray from "@ohos.util.PlainArray"
4003let plainArray = new PlainArray();
4004plainArray.add(1, "A");
4005plainArray.add(2, "B");
4006plainArray.add(3, "C");
4007plainArray.clear();
4008```
4009233.clone()
4010```
4011import PlainArray from "@ohos.util.PlainArray"
4012let plainArray = new PlainArray();
4013plainArray.add(1, "A");
4014plainArray.add(2, "B");
4015plainArray.add(3, "C");
4016let clonePlainarray = plainArray.clone();
4017```
4018234.has()
4019```
4020import PlainArray from "@ohos.util.PlainArray"
4021let plainArray = new PlainArray();
4022plainArray.add(1, "A");
4023plainArray.add(2, "B");
4024plainArray.add(3, "C");
4025let res = plainArray.has(6);
4026```
4027235.get()
4028```
4029import PlainArray from "@ohos.util.PlainArray"
4030let plainArray = new PlainArray();
4031plainArray.add(1, "A");
4032plainArray.add(2, "B");
4033plainArray.add(3, "C");
4034let value = plainArray.get(2);
4035```
4036236.getIndexOfKey()
4037```
4038import PlainArray from "@ohos.util.PlainArray"
4039let plainArray = new PlainArray();
4040plainArray.add(1, "A");
4041plainArray.add(2, "B");
4042plainArray.add(3, "C");
4043let res = plainArray.getIndexOfKey(9);
4044```
4045237.getIndexOfValue()
4046```
4047import PlainArray from "@ohos.util.PlainArray"
4048let plainArray = new PlainArray();
4049plainArray.add(1, "A");
4050plainArray.add(2, "B");
4051plainArray.add(3, "C");
4052let res = plainArray.getIndexOfValue("Asad");
4053```
4054238.isEmpty()
4055```
4056import PlainArray from "@ohos.util.PlainArray"
4057let plainArray = new PlainArray();
4058plainArray.add(1, "A");
4059plainArray.add(2, "B");
4060plainArray.add(3, "C");
4061let res = plainArray.isEmpty();
4062```
4063239.getKeyAt()
4064```
4065import PlainArray from "@ohos.util.PlainArray"
4066let plainArray = new PlainArray();
4067plainArray.add(1, "A");
4068plainArray.add(2, "B");
4069plainArray.add(3, "C");
4070let res = plainArray.getKeyAt(2);
4071```
4072240.remove()
4073```
4074import PlainArray from "@ohos.util.PlainArray"
4075let plainArray = new PlainArray();
4076plainArray.add(1, "A");
4077plainArray.add(2, "B");
4078plainArray.add(3, "C");
4079let res = plainArray.remove(2);
4080```
4081241.removeAt()
4082```
4083import PlainArray from "@ohos.util.PlainArray"
4084let plainArray = new PlainArray();
4085plainArray.add(1, "A");
4086plainArray.add(2, "B");
4087plainArray.add(3, "C");
4088let res = plainArray.removeAt(2);
4089```
4090242.removeRangeFrom()
4091```
4092import PlainArray from "@ohos.util.PlainArray"
4093let plainArray = new PlainArray();
4094plainArray.add(1, "A");
4095plainArray.add(2, "B");
4096plainArray.add(3, "C");
4097plainArray.removeRangeFrom(2, 2);
4098```
4099243.setValueAt()
4100```
4101import PlainArray from "@ohos.util.PlainArray"
4102let plainArray = new PlainArray();
4103plainArray.add(1, "A");
4104plainArray.add(2, "B");
4105plainArray.add(3, "C");
4106plainArray.setValueAt(2, "V");
4107```
4108244.toString()
4109```
4110import PlainArray from "@ohos.util.PlainArray"
4111let plainArray = new PlainArray();
4112plainArray.add(1, "A");
4113plainArray.add(2, "B");
4114plainArray.add(3, "C");
4115let res1 = plainArray.toString();
4116```
4117245.getValueAt()
4118```
4119import PlainArray from "@ohos.util.PlainArray"
4120let plainArray = new PlainArray();
4121plainArray.add(1, "A");
4122plainArray.add(2, "B");
4123plainArray.add(3, "C");
4124let res = plainArray.getValueAt(2);
4125```
4126246.forEach()
4127```
4128import PlainArray from "@ohos.util.PlainArray"
4129let plainArray = new PlainArray();
4130plainArray.add(1, "A");
4131plainArray.add(2, "B");
4132plainArray.add(3, "C");
4133let arr = [];
4134res.forEach((value, index) => {
4135    arr.push(value);
4136});
4137```
4138247.[Symbol.iterator]()
4139```
4140import PlainArray from "@ohos.util.PlainArray"
4141let plainArray = new PlainArray();
4142plainArray.add(1, "A");
4143plainArray.add(2, "B");
4144plainArray.add(3, "C");
4145let iters = plainArray[Symbol.iterator]();
4146```
4147248.add()
4148```
4149import Queue from "@ohos.util.Queue"
4150let queue = new Queue();
4151queue.add("四");
4152```
4153249.getFirst()
4154```
4155import Queue from "@ohos.util.Queue"
4156let queue = new Queue();
4157queue.add("四");
4158let res = queue.getFirst();
4159```
4160250.pop()
4161```
4162import Queue from "@ohos.util.Queue"
4163let queue = new Queue();
4164queue.add("四");
4165let res = queue.pop();
4166```
4167251.forEach()
4168```
4169import Queue from "@ohos.util.Queue"
4170let queue = new Queue();
4171queue.add(1);
4172queue.add(2);
4173queue.add(3);
4174queue.add(4);
4175queue.forEach((item, index) => {
4176    arr.push(item);
4177});
4178```
4179252.[Symbol.iterator]()
4180```
4181import Queue from "@ohos.util.Queue"
4182let queue = new Queue();
4183queue.add("四");
4184let itr = queue[Symbol.iterator]();
4185```
4186253.isEmpty()
4187```
4188import Stack from "@ohos.util.Stack"
4189let stack = new Stack();
4190stack.push(8);
4191stack.push(5);
4192let res = stack.isEmpty();
4193```
4194254.peek()
4195```
4196import Stack from "@ohos.util.Stack"
4197let stack = new Stack();
4198stack.push(1234);
4199let res = stack.peek();
4200```
4201255.pop()
4202```
4203import Stack from "@ohos.util.Stack"
4204let stack = new Stack();
4205stack.push(1234);
4206let res = stack.pop();
4207```
4208256.push()
4209```
4210import Stack from "@ohos.util.Stack"
4211let stack = new Stack();
4212stack.push(12);
4213```
4214257.locate()
4215```
4216import Stack from "@ohos.util.Stack"
4217let stack = new Stack();
4218stack.push("A");
4219stack.push("B");
4220stack.push(1);
4221let res = stack.locate("A");
4222```
4223258.forEach()
4224```
4225import Stack from "@ohos.util.Stack"
4226let stack = new Stack();
4227stack.push(8);
4228stack.push(5);
4229stack.push(c);
4230stack.push(6);
4231stack.forEach((item, index) => {
4232    arr.push(item);
4233});
4234```
4235259.[Symbol.iterator]()
4236```
4237import Stack from "@ohos.util.Stack"
4238let stack = new Stack();
4239stack.push("A");
4240stack.push("B");
4241stack.push(1);
4242let itr = stack[Symbol.iterator]();
4243```
4244260.isEmpty()
4245```
4246import TreeMap from "@ohos.util.TreeMap"
4247let treeMap = new TreeMap();
4248treeMap.set(0, "a");
4249treeMap.set(1, "b");
4250let res = treeMap.isEmpty();
4251```
4252261.hasKey()
4253```
4254import TreeMap from "@ohos.util.TreeMap"
4255let treeMap = new TreeMap();
4256treeMap.set(0, "a");
4257treeMap.set(1, "b");
4258let res = treeMap.hasKey(1);
4259```
4260262.hasValue()
4261```
4262import TreeMap from "@ohos.util.TreeMap"
4263let treeMap = new TreeMap();
4264treeMap.set(0, "a");
4265treeMap.set(1, "b");
4266let res = treeMap.hasValue("a");
4267```
4268263.get()
4269```
4270import TreeMap from "@ohos.util.TreeMap"
4271let treeMap = new TreeMap();
4272treeMap.set(0, "a");
4273treeMap.set(1, "b");
4274let res = treeMap.get(1);
4275```
4276264.getFirstKey()
4277```
4278import TreeMap from "@ohos.util.TreeMap"
4279let treeMap = new TreeMap();
4280treeMap.set(0, "a");
4281treeMap.set(1, "b");
4282let res = treeMap.getFirstKey();
4283```
4284265.getLastKey()
4285```
4286import TreeMap from "@ohos.util.TreeMap"
4287let treeMap = new TreeMap();
4288treeMap.set(0, "a");
4289treeMap.set(1, "b");
4290let res = treeMap.getLastKey();
4291```
4292266.setAll()
4293```
4294import TreeMap from "@ohos.util.TreeMap"
4295let treeMap = new TreeMap();
4296treeMap.set(0, "a");
4297treeMap.set(1, "b");
4298let treeMap1 = new TreeMap();
4299treeMap1.set(0, "a");
4300treeMap1.set(1, "b");
4301treeMap1.set(2, "c");
4302treeMap.setAll(treeMap1);
4303```
4304267.set()
4305```
4306import TreeMap from "@ohos.util.TreeMap"
4307let treeMap = new TreeMap();
4308treeMap.set(0, "a");
4309treeMap.set(1, "b");
4310```
4311268.remove()
4312```
4313import TreeMap from "@ohos.util.TreeMap"
4314let treeMap = new TreeMap();
4315treeMap.set(0, "a");
4316treeMap.set(1, "b");
4317let res = treeMap.remove(1);
4318```
4319269.clear()
4320```
4321import TreeMap from "@ohos.util.TreeMap"
4322let treeMap = new TreeMap();
4323treeMap.set(0, "a");
4324treeMap.set(1, "b");
4325treeMap.clear();
4326```
4327270.getLowerKey()
4328```
4329import TreeMap from "@ohos.util.TreeMap"
4330let treeMap = new TreeMap();
4331treeMap.set(0, "a");
4332treeMap.set(1, "b");
4333let res = treeMap.getLowerKey(1);
4334```
4335271.getHigherKey()
4336```
4337import TreeMap from "@ohos.util.TreeMap"
4338let treeMap = new TreeMap();
4339treeMap.set(0, "a");
4340treeMap.set(1, "b");
4341let res = treeMap.getHigherKey(1);
4342```
4343272.keys()
4344```
4345import TreeMap from "@ohos.util.TreeMap"
4346let treeMap = new TreeMap();
4347treeMap.set(0, "a");
4348treeMap.set(1, "b");
4349let res = treeMap.keys();
4350```
4351273.values()
4352```
4353import TreeMap from "@ohos.util.TreeMap"
4354let treeMap = new TreeMap();
4355treeMap.set(0, "a");
4356treeMap.set(1, "b");
4357let res = treeMap.values();
4358```
4359274.replace()
4360```
4361import TreeMap from "@ohos.util.TreeMap"
4362let treeMap = new TreeMap();
4363treeMap.set(0, "a");
4364treeMap.set(1, "b");
4365let res = treeMap.replace(1, "B");
4366```
4367275.forEach()
4368```
4369import TreeMap from "@ohos.util.TreeMap"
4370let treeMap = new TreeMap();
4371treeMap.set(0, "a");
4372treeMap.set(1, "b");
4373treeMap.set(2, "c");
4374treeMap.set(3, "d");
4375treeMap.set(4, "g");
4376let arr1 = [];
4377treeMap.forEach((value, key) => {
4378    arr1.push(value);
4379});
4380```
4381276.entries()
4382```
4383import TreeMap from "@ohos.util.TreeMap"
4384let treeMap = new TreeMap();
4385treeMap.set(0, "a");
4386treeMap.set(1, "b");
4387treeMap.set(2, "c");
4388let entries = treeMap.entries();
4389```
4390277.[Symbol.iterator]()
4391```
4392import TreeMap from "@ohos.util.TreeMap"
4393let treeMap = new TreeMap();
4394treeMap.set(0, "a");
4395treeMap.set(1, "b");
4396treeMap.set(2, "c");
4397let iters = treeMap[Symbol.iterator]();
4398```
4399278.isEmpty()
4400```
4401import TreeSet from "@ohos.util.TreeSet"
4402let treeSet = new TreeSet();
4403treeSet.add("a");
4404let res = treeSet.isEmpty();
4405```
4406279.has()
4407```
4408import TreeSet from "@ohos.util.TreeSet"
4409let treeSet = new TreeSet();
4410treeSet.add("a");
4411treeSet.add("b");
4412treeSet.add("c");
4413let res = treeSet.has("c");
4414```
4415280.add()
4416```
4417import TreeSet from "@ohos.util.TreeSet"
4418let treeSet = new TreeSet();
4419treeSet.add("a");
4420treeSet.add("b");
4421treeSet.add("c");
4422```
4423281.remove()
4424```
4425import TreeSet from "@ohos.util.TreeSet"
4426let treeSet = new TreeSet();
4427treeSet.add("a");
4428treeSet.add("b");
4429treeSet.add("c");
4430let res = treeSet.remove("c");
4431```
4432282.clear()
4433```
4434import TreeSet from "@ohos.util.TreeSet"
4435let treeSet = new TreeSet();
4436treeSet.add("a");
4437treeSet.add("b");
4438treeSet.add("c");
4439treeSet.clear();
4440```
4441283.getFirstValue()
4442```
4443import TreeSet from "@ohos.util.TreeSet"
4444let treeSet = new TreeSet();
4445treeSet.add("a");
4446treeSet.add("b");
4447treeSet.add("c");
4448let res = treeSet.getFirstValue();
4449```
4450284.getLastValue()
4451```
4452import TreeSet from "@ohos.util.TreeSet"
4453let treeSet = new TreeSet();
4454treeSet.add("a");
4455treeSet.add("b");
4456treeSet.add("c");
4457let res = treeSet.getLastValue();
4458```
4459285.getLowerValue()
4460```
4461import TreeSet from "@ohos.util.TreeSet"
4462let treeSet = new TreeSet();
4463treeSet.add(0);
4464treeSet.add(1);
4465treeSet.add(2);
4466treeSet.add(3);
4467let res = treeSet.getLowerValue(2);
4468```
4469286.getHigherValue()
4470```
4471import TreeSet from "@ohos.util.TreeSet"
4472let treeSet = new TreeSet();
4473treeSet.add(0);
4474treeSet.add(1);
4475treeSet.add(2);
4476treeSet.add(3);
4477let res = treeSet.getHigherValue(3);
4478```
4479287.popFirst()
4480```
4481import TreeSet from "@ohos.util.TreeSet"
4482let treeSet = new TreeSet();
4483treeSet.add(0);
4484treeSet.add(1);
4485treeSet.add(2);
4486treeSet.add(3);
4487let res = treeSet.popFirst();
4488```
4489288.popLast()
4490```
4491import TreeSet from "@ohos.util.TreeSet"
4492let treeSet = new TreeSet();
4493treeSet.add(0);
4494treeSet.add(1);
4495treeSet.add(2);
4496treeSet.add(3);
4497let res = treeSet.popLast();
4498```
4499289.forEach()
4500```
4501import TreeSet from "@ohos.util.TreeSet"
4502let treeSet = new TreeSet();
4503treeSet.add(0);
4504treeSet.add(1);
4505treeSet.add(2);
4506treeSet.add(3);
4507treeSet.add(4);
4508let arr1 = [];
4509treeSet.forEach((value, key) => {
4510    arr1.push(value);
4511});
4512```
4513290.values()
4514```
4515import TreeSet from "@ohos.util.TreeSet"
4516let treeSet = new TreeSet();
4517treeSet.add("a");
4518treeSet.add("b");
4519treeSet.add("c");
4520let res = treeSet.values();
4521```
4522291.entries()
4523```
4524import TreeSet from "@ohos.util.TreeSet"
4525let treeSet = new TreeSet();
4526treeSet.add("a");
4527treeSet.add("b");
4528treeSet.add("c");
4529let res = treeSet.entries();
4530```
4531292.[Symbol.iterator]()
4532```
4533import TreeSet from "@ohos.util.TreeSet"
4534let treeSet = new TreeSet();
4535treeSet.add("a");
4536treeSet.add("b");
4537treeSet.add("c");
4538let res = treeSet[Symbol.iterator]();
4539```
4540
4541## 3. js_sys_module子模块
4542### 3.1. 简介
4543进程主要用于获取进程的相关ID,获取和修改进程的工作目录,退出和关闭进程。 childprocess 对象可用于创建新进程。 主进程可以获取子进程的标准输入输出,发送信号,关闭子进程。
4544### 3.2. 目录
4545
4546```
4547commomlibrary/ets_utils/js_sys_module/
4548├── Class:PROCESS                   # PROCESS类
4549├── Uid                             # Uid属性
4550├── Gid                             # Gid属性
4551├── EUid                            # EUid属性
4552├── EGid                            # EGid属性
4553├── Groups                          # Groups属性
4554├── Pid                             # Pid属性
4555├── Ppid                            # Ppid属性
4556├── chdir()                         # chdir方法
4557├── uptime()                        # uptime方法
4558├── kill()                          # kill方法
4559├── abort()                         # abort方法
4560├── on()                            # on方法
4561├── tid                             # tid方法
4562├── getStartRealtime()              # getStartRealtime方法
4563├── getAvailableCores()             # getAvailableCores方法
4564├── getPastCputime()                # getPastCputime方法
4565├── isIsolatedProcess()             # isIsolatedProcess方法
4566├── is64Bit()                       # is64Bit方法
4567├── isAppUid()                      # isAppUid方法
4568├── getUidForName()                 # getUidForName方法
4569├── getThreadPriority()             # getThreadPriority方法
4570├── getSystemConfig()               # getSystemConfig方法
4571├── getEnvironmentVar()             # getEnvironmentVar方法
4572├── exit()                          # exit方法
4573├── cwd()                           # cwd方法
4574├── off()                           # off方法
4575├── runCmd()                        # runCmd方法
4576└─── Class:CHILDPROCESS             # class of CHILDPROCESS类
4577    ├── close()                     # close方法
4578    ├── kill()                      # kill方法
4579    ├── getOutput()                 # getOutput方法
4580    ├── getErrorOutput()            # getErrorOutput方法
4581    ├── wait()                      # wait方法
4582    ├── killed                      # killed属性
4583    ├── pid                         # pid属性
4584    ├── ppid                        # ppid属性
4585    └── exitCode                    # exitCode属性
4586|—— Class:CONSOLE
4587    ├── debug()                     # debug方法
4588    ├── log()                       # log方法
4589    ├── info()                      # info方法
4590    ├── warn()                      # warn方法
4591    ├── error()                     # error方法
4592    ├── assert()                    # assert方法
4593    ├── count()                     # count方法
4594    ├── countReset()                # countReset方法
4595    ├── dir()                       # dir方法
4596    ├── dirxml()                    # dirxml方法
4597    ├── group()                     # group方法
4598    ├── groupCollapsed()            # groupCollapsed方法
4599    ├── groupEnd()                  # groupEnd方法
4600    ├── table()                     # table方法
4601    ├── time()                      # time方法
4602    ├── timeEnd()                   # timeEnd方法
4603    ├── timeLog()                   # timeLog方法
4604    ├── trace()                     # trace方法
4605|—— Class:TIMER
4606    ├── setInterval()               # setInterval方法
4607    ├── setTimeout()                # setTimeout方法
4608    ├── clearInterval()             # clearInterval方法
4609    ├── clearTimeout()              # clearTimeout方法
4610```
4611
4612### 3.3. 说明
4613
4614#### 3.3.1. 接口说明
4615| 接口名 | 说明 |
4616| -------- | -------- |
4617| const uid :number | 返回进程的数字用户 ID。 |
4618| const gid :number | 返回进程的数字组 ID。 |
4619| const euid :number | 返回进程的数字有效用户身份。 |
4620| const egid :number | 返回 node.js 进程的数字有效组 ID。 |
4621| const groups :number[] |  返回具有补充组 ID 的数组。 |
4622| const pid :number | 返回进程的PID。 |
4623| const ppid :number |  返回当前进程的父进程的PID。 |
4624| chdir(dir:string) :void | 更改 node.js 进程的当前工作目录。 |
4625| uptime() :number |  返回当前系统已经运行的秒数。 |
4626| Kill(pid:number, signal:number) :boolean | 将信号发送到识别的进程PID,true表示发送成功。 |
4627| abort() :void | 导致 node.js 进程立即退出并生成核心文件。 |
4628| on(type:string ,listener:EventListener) :void | 用于存储用户触发的事件。 |
4629| exit(code:number):void | 导致 node.js 进程立即退出。 |
4630| cwd():string |  返回 node.js 进程的当前工作目录。 |
4631| off(type: string): boolean | 清除用户存储的事件。 True 表示清算成功。 |
4632| runCmd(command: string, options?: { timeout : number, killSignal : number \| string, maxBuffer : number }): ChildProcess |通过runcmd,你可以fork一个新进程来运行一个shell并返回childprocess对象。 第一个参数command指的是要运行的shell,第二个参数options指的是子进程的一些运行参数。 这些参数主要是指 timeout、killsignal 和 maxbuffer。 如果设置了timeout,则子进程会在超时后发送killsignal信号。 Maxbuffer 用于限制可以接收的最大 stdout 和 stderr 大小。 |
4633| wait(): Promise\<number> | 用于等待子进程运行并返回promise对象,其值为子进程的退出码。 |
4634| getOutput(): Promise\<Uint8Array> |  用于获取子进程的标准输出。 |
4635| getErrorOutput(): Promise\<Uint8Array> | 用于获取子进程的标准错误输出。 |
4636| const tid:number | 返回进程的 TID。 |
4637| getStartRealtime() :number | 获取从系统启动到进程启动所经过的实时时间(以毫秒为单位)。 |
4638| getAvailableCores() :number[] | 获取多核设备上当前进程可用的 CPU 内核。 |
4639| getPastCputime() :number | 获取从进程开始到当前时间的 CPU 时间(以毫秒为单位)。 |
4640| isIsolatedProcess(): boolean | 检查进程是否被隔离。 |
4641| is64Bit(): boolean | 检查进程是否在 64 位环境中运行。 |
4642| isAppUid(v:number): boolean | 检查指定的 uid 是否属于特定应用程序。 |
4643| getUidForName(v:string): number | 根据用户名获取用户所属的用户组ID |
4644| getThreadPriority(v:number): number | 根据指定的 TID 获取线程优先级。 |
4645| getSystemConfig(name:number): number | 根据指定的系统配置名称获取系统的配置。 |
4646| getEnvironmentVar(name:string): string | 根据环境变量的名称获取对应的值。 |
4647| close(): void | 用于关闭正在运行的子进程。 |
4648| kill(signal: number \| string): void |  用于向子进程发送信号。 |
4649| readonly killed: boolean | 表示信号是否发送成功,true表示信号发送成功。 |
4650| readonly exitCode: number | 表示子进程的退出代码。 |
4651| readonly pid: number | 表示子进程ID。 |
4652| readonly ppid: number | 代表主进程ID。 |
4653| debug(message: string, ...arguments: any[]): void | 打印debug信息。 |
4654| log(message: string, ...arguments: any[]): void | 打印log信息。 |
4655| info(message: string, ...arguments: any[]): void | 打印info信息。 |
4656| warn(message: string, ...arguments: any[]): void | 打印warn信息。 |
4657| error(message: string, ...arguments: any[]): void | 打印error信息。 |
4658| assert(value?: Object, ...arguments: Object[]): void | 若value为假,打印后续内容。 |
4659| count(label?: string): void | 对label名计数。 |
4660| countReset(label?: string): void | 清除label名的计数。 |
4661| dir(dir?: Object): void | 打印对象内容。 |
4662| dirxml(...arguments: Object[]): void | 打印日志。 |
4663| group(...arguments: Object[]): void | 缩进一组。 |
4664| groupCollapsed(...arguments: Object[]): void | 缩进一组。 |
4665| groupEnd(): void | 取消缩进一组。 |
4666| table(tableData?: Object): void | 以表格形式打印数据。 |
4667| time(label?: string): void | 开始计时。 |
4668| timeEnd(label?: string): void | 结束计时。 |
4669| timeLog(label?: string, ...arguments: Object[]): void | 打印当前计时。 |
4670| trace(...arguments: Object[]): void | 打印当前栈。 |
4671|  setInterval(handler: Function \| string, delay: number, ...arguments: any[]): number | 定时调用回调函数。 |
4672|  setTimeout(handler: Function \| string, delay?: number, ...arguments: any[]): number | 计时结束调用回调函数。 |
4673|  clearInterval(intervalID?: number): void | 清除定时回调。 |
4674|  clearTimeout(timeoutID?: number): void | 清除计时回调。 |
4675
4676#### 3.3.2. 使用说明
4677
4678各接口使用方法如下:
46791.uid()
4680```
4681uid(){
4682    var res =  Process.uid;
4683}
4684```
46852.gid()
4686```
4687gid(){
4688    var result = Process.gid;
4689}
4690```
46913.euid()
4692```
4693euid(){
4694    var and = Process.euid;
4695}
4696```
46974.egid()
4698```
4699egid(){
4700    var resb = Process.egid;
4701}
4702```
47035.groups()
4704```
4705groups(){
4706    var answer = Process.groups;
4707}
4708```
47096.pid()
4710```
4711pid(){
4712    var result = Process.pid;
4713}
4714```
47157.ppid()
4716```
4717ppid(){
4718    var result = Process.ppid;
4719}
4720```
47218.chdir()
4722```
4723chdir(){
4724    Process.chdir("123456");
4725}
4726```
47279.uptime()
4728```
4729uptime(){
4730    var num = Process.uptime();
4731}
4732```
473310.kill()
4734```
4735kill(){
4736    var ansu = Process.kill(5,23);
4737}
4738```
473911.abort()
4740```
4741abort(){
4742    Process.abort();
4743}
4744```
474512.on()
4746```
4747on(){
4748    function add(num){
4749        var value = num + 5;
4750        return value;
4751    }
4752    Process.on("add",add);
4753}
4754```
475513.exit()
4756```
4757exit(){
4758    Process.exit(15);
4759}
4760```
476114.Cwd()
4762```
4763Cwd(){
4764    var result = Process.cwd();
4765}
4766```
476715.off()
4768
4769```
4770off(){
4771    var result =  Process.off("add");
4772}
4773```
477416.runCmd()
4775```
4776runCmd(){
4777    var child = process.runCmd('echo abc')
4778    // killSignal can be a number or a string
4779    var child = process.runCmd('echo abc;', {killSignal : 'SIGKILL'});
4780    var child = process.runCmd('sleep 5; echo abc;', {timeout : 1, killSignal : 9, maxBuffer : 2})
4781}
4782```
478317.wait()
4784```
4785wait()
4786{
4787    var child = process.runCmd('ls')
4788    var status = child.wait();
4789    status.then(val => {
4790        console.log(val);
4791    })
4792}
4793```
479418.getOutput()
4795```
4796getOutput(){
4797    var child = process.runCmd('echo bcd;');
4798    var res = child.getOutput();
4799    child.wait();
4800    res.then(val => {
4801        console.log(val);
4802    })
4803}
4804```
480519.getErrorOutput()
4806```
4807getErrorOutput(){
4808    var child = process.runCmd('makdir 1.txt'); // execute an error command
4809    var res = child.getErrorOutput();
4810    child.wait();
4811    res.then(val => {
4812        console.log(val);
4813    })
4814}
4815```
481620.close()
4817```
4818close(){
4819    var child =  process.runCmd('ls; sleep 5s;')
4820    var result = child.close()
4821}
4822```
482321.kill()
4824```
4825kill(){
4826    var child =  process.runCmd('ls; sleep 5s;')
4827    var result = child.kill('SIGHUP');
4828    child.wait();
4829    var temp = child.killed;
4830}
4831```
483222.killed
4833```
4834{
4835    var child = process.runCmd('ls; sleep 5;')
4836    child.kill(3);
4837    var killed_ = child.killed;
4838    child.wait();
4839}
4840```
484123.exitCode
4842```
4843{
4844    var child = process.runCmd('ls; sleep 5;')
4845    child.kill(9);
4846    child.wait();
4847    var exitCode_ = child.exitCode;
4848}
4849```
485024.pid
4851```
4852pid
4853{
4854    var child = process.runCmd('ls; sleep 5;')
4855    var pid_ = child.pid;
4856    child.wait();
4857}
4858```
485925.ppid
4860```
4861ppid
4862{
4863    var child = process.runCmd('ls; sleep 5;')
4864    var ppid_ = child.ppid;
4865    child.wait();
4866}
4867```
486826.tid
4869```
4870tid(){
4871    var ansu = Process.tid;
4872}
4873```
487427.isIsolatedProcess()
4875```
4876isIsolatedProcess(){
4877    var ansu = Process.isIsolatedProcess()();
4878}
4879```
488028.isAppUid()
4881```
4882isAppUid(){
4883    var ansu = Process.isAppUid(10000);
4884}
4885```
488629.is64Bit()
4887```
4888is64Bit(){
4889    var ansu = Process.is64Bit();
4890}
4891```
489230.getUidForName()
4893```
4894getUidForName(){
4895    var buf = "root";
4896    var ansu = Process.getUidForName(buf);
4897}
4898```
489931.getEnvironmentVar()
4900```
4901getEnvironmentVar(){
4902    var ansu = Process.getEnvironmentVar('USER');
4903}
4904```
490532.getAvailableCores()
4906```
4907getAvailableCores(){
4908    var ansu = Process.getAvailableCores();
4909}
4910```
491133.getThreadPriority()
4912```
4913getThreadPriority(){
4914    var result = Process.getTid();
4915    var ansu = getThreadPriority(result);
4916}
4917```
491834.getStartRealtime()
4919```
4920getStartRealtime(){
4921    var ansu = Process.getStartRealtime();
4922}
4923```
492435.getPastCputime()
4925```
4926getPastCputime(){
4927    var ansu = Process.getPastCputime();
4928}
4929```
493036.getSystemConfig()
4931```
4932getSystemConfig(){
4933    var _SC_ARG_MAX = 0;
4934    var ansu = Process.getSystemConfig(_SC_ARG_MAX)
4935}
4936```
493737.console.debug()
4938```
4939console.debug("print debug log");
4940}
4941```
494238.console.log()
4943```
4944console.debug("print log");
4945}
4946```
494739.console.info()
4948```
4949console.debug("print info log");
4950}
4951```
495240.console.warn()
4953```
4954console.debug("print warn log");
4955}
4956```
495741.console.error()
4958```
4959console.debug("print error log");
4960}
4961```
496242.console.assert()
4963```
4964for (let number = 2; number <= 5; number++) {
4965    console.assert(number % 2 === 0, "error");
4966}
4967```
496843.console.count()
4969```
4970console.count("myObj");
4971```
497244.console.countReset()
4973```
4974console.count("myObj");
4975console.countReset("myObj");
4976```
497745.console.dir()
4978```
4979function cat(name, age, score){
4980  this.name = name;
4981  this.age = age;
4982  this.score = score;
4983}
4984var c = new cat("ohos", 2, [6,8,7]);
4985console.dir(c);
4986```
498746.console.dirxml()
4988```
4989console.xml("print log");
4990```
499147.console.group()
4992```
4993console.group();
4994```
499548.console.groupCollapsed()
4996```
4997console.groupCollapsed();
4998```
499949.console.groupEnd()
5000```
5001console.groupEnd();
5002```
500350.console.table()
5004```
5005var languages = {
5006  csharp: { name: "C#", paradigm: "undefined" },
5007  fsharp: { name: "F#", paradigm: "functional" }
5008};
5009console.table(languages);
5010```
501151.console.time()
5012```
5013console.time("timer1");
5014```
501552.console.timeEnd()
5016```
5017console.time("timer1");
5018console.timeEnd("timer1");
5019```
502053.console.timeLog()
5021```
5022console.time("timer1");
5023console.timeLog("timer1");
5024```
502554.console.trace()
5026```
5027console.trace();
5028```
502955.setInterval()
5030```
5031function callback() {
5032  console.log("setInterval");
5033};
5034setInterval(callback, 100);
5035```
503655.setTimeout()
5037```
5038function callback() {
5039  console.log("setTimeout");
5040};
5041setTimeout(callback, 100);
5042```
504355.clearInterval()
5044```
5045function callback() {
5046  console.log("clearInterval");
5047};
5048var myVar = setInterval(callback, 1000);
5049clearInterval(myVar);
5050```
505156.clearTimeout()
5052```
5053function callback() {
5054  console.log("clearTimeout");
5055};
5056var myVar = setTimeout(callback, 1000);
5057clearTimeout(myVar);
5058```
5059
5060## 4. js_concurrent_module子模块
5061
5062### 4.1. 简介
5063
5064worker能够让js拥有多线程的能力,通过postMessage完成worker线程与宿主线程通信。
5065
5066### 4.2. 接口说明
5067接口实现详见:js_concurrent_module/worker
5068
5069#### 4.2.1. Worker对象描述
5070
5071宿主线程用于与worker线程通信的Object对象。
5072
5073##### 4.2.1.1. 接口
5074
50751.
5076
5077- 接口名
5078
5079|constructor(scriptURL:string, options?:WorkerOptions) | 构造函数 |
5080|---|---|
5081
5082- 使用示例
5083
5084通过判断存放worker.ts的workers目录是否与pages目录同级(以下简称目录同级)和创建项目的模型类别,共有以下四种新建Worker的方式:
5085
5086(1) FA模型: 目录同级
5087```
5088import worker from "@ohos.worker";
5089const workerInstance = new worker.Worker("workers/worker.js", {name:"first worker"});
5090```
5091(2) FA模型: 目录不同级(以workers目录放置pages目录前一级为例)
5092```
5093import worker from "@ohos.worker";
5094const workerInstance = new worker.Worker("../workers/worker.js", {name:"first worker"});
5095```
5096(3)  Stage模型: 目录同级
5097```
5098import worker from "@ohos.worker";
5099const workerInstance = new worker.Worker('entry/ets/workers/worker.ts');
5100```
5101(4) Stage模型: 目录不同级(以workers目录放置pages目录后一级为例)
5102```
5103import worker from "@ohos.worker";
5104const workerInstance = new worker.Worker('entry/ets/pages/workers/worker.ts');
5105```
5106对于Stage模型中scriptURL——"entry/ets/workers/worker.ts"的解释:
5107- entry: 为module.json5中module中name属性的值;
5108- ets: 表明当前工程使用的语言;
5109- worker.ts: 创建worker.ts文件或者worker.js文件都可以。
5110
5111另外,需在工程的模块级build-profile.json5文件的buildOption属性中添加配置信息,主要分为下面两种情况:
5112
5113(1) 目录同级(**此情况不添加亦可**)
5114
5115FA模型:
5116```
5117  "buildOption": {
5118    "sourceOption": {
5119      "workers": [
5120        "./src/main/ets/MainAbility/workers/worker.js"
5121      ]
5122    }
5123  }
5124```
5125Stage模型:
5126```
5127  "buildOption": {
5128    "sourceOption": {
5129      "workers": [
5130        "./src/main/ets/workers/worker.ts"
5131      ]
5132    }
5133  }
5134```
5135(2) 目录不同级(**此情况必须添加**)
5136
5137FA模型:
5138```
5139  "buildOption": {
5140    "sourceOption": {
5141      "workers": [
5142        "./src/main/ets/workers/worker.js"
5143      ]
5144    }
5145  }
5146```
5147Stage模型(workers目录放在pages目录里为例):
5148```
5149  "buildOption": {
5150    "sourceOption": {
5151      "workers": [
5152        "./src/main/ets/pages/workers/worker.ts"
5153      ]
5154    }
5155  }
5156```
51572.
5158
5159- 接口名
5160
5161| postMessage(message:Object, options?:PostMessageOptions)  | 向worker线程发送消息  |
5162|---|---|
5163| postMessage(message:Object, transfer:ArrayBuffer[])  | 向worker线程发送消息  |
5164
5165- 使用示例
5166
5167```
5168// 示例一
5169import worker from "@ohos.worker"
5170const worker = new worker.Worker("workers/worker.js");
5171worker.postMessage("hello world");
5172
5173// 示例二
5174import worker from "@ohos.worker"
5175const worker = new worker.Worker("workers/worker.js");
5176var buffer = new ArrayBuffer(8);
5177worker.postMessage(buffer, [buffer]);
5178```
5179
51803.
5181
5182- 接口名
5183
5184| on(type:string, listener:EventListener)  | 向worker添加一个事件监听  |
5185|---|---|
5186
5187- 使用示例
5188
5189```
5190import worker from "@ohos.worker"
5191const worker = new worker.Worker("workers/worker.js");
5192worker.on("alert", (e)=>{
5193     console.log("worker on...");
5194});
5195```
5196
51974.
5198
5199- 接口名
5200
5201| once(type:string, listener:EventListener)  | 向worker添加一个事件监听, 事件监听只执行一次便自动删除  |
5202|---|---|
5203
5204- 使用示例
5205
5206```
5207import worker from "@ohos.worker"
5208const worker = new worker.Worker("workers/worker.js");
5209worker.once("alert", (e)=>{
5210    console.log("worker once...");
5211});
5212```
5213
52145.
5215
5216- 接口名
5217
5218| off(type:string, listener?:EventListener)  | 删除worker的事件监听  |
5219|---|---|
5220
5221- 使用示例
5222
5223```
5224import worker from "@ohos.worker"
5225const worker = new worker.Worker("workers/worker.js");
5226worker.off("alert");
5227```
5228
52296.
5230
5231- 接口名
5232
5233| terminate()  | 关闭worker线程,终止worker发送消息  |
5234|---|---|
5235
5236- 使用示例
5237
5238```
5239import worker from "@ohos.worker"
5240const worker = new worker.Worker("workers/worker.js");
5241worker.terminate();
5242```
5243
52447.
5245
5246- 接口名
5247
5248| removeEventListener(type:string, listener?:EventListener)  | 删除worker的事件监听  |
5249|---|---|
5250
5251- 使用示例
5252
5253```
5254import worker from "@ohos.worker"
5255const worker = new worker.Worker("workers/worker.js");
5256worker.removeEventListener("alert", (e)=>{
5257    console.log("worker removeEventListener...");
5258});
5259```
5260
52618.
5262
5263- 接口名
5264
5265| dispatchEvent(event: Event)  | 分发定义在worker的事件  |
5266|---|---|
5267
5268- 使用示例
5269
5270```
5271import worker from "@ohos.worker"
5272const worker = new worker.Worker("workers/worker.js");
5273worker.dispatchEvent({type:"alert"});
5274```
5275
52769.
5277
5278- 接口名
5279
5280| removeAllListener()  | 删除worker的所有事件监听  |
5281|---|---|
5282
5283- 使用示例
5284
5285```
5286import worker from "@ohos.worker"
5287const worker = new worker.Worker("workers/worker.js");
5288worker.removeAllListener();
5289```
5290
5291##### 4.2.1.2. 属性
5292
52931.
5294
5295- 属性名
5296
5297| onexit?:(code:number)=>void  | worker退出时被调用的事件处理程序,处理程序在宿主线程中执行  |
5298|---|---|
5299
5300- 使用示例
5301
5302```
5303import worker from "@ohos.worker"
5304const worker = new worker.Worker("workers/worker.js");
5305worker.onexit = function(e) {
5306    console.log("onexit...");
5307}
5308```
5309
53102.
5311
5312- 属性名
5313
5314| onerror?:(ev:ErrorEvent)=>void  | worker在执行过程中发生异常被调用的事件处理程序,处理程序在宿主线程中执行  |
5315|---|---|
5316
5317- 使用示例
5318
5319```
5320import worker from "@ohos.worker"
5321const worker = new worker.Worker("workers/worker.js");
5322worker.onerror = function(e) {
5323    console.log("onerror...");
5324}
5325```
5326
53273.
5328
5329- 属性名
5330
5331| onmessage?:(ev:MessageEvent)=>void  | 宿主线程收到来自其创建的worker通过parentPort.postMessage接口发送的消息时被调用的事件处理程序, 处理程序在宿主线程中执行 |
5332|---|---|
5333
5334- 使用示例
5335
5336```
5337import worker from "@ohos.worker"
5338const worker = new worker.Worker("workers/worker.js");
5339worker.onmessage = function(e) {
5340    console.log("onmessage...");
5341}
5342```
5343
53444.
5345
5346- 属性名
5347
5348| onmessageerror?:(event:MessageEvent)=>void  | worker对象接收到一条无法序列化的消息时被调用的事件处理程序, 处理程序在宿主线程中执行 |
5349|---|---|
5350
5351- 使用示例
5352
5353```
5354import worker from "@ohos.worker"
5355const worker = new worker.Worker("workers/worker.js");
5356worker.onmessageerror = function(e) {
5357    console.log("onmessageerror...");
5358}
5359```
5360
5361#### 4.2.2. parentPort对象描述
5362
5363worker线程用于与宿主线程通信的Object对象。
5364
5365##### 4.2.2.1. 接口
5366
53671.
5368
5369- 接口名
5370
5371| postMessage(message:Object, options?:PostMessageOptions)  | 向宿主线程发送消息 |
5372|---|---|
5373| postMessage(message:Object, transfer:ArrayBuffer[])  | 向宿主线程发送消息  |
5374
5375- 使用示例
5376
5377```
5378// main.js
5379import worker from "@ohos.worker"
5380const worker = new worker.Worker("workers/worker.js");
5381worker.postMessage("hello world");
5382
5383// worker.js
5384import worker from "@ohos.worker"
5385const parentPort = worker.parentPort;
5386parentPort.onmessage = function(e) {
5387    parentPort.postMessage("hello world from worker.js");
5388}
5389```
5390
53912.
5392
5393- 接口名
5394
5395| close()  | 关闭worker线程,终止worker接收消息  |
5396|---|---|
5397
5398- 使用示例
5399
5400```
5401// main.js
5402import worker from "@ohos.worker"
5403const worker = new worker.Worker("workers/worker.js");
5404worker.postMessage("hello world");
5405
5406// worker.js
5407import worker from "@ohos.worker"
5408const parentPort = worker.parentPort;
5409parentPort.onmessage = function(e) {
5410    parentPort.close();
5411}
5412```
5413
5414##### 4.2.2.2. 属性
5415
54161.
5417
5418- 属性名
5419
5420| onmessage?:(event:MessageEvent)=>void  | 宿主线程收到来自其创建的worker通过worker.postMessage接口发送的消息时被调用的事件处理程序,处理程序在worker线程中执行  |
5421|---|---|
5422
5423- 使用示例
5424
5425```
5426// main.js
5427import worker from "@ohos.worker"
5428const worker = new worker.Worker("workers/worker.js");
5429worker.postMessage("hello world");
5430
5431// worker.js
5432import worker from "@ohos.worker"
5433const parentPort = worker.parentPort;
5434parentPort.onmessage = function(e) {
5435    console.log("receive main.js message");
5436}
5437```
5438
54392.
5440
5441- 属性名
5442
5443| onerror?:(ev: ErrorEvent)=>void  | worker在执行过程中发生异常被调用的事件处理程序,处理程序在worker线程中执行  |
5444|---|---|
5445
5446- 使用示例
5447
5448```
5449// main.js
5450import worker from "@ohos.worker"
5451const worker = new worker.Worker("workers/worker.js");
5452worker.postMessage("hello world");
5453
5454// worker.js
5455import worker from "@ohos.worker"
5456const parentPort = worker.parentPort;
5457parentPort.onerror = function(e) {
5458    console.log("onerror...");
5459}
5460
5461```
5462
54633.
5464
5465- 属性名
5466
5467| onmessageerror?:(event: MessageEvent)=>void  | worker对象接收到一条无法被反序列化的消息时被调用的事件处理程序, 处理程序在worker线程中执行  |
5468|---|---|
5469
5470- 使用示例
5471
5472```
5473// main.js
5474import worker from "@ohos.worker"
5475const worker = new worker.Worker("workers/worker.js");
5476worker.postMessage("hello world");
5477
5478// worker.js
5479import worker from "@ohos.worker"
5480const parentPort = worker.parentPort;
5481parentPort.onmessageerror = function(e) {
5482    console.log("onmessageerror...");
5483}
5484```
5485
5486### 4.3. 涉及仓
5487
5488[arkcompiler_ets_runtime](https://gitee.com/openharmony/arkcompiler_ets_runtime/blob/master/README_zh.md)
5489[arkui_ace_engine](https://gitee.com/openharmony/arkui_ace_engine/blob/master/README_zh.md)
5490[arkui_napi](https://gitee.com/openharmony/arkui_napi/blob/master/README_zh.md)
5491
5492
5493# 相关仓
5494
5495[ets_utils子系统](https://gitee.com/openharmony/commonlibrary_ets_utils/blob/master/README.md)
5496
5497# 许可证
5498
5499js_api_module子模块在[Mozilla许可证](https://www.mozilla.org/en-US/MPL/)下可用,有关完整的许可证文本,请参见[许可证](https://gitee.com/openharmony/commonlibrary_ets_utils/blob/master/js_api_module/mozilla_docs.txt)5500
5501js_util_module子模块在[Mozilla许可证](https://www.mozilla.org/en-US/MPL/)下可用,有关完整的许可证文本,请参见[许可证](https://gitee.com/openharmony/commonlibrary_ets_utils/blob/master/js_util_module/mozilla_docs.txt)5502
5503js_concurrent_module子模块在[Mozilla许可证](https://www.mozilla.org/en-US/MPL/)下可用,有关完整的许可证文本,请参见[许可证](https://gitee.com/openharmony/commonlibrary_ets_utils/blob/master/js_concurrent_module/mozilla_docs.txt)5504
5505js_sys_module子模块在[Mozilla许可证](https://www.mozilla.org/en-US/MPL/)下可用,有关完整的许可证文本,请参见[许可证](https://gitee.com/openharmony/commonlibrary_ets_utils/blob/master/js_sys_module/mozilla_docs.txt)