• Home
Name Date Size #Lines LOC

..--

js_api_module/12-May-2024-20,37817,008

js_concurrent_module/12-May-2024-6,6824,992

js_sys_module/12-May-2024-3,6812,765

js_util_module/12-May-2024-14,24512,085

LICENSED12-May-20249.9 KiB178150

README.en.mdD12-May-202488 KiB2,2182,035

README.mdD12-May-2024155.5 KiB4,4994,305

bundle.jsonD12-May-20242.7 KiB7776

README.en.md

1# ets_utils
2
3-   [Submodule](#Submodule)
4    -   [1.js_api_module submodule](#1.js_api_module submodule)
5        -   [1.1.Introduction](#1.1.Introduction)
6        -   [1.2.Contents](#1.2.Contents)
7        -   [1.3.Illustrate](#1.3.Illustrate)
8            -   [1.3.1.Interface Description](#1.3.1.Interface Description)
9            -   [1.3.2.Instructions for use](#1.3.2.Instructions for use)
10    -   [2.js_util_module submodule](#2.js_util_module submodule)
11        -   [2.1.Introduction](#2.1.Introduction)
12        -   [2.2.Contents](#2.2.Contents)
13        -   [2.3.Illustrate](#2.3.Illustrate)
14            -   [2.3.1.Interface Description](#2.3.1.Interface Description)
15            -   [2.3.2.Instructions for use](#2.3.2.Instructions for use)
16    -   [3.js_sys_module submodule](#3.js_sys_module submodule)
17        -   [3.1.Introduction](#3.1.Introduction)
18        -   [3.2.Contents](#3.2.Contents)
19        -   [3.3.Illustrate](#3.3.Illustrate)
20            -   [3.3.1.Interface Description](#3.3.1.Interface Description)
21            -   [3.3.2.Instructions for use](#3.3.2.Instructions for use)
22    -   [4.js_concurrent_module submodule](#4.js_concurrent_module submodule)
23        -   [4.1.Introduction](#4.1.Introduction)
24        -   [4.2.Interface description](#4.2.Interface description)
25            -   [4.2.1.Worker object description](#4.2.1.Worker object description)
26                -   [4.2.1.1.Interface](#4.2.1.1.Interface)
27                -   [4.2.1.2.Attribute](#4.2.1.2.Attribute)
28            -   [4.2.2.parentPort object description](#4.2.2.parentPort object description)
29                -   [4.2.2.1.Interface](#4.2.2.1.Interface)
30                -   [4.2.2.2.Attribute](#4.2.2.2.Attribute)
31-   [Related warehouse](#Related warehouse)
32-   [License](#License)
33
34## 1.js_api_module_submodule
35### 1.1.Introduction
36
37The interface of URL is used to parse, construct, normalize, and encode URLs. The constructor of URL creates a new URL object. In order to make changes to the resolved components of the URL or to the URL. The URLSearchParams interface defines some practical methods to process URL query strings.
38
39URI Represents a Uniform Resource Identifier (URI) reference.
40
41XML representation refers to extensible markup language.
42
43The XmlSerializer interface is used to generate an xml file. The constructor of XmlSerializer creates a new XmlSerializer object, and calls the method of the XmlSerializer object to generate an xml file. The XmlPullParser interface is used to parse the existing xml file. The constructor of XmlPullParser creates a new XmlPullParser object, and calls the method of the XmlPullParser object to parse the xml file.
44
45### 1.2.Contents
46
47```
48commomlibrary/ets_utils/js_api_module/
49├── Class:URL                                                                # URL class
50│   ├── new URL(input[, base])                                               # Create URL object
51│   ├── hash                                                                 # hash attribute
52│   ├── host                                                                 # host attribute
53│   ├── hostname                                                             # hostname attribute
54│   ├── href                                                                 # href attribute
55│   ├── origin                                                               # origin attribute
56│   ├── password                                                             # password attribute
57│   ├── pathname                                                             # pathname attribute
58│   ├── port                                                                 # port attribute
59│   ├── protocol                                                             # protocol attribute
60│   ├── search                                                               # search attribute
61│   ├── searchParams                                                         # searchParams attribute
62│   ├── username                                                             # username attribute
63│   ├── toString()                                                           # toString method
64│   └── toJSON()                                                             # toJSON method
65├── Class: URLSearchParams                                                   # URLSearchParams class
66│   ├── new URLSearchParams()                                                # Create URLSearchParams object
67│   ├── new URLSearchParams(string)                                          # Create URLSearchParams object
68│   ├── new URLSearchParams(obj)                                             # Create URLSearchParams object
69│   ├── new URLSearchParams(iterable)                                        # Create URLSearchParams object
70│   ├── append(name, value)                                                  # append method
71│   ├── delete(name)                                                         # delete method
72│   ├── entries()                                                            # entries method
73│   ├── forEach(fn[, thisArg])                                               # forEach method
74│   ├── get(name)                                                            # get method
75│   ├── getAll(name)                                                         # getAll method
76│   ├── has(name)                                                            # has method
77│   ├── keys()                                                               # keys method
78│   ├── set(name, value)                                                     # set method
79│   ├── sort()                                                               # sort method
80│   ├── toString()                                                           # toString method
81│   ├── values()                                                             # values method
82│   └── urlSearchParams[Symbol.iterator]()                                   # Create URLSearchParams object
83├── Class:URI                                                                # URI class
84│   ├── URI(str: string)                                                     # Create URI object
85│   ├── scheme                                                               # scheme attribute
86│   ├── authority                                                            # authority attribute
87│   ├── ssp                                                                  # ssp attribute
88│   ├── userinfo                                                             # userinfo attribute
89│   ├── host                                                                 # host attribute
90│   ├── port                                                                 # port attribute
91│   ├── query                                                                # query attribute
92│   ├── fragment                                                             # fragment attribute
93│   ├── path                                                                 # path method
94│   ├── equals(ob: Object)                                                   # equals method
95│   ├── normalize()                                                          # normalize method
96│   ├── checkIsAbsolute()                                                    # checkIsAbsolute method
97│   ├── normalize()                                                          # normalize method
98│   ├── toString()                                                           # toString method
99├── Class:ConvertXml                                                         # ConvertXml class
100│   ├── ConvertXml()                                                         # Create convertxml class object
101│   └── convert(xml: string, options: Object)                                # convert method
102├── Class:XmlSerializer                                                      # XmlSerializer class
103│   ├── new XmlSerializer(buffer: ArrayBuffer | DataView, encoding?: string) # Create XmlSerializer class object
104│   ├── setAttributes(name: string, value: string)                           # Set Attributes method
105│   ├── addEmptyElement(name: string)                                        # Add an empty element method
106│   ├── setDeclaration()                                                     # Set the Declaration method
107│   ├── startElement(name: string)                                           # Set the start element method
108│   ├── endElement()                                                         # Set the end element method
109│   ├── setNamespace(prefix: string, namespace: string)                      # Namespace method
110│   ├── setCommnet(text: string)                                             # Set up Commnet method
111│   ├── setCData(text: string)                                               # Set the CData method
112│   ├── setText(text: string)                                                # Set the Text method
113│   ├── setDocType(text: string)                                             # Set DocType method
114└── Class: XmlPullParser                                                     # XmlPullParser class
115    ├── new (buffer: ArrayBuffer | DataView, encoding?: string)              # Create XmlPullParser object
116    └── parse(option: ParseOptions)                                          # parse method
117```
118
119### 1.3.Illustrate
120
121#### 1.3.1.Interface Description
122
123
124| Interface name | Illustrate                                                         |
125| -------- | -------- |
126| new URL(url: string,base?:string \| URL) | Create and return a URL object that references the URL specified by the absolute URL string, the relative URL string, and the basic URL string. |
127| tostring():string | The stringification method returns a USVString containing the complete URL. It is equivalent to the read-only URL.href. |
128| toJSON():string | This method returns a USVString, which contains a serialized URL version. |
129| new URLSearchParams() | The URLSearchParams() constructor has no parameters. This method creates and returns a new URLSearchParams object. The beginning'?' character will be ignored. |
130| new URLSearchParams(string) | The input parameter of URLSearchParams(string) constructor is string data type. This method creates and returns a new URLSearchParams object. The beginning'?' character will be ignored. |
131| new URLSearchParams(obj) | URLSearchParams(obj) The input parameter of the constructor is the obj data type. This method creates and returns a new URLSearchParams object. The beginning'?' character will be ignored. |
132| new URLSearchParams(iterable) | URLSearchParams(iterable) The input parameter of the constructor is the iterable data type. This method creates and returns a new URLSearchParams object. The beginning'?' character will be ignored. |
133| has(name: string): boolean | Retrieve whether the searchParams object contains name. If yes, it returns true, otherwise it returns false. |
134| set(name: string, value string): void |  Retrieve whether the searchParams object contains a key-value pair whose key is name. If not, add the key-value pair, if any, modify the value corresponding to the first key in the object, and delete the remaining key-value pairs whose key is name. |
135| sort(): void | According to the Unicode code point of the key, sort all key/value pairs contained in this object and return undefined. |
136| toString(): string | According to the searchParams object, the query string applicable in the URL is returned. |
137| keys(): iterableIterator\<string> | Return an iterator, which allows iterating through all the key values contained in the object. |
138| values(): iterableIterator\<string> | Returns an iterator, which allows iterating over all the value values contained in the object. |
139| append(name: string, value: string): void | Insert the name, value key-value pair in the searchParams object. |
140| delete(name: string): void | Traverse the searchParams object, find all the names, and delete the corresponding key-value pairs. |
141| get(name: string): string | Retrieve the first name in the searchParams object and return the value corresponding to the name key. |
142| getAll(name: string): string[] | Retrieve all names in the searchParams object and return all the values corresponding to the name key. |
143| entries(): iterableIterator<[string, string]> | Returns an iterator that allows iterating through all key/value pairs contained in the searchParams object. |
144| forEach(): void | Through the callback function to traverse the key-value pairs on the URLSearchParams instance object. |
145| urlSearchParams\[Symbol.iterator]() | Returns an ES6 iterator for each name-value pair in the query string. Each item of the iterator is a JavaScript array. |
146| URI​(str: string) | Construct the URI by parsing the given input parameter (String str). This constructor parses the given string strictly in accordance with the grammatical provisions in RFC 2396 Appendix A. |
147| getScheme​() | Return the scheme component of this URI, or null if the scheme is not defined. |
148| getAuthority​() | Returns the decoded authority component of this URI, or null if authority is not defined. The string returned by this method is the same as the string returned by the getRawAuthority method, except that all escaped octet sequences are decoded. |
149| getSchemeSpecificPart​() |  Returns the decoding scheme-specific part of this URI. The string returned by this method is the same as the string returned by the getRawSchemeSpecificPart method, except that all escaped octet sequences are decoded. |
150| getUserInfo​() | Returns the decoded userinfo component of this URI. The userinfo component of the URI (if defined) only contains characters in unreserved, punctuation, escape, and other categories. |
151| getHost​() | Return the host component of this URI, or null if host is not defined. |
152| getPort​() | Return the port of this URI, or -1 if the port is not defined. The port component of the URI (if defined) is a non-negative integer. |
153| getQuery​() | Returns the decoded query component of this URI, or null if the query is not defined. The string returned by this method is the same as the string returned by the getRawQuery method, except that all escaped octet sequences are decoded. |
154| getFragment​() | Returns the decoded fragment component of this URI, or null if the fragment is not defined. The string returned by this method is the same as the string returned by the getRawFragment method, except that all escaped octet sequences are decoded. |
155| getPath​() | Returns the decoded path component of this URI, or null if path is not defined. The string returned by this method is the same as the string returned by the getRawPath method, except that all escaped octet sequences are decoded. |
156| equals(ob: Object) | Test whether this URI is equal to another object. If the given object is not a URI, this method immediately returns false. |
157| normalize​() | Normalize the path of this URI. If this URI is opaque, or its path is already in normal form, then this URI is returned. Otherwise, a new URI identical to this URI will be constructed. |
158| checkIsAbsolute() | Determine whether this URI is absolute. If and only if it has a scheme component, the URI is absolute and the return value is true, otherwise the return value is false. |
159| toString() | Return the content of this URI as a string. |
160| ConvertXml() | The constructor used to construct the convertxml class object. This constructor does not need to pass in parameters. |
161| convert(xml: string, options: Object)  | Returns a JavaScript object that converts an XML string as required by the option. |
162| XmlSerializer(buffer: ArrayBuffer \| DataView, encoding?: string) | Create and return an XmlSerializer object. The XmlSerializer object passes two parameters. The first parameter is ArrayBuffer or DataView, and the second parameter is the file format (UTF-8 by default). |
163| setAttributes(name: string, value: string): void | Write the Attributes attribute to the xml file. |
164| addEmptyElement(name: string): void | Write an empty element. |
165| setDeclaration(): void | Set the Declaration to use the encoding to write the xml declaration. For example: <? xml version="1.0" encoding="utf-8"> |
166| startElement(name: string): void | Write the elemnet start tag with the given name.|
167| endElement(): void | Write the end tag of the element. |
168| setNamespace(prefix: string, namespace: string): void | Write the namespace of the current element tag. |
169| setCommnet(text: string): void | Write the comment attribute. |
170| setCData(text: string): void | Write the CData attribute. |
171| setText(text: string): void | Write the Text property. |
172| setDocType(text: string): void | Write the DocType attribute. |
173| XmlPullParser(buffer: ArrayBuffer \| DataView, encoding?: string) | Create and return an XmlPullParser object. The XmlPullParser object passes two parameters. The first parameter is ArrayBuffer or DataView, and the second parameter is the file format (default is UTF-8). |
174| parse(option: ParseOptions): void | This interface is used to parse xml. The ParseOptions parameter is an interface containing five optional parameters {supportDoctype?: boolea ignoreNameSpace?: boolean tagValueCallbackFunction?: (name: string, value: string) => boolean attributeValueCallbackFunction?: (name: string, value: string) => boolean) tokenValueCallbackFunction?: (eventType: EventType, value: ParseInfo) => boolean }. The input parameter 1 of the tokenValueCallbackFunction callback function is the event type, and the input parameter 2 is the info interface containing get attributes such as getColumnNumber and getDepth. The user can obtain the depth and other information in the current parsing process through methods such as info.getDepth(). |
175#### 1.3.2.Instructions for use
176
177The usage of each interface is as follows:
178
179
1801、new URL(url: string,base?:string|URL)
181```
182let b = new URL('https://developer.mozilla.org'); // => 'https://developer.mozilla.org/'
183
184let a = new URL( 'sca/./path/path/../scasa/text', 'http://www.example.com');
185// => 'http://www.example.com/sca/path/scasa/text'
186```
1872、tostring():string
188```
189const url = new URL('http://10.0xFF.O400.235:8080/directory/file?query#fragment');
190url.toString() // => 'http://10.0xff.o400.235:8080/directory/file?query#fragment'
191
192const url = new URL("http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html");
193url.toString() // => 'http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/index.html'
194
195const url = new URL("http://username:password@host:8080/directory/file?query#fragment");
196url.toString() // => 'http://username:password@host:8080/directory/file?query#fragment'
197```
1983、toJSON():string
199```
200const url = new URL("https://developer.mozilla.org/en-US/docs/Web/API/URL/toString");
201url.toJSON(); // =>  'https://developer.mozilla.org/en-US/docs/Web/API/URL/toString'
202```
2034、new URLSearchParams()
204```
205let params = new URLSearchParams('foo=1&bar=2');
206```
2075、new URLSearchParams(string)
208```
209params = new URLSearchParams('user=abc&query=xyz');
210console.log(params.get('user'));
211// Prints 'abc'
212```
2136、new URLSearchParams(obj)
214```
215const params = new URLSearchParams({
216    user: 'abc',
217    query: ['first', 'second']
218});
219console.log(params.getAll('query'));
220// Prints [ 'first,second' ]
221```
2227、new URLSearchParams(iterable)
223```
224let params;
225
226// Using an array
227params = new URLSearchParams([
228    ['user', 'abc'],
229    ['query', 'first'],
230    ['query', 'second'],
231]);
232console.log(params.toString());
233// Prints 'user = abc & query = first&query = second'
234```
2358、has(name: string): boolean
236```
237console.log(params.has('bar')); // =>true
238```
2399、set(name: string, value string): void
240```
241params.set('baz', 3);
242```
24310、sort(): void
244```
245params .sort();
246```
24711、toString(): string
248```
249console.log(params .toString()); // =>bar=2&baz=3&foo=1'
250```
25112、keys(): iterableIterator\<string>
252```
253for(var key of params.keys()) {
254  console.log(key);
255} // =>bar  baz  foo
256```
25713、values(): iterableIterator\<string>
258```
259for(var value of params.values()) {
260  console.log(value);
261} // =>2  3  1
262```
26314、append(name: string, value: string): void
264```
265params.append('foo', 3); // =>bar=2&baz=3&foo=1&foo=3
266```
26715、delete(name: string): void
268```
269params.delete('baz'); // => bar=2&foo=1&foo=3
270```
27116、get(name: string): string
272```
273params.get('foo'); // => 1
274```
27517、getAll(name: string): string[]
276```
277params.getAll('foo'); // =>[ '1', '3' ]
278```
27918、entries(): iterableIterator<[string, string]>
280```
281for(var pair of searchParams.entries()) {
282   console.log(pair[0]+ ', '+ pair[1]);
283} // => bar, 2   foo, 1  foo, 3
284```
28519、forEach(): void
286```
287url.searchParams.forEach((value, name, searchParams) => {
288  console.log(name, value, url.searchParams === searchParams);
289});
290// => foo 1 true
291// => bar 2 true
292```
29320、urlSearchParams[Symbol.iterator] ()
294```
295const params = new URLSearchParams('foo=bar&xyz=baz');
296for (const [name, value] of params) {
297    console.log(name, value);
298}
299// Prints:
300// foo bar
301// xyz bar
302```
303
304
30521、URI​(String str)
306```
307let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
308```
30922、scheme
310```
311let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
312gaogao.scheme        // => "http";
313```
31423、authority
315```
316let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
317gaogao.authority     // => "gg:gaogao@www.baidu.com:99";
318```
31924、ssp
320```
321let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
322gaogao.ssp "         // => gg:gaogao@www.baidu.com:99/path/path?query";
323```
32425、userinfo
325```
326let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
327gaogao.userinfo      // => "gg:gaogao";
328```
32926、host
330```
331let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
332gaogao.host          // => "www.baidu.com";
333```
33427、port
335```
336let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
337gaogao.port          // => "99";
338```
33928、query
340```
341let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
342gaogao.query         // => "query";
343```
34429、fragment
345```
346let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
347gaogao.fragment      // => "fagment";
348```
34930、path
350```
351let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
352gaogao.path          // => "/path/path";
353```
35431、equals(Object ob)
355```
356let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment');
357let gaogao1 = gaogao;
358let res = gaogao.equals(gaogao1);
359console.log(res);      // => true;
360```
36132、normalize​()
362```
363let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/66./../././mm/.././path1?query#fagment');
364let res = gaogao.normalize();
365console.log(res.path);        // => "/path/path1"
366console.log(res.toString());  // => "http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/path1?query#fagment"
367```
36833、checkIsAbsolute()
369```
370let gaogao = new Uri.URI('f/tp://username:password@www.baidu.com:88/path?query#fagment');
371let res = gaogao.checkIsAbsolute();
372console.log(res);              //=> false;
373```
37434、toString()
375```
376let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path/.././../aa/bb/cc?query#fagment');
377let res = gaogao.toString();
378console.log(res.toString());     // => 'http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path/.././../aa/bb/cc?query#fagment';
379```
380
381
38235、ConvertXml()
383```
384var convertml = new convertXml.ConvertXml();
385```
38636、convert(xml: string, options: Object)
387```
388var result = convertml.convert(xml, {compact: false, spaces: 4});
389```
39037、new XmlSerializer(buffer: ArrayBuffer | DataView, encoding?: string)
391```
392
393var arrayBuffer = new ArrayBuffer(1024);
394var bufView = new DataView(arrayBuffer);
395var thatSer = new xml.XmlSerializer(bufView);
396```
39738、setDeclaration():void
398```
399var thatSer = new xml.XmlSerializer(bufView);
400thatSer.setDeclaration() // => <?xml version="1.0" encoding="utf-8"?>;
401```
40239、setCommnet(text: string):void
403```
404var thatSer = new xml.XmlSerializer(bufView);
405thatSer.setCommnet("Hello, World!"); // => <!--Hello, World!-->;
406```
40740、setCData(text: string) :void
408```
409var thatSer = new xml.XmlSerializer(bufView);
410thatSer.setDocType('root SYSTEM "http://www.test.org/test.dtd"'); // => <![CDATA[root SYSTEM \“http://www.test.org/test.dtd\”]]>
411```
41241、setDocType(text: string):void
413```
414var thatSer = new xml.XmlSerializer(bufView);
415thatSer.setDocType("foo"); // => <!DOCTYPE foo>
416```
41742、setNamespace(prefix: string, namespace: string): void
41843、startElement(name: string): void
41944、setAttributes(name: string, value: string): void
42045、endElement(): void
42146、setText(text: string): void
422```
423var thatSer = new xml.XmlSerializer(bufView);
424thatSer.setNamespace("h", "http://www.w3.org/TR/html4/");
425thatSer.startElement("table");
426thatSer.setAttributes("importance", "high");
427thatSer.setText("Happy");
428endElement(); // => <h:table importance="high" xmlns:h="http://www.w3.org/TR/html4/">Happy</h:table>
429```
43047、addEmptyElement(name: string): void
431```
432var thatSer = new xml.XmlSerializer(bufView);
433thatSer.addEmptyElement("b"); // => <b/>
434```
43548、new (buffer: ArrayBuffer | DataView, encoding?: string)
436```
437var strXml =
438            '<?xml version="1.0" encoding="utf-8"?>' +
439            '<note importance="high" logged="true">' +
440            '    <title>Happy</title>' +
441            '</note>';
442var arrayBuffer = new ArrayBuffer(strXml.length*2);
443var bufView = new Uint8Array(arrayBuffer);
444var strLen = strXml.length;
445for (var i = 0; i < strLen; ++i) {
446    bufView[i] = strXml.charCodeAt(i);//设置arraybuffer 方式
447}
448var that = new xml.XmlPullParser(arrayBuffer);
449
450```
45149、parse(option: ParseOptions): void
452```
453var strXml =
454            '<?xml version="1.0" encoding="utf-8"?>' +
455            '<note importance="high" logged="true">' +
456            '    <title>Happy</title>' +
457            '</note>';
458var arrayBuffer = new ArrayBuffer(strXml.length*2);
459var bufView = new Uint8Array(arrayBuffer);
460var strLen = strXml.length;
461for (var i = 0; i < strLen; ++i) {
462    bufView[i] = strXml.charCodeAt(i);
463}
464var that = new xml.XmlPullParser(arrayBuffer);
465var arrTag = {};
466arrTag[0] = '132';
467var i = 1;
468function func(key, value){
469    arrTag[i] = 'key:'+key+' value:'+ value.getDepth();
470    i++;
471    return true;
472}
473var options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func};
474that.parse(options);
475```
476
477## 2.js_util_module submodule
478### 2.1.Introduction
479The interface of util is used for character Textencoder, TextDecoder and HelpFunction module.The TextEncoder represents a text encoder that accepts a string as input, encodes it in UTF-8 format, and outputs UTF-8 byte stream. The TextDecoder interface represents a text decoder. The decoder takes the byte stream as the input and outputs the String string. HelpFunction is mainly used to callback and promise functions, write and output error codes, and format class strings.
480Encodes all bytes from the specified u8 array into a newly-allocated u8 array using the Base64 encoding scheme or Encodes the specified byte array into a String using the Base64 encoding scheme.Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 array using the Base64 encoding scheme.The rational number is mainly to compare rational numbers and obtain the numerator and denominator.The LruBuffer algorithm replaces the least used data with new data when the buffer space is insufficient. The algorithm derives from the need to access resources: recently accessed data can be Will visit again in the near future. The least accessed data is the least valuable data that should be kicked out of the cache space. The Scope interface is used to describe the valid range of a field. The constructor for the Scope instance is used to create objects with specified lower and upper bounds and require that these objects be comparable.
481### 2.2.contants
482
483```
484commomlibrary/ets_utils/js_util_module/
485├── Class:TextEncoder                   # TextEncoder class
486│   ├──  new TextEncoder()              # create textencoder object
487│   ├──  encode()                       # encode method
488│   ├──  encoding                       # encoding property
489│   └──  encodeInto()                   # encodeInto method
490├── Class:TextDecoder                   # TextDecoder class
491│   ├──  new TextDecoder()              # create TextDecoder object
492│   ├──  decode()                       # decode method
493|   ├──  decodeWithStream()             # decodeWithStream method
494│   ├──  encoding                       # encoding property
495│   ├──  fatal                          # fatal property
496│   └──  ignoreBOM                      # ignoreBOM property
497├── printf()                            # printf method
498├── getErrorString()                    # getErrorString method
499├── callbackWrapper()                   # callbackWrapper method
500├── promiseWrapper()                    # promiseWrapper method
501├── Class:Base64                        # Base64 class
502│   ├──  new Base64()                   # create Base64 object
503│   ├──  encodeSync()                   # encodeSync method
504│   ├──  encodeToStringSync()           # encodeToStringSync method
505│   ├──  decodeSync()                   # decodeSync method
506│   ├──  encode()                       # encode method
507│   ├──  encodeToString()               # encodeToString method
508│   └──  decode()                       # decode method
509├── Class:RationalNumber                # RationalNumber class
510│   ├──  new RationalNumber()           # create RationalNumber object
511│   ├──  createRationalFromString()     # creatRationalFromString method
512│   ├──  compareTo()                    # compareTo method
513│   ├──  equals()                       # equals method
514│   ├──  valueOf()                      # valueOf method
515│   ├──  getCommonDivisor()             # getCommonDivisor method
516│   ├──  getDenominator()               # getDenominator method
517│   ├──  getNumerator()                 # getNumerator method
518│   ├──  isFinite()                     # isFinite method
519│   ├──  isNaN()                        # isNaN method
520│   ├──  isZero()                       # isZero method
521│   └──  toString()                     # toString method
522├── Class:LruBuffer                     # LruBuffer class
523│   ├──  new LruBuffer()                # create RationalNumber object
524│   ├──  updateCapacity()               # updateCapacity method
525│   ├──  toString()                     # toString method
526│   ├──  values()                       # values method
527│   ├──  length                         # attribute of length
528│   ├──  getCapacity()                  # getCapacity method
529│   ├──  clear()                        # clear method
530│   ├──  getCreateCount                 # getCreateCount method
531│   ├──  getMissCount()                 # getMissCount method
532│   ├──  getRemovalCount()              # getRemovalCount method
533│   ├──  getMatchCount()                # getMatchCount method
534│   ├──  getPutCount()                  # getPutCount method
535│   ├──  isEmpty()                      # isEmpty method
536│   ├──  get()                          # get method
537│   ├──  put()                          # put method
538│   ├──  keys()                         # keys method
539│   ├──  remove()                       # remove method
540│   ├──  afterRemoval()                 # afterRemoval method
541│   ├──  contains()                     # contains method
542│   ├──  createDefault()                # createDefault method
543│   ├──  entries()                      # entries method
544│   └──  [Symbol.iterator]()            # Symboliterator method
545├── Class:Scope                         # Scope class
546|   ├── constructor()                   # create Scope object
547|   ├── toString()                      # toString method
548|   ├── intersect()                     # intersect method
549|   ├── intersect()                     # intersect method
550|   ├── getUpper()                      # getUpper method
551|   ├── getLower()                      # getLower method
552|   ├── expand()                        # expand method
553|   ├── expand()                        # expand method
554|   ├── expand()                        # expand method
555|   ├── contains()                      # contains method
556|   ├── contains()                      # contains method
557|   └── clamp()                         # clamp method
558└── Class:Types                         # Types class
559    ├── isAnyArrayBuffer()              # isAnyArrayBuffer method
560    ├── isArrayBufferView()             # isArrayBufferView method
561    ├── isArgumentsObject()             # isArgumentsObject method
562    ├── isArrayBuffer()                 # isArrayBuffer method
563    ├── isAsyncFunction()               # isAsyncFunction method
564    ├── isBigInt64Array()               # isBigInt64Array method
565    ├── isBigUint64Array()              # isBigUint64Array method
566    ├── isBooleanObject()               # isBooleanObject method
567    ├── isBoxedPrimitive()              # isBoxedPrimitive method
568    ├── isDataView()                    # isDataView method
569    ├── isDate()                        # isDate method
570    ├── isExternal()                    # isExternal method
571    ├── isFloat32Array()                # isFloat32Arraymethod
572    ├── isFloat64Array()                # isFloat64Array method
573    ├── isGeneratorFunction()           # isGeneratorFunction method
574    ├── isGeneratorObject()             # isGeneratorObject method
575    ├── isInt8Array()                   # isInt8Array method
576    ├── isInt16Array()                  # isInt16Array method
577    ├── isInt32Array()                  # isInt32Array method
578    ├── isMap()                         # isMap method
579    ├── isMapIterator()                 # isMapIterator method
580    ├── isModuleNamespaceObject()       # isModuleNamespaceObject method
581    ├── isNativeError()                 # isNativeError method
582    ├── isNumberObject()                # isNumberObject method
583    ├── isPromise()                     # isPromise method
584    ├── isProxy()                       # isProxy method
585    ├── isRegExp()                      # isRegExp method
586    ├── isSet()                         # isSet method
587    ├── isSetIterator()                 # isSetIterator method
588    ├── isSharedArrayBuffer()           # isSharedArrayBuffer method
589    ├── isStringObject()                # isStringObject method
590    ├── isSymbolObject()                # isSymbolObject method
591    ├── isTypedArray()                  # isTypedArray method
592    ├── isUint8Array()                  # isUint8Array method
593    ├── isUint8ClampedArray()           # isUint8ClampedArray method
594    ├── isUint16Array()                 # isUint16Array method
595    ├── isUint32Array()                 # isUint32Array method
596    ├── isWeakMap()                     # isWeakMap method
597    └── isWeakSet()                     # isWeakSet method
598```
599
600### 2.3.Description
601
602#### 2.3.1.Interface description
603| Interface name | Description |
604| -------- | -------- |
605| constructor(encoding? : string) | Constructor, the parameter encoding indicates the format of encoding. Default utf-8, Support gb18030, gbk, gb2312. |
606| readonly encoding : string | In the TextEncoder module, get the encoding format. |
607| encode(input : string) : Uint8Array | Input string string, encoding according to encoding and output uint8 byte stream. |
608| encodeInto(input : string, dest : Uint8Array) : {read : number, written : number} | Enter the string string, dest represents the storage location after encoding, and returns an object, read represents the number of characters that have been encoded,and written represents the size of bytes occupied by the encoded characters. |
609| constructor(encoding? : string, options? : {fatal? : boolean, ignoreBOM? : boolean}) | Constructor, the first parameter encoding indicates the format of decoding.The second parameter represents some attributes.Fatal in the attribute indicates whether an exception is thrown, and ignoreBOM indicates whether to ignore the bom flag. |
610| readonly encoding : string | In the TextDecoder module, get the set decoding format. |
611| readonly fatal : boolean | Get the setting that throws the exception. |
612| readonly ignoreBOM : boolean | Get whether to ignore the setting of the bom flag. |
613| decode(input : Uint8Array, options?: { stream?: false }) : string | Input the data to be decoded, and solve the corresponding string character string.The first parameter input represents the data to be decoded, and the second parameter options represents a bool flag, which means that additional data will be followed. The default is false. |
614| decodeWithStream(input : Uint8Array, options?: { stream?: false }) : string | Input the data to be decoded, and solve the corresponding string character string.The first parameter input represents the data to be decoded, and the second parameter options represents a bool flag, which means that additional data will be followed. The default is false. |
615| encodeSync(src: Uint8Array): Uint8Array; | Encodes all bytes in the specified u8 array into the newly allocated u8 array using the Base64 encoding scheme. |
616| encodeToStringSync(src: Uint8Array): string; | Encodes the specified byte array as a String using the Base64 encoding scheme. |
617| decodeSync(src: Uint8Array \| string): Uint8Array; | Decodes the Base64-encoded string or input u8 array into the newly allocated u8 array using the Base64 encoding scheme. |
618| encode(src: Uint8Array): Promise\<Uint8Array\>; | Asynchronously encodes all bytes in the specified u8 array into the newly allocated u8 array using the Base64 encoding scheme. |
619| encodeToString(src: Uint8Array): Promise\<string\>; | Asynchronously encodes the specified byte array into a String using the Base64 encoding scheme. |
620| decode(src: Uint8Array \| string): Promise\<Uint8Array\>; | Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 array into a newly allocated u8 array. |
621| static createRationalFromString(rationalString: string): RationalNumber | Create a RationalNumber object based on the given string. |
622| compareTo(another: RationalNumber): number | Compare the current RationalNumber object with the given object. |
623| equals(obj: object): number | Check if the given object is the same as the current RationalNumber object.|
624| valueOf(): number | Take the current RationalNumber object to an integer value or a floating point value. |
625| static getCommonDivisor(number1: number, number2: number,): number | Obtain the greatest common divisor of two specified numbers. |
626| getDenominator(): number | Get the denominator of the current RationalNumber object. |
627| getNumerator(): number | Get the numerator of the current RationalNumber object. |
628| isFinite(): boolean | Check that the current RationalNumber object is limited. |
629| isNaN(): boolean | Check whether the current RationalNumber object represents a non-number (NaN) value. |
630| isZero(): boolean | Check whether the current RationalNumber object represents a zero value. |
631| toString(): string | Get the string representation of the current RationalNumber object. |
632| constructor(capacity?: number) | The Create Default constructor is used to create a new LruBuffer instance with a default capacity of 64. |
633| updateCapacity(newCapacity: number): void | Updates the buffer capacity to the specified capacity. This exception is thrown if newCapacity is less than or equal to 0. |
634| toString(): string | Returns the string representation of the object and outputs the string representation of the object. |
635| values(): V[ ] | Gets a list of all values in the current buffer, and the output returns a list of all values in the current buffer in ascending order, from most recently accessed to least recently accessed. |
636| length: number | represents the total number of values in the current buffer. The output returns the total number of values in the current buffer. |
637| getCapacity(): number | Gets the capacity of the current buffer. The output returns the capacity of the current buffer. |
638| clear(): void | The key value pairs are cleared from the current buffer, after the key value is cleared, the afterRemoval () method is invoked to perform subsequent operations in turn. |
639| getCreateCount(): number | Get the number of times the returned value of createdefault(), and output the number of times the returned value of createdefault(). |
640| getMissCount(): number | Get the number of times the query value does not match, and output the number of times the query value does not match. |
641| getRemovalCount(): number | Gets the number of evictions from the buffer, and outputs the number of evictions from the buffer. |
642| getMatchCount​(): number | Obtain the number of successful matching of query values, and output the number of successful matching of query values. |
643| getPutCount(): number | Gets the number of times the value was added to the buffer, and the output returns the number of times the value was added to the buffer. |
644| isEmpty(): boolean | Checks whether the current buffer is empty and returns true if the current buffer does not contain any values. |
645| get(key: K):V \| undefined | Indicates the key to query. If the specified key exists in the buffer, the value associated with the key will be returned; Otherwise, undefined is returned. |
646| put(key: K, value: V): V | Adding the key value pair to the buffer and outputting the value associated with the added key; If the key to be added already exists, the original value is returned. If the key or value is empty, this exception is thrown. |
647| keys(): K[ ] | Get the key list of the value in the current buffer, and the output returns the key list sorted from the most recent access to the least recent access. |
648| remove​(key: K):V \| undefined | Deletes the specified key and its associated value from the current buffer. |
649| afterRemoval(isEvict: boolean, key: K, value: V, newValue: V): void | Perform subsequent operations after deleting the value. |
650| contains(key: K): boolean | Checks whether the current buffer contains the specified key, and returns true if the buffer contains the specified key. |
651| createDefault(key: K): V | If the value of a specific key is not calculated, subsequent operations are performed. The parameter represents the missing key, and the output returns the value associated with the key. |
652| entries(): [K,V] | Allows you to iterate over all key value pairs contained in this object. The keys and values of each pair are objects. |
653| \[Symbol.iterator\](): [K,V]| Returns a two-dimensional array in the form of key value pairs. |
654| constructor(lowerObj: ScopeType, upperObj: ScopeType) | Creates and returns a Scope object that creates a constructor for a scope instance that specifies a lower and upper bound. |
655| toString():string | The stringification method returns a  string representation that contains the current range. |
656| intersect(range: Scope): Scope | Gets the intersection of the given range and the current range. |
657| intersect(lowerObj: ScopeType, upperObj: ScopeType): Scope | Gets the intersection of the current range with a given lower and upper bound range. |
658| getUpper(): ScopeType | Gets the upper bound of the current scope. |
659| getLower(): ScopeType | Gets the lower bound of the current scope. |
660| expand(lowerObj: ScopeType, upperObj:  ScopeType): Scope | Creates and returns a union that includes the current range and a given lower and upper bound. |
661| expand(range: Scope): Scope | Creates and returns a union that includes the current range and the given range. |
662| expand(value: ScopeType): Scope | Creates and returns a union that includes the current range and the given value. |
663| contains(value: ScopeType): boolean | Checks whether the given value is included in the current range. |
664| contains(range: Scope): boolean | Checks whether the given range is within the current range. |
665| clamp(value: ScopeType): ScopeType | Clips the specified value to the current range. |
666| function printf(format: string, ...args: Object[]): string | The util.format() method returns a formatted string using the first argument as a printf-like format string which can contain zero or more format specifiers. |
667| function getErrorString(errno: number): string |  The geterrorstring () method uses a system error number as a parameter to return system error information. |
668| function callbackWrapper(original: Function): (err: Object, value: Object) => void | Takes an async function (or a function that returns a Promise) and returns a function following the error-first callback style, i.e. taking an (err, value) => ... callback as the last argument. In the callback, the first argument will be the rejection reason (or null if the Promise resolved), and the second argument will be the resolved value. |
669| function promiseWrapper(original: (err: Object, value: Object) => void): Object | Takes a function following the common error-first callback style, i.e. taking an (err, value) => ... callback as the last argument, and returns a version that returns promises. |
670| isAnyArrayBuffer(value: Object): boolean | Check whether the entered value is of arraybuffer or sharedarraybuffer type. |
671| isArrayBufferView(value: Object): boolean | Check whether the entered value is napi_ int8_ array or napi_ uint8_ array or naPi_ uint8_ clamped_ array or naPi_ int16_ array or naPi_ uint16_ array or napi_ int32_ array or napi_ uint32_ array or napi_ float32_ array or napi_ float64_ array array or DataView type. |
672| isArgumentsObject(value: Object): boolean | Check whether the entered value is an arguments object type. |
673| isArrayBuffer(value: Object): boolean | Check whether the entered value is of arraybuffer type. |
674| isAsyncFunction(value: Object): boolean | Check whether the value entered is an asynchronous function type. |
675| isBigInt64Array(value: Object): boolean | Check whether the entered value is of bigint64array array type. |
676| isBigUint64Array(value: Object): boolean | Check whether the entered value is of biguint64array array array type. |
677| isBooleanObject(value: Object): boolean | Check whether the entered value is a Boolean object type. |
678| isBoxedPrimitive(value: Object): boolean | Check whether the entered value is a Boolean or number or string or symbol object type. |
679| isDataView(value: Object): boolean | Check whether the entered value is of DataView type. |
680| isDate(value: Object): boolean | Check whether the entered value is of type date. |
681| isExternal(value: Object): boolean | Check whether the entered value is a native external value type. |
682| isFloat32Array(value: Object): boolean | Check whether the entered value is of float32array array type. |
683| isFloat64Array(value: Object): boolean | Check whether the entered value is of float64array array type. |
684| isGeneratorFunction(value: Object): boolean | Check whether the input value is a generator function type. |
685| isGeneratorObject(value: Object): boolean | Check whether the entered value is a generator object type. |
686| isInt8Array(value: Object): boolean | Check whether the entered value is of int8array array type. |
687| isInt16Array(value: Object): boolean | Check whether the entered value is the int16array type. |
688| isInt32Array(value: Object): boolean | Check whether the entered value is the int32array array type. |
689| isMap(value: Object): boolean | Check whether the entered value is of map type. |
690| isMapIterator(value: Object): boolean | Check whether the entered value is the iterator type of map. |
691| isModuleNamespaceObject(value: Object): boolean | Check whether the entered value is the module namespace object object type. |
692| isNativeError(value: Object): boolean | Check whether the value entered is of type error. |
693| isNumberObject(value: Object): boolean | Check whether the entered value is of the number object type. |
694| isPromise(value: Object): boolean | Check whether the entered value is of promise type. |
695| isProxy(value: Object): boolean | Check whether the value entered is of proxy type. |
696| isRegExp(value: Object): boolean | Check whether the entered value is of type regexp. |
697| isSet(value: Object): boolean | Check whether the entered value is of type set. |
698| isSetIterator(value: Object): boolean | Check whether the entered value is the iterator type of set. |
699| isSharedArrayBuffer(value: Object): boolean | Check whether the entered value is of type sharedarraybuffer. |
700| isStringObject(value: Object): boolean | Check whether the entered value is a string object type. |
701| isSymbolObject(value: Object): boolean | Check whether the entered value is a symbol object type. |
702| isTypedArray(value: Object): boolean | Check whether the entered value is a type contained in typedarray. |
703| isUint8Array(value: Object): boolean | Check whether the entered value is the uint8array array type. |
704| isUint8ClampedArray(value: Object): boolean | Check whether the entered value is the uint8clapedarray array type. |
705| isUint16Array(value: Object): boolean | Check whether the entered value is the uint16array array array type. |
706| isUint32Array(value: Object): boolean | Check whether the entered value is the uint32array array type. |
707| isWeakMap(value: Object): boolean | Check whether the entered value is of type weakmap. |
708| isWeakSet(value: Object): boolean | Check whether the entered value is of type weakset. |
709
710Each specifier in printf is replaced with a converted value from the corresponding parameter. Supported specifiers are:
711| Stylized character | Style requirements |
712| -------- | -------- |
713|    %s:  | String will be used to convert all values except BigInt, Object and -0. |
714|    %d:  | Number will be used to convert all values except BigInt and Symbol. |
715|    %i:  | parseInt(value, 10) is used for all values except BigInt and Symbol. |
716|    %f:  | parseFloat(value) is used for all values expect Symbol. |
717|    %j:  | JSON. Replaced with the string '[Circular]' if the argument contains circular references. |
718|    %o:  | Object. A string representation of an object with generic JavaScript object formatting. Similar to util.inspect() with options { showHidden: true, showProxy: true }. This will show the full object including non-enumerable properties and proxies. |
719|    %O:  | Object. A string representation of an object with generic JavaScript object formatting. Similar to util.inspect() without options. This will show the full object not including non-enumerable properties and proxies. |
720|    %c:  | CSS. This specifier is ignored and will skip any CSS passed in. |
721|    %%:  | single percent sign ('%'). This does not consume an argument. |
722
723#### 2.3.2.Instruction for use
724
725
726The use methods of each interface are as follows:
727
7281.readonly encoding()
729
730```
731import util from '@ohos.util'
732var textEncoder = new util.TextEncoder();
733var getEncoding = textEncoder.encoding();
734```
7352.encode()
736```
737import util from '@ohos.util'
738var textEncoder = new util.TextEncoder();
739var result = textEncoder.encode('abc');
740```
7413.encodeInto()
742```
743import util from '@ohos.util'
744var textEncoder = new util.TextEncoder();
745var obj = textEncoder.encodeInto('abc', dest);
746```
7474.textDecoder()
748```
749import util from '@ohos.util'
750var textDecoder = new util.textDecoder("utf-16be", {fatal : true, ignoreBOM : false});
751```
7525.readonly encoding()
753```
754import util from '@ohos.util'
755var textDecoder = new util.textDecoder("utf-16be", {fatal : true, ignoreBOM : false});
756var getEncoding = textDecoder.encoding();
757```
7586.readonly fatal()
759```
760import util from '@ohos.util'
761var textDecoder = new util.textDecoder("utf-16be", {fatal : true, ignoreBOM : false});
762var fatalStr = textDecoder.fatal();
763```
7647.readonly ignoreBOM()
765```
766import util from '@ohos.util'
767var textDecoder = new util.textDecoder("utf-16be", {fatal : true, ignoreBOM : false});
768var ignoreBom = textDecoder.ignoreBOM();
769```
7708.decode()
771```
772import util from '@ohos.util'
773var textDecoder = new util.textDecoder("utf-16be", {fatal : true, ignoreBOM : false});
774var result = textDecoder.decode(input, {stream : true});
775```
7769.decodeWithStream()
777```
778import util from '@ohos.util'
779var textDecoder = new util.textDecoder("utf-16be", {fatal : true, ignoreBOM : false});
780var result = textDecoder.decodeWithStream(input, {stream : true});
781```
78210.printf()
783```
784import util from '@ohos.util'
785var format = "%%%o%%%i%s";
786var value =  function aa(){};
787var value1 = 1.5;
788var value2 = "qwer";
789var result = util.printf(format,value,value1,value2);
790```
79111.getErrorString()
792```
793import util from '@ohos.util'
794var errnum = 13;
795var result = util.getErrorString(errnum);
796```
79712.callbackWrapper()
798```
799import util from '@ohos.util'
800async function promiseFn() {
801    return Promise.resolve('value');
802};
803var cb = util.callbackWrapper(promiseFn);
804cb((err, ret) => {
805    expect(err).strictEqual(null);
806    expect(ret).strictEqual('value');
807})
808```
80913.promiseWrapper()
810```
811import util from '@ohos.util'
812function aysnFun(str1, str2, callback) {
813    if (typeof str1 === 'string' && typeof str1 === 'string') {
814        callback(null, str1 + str2);
815    } else {
816        callback('type err');
817    }
818}
819let newPromiseObj = util.promiseWrapper(aysnFun)("Hello", 'World');
820newPromiseObj.then(res => {
821    expect(res).strictEqual('HelloWorld');
822})
823```
82414.encodeSync()
825```
826import util from '@ohos.util'
827var that = new util.Base64();
828var array = new Uint8Array([115,49,51]);
829var result = that.encodeSync(array);
830```
83115.encodeToStringSync()
832```
833import util from '@ohos.util'
834var that = new util.Base64();
835var array = new Uint8Array([115,49,51]);
836var result = that.encodeToStringSync(array);
837```
83816.decodeSync()
839```
840import util from '@ohos.util'
841var that = new util.Base64()
842var buff = 'czEz';
843var result = that.decodeSync(buff);
844```
84517.encode()
846```
847import util from '@ohos.util'
848var that = new util.Base64()
849var array = new Uint8Array([115,49,51]);
850await that.encode(array).then(val=>{
851})
852done()
853```
85418.encodeToString()
855```
856import util from '@ohos.util'
857var that = new util.Base64()
858var array = new Uint8Array([115,49,51]);
859await that.encodeToString(array).then(val=>{
860})
861done()
862```
86319.decode()
864```
865import util from '@ohos.util'
866var that = new util.Base64()
867var buff = 'czEz';
868await that.decode(buff).then(val=>{
869})
870done()
871```
87220.createRationalFromString()
873```
874import util from '@ohos.util'
875var pro = new util.RationalNumber(0, 0);
876var res = pro.createRationalFromString("-1:2");
877var result1 = res.value();
878```
87921.compareTo()
880```
881import util from '@ohos.util'
882var pro = new util.RationalNumber(2, 1);
883var proc = new util.RationalNumber(3, 4);
884var res = pro.compareTo(proc);
885```
88622.equals()
887```
888import util from '@ohos.util'
889var pro = new util.RationalNumber(2, 1);
890var proc = new util.RationalNumber(3, 4);
891var res = pro.equals(proc);
892```
89323.valueOf()
894```
895import util from '@ohos.util'
896var pro = new util.RationalNumber(2, 1);
897var res = pro.value();
898```
89924.getCommonDivisor()
900```
901import util from '@ohos.util'
902var pro = new util.RationalNumber(0, 0);
903var res = pro.getCommonDivisor(4, 8);
904```
90525.getDenominator()
906```
907import util from '@ohos.util'
908var pro = new util.RationalNumber(2, 1);
909var res = pro.getDenominator();
910```
91126.getNumerator()
912```
913import util from '@ohos.util'
914var pro = new util.RationalNumber(-2, 1);
915var res = pro.getNumerator();
916```
91727.isFinite()
918```
919import util from '@ohos.util'
920var pro = new util.RationalNumber(-2, 1);
921var res = pro.isFinite();
922```
92328.isNaN()
924```
925import util from '@ohos.util'
926var pro = new util.RationalNumber(-2, 1);
927var res = pro.isNaN();
928```
92929.isZero()
930```
931import util from '@ohos.util'
932var pro = new util.RationalNumber(-2, 1);
933var res = pro.isZero();
934
935```
93630.toString()
937```
938import util from '@ohos.util'
939var pro = new util.RationalNumber(-2, 1);
940var res = pro.toString();
941
942```
94331.updateCapacity()
944```
945import util from '@ohos.util'
946var pro = new util.LruBuffer();
947var result = pro.updateCapacity(100);
948```
94932.toString()
950```
951import util from '@ohos.util'
952var pro = new util.LruBuffer();
953pro.put(2,10);
954pro.get(2);
955pro.remove(20);
956var result = pro.toString();
957```
95833.values()
959```
960import util from '@ohos.util'
961var pro = new util.LruBuffer();
962pro.put(2,10);
963pro.put(2,"anhu");
964pro.put("afaf","grfb");
965var result = pro.values();
966```
96734.length
968```
969import util from '@ohos.util'
970var pro = new util.LruBuffer();
971pro.put(2,10);
972pro.put(1,8);
973var result = pro.length;
974```
97535.getCapacity()
976```
977import util from '@ohos.util'
978var pro = new util.LruBuffer();
979var result = pro.getCapacity();
980```
98136.clear()
982```
983import util from '@ohos.util'
984var pro = new util.LruBuffer();
985pro.put(2,10);
986pro.clear();
987```
98837.getCreateCount()
989```
990import util from '@ohos.util'
991var pro = new util.LruBuffer();
992pro.put(1,8);
993var result = pro.getCreateCount();
994```
99538.getMissCount()
996```
997import util from '@ohos.util'
998var pro = new util.LruBuffer();
999pro.put(2,10);
1000pro.get(2)
1001var result = pro.getMissCount();
1002```
100339.getRemovalCount()
1004```
1005import util from '@ohos.util'
1006var pro = new util.LruBuffer();
1007pro.put(2,10);
1008pro.updateCapacity(2);
1009pro.put(50,22);
1010var result = pro.getRemovalCount();
1011```
101240.getMatchCount()
1013```
1014import util from '@ohos.util'
1015var pro = new util.LruBuffer();
1016pro.put(2,10);
1017pro.get(2);
1018var result = pro.getMatchCount();
1019```
102041.getPutCount()
1021```
1022import util from '@ohos.util'
1023var pro = new util.LruBuffer();
1024pro.put(2,10);
1025var result = pro.getPutCount();
1026```
102742.isEmpty()
1028```
1029import util from '@ohos.util'
1030var pro = new util.LruBuffer();
1031pro.put(2,10);
1032var result = pro.isEmpty();
1033```
103443.get()
1035```
1036import util from '@ohos.util'
1037var pro = new util.LruBuffer();
1038pro.put(2,10);
1039var result = pro.get(2);
1040```
104144.put()
1042```
1043import util from '@ohos.util'
1044var pro = new util.LruBuffer();
1045var result = pro.put(2,10);
1046```
104745.keys()
1048```
1049import util from '@ohos.util'
1050var pro = new util.LruBuffer();
1051 pro.put(2,10);
1052var result = pro.keys();
1053```
105446.remove()
1055```
1056import util from '@ohos.util'
1057var pro = new util.LruBuffer();
1058pro.put(2,10);
1059var result = pro.remove(20);
1060```
106147.contains()
1062```
1063import util from '@ohos.util'
1064var pro = new util.LruBuffer();
1065pro.put(2,10);
1066var result = pro.contains(20);
1067```
106848.createDefault()
1069```
1070import util from '@ohos.util'
1071var pro = new util.LruBuffer();
1072var result = pro.createDefault(50);
1073```
107449.entries()
1075```
1076import util from '@ohos.util'
1077var pro = new util.LruBuffer();
1078pro.put(2,10);
1079var result = pro.entries();
1080```
108150.\[Symbol.iterator\]()
1082```
1083import util from '@ohos.util'
1084var pro = new util.LruBuffer();
1085pro.put(2,10);
1086var result = pro[symbol.iterator]();
1087```
108851.afterRemoval()
1089```
1090import util from '@ohos.util'
1091var arr = [];
1092class ChildLruBuffer extends util.LruBuffer
1093{
1094    constructor()
1095    {
1096        super();
1097    }
1098    static getInstance()
1099    {
1100        if(this.instance ==  null)
1101        {
1102            this.instance = new ChildLruBuffer();
1103        }
1104        return this.instance;
1105    }
1106    afterRemoval(isEvict, key, value, newValue)
1107    {
1108        if (isEvict === false)
1109        {
1110            arr = [key, value, newValue];
1111        }
1112    }
1113}
1114ChildLruBuffer.getInstance().afterRemoval(false,10,30,null)
1115```
1116Construct a new class in the Scope interface to implement the compareTo method.
1117
1118```
1119class Temperature {
1120    constructor(value) {
1121        this._temp = value;
1122    }
1123    compareTo(value) {
1124        return this._temp >= value.getTemp();
1125    }
1126    getTemp() {
1127        return this._temp;
1128    }
1129    toString() {
1130        return this._temp.toString();
1131    }
1132}
1133```
1134
113552.constructor()
1136
1137```
1138var tempLower = new Temperature(30);
1139var tempUpper = new Temperature(40);
1140var range = new Scope(tempLower, tempUpper);
1141```
1142
114353.toString()
1144
1145```
1146var tempLower = new Temperature(30);
1147var tempUpper = new Temperature(40);
1148var range = new Scope(tempLower, tempUpper);
1149var result = range.toString() // => [30,40]
1150```
1151
115254.intersect()
1153
1154```
1155var tempLower = new Temperature(30);
1156var tempUpper = new Temperature(40);
1157var range = new Scope(tempLower, tempUpper);
1158var tempMiDF = new Temperature(35);
1159var tempMidS = new Temperature(39);
1160var rangeFir = new Scope(tempMiDF, tempMidS);
1161var result = range.intersect(rangeFir)  // => [35,39]
1162```
1163
116455.intersect()
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.intersect(tempMiDF, tempMidS)  // => [35,39]
1173```
1174
117556.getUpper()
1176
1177```
1178var tempLower = new Temperature(30);
1179var tempUpper = new Temperature(40);
1180var range = new Scope(tempLower, tempUpper);
1181var result = range.getUpper() // => 40
1182```
1183
118457.getLower()
1185
1186```
1187var tempLower = new Temperature(30);
1188var tempUpper = new Temperature(40);
1189var range = new Scope(tempLower, tempUpper);
1190var result = range.getLower() // => 30
1191```
1192
119358.expand()
1194
1195```
1196var tempLower = new Temperature(30);
1197var tempUpper = new Temperature(40);
1198var tempMiDF = new Temperature(35);
1199var tempMidS = new Temperature(39);
1200var range = new Scope(tempLower, tempUpper);
1201var result = range.expand(tempMiDF, tempMidS)  // => [30,40]
1202```
1203
120459.expand()
1205
1206```
1207var tempLower = new Temperature(30);
1208var tempUpper = new Temperature(40);
1209var tempMiDF = new Temperature(35);
1210var tempMidS = new Temperature(39);
1211var range = new Scope(tempLower, tempUpper);
1212var rangeFir = new Scope(tempMiDF, tempMidS);
1213var result = range.expand(rangeFir) // => [30,40]
1214```
1215
121660.expand()
1217
1218```
1219var tempLower = new Temperature(30);
1220var tempUpper = new Temperature(40);
1221var tempMiDF = new Temperature(35);
1222var range = new Scope(tempLower, tempUpper);
1223var result = range.expand(tempMiDF)  // => [30,40]
1224```
1225
122661.contains()
1227
1228```
1229var tempLower = new Temperature(30);
1230var tempUpper = new Temperature(40);
1231var tempMiDF = new Temperature(35);
1232var range = new Scope(tempLower, tempUpper);
1233var result = range.contains(tempMiDF) // => true
1234```
1235
123662.contains()
1237
1238```
1239var tempLower = new Temperature(30);
1240var tempUpper = new Temperature(40);
1241var range = new Scope(tempLower, tempUpper);
1242var tempLess = new Temperature(20);
1243var tempMore = new Temperature(45);
1244var rangeSec = new Scope(tempLess, tempMore);
1245var result = range.contains(rangeSec) // => true
1246```
1247
124863.clamp()
1249
1250```
1251var tempLower = new Temperature(30);
1252var tempUpper = new Temperature(40);
1253var tempMiDF = new Temperature(35);
1254var range = new Scope(tempLower, tempUpper);
1255var result = range.clamp(tempMiDF) // => 35
1256```
125764.isAnyArrayBuffer()
1258```
1259import util from '@ohos.util'
1260var proc = new util.Types();
1261var result = proc.isAnyArrayBuffer(new ArrayBuffer([]))
1262```
126365.isArrayBufferView()
1264```
1265import util from '@ohos.util'
1266var proc = new util.Types();
1267var result = proc.isArrayBufferView(new DataView(new ArrayBuffer(16)));
1268```
126966.isArgumentsObject()
1270```
1271import util from '@ohos.util'
1272function foo() {
1273        var result = proc.isArgumentsObject(arguments);
1274    }
1275var f = foo();
1276```
127767.isArrayBuffer()
1278```
1279import util from '@ohos.util'
1280var proc = new util.Types();
1281var result = proc.isArrayBuffer(new ArrayBuffer([]));
1282```
128368.isAsyncFunction()
1284```
1285import util from '@ohos.util'
1286var proc = new util.Types();
1287var result = proc.isAsyncFunction(async function foo() {});
1288```
128969.isBigInt64Array()
1290```
1291import util from '@ohos.util'
1292var proc = new util.Types();
1293var result = proc.isBigInt64Array(new Int16Array([]));
1294```
129570.isBigUint64Array()
1296```
1297import util from '@ohos.util'
1298var proc = new util.Types();
1299var result = proc.isBigUint64Array(new Int16Array([]));
1300```
130171.isBooleanObject()
1302```
1303import util from '@ohos.util'
1304var proc = new util.Types();
1305var result = proc.isBooleanObject(new Boolean(false));
1306```
130772.isBoxedPrimitive()
1308```
1309import util from '@ohos.util'
1310var proc = new util.Types();
1311var result = proc.isBoxedPrimitive(new Boolean(false));
1312```
131373.isDataView()
1314```
1315import util from '@ohos.util'
1316var proc = new util.Types();
1317const ab = new ArrayBuffer(20);
1318var result = proc.isDataView(new DataView(ab));
1319```
132074.isDate()
1321```
1322import util from '@ohos.util'
1323var proc = new util.Types();
1324var result = proc.isDate(new Date());
1325```
132675.isExternal()
1327```
1328import util from '@ohos.util'
1329const data = util.createExternalType();
1330var reult13 = proc.isExternal(data);
1331```
133276.isFloat32Array()
1333```
1334import util from '@ohos.util'
1335var proc = new util.Types();
1336var result = proc.isFloat32Array(new Float32Array([]));
1337```
133877.isFloat64Array()
1339```
1340import util from '@ohos.util'
1341var proc = new util.Types();
1342var result = proc.isFloat64Array(new Float64Array([]));
1343```
134478.isGeneratorFunction()
1345```
1346import util from '@ohos.util'
1347var proc = new util.Types();
1348var result = proc.isGeneratorFunction(function* foo() {});
1349```
135079.isGeneratorObject()
1351```
1352import util from '@ohos.util'
1353var proc = new util.Types();
1354function* foo() {}
1355const generator = foo();
1356var result = proc.isGeneratorObject(generator);
1357```
135880.isInt8Array()
1359```
1360import util from '@ohos.util'
1361var proc = new util.Types();
1362var result = proc.isInt8Array(new Int8Array([]));
1363```
136481.isInt16Array()
1365```
1366import util from '@ohos.util'
1367var proc = new util.Types();
1368var result = proc.isInt16Array(new Int16Array([]));
1369```
137082.isInt32Array()
1371```
1372import util from '@ohos.util'
1373var proc = new util.Types();
1374var result = proc.isInt32Array(new Int32Array([]));
1375```
137683.isMap()
1377```
1378import util from '@ohos.util'
1379var proc = new util.Types();
1380var result = proc.isMap(new Map());
1381```
138284.isMapIterator()
1383```
1384import util from '@ohos.util'
1385var proc = new util.Types();
1386var result = proc.isMapIterator(map.keys());
1387```
138885.isModuleNamespaceObject()
1389```
1390import util from '@ohos.util'
1391var proc = new util.Types();
1392var result = proc.isModuleNamespaceObject(util);
1393```
139486.isNativeError()
1395```
1396import util from '@ohos.util'
1397var proc = new util.Types();
1398var result = proc.isNativeError(new TypeError());
1399```
140087.isNumberObject()
1401```
1402import util from '@ohos.util'
1403var proc = new util.Types();
1404var result = proc.isNumberObject(new Number(0));
1405```
140688.isPromise()
1407```
1408import util from '@ohos.util'
1409var proc = new util.Types();
1410var result = proc.isPromise(Promise.resolve(42));
1411```
141289.isProxy()
1413```
1414import util from '@ohos.util'
1415var proc = new util.Types();
1416const target = {};
1417const proxy = new Proxy(target, {});
1418var result = proc.isProxy(proxy);
1419```
142090.isRegExp()
1421```
1422import util from '@ohos.util'
1423var proc = new util.Types();
1424var result = proc.isRegExp(new RegExp('abc'));
1425```
142691.isSet()
1427```
1428import util from '@ohos.util'
1429var proc = new util.Types();
1430var result = proc.isSet(new Set());
1431```
143292.isSetIterator()
1433```
1434import util from '@ohos.util'
1435var proc = new util.Types();
1436const set = new Set();
1437var result = proc.isSetIterator(set.keys());
1438```
143993.isSharedArrayBuffer()
1440```
1441import util from '@ohos.util'
1442var proc = new util.Types();
1443var result = proc.isSharedArrayBuffer(new ArrayBuffer([]));
1444```
144594.isStringObject()
1446```
1447import util from '@ohos.util'
1448var proc = new util.Types();
1449var result = proc.isStringObject(new String('foo'));
1450```
145195.isSymbolObject()
1452```
1453import util from '@ohos.util'
1454var proc = new util.Types();
1455const symbols = Symbol('foo');
1456var result = proc.isSymbolObject(Object(symbols));
1457```
145896.isTypedArray()
1459```
1460import util from '@ohos.util'
1461var proc = new util.Types();
1462var result = proc.isTypedArray(new Float64Array([]));
1463```
146497.isUint8Array()
1465```
1466import util from '@ohos.util'
1467var proc = new util.Types();
1468var result = proc.isUint8Array(new Uint8Array([]));
1469```
147098.isUint8ClampedArray()
1471```
1472import util from '@ohos.util'
1473var proc = new util.Types();
1474var result = proc.isUint8ClampedArray(new Uint8ClampedArray([]));
1475```
147699.isUint16Array()
1477```
1478import util from '@ohos.util'
1479var proc = new util.Types();
1480var result = proc.isUint16Array(new Uint16Array([]));
1481```
1482100.isUint32Array()
1483```
1484import util from '@ohos.util'
1485var proc = new util.Types();
1486var result = proc.isUint32Array(new Uint32Array([]));
1487```
1488101.isWeakMap()
1489```
1490import util from '@ohos.util'
1491var proc = new util.Types();
1492var result = proc.isWeakMap(new WeakMap());
1493```
1494102.isWeakSet()
1495```
1496import util from '@ohos.util'
1497var proc = new util.Types();
1498var result = proc.isWeakSet(new WeakSet());
1499```
1500
1501## 3.js_sys_module submodule
1502### 3.1.Introduction
1503Process is mainly used to obtain the relevant ID of the process, obtain and modify the working directory of the process, exit and close the process. The childprocess object can be used to create a new process. The main process can obtain the standard input and output of the child process, send signals and close the child process.
1504### 3.2.Directory
1505
1506```
1507commomlibrary/ets_utils/js_sys_module/
1508├── Class:PROCESS                   # class of PROCESS
1509├── Uid                             # attribute of Uid
1510├── Gid                             # attribute of Gid
1511├── EUid                            # attribute of EUid
1512├── EGid                            # attribute of EGid
1513├── Groups                          # attribute of Groups
1514├── Pid                             # attribute of Pid
1515├── Ppid                            # attribute of Ppid
1516├── chdir()                         # method of chdir
1517├── uptime()                        # method of uptime
1518├── kill()                          # method of kill
1519├── abort()                         # method of abort
1520├── on()                            # method of on
1521├── tid                             # method of tid
1522├── getStartRealtime()              # method of getStartRealtime
1523├── getAvailableCores()             # method of getAvailableCores
1524├── getPastCputime()                # method of getPastCputime
1525├── isIsolatedProcess()             # method of isIsolatedProcess
1526├── is64Bit()                       # method of is64Bit
1527├── isAppUid()                      # method of isAppUid
1528├── getUidForName()                 # method of getUidForName
1529├── getThreadPriority()             # method of getThreadPriority
1530├── getSystemConfig()               # method of getSystemConfig
1531├── getEnvironmentVar()             # method of getEnvironmentVar
1532├── exit()                          # method of exit
1533├── cwd()                           # method of cwd
1534├── off()                           # method of off
1535├── runCmd()                        # method of runCmd
1536└─── Class:CHILDPROCESS             # class of CHILDPROCESS
1537    ├── close()                     # method of close
1538    ├── kill()                      # method of kill
1539    ├── getOutput()                 # method of getOutput
1540    ├── getErrorOutput()            # method of getErrorOutput
1541    ├── wait()                      # method of wait
1542    ├── killed                      # attribute of killed
1543    ├── pid                         # attribute of pid
1544    ├── ppid                        # attribute of ppid
1545    └── exitCode                    # attribute of exitCode
1546```
1547
1548### 3.3.Description
1549
1550#### 3.3.1.Interface description
1551| Interface name | description |
1552| -------- | -------- |
1553| const uid :number | returns the digital user ID of the process. |
1554| const gid :number | returns the numeric group ID of the process. |
1555| const euid :number | returns the numeric valid user identity of the process. |
1556| const egid :number | returns the numeric valid group ID of the node.js process. |
1557| const groups :number[] |  returns an array with supplementary group ID. |
1558| const pid :number | returns the PID of the process. |
1559| const ppid :number |  returns the PID of the parent process of the current process. |
1560| chdir(dir:string) :void | change the current working directory of the node.js process. |
1561| uptime() :number |  returns the number of seconds the current system has been running. |
1562| Kill(pid:number, signal:number) :boolean | send the signal to the identified process PID, and true means the sending is successful. |
1563| abort() :void | cause the node.js process to exit immediately and generate a core file. |
1564| on(type:string ,listener:EventListener) :void | used to store events triggered by users. |
1565| exit(code:number):void | cause the node.js process to exit immediately. |
1566| cwd():string |  returns the current working directory of the node.js process. |
1567| off(type: string): boolean | clear the events stored by the user. True means the clearing is successful. |
1568| runCmd(command: string, options?: { timeout : number, killSignal : number \| string, maxBuffer : number }): ChildProcess |through runcmd, you can fork a new process to run a shell and return the childprocess object. The first parameter command refers to the shell to be run, and the second parameter options refers to some running parameters of the child process. These parameters mainly refer to timeout, killsignal and maxbuffer. If timeout is set, the child process will send a signal killsignal after timeout is exceeded. Maxbuffer is used to limit the maximum stdout and stderr sizes that can be received. |
1569| wait(): Promise\<number> | is used to wait for the child process to run and return the promise object, whose value is the exit code of the child process. |
1570| getOutput(): Promise\<Uint8Array> |  used to get the standard output of the child process. |
1571| getErrorOutput(): Promise\<Uint8Array> | used to get the standard error output of the child process. |
1572| const tid:number | Returns the TID of the process. |
1573| getStartRealtime() :number | Gets the real time elapsed (in milliseconds) from system startup to process startup. |
1574| getAvailableCores() :number[] | Gets the CPU kernel available to the current process on the multi-core device. |
1575| getPastCputime() :number | Gets the CPU time (in milliseconds) from the start of the process to the current time. |
1576| isIsolatedProcess(): boolean | Check if the process is quarantined. |
1577| is64Bit(): boolean | Check whether the process is running in a 64 bit environment. |
1578| isAppUid(v:number): boolean | Checks whether the specified uid belongs to a specific application. |
1579| getUidForName(v:string): number | Obtain the user group ID to which the user belongs according to the user name |
1580| getThreadPriority(v:number): number | Gets the thread priority based on the specified TID. |
1581| getSystemConfig(name:number): number | Gets the configuration of the system according to the specified system configuration name. |
1582| getEnvironmentVar(name:string): string | Obtain the corresponding value according to the name of the environment variable. |
1583| close(): void | used to close the running child process. |
1584| kill(signal: number \| string): void |  used to send signals to child processes. |
1585| readonly killed: boolean | indicates whether the signal is sent successfully, and true indicates that the signal is sent successfully. |
1586| readonly exitCode: number | indicates the exit code of the child process. |
1587| readonly pid: number | represents the child process ID. |
1588| readonly ppid: number | represents the main process ID. |
1589
1590#### 3.3.2.Interface instructions
1591
1592Example of using interface:
15931.uid()
1594```
1595uid(){
1596    var res =  Process.uid;
1597}
1598```
15992.gid()
1600```
1601gid(){
1602    var result = Process.gid;
1603}
1604```
16053.euid()
1606```
1607euid(){
1608    var and = Process.euid;
1609}
1610```
16114.egid()
1612```
1613egid(){
1614    var resb = Process.egid;
1615}
1616```
16175.groups()
1618```
1619groups(){
1620    var answer = Process.groups;
1621}
1622```
16236.pid()
1624```
1625pid(){
1626    var result = Process.pid;
1627}
1628```
16297.ppid()
1630```
1631ppid(){
1632    var result = Process.ppid;
1633}
1634```
16358.chdir()
1636```
1637chdir(){
1638    Process.chdir("123456");
1639}
1640```
16419.uptime()
1642```
1643uptime(){
1644    var num = Process.uptime();
1645}
1646```
164710.kill()
1648```
1649kill(){
1650    var ansu = Process.kill(5,23);
1651}
1652```
165311.abort()
1654```
1655abort(){
1656    Process.abort();
1657}
1658```
165912.on()
1660```
1661on(){
1662    function add(num){
1663        var value = num + 5;
1664        return value;
1665    }
1666    Process.on("add",add);
1667}
1668```
166913.exit()
1670```
1671exit(){
1672    Process.exit(15);
1673}
1674```
167514.Cwd()
1676```
1677Cwd(){
1678    var result = Process.cwd();
1679}
1680```
168115.off()
1682
1683```
1684off(){
1685    var result =  Process.off("add");
1686}
1687```
168816.runCmd()
1689```
1690runCmd(){
1691    var child = process.runCmd('echo abc')
1692    // killSignal can be a number or a string
1693    var child = process.runCmd('echo abc;', {killSignal : 'SIGKILL'});
1694    var child = process.runCmd('sleep 5; echo abc;', {timeout : 1, killSignal : 9, maxBuffer : 2})
1695}
1696```
169717.wait()
1698```
1699wait()
1700{
1701    var child = process.runCmd('ls')
1702    var status = child.wait();
1703    status.then(val => {
1704        console.log(val);
1705    })
1706}
1707```
170818.getOutput()
1709```
1710getOutput(){
1711    var child = process.runCmd('echo bcd;');
1712    var res = child.getOutput();
1713    child.wait();
1714    res.then(val => {
1715        console.log(val);
1716    })
1717}
1718```
171919.getErrorOutput()
1720```
1721getErrorOutput(){
1722    var child = process.runCmd('makdir 1.txt'); // execute an error command
1723    var res = child.getErrorOutput();
1724    child.wait();
1725    res.then(val => {
1726        console.log(val);
1727    })
1728}
1729```
173020.close()
1731```
1732close(){
1733    var child =  process.runCmd('ls; sleep 5s;')
1734    var result = child.close()
1735}
1736```
173721.kill()
1738```
1739kill(){
1740    var child =  process.runCmd('ls; sleep 5s;')
1741    var result = child.kill('SIGHUP');
1742    child.wait();
1743    var temp = child.killed;
1744}
1745```
174622.killed
1747```
1748{
1749    var child = process.runCmd('ls; sleep 5;')
1750    child.kill(3);
1751    var killed_ = child.killed;
1752    child.wait();
1753}
1754```
175523.exitCode
1756```
1757{
1758    var child = process.runCmd('ls; sleep 5;')
1759    child.kill(9);
1760    child.wait();
1761    var exitCode_ = child.exitCode;
1762}
1763```
176424.pid
1765```
1766pid
1767{
1768    var child = process.runCmd('ls; sleep 5;')
1769    var pid_ = child.pid;
1770    child.wait();
1771}
1772```
177325.ppid
1774```
1775ppid
1776{
1777    var child = process.runCmd('ls; sleep 5;')
1778    var ppid_ = child.ppid;
1779    child.wait();
1780}
1781```
178226.tid
1783```
1784tid(){
1785    var ansu = Process.tid;
1786}
1787```
178827.isIsolatedProcess()
1789```
1790isIsolatedProcess(){
1791    var ansu = Process.isIsolatedProcess()();
1792}
1793```
179428.isAppUid()
1795```
1796isAppUid(){
1797    var ansu = Process.isAppUid(10000);
1798}
1799```
180029.is64Bit()
1801```
1802is64Bit(){
1803    var ansu = Process.is64Bit();
1804}
1805```
180630.getUidForName()
1807```
1808getUidForName(){
1809    var buf = "root";
1810    var ansu = Process.getUidForName(buf);
1811}
1812```
181331.getEnvironmentVar()
1814```
1815getEnvironmentVar(){
1816    var ansu = Process.getEnvironmentVar('USER');
1817}
1818```
181932.getAvailableCores()
1820```
1821getAvailableCores(){
1822    var ansu = Process.getAvailableCores();
1823}
1824```
182533.getThreadPriority()
1826```
1827getThreadPriority(){
1828    var result = Process.getTid();
1829    var ansu = getThreadPriority(result);
1830}
1831```
183234.getStartRealtime()
1833```
1834getStartRealtime(){
1835    var ansu = Process.getStartRealtime();
1836}
1837```
183835.getPastCputime()
1839```
1840getPastCputime(){
1841    var ansu = Process.getPastCputime();
1842}
1843```
184436.getSystemConfig()
1845```
1846getSystemConfig(){
1847    var _SC_ARG_MAX = 0;
1848    var ansu = Process.getSystemConfig(_SC_ARG_MAX)
1849}
1850```
1851
1852## 4.js_concurrent_module submodule
1853
1854### 4.1.Introduction
1855
1856Worker enables JS to have the ability of multithreading, and completes the communication between worker thread and host thread through PostMessage.
1857
1858### 4.2.Interface description
1859For interface implementation, see: js_concurrent_module/jsapi/worker
1860
1861#### 4.2.1.Worker object description
1862
1863The object object used by the host thread to communicate with the worker thread.
1864
1865##### 4.2.1.1.Interface
1866
18671.
1868
1869- name
1870
1871|constructor(scriptURL:string, options? WorkerOptions) | worker constructor to Creates a worker instance |
1872|---|---|
1873
1874- example
1875
1876```
1877import worker from "@ohos.worker"
1878const worker = new worker.Worker("workers/worker.js");
1879```
1880
18812.
1882
1883- name
1884
1885| postMessage(message:Object, options?:PostMessageOptions)  | Sends a message to the worker thread |
1886|---|---|
1887| postMessage(message:Object, transfer:ArrayBuffer[])  | Sends a message to the worker thread |
1888
1889- example
1890
1891```
1892// example 1
1893import worker from "@ohos.worker"
1894const worker = new worker.Worker("workers/worker.js");
1895worker.postMessage("hello world");
1896
1897// example 2
1898import worker from "@ohos.worker"
1899const worker = new worker.Worker("workers/worker.js");
1900var buffer = new ArrayBuffer(8);
1901worker.postMessage(buffer, [buffer]);
1902```
1903
19043.
1905
1906- name
1907
1908| on(type:string, listener:EventListener)  | Adds an event listener to the worker  |
1909|---|---|
1910
1911- example
1912
1913```
1914import worker from "@ohos.worker"
1915const worker = new worker.Worker("workers/worker.js");
1916worker.on("alert", (e)=>{
1917     console.log("worker on...");
1918})
1919```
1920
19214.
1922
1923- name
1924
1925| once(type:string, listener:EventListener)  | Adds an event listener to the worker and removes the event listener automically after it is invoked once  |
1926|---|---|
1927
1928- example
1929
1930```
1931import worker from "@ohos.worker"
1932const worker = new worker.Worker("workers/worker.js");
1933worker.once("alert", (e)=>{
1934    console.log("worker on...");
1935})
1936```
1937
19385.
1939
1940- name
1941
1942| off(type:string, listener?:EventListener)  | Removes an event listener to the worker  |
1943|---|---|
1944
1945- example
1946
1947```
1948import worker from "@ohos.worker"
1949const worker = new worker.Worker("workers/worker.js");
1950worker.off("alert");
1951```
1952
19536.
1954
1955- name
1956
1957| terminate()  | Terminates the worker thread to stop the worker from receiving messages  |
1958|---|---|
1959
1960- example
1961
1962```
1963import worker from "@ohos.worker"
1964const worker = new worker.Worker("workers/worker.js");
1965worker.terminate();
1966```
1967
19687.
1969
1970- name
1971
1972| removeEventListener(type:string, listener?:EventListener)  | Removes an event defined for the worker  |
1973|---|---|
1974
1975- example
1976
1977```
1978import worker from "@ohos.worker"
1979const worker = new worker.Worker("workers/worker.js");
1980worker.removeEventListener("alert");
1981```
1982
19838.
1984
1985- name
1986
1987| dispatchEvent(event: Event)  | Dispatches the event defined for the worker  |
1988|---|---|
1989
1990- example
1991
1992```
1993import worker from "@ohos.worker"
1994const worker = new worker.Worker("workers/worker.js");
1995worker.dispatchEvent({type:"alert"});
1996```
1997
19989.
1999
2000- name
2001
2002| removeAllListener()  | Removes all event listeners for the worker  |
2003|---|---|
2004
2005- example
2006
2007```
2008import worker from "@ohos.worker"
2009const worker = new worker.Worker("workers/worker.js");
2010worker.removeAllListener();
2011```
2012
2013##### 4.2.1.2.Attribute
2014
20151.
2016
2017- name
2018
2019| onexit?:(code:number)=>void  | The onexit attribute of the worker specifies the event handler to be called when the worker exits. The handler is executed in the host thread  |
2020|---|---|
2021
2022- example
2023
2024```
2025import worker from "@ohos.worker"
2026const worker = new worker.Worker("workers/worker.js");
2027worker.onexit = function(e) {
2028    console.log("onexit...");
2029}
2030```
2031
20322.
2033
2034- name
2035
2036| onerror?:(ev:ErrorEvent)=>void  |  The onerror attribute of the worker specifies the event handler to be called when an exception occurs during worker execution. The event handler is executed in the host thread |
2037|---|---|
2038
2039- example
2040
2041```
2042import worker from "@ohos.worker"
2043const worker = new worker.Worker("workers/worker.js");
2044worker.onerror = function(e) {
2045    console.log("onerror...");
2046}
2047```
2048
20493.
2050
2051- name
2052
2053| onmessage?:(ev:MessageEvent)=>void  | The onmessage attribute of the worker specifies the event handler to be called then the host thread receives a  message created by itself and sent by the worker through the parentPort.postMessage. The event handler is executed in the host thread  |
2054|---|---|
2055
2056- example
2057
2058```
2059import worker from "@ohos.worker"
2060const worker = new worker.Worker("workers/worker.js");
2061worker.onmessage = function(e) {
2062    console.log("onmessage...");
2063}
2064```
2065
20664.
2067
2068- name
2069
2070| onmessageerror?:(event:MessageEvent)=>void  | The onmessage attribute of the worker specifies the event handler when the worker receives a message that   cannot be serialized. The event handler is executed in the host thread |
2071|---|---|
2072
2073- example
2074
2075```
2076import worker from "@ohos.worker"
2077const worker = new worker.Worker("workers/worker.js");
2078worker.onmessageerror = function(e) {
2079    console.log("onmessageerror...");
2080}
2081```
2082
2083#### 4.2.2.parentPort object description
2084
2085Object of the worker thread used to communicate with the host thread
2086
2087##### 4.2.2.1.Interface
2088
20891.
2090
2091- name
2092
2093| postMessage(message:Object, options?:PostMessageOptions)  | Send a message to host thread  |
2094|---|---|
2095| postMessage(message:Object, transfer:ArrayBuffer[])  | Send a message to host thread |
2096
2097- example
2098
2099```
2100// main.js
2101import worker from "@ohos.worker"
2102const worker = new worker.Worker("workers/worker.js");
2103worker.postMessage("hello world");
2104
2105// worker.js
2106import worker from "@ohos.worker"
2107const parentPort = worker.parentPort;
2108parentPort.onmessage = function(e) {
2109    parentPort.postMessage("hello world from worker.js");
2110}
2111```
2112
21132.
2114
2115- name
2116
2117| close()  | Close the worker thread to stop the worker from receiving messages  |
2118|---|---|
2119
2120- example
2121
2122```
2123// main.js
2124import worker from "@ohos.worker"
2125const worker = new worker.Worker("workers/worker.js");
2126worker.postMessage("hello world");
2127
2128// worker.js
2129import worker from "@ohos.worker"
2130const parentPort = worker.parentPort;
2131parentPort.onmessage = function(e) {
2132    parentPort.close();
2133}
2134```
2135
2136##### 4.2.2.2.Attribute
2137
21381.
2139
2140- name
2141
2142| onmessage?:(event:MessageEvent)=>void  | The onmessage attribute of parentPort specifies the event handler to be called then the worker thread receives a message sent by the host thread through worker postMessage. The event handler is executed in the worker thread  |
2143|---|---|
2144
2145- example
2146
2147```
2148// main.js
2149import worker from "@ohos.worker"
2150const worker = new worker.Worker("workers/worker.js");
2151worker.postMessage("hello world");
2152
2153// worker.js
2154import worker from "@ohos.worker"
2155const parentPort = worker.parentPort;
2156parentPort.onmessage = function(e) {
2157    console.log("receive main.js message");
2158}
2159```
2160
21612.
2162
2163- name
2164
2165| onerror?:(ev: ErrorEvent)=>void  | The onerror attribute of parentPort specifies the event handler to be called when an exception occurs during worker execution. The event handler is executed in the worker thread  |
2166|---|---|
2167
2168- example
2169
2170```
2171// main.js
2172import worker from "@ohos.worker"
2173const worker = new worker.Worker("workers/worker.js");
2174worker.postMessage("hello world");
2175
2176// worker.js
2177import worker from "@ohos.worker"
2178const parentPort = worker.parentPort;
2179parentPort.onerror = function(e) {
2180    console.log("onerror...");
2181}
2182
2183```
2184
21853.
2186
2187- name
2188
2189| onmessageerror?:(event: MessageEvent)=>void  | The onmessage attribute of parentPort specifies the event handler to be called then the worker receives a message that cannot be deserialized. The event handler is executed in the worker thread.  |
2190|---|---|
2191
2192- example
2193
2194```
2195// main.js
2196import worker from "@ohos.worker"
2197const worker = new worker.Worker("workers/worker.js");
2198worker.postMessage("hello world");
2199
2200// worker.js
2201import worker from "@ohos.worker"
2202const parentPort = worker.parentPort;
2203parentPort.onmessageerror = function(e) {
2204    console.log("onmessageerror...");
2205}
2206```
2207
2208### Repositories Involved
2209
2210- ace_ace_engine(foundation/arkui/ace_engine-readme.md)
2211- ace_napi(foundation/arkui/napi-readme.md)
2212
2213## Related warehouse
2214[ets_utils Subsystem](commonlibrary/ets_utils/README.en.md)
2215
2216## License
2217
2218URL is available under [Mozilla license](https://www.mozilla.org/en-US/MPL/), and the documentation is detailed in [documentation](https://gitee.com/openharmony/js_api_module/blob/master/mozilla_docs.txt). See [LICENSE](https://gitee.com/openharmony-sig/commonlibrary_ets_utils/blob/master/LICENSE) for the full license text.

README.md

1# ets_utils组件
2ets_utils组件共提供四个子模块,分别是:js_api_module、js_util_module、js_sys_module和js_worker_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```
89
90### 1.3. 说明
91
92#### 1.3.1. 接口说明
93
94
95| 接口名 | 说明 |
96| -------- | -------- |
97| URL(url: string,base?:string \| URL) | 创建并返回一个URL对象,该URL对象引用使用绝对URL字符串,相对URL字符串和基本URL字符串指定的URL。 |
98| tostring():string | 该字符串化方法返回一个包含完整 URL 的 USVString。它的作用等同于只读的 URL.href。 |
99| toJSON():string | 该方法返回一个USVString,其中包含一个序列化的URL版本。 |
100| new URLSearchParams() | URLSearchParams() 构造器无入参,该方法创建并返回一个新的URLSearchParams 对象。 开头的'?' 字符会被忽略。 |
101| new URLSearchParams(string) | URLSearchParams(string) 构造器的入参为string数据类型,该方法创建并返回一个新的URLSearchParams 对象。 开头的'?' 字符会被忽略。 |
102| new URLSearchParams(obj) | URLSearchParams(obj) 构造器的入参为obj数据类型,该方法创建并返回一个新的URLSearchParams 对象。 开头的'?' 字符会被忽略。 |
103| new URLSearchParams(iterable) | URLSearchParams(iterable) 构造器的入参为iterable数据类型,该方法创建并返回一个新的URLSearchParams 对象。 开头的'?' 字符会被忽略。 |
104| has(name: string): boolean | 检索searchParams对象中是否含有name。有则返回true,否则返回false。 |
105| set(name: string, value string): void |  检索searchParams对象中是否含有key为name的键值对。没有的话则添加该键值对,有的话则修改对象中第一个key所对应的value,并删除键为name的其余键值对。 |
106| sort(): void | 根据键的Unicode代码点,对包含在此对象中的所有键/值对进行排序,并返回undefined。 |
107| toString(): string | 根据searchParams对象,返回适用在URL中的查询字符串。 |
108| keys(): iterableIterator\<string> | 返回一个iterator,遍历器允许遍历对象中包含的所有key值。 |
109| values(): iterableIterator\<string> | 返回一个iterator,遍历器允许遍历对象中包含的所有value值。 |
110| append(name: string, value: string): void | 在searchParams对象中插入name, value键值对。 |
111| delete(name: string): void | 遍历searchParams对象,查找所有的name,删除对应的键值对。 |
112| get(name: string): string | 检索searchParams对象中第一个name,返回name键对应的值。 |
113| getAll(name: string): string[] | 检索searchParams对象中所有name,返回name键对应的所有值。 |
114| entries(): iterableIterator<[string, string]> | 返回一个iterator,允许遍历searchParams对象中包含的所有键/值对。 |
115| forEach(): void | 通过回调函数来遍历URLSearchParams实例对象上的键值对。 |
116| urlSearchParams\[Symbol.iterator]() | 返回查询字符串中每个名称-值对的ES6迭代器。迭代器的每个项都是一个JavaScript数组。 |
117| URI​(str: string) | 通过解析给定入参(String str)来构造URI。此构造函数严格按照RFC 2396附录A中的语法规定解析给定字符串。 |
118| scheme​ | 返回此 URI 的scheme部分,如果scheme未定义,则返回 null |
119| authority​ | 返回此 URI 的解码authority部分,如果authority未定义,则返回 null。 |
120| ssp​ |  返回此 URI 的解码scheme-specific部分。 |
121| userinfo​ | 返回此 URI 的解码userinfo部分。包含passworld和username。 |
122| host​ | 返回此 URI 的host部分,如果host未定义,则返回 null。 |
123| port​ | 返回此 URI 的port部分,如果port未定义,则返回 -1。URI 的port组件(如果已定义)是一个非负整数。 |
124| query​ | 返回此 URI 的query部分,如果query未定义,则返回 null。 |
125| fragment​ | 返回此 URI 的解码fragment组件,如果fragment未定义,则返回 null。|
126| path​ | 返回此 URI 的解码path组件,如果path未定义,则返回 null。 |
127| equals(ob: Object) | 测试此 URI 是否与另一个对象相等。如果给定的对象不是 URI,则此方法立即返回 false。 |
128| normalize​() | 规范化这个 URI 的路径。如果这个 URI 的path不规范,将规范后构造一个新 URI对象返回。 |
129| checkIsAbsolute​() | 判断这个 URI 是否是绝对的。当且仅当它具有scheme部分时,URI 是绝对的,返回值为true,否则返回值为false。 |
130| ConvertXml() | 用于构造ConvertXml类对象的构造函数。此构造函数无需传入参数。 |
131| convert(xml: string, options: Object)  | 返回按选项要求转化xml字符串的JavaScrip对象。 |
132| XmlSerializer(buffer: ArrayBuffer \| DataView, encoding?: string) | 创建并返回一个XmlSerializer对象,该XmlSerializer对象传参两个第一参数是ArrayBuffer或DataView一段内存,第二个参数为文件格式(默认为UTF-8)。 |
133| setAttributes(name: string, value: string): void | 给xml文件中写入属性Attributes属性。 |
134| addEmptyElement(name: string): void | 写入一个空元素。 |
135| setDeclaration(): void | 设置Declaration使用编码写入xml声明。例如:<?xml version=“1.0”encoding=“utf-8”> |
136| startElement(name: string): void | 写入具有给定名称的elemnet开始标记。|
137| endElement(): void | 写入元素的结束标记。 |
138| setNamespace(prefix: string, namespace: string): void | 写入当前元素标记的命名空间。 |
139| setCommnet(text: string): void | 写入comment属性。 |
140| setCData(text: string): void | 写入CData属性。 |
141| setText(text: string): void | 写入Text属性。 |
142| setDocType(text: string): void | 写入DocType属性。 |
143| XmlPullParser(buffer: ArrayBuffer \| DataView, encoding?: string) | 创建并返回一个XmlPullParser对象,该XmlPullParser对象传参两个第一参数是ArrayBuffer或DataView一段内存,第二个参数为文件格式(默认为UTF-8)。 |
144| 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等信息。 |
145#### 1.3.2. 使用说明
146
147各接口使用方法如下:
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、setCommnet(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);//设置arraybuffer 方式
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## 2. js_util_module子模块
448### 2.1. 简介
449
450UTIL接口用于字符编码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实例的构造函数用于创建具有指定下限和上限的对象,并要求这些对象必须具有可比性。
451### 2.2. 目录
452
453```
454commomlibrary/ets_utils/js_util_module/
455├── Class:TextEncoder                   # TextEncoder类
456│   ├──  new TextEncoder()              # 创建TextEncoder对象
457│   ├──  encode()                       # encode方法
458│   ├──  encoding                       # encoding属性
459│   └──  encodeInto()                   # encodeInto方法
460├── Class:TextDecoder                   # TextDecoder类
461│   ├──  new TextDecoder()              # 创建TextDecoder对象
462│   ├──  decode()                       # decode方法
463|   ├──  decodeWithStream()             # decodeWithStream方法
464│   ├──  encoding                       # encoding属性
465│   ├──  fatal                          # fatal属性
466│   └──  ignoreBOM                      # ignoreBOM属性
467├── printf()                            # printf方法
468├── getErrorString()                    # getErrorString方法
469├── callbackWrapper()                   # callbackWrapper方法
470├── promiseWrapper()                    # promiseWrapper方法
471├── Class:Base64                        # Base64类
472│   ├──  new Base64()                   # 创建Base64对象
473│   ├──  encodeSync()                   # encodeSync方法
474│   ├──  encodeToStringSync()           # encodeToStringSync方法
475│   ├──  decodeSync()                   # decodeSync方法
476│   ├──  encode()                       # encode方法
477│   ├──  encodeToString()               # encodeToString方法
478│   └──  decode()                       # decode方法
479├── Class:RationalNumber                # RationalNumber类
480│   ├──  new RationalNumber()           # 创建RationalNumber对象
481│   ├──  createRationalFromString()     # createRationalFromString方法
482│   ├──  compareTo()                    # compareTo方法
483│   ├──  equals()                       # equals方法
484│   ├──  valueOf()                      # valueOf方法
485│   ├──  getCommonDivisor()             # getCommonDivisor方法
486│   ├──  getDenominator()               # getDenominator方法
487│   ├──  getNumerator()                 # getNumerator方法
488│   ├──  isFinite()                     # isFinite方法
489│   ├──  isNaN()                        # isNaN方法
490│   ├──  isZero()                       # isZero方法
491│   └──  toString()                     # toString方法
492├── Class:LruBuffer                     # LruBuffer类
493│   ├──  new LruBuffer()                # 创建LruBuffer对象
494│   ├──  updateCapacity()               # updateCapacity方法
495│   ├──  toString()                     # toString方法
496│   ├──  values()                       # values方法
497│   ├──  length                         # length属性
498│   ├──  getCapacity()                  # getCapacity方法
499│   ├──  clear()                        # clear方法
500│   ├──  getCreateCount()               # getCreateCount方法
501│   ├──  getMissCount()                 # getMissCount方法
502│   ├──  getRemovalCount()              # getRemovalCount方法
503│   ├──  getMatchCount()                # getMatchCount方法
504│   ├──  getPutCount()                  # getPutCount方法
505│   ├──  isEmpty()                      # isEmpty方法
506│   ├──  get()                          # get方法
507│   ├──  put()                          # put方法
508│   ├──  keys()                         # keys方法
509│   ├──  remove()                       # remove方法
510│   ├──  afterRemoval()                 # afterRemoval方法
511│   ├──  contains()                     # contains方法
512│   ├──  createDefault()                # createDefault方法
513│   ├──  entries()                      # entries方法
514│   └──  [Symbol.iterator]()            # Symboliterator方法
515|—— Class:Scope                         # Scope类
516|   ├── constructor()                   # 创建Scope对象
517|   ├── toString()                      # toString方法
518|   ├── intersect()                     # intersect方法
519|   ├── intersect()                     # intersect方法
520|   ├── getUpper()                      # getUpper方法
521|   ├── getLower()                      # getLower方法
522|   ├── expand()                        # expand方法
523|   ├── expand()                        # expand方法
524|   ├── expand()                        # expand法
525|   ├── contains()                      # contains方法
526|   ├── contains()                      # contains方法
527|   └── clamp()                         # clamp方法
528|—— Class:Types                         # Types类
529|   ├── isAnyArrayBuffer()              # isAnyArrayBuffer方法
530|   ├── isArrayBufferView()             # isArrayBufferView方法
531|   ├── isArgumentsObject()             # isArgumentsObject方法
532|   ├── isArrayBuffer()                 # isArrayBuffer方法
533|   ├── isAsyncFunction()               # isAsyncFunction方法
534|   ├── isBigInt64Array()               # isBigInt64Array方法
535|   ├── isBigUint64Array()              # isBigUint64Array方法
536|   ├── isBooleanObject()               # isBooleanObject方法
537|   ├── isBoxedPrimitive()              # isBoxedPrimitive方法
538|   ├── isDataView()                    # isDataView方法
539|   ├── isDate()                        # isDate方法
540|   ├── isExternal()                    # isExternal方法
541|   ├── isFloat32Array()                # isFloat32Array方法
542|   ├── isFloat64Array()                # isFloat64Array方法
543|   ├── isGeneratorFunction()           # isGeneratorFunction方法
544|   ├── isGeneratorObject()             # isGeneratorObject方法
545|   ├── isInt8Array()                   # isInt8Array方法
546|   ├── isInt16Array()                  # isInt16Array方法
547|   ├── isInt32Array()                  # isInt32Array方法
548|   ├── isMap()                         # isMap方法
549|   ├── isMapIterator()                 # isMapIterator方法
550|   ├── isModuleNamespaceObject()       # isModuleNamespaceObject方法
551|   ├── isNativeError()                 # isNativeError方法
552|   ├── isNumberObject()                # isNumberObject方法
553|   ├── isPromise()                     # isPromise方法
554|   ├── isProxy()                       # isProxy方法
555|   ├── isRegExp()                      # isRegExp方法
556|   ├── isSet()                         # isSet方法
557|   ├── isSetIterator()                 # isSetIterator方法
558|   ├── isSharedArrayBuffer()           # isSharedArrayBuffer方法
559|   ├── isStringObject()                # isStringObject方法
560|   ├── isSymbolObject()                # isSymbolObject方法
561|   ├── isTypedArray()                  # isTypedArray方法
562|   ├── isUint8Array()                  # isUint8Array方法
563|   ├── isUint8ClampedArray()           # isUint8ClampedArray方法
564|   ├── isUint16Array()                 # isUint16Array方法
565|   ├── isUint32Array()                 # isUint32Array方法
566|   ├── isWeakMap()                     # isWeakMap方法
567|   └── isWeakSet()                     # isWeakSet方法
568|—— Class:ArrayList
569|   ├── new ArrayList()                 # 创建ArrayList对象
570|   ├── length                          # length属性
571|   ├── add()                           # add方法
572|   ├── insert()                        # insert方法
573|   ├── has()                           # has方法
574|   ├── getIndexOf()                    # getIndexOf方法
575|   ├── removeByIndex()                 # removeByIndex方法
576|   ├── remove()                        # remove方法
577|   ├── getLastIndexOf()                # getLastIndexOf方法
578|   ├── removeByRange()                 # removeByRange方法
579|   ├── replaceAllElements()            # replaceAllElements方法
580|   ├── forEach()                       # forEach方法
581|   ├── sort()                          # sort方法
582|   ├── subArrayList()                  # subArrayList方法
583|   ├── clear()                         # clear方法
584|   ├── clone()                         # clone方法
585|   ├── getCapacity()                   # getCapacity方法
586|   ├── convertToArray()                # convertToArray方法
587|   ├── isEmpty()                       # isEmpty方法
588|   ├── increaseCapacityTo()            # increaseCapacityTo方法
589|   ├── trimToCurrentLength()           # trimToCurrentLength方法
590|   └── isEmpty()                       # isEmpty方法
591|—— Class:Deque
592|   ├── new Deque()                     # 创建Deque对象
593|   ├── length                          # length属性
594|   ├── add()                           # add方法
595|   ├── insertFront()                   # insertFront方法
596|   ├── insertEnd()                     # insertEnd方法
597|   ├── has()                           # has方法
598|   ├── getFirst()                      # getFirst方法
599|   ├── getLast()                       # getLast方法
600|   ├── popFirst()                      # popFirst方法
601|   ├── popLast()                       # popLast方法
602|   └── forEach()                       # forEach方法
603|—— Class:HashMap
604|   ├── new HashMap()                   # 创建HashMap对象
605|   ├── length                          # length属性
606|   ├── isEmpty()                       # isEmpty方法
607|   ├── hasKey()                        # hasKey方法
608|   ├── hasValue()                      # hasValue方法
609|   ├── setAll()                        # setAll方法
610|   ├── set()                           # set方法
611|   ├── remove()                        # remove方法
612|   ├── clear()                         # clear方法
613|   ├── keys()                          # keys方法
614|   ├── values()                        # values方法
615|   ├── replace()                       # replace方法
616|   ├── forEach()                       # forEach方法
617|   └── entries()                       # entries方法
618|—— Class:HashSet
619|   ├── new HashSet()                   # 创建HashSet对象
620|   ├── length                          # length属性
621|   ├── isEmpty()                       # isEmpty方法
622|   ├── has()                           # has方法
623|   ├── add()                           # add方法
624|   ├── remove()                        # remove方法
625|   ├── clear()                         # clear方法
626|   ├── forEach()                       # forEach方法
627|   ├── values()                        # values方法
628|   └── entries()                       # entries方法
629|—— Class:LightWeightMap
630|   ├── new LightWeightMap()            # 创建LightWeightMap对象
631|   ├── length                          # length属性
632|   ├── hasAll()                        # hasAll方法
633|   ├── hasKey()                        # hasKey方法
634|   ├── hasValue()                      # hasValue方法
635|   ├── increaseCapacityTo()            # increaseCapacityTo方法
636|   ├── entries()                       # entries方法
637|   ├── get()                           # get方法
638|   ├── getIndexOfKey()                 # getIndexOfKey方法
639|   ├── getIndexOfValue()               # getIndexOfValue方法
640|   ├── isEmpty()                       # isEmpty方法
641|   ├── getKeyAt()                      # getKeyAt方法
642|   ├── keys()                          # keys方法
643|   ├── setAll()                        # setAll方法
644|   ├── set()                           # set方法
645|   ├── remove()                        # remove方法
646|   ├── removeAt()                      # removeAt方法
647|   ├── clear()                         # clear方法
648|   ├── setValueAt()                    # setValueAt方法
649|   ├── forEach()                       # forEach方法
650|   ├── toString()                      # toString方法
651|   ├── getValueAt()                    # getValueAt方法
652|   ├── values()                        # values方法
653|   └── [Symbol.iterator]()             # [Symbol.iterator]方法
654|—— Class:LightWeightSet
655|   ├── new LightWeightSet()            # 创建LightWeightSet对象
656|   ├── length                          # length属性
657|   ├── add()                           # add方法
658|   ├── addAll()                        # addAll方法
659|   ├── hasAll()                        # hasAll方法
660|   ├── has()                           # has方法
661|   ├── equal()                         # equal方法
662|   ├── increaseCapacityTo()            # increaseCapacityTo方法
663|   ├── getIndexOf()                    # getIndexOf方法
664|   ├── remove()                        # remove方法
665|   ├── removeAt()                      # removeAt方法
666|   ├── clear()                         # clear方法
667|   ├── forEach()                       # forEach方法
668|   ├── [Symbol.iterator]()             # [Symbol.iterator]方法
669|   ├── toString()                      # toString方法
670|   ├── toArray()                       # toArray方法
671|   ├── getValueAt()                    # getValueAt方法
672|   ├── values()                        # values方法
673|   ├── entries()                       # entries方法
674|   └── isEmpty()                       # isEmpty方法
675|—— Class:LinkedList
676|   ├── new LinkedList()                # 创建LinkedList对象
677|   ├── length                          # length属性
678|   ├── add()                           # add方法
679|   ├── insert()                        # insert方法
680|   ├── get()                           # get方法
681|   ├── addFirst()                      # addFirst方法
682|   ├── removeFirst()                   # removeFirst方法
683|   ├── removeLast()                    # removeLast方法
684|   ├── has()                           # has方法
685|   ├── getIndexOf()                    # getIndexOf方法
686|   ├── removeByIndex()                 # removeByIndex方法
687|   ├── remove()                        # remove方法
688|   ├── removeFirstFound()              # removeFirstFound方法
689|   ├── removeLastFound()               # removeLastFound方法
690|   ├── getLastIndexOf()                # getLastIndexOf方法
691|   ├── getFirst()                      # getFirst方法
692|   ├── getLast()                       # getLast方法
693|   ├── set()                           # set方法
694|   ├── forEach()                       # forEach方法
695|   ├── clear()                         # clear方法
696|   ├── clone()                         # clone方法
697|   ├── convertToArray()                # convertToArray方法
698|   └── [Symbol.iterator]()             # [Symbol.iterator]方法
699|—— Class:List
700|   ├── new List()                      # 创建List对象
701|   ├── length                          # length属性
702|   ├── add()                           # add方法
703|   ├── insert()                        # insert方法
704|   ├── get()                           # get方法
705|   ├── has()                           # has方法
706|   ├── getIndexOf()                    # getIndexOf方法
707|   ├── removeByIndex()                 # removeByIndex方法
708|   ├── remove()                        # remove方法
709|   ├── getLastIndexOf()                # getLastIndexOf方法
710|   ├── getFirst()                      # getFirst方法
711|   ├── getLast()                       # getLast方法
712|   ├── set()                           # set方法
713|   ├── equal()                         # equal方法
714|   ├── forEach()                       # forEach方法
715|   ├── sort()                          # sort方法
716|   ├── clear()                         # clear方法
717|   ├── getSubList()                    # getSubList方法
718|   ├── replaceAllElements()            # replaceAllElements方法
719|   ├── convertToArray()                # convertToArray方法
720|   ├── isEmpty()                       # isEmpty方法
721|   └── [Symbol.iterator]()             # [Symbol.iterator]方法
722|—— Class:PlainArray
723|   ├── new PlainArray()                # 创建PlainArray对象
724|   ├── length                          # length属性
725|   ├── add()                           # add方法
726|   ├── clear()                         # clear方法
727|   ├── clone()                         # clone方法
728|   ├── has()                           # has方法
729|   ├── get()                           # get方法
730|   ├── getIndexOfKey()                 # getIndexOfKey方法
731|   ├── getIndexOfValue()               # getIndexOfValue方法
732|   ├── isEmpty()                       # isEmpty方法
733|   ├── getKeyAt()                      # getKeyAt方法
734|   ├── remove()                        # remove方法
735|   ├── removeAt()                      # removeAt方法
736|   ├── removeRangeFrom()               # removeRangeFrom方法
737|   ├── setValueAt()                    # setValueAt方法
738|   ├── toString()                      # toString方法
739|   ├── getValueAt()                    # getValueAt方法
740|   ├── forEach()                       # forEach方法
741|   └── [Symbol.iterator]()             # [Symbol.iterator]方法
742|—— Class:Queue
743|   ├── new Queue()                     # 创建Queue对象
744|   ├── length                          # length属性
745|   ├── add()                           # add方法
746|   ├── getFirst()                      # getFirst方法
747|   ├── pop()                           # pop方法
748|   ├── forEach()                       # forEach方法
749|   └── [Symbol.iterator]()             # [Symbol.iterator]方法
750|—— Class:Stack
751|   ├── new Stack()                     # 创建Stack对象
752|   ├── length                          # length属性
753|   ├── isEmpty()                       # isEmpty方法
754|   ├── peek()                          # peek方法
755|   ├── pop()                           # pop方法
756|   ├── push()                          # push方法
757|   ├── locate()                        # locate方法
758|   ├── forEach()                       # forEach方法
759|   └── [Symbol.iterator]()             # [Symbol.iterator]方法
760|—— Class:TreeMap
761|   ├── new TreeMap()                   # 创建TreeMap对象
762|   ├── length                          # length属性
763|   ├── isEmpty()                       # isEmpty方法
764|   ├── hasKey()                        # hasKey方法
765|   ├── hasValue()                      # hasValue方法
766|   ├── get()                           # get方法
767|   ├── getFirstKey()                   # getFirstKey方法
768|   ├── getLastKey()                    # getLastKey方法
769|   ├── setAll()                        # setAll方法
770|   ├── set()                           # set方法
771|   ├── remove()                        # remove方法
772|   ├── clear()                         # clear方法
773|   ├── getLowerKey()                   # getLowerKey方法
774|   ├── getHigherKey()                  # getHigherKey方法
775|   ├── keys()                          # keys方法
776|   ├── values()                        # values方法
777|   ├── replace()                       # replace方法
778|   ├── forEach()                       # forEach方法
779|   ├── entries()                       # entries方法
780|   └── [Symbol.iterator]()             # [Symbol.iterator]方法
781└── Class:TreeSet
782    ├── new TreeSet()                   # 创建TreeSet对象
783    ├── length                          # length属性
784    ├── isEmpty()                       # isEmpty方法
785    ├── has()                           # has方法
786    ├── add()                           # add方法
787    ├── remove()                        # remove方法
788    ├── clear()                         # clear方法
789    ├── getFirstValue()                 # getFirstValue方法
790    ├── getLastValue()                  # getLastValue方法
791    ├── getLowerValue()                 # getLowerValue方法
792    ├── getHigherValue()                # getHigherValue方法
793    ├── popFirst()                      # popFirst方法
794    ├── popLast()                       # popLast方法
795    ├── forEach()                       # forEach方法
796    ├── values()                        # values方法
797    ├── entries()                       # entries方法
798    └── [Symbol.iterator]()             # [Symbol.iterator]方法
799```
800
801### 2.3. 说明
802
803#### 2.3.1. 接口说明
804
805
806| 接口名 | 说明 |
807| -------- | -------- |
808| constructor(encoding? : string) | 构造函数,参数encoding表示编码的格式。默认utf-8, 支持gb18030, gbk, gb2312. |
809| readonly encoding : string | 在TextEncoder类中,获取编码的格式,只支持UTF-8。 |
810| encode(input : string) : Uint8Array | 输入stirng字符串,根据encodeing编码并输出uint8字节流。 |
811| encodeInto(input : string, dest : Uint8Array) : {read : number, written : number} | 输入stirng字符串,dest表示编码后存放位置,返回一个对象,read表示已经编码的字符的个数,written表示已编码字符所占字节的大小。 |
812| constructor(encoding? : string, options? : {fatal? : boolean, ignoreBOM? : boolean}) | 构造函数,第一个参数encoding表示解码的格式。第二个参数表示一些属性。属性中fatal表示是否抛出异常,ignoreBOM表示是否忽略bom标志。 |
813| readonly encoding : string | 在TextDecoder类中,获取设置的解码格式。 |
814| readonly fatal : boolean | 获取抛出异常的设置。 |
815| readonly ignoreBOM : boolean | 获取是否忽略bom标志的设置。 |
816| decode(input : Uint8Array, options?: { stream?: false }) : string | 输入要解码的数据,解出对应的string字符串。第一个参数input表示要解码的数据,第二个参数options表示一个bool标志,表示将跟随附加数据,默认为false。 |
817| decodeWithStream(input : Uint8Array, options?: { stream?: false }) : string | 输入要解码的数据,解出对应的string字符串。第一个参数input表示要解码的数据,第二个参数options表示一个bool标志,表示将跟随附加数据,默认为false。 |
818| encodeSync(src: Uint8Array): Uint8Array; | 使用Base64编码方案将指定u8数组中的所有字节编码到新分配的u8数组中。 |
819| encodeToStringSync(src: Uint8Array): string; | 使用Base64编码方案将指定的字节数组编码为String。 |
820| decodeSync(src: Uint8Array \| string): Uint8Array; | 使用Base64编码方案将Base64编码的字符串或输入u8数组解码为新分配的u8数组。 |
821| encode(src: Uint8Array): Promise\<Uint8Array\>; | 使用Base64编码方案将指定u8数组中的所有字节异步编码到新分配的u8数组中。 |
822| encodeToString(src: Uint8Array): Promise\<string\>; | 使用Base64编码方案将指定的字节数组异步编码为String。 |
823| decode(src: Uint8Array \| string): Promise\<Uint8Array\>; | 使用Base64编码方案将Base64编码的字符串或输入u8数组异步解码为新分配的u8数组。 |
824| static createRationalFromString(rationalString: string): RationalNumber | 基于给定的字符串创建一个RationalNumber对象。 |
825| compareTo(another: RationalNumber): number | 将当前的RationalNumber对象与给定的对象进行比较。 |
826| equals(obj: object): number | 检查给定对象是否与当前 RationalNumber 对象相同。 |
827| valueOf(): number | 将当前的RationalNumber对象进行取整数值或者浮点数值。 |
828| static getCommonDivisor(number1: number, number2: number,): number | 获得两个指定数的最大公约数。 |
829| getDenominator(): number | 获取当前的RationalNumber对象的分母。 |
830| getNumerator(): number | 获取当前的RationalNumber对象的分子。 |
831| isFinite(): boolean | 检查当前的RationalNumber对象是有限的。 |
832| isNaN(): boolean | 检查当前RationalNumber对象是否表示非数字(NaN)值。 |
833| isZero(): boolean | 检查当前RationalNumber对象是否表示零值。 |
834| toString(): string | 获取当前RationalNumber对象的字符串表示形式。 |
835| constructor(capacity?: number) | 创建默认构造函数用于创建一个新的LruBuffer实例,默认容量为64。 |
836| updateCapacity(newCapacity: number): void | 将缓冲区容量更新为指定容量,如果 newCapacity 小于或等于 0,则抛出此异常。 |
837| toString(): string | 返回对象的字符串表示形式,输出对象的字符串表示  |
838| values(): V[] | 获取当前缓冲区中所有值的列表,输出按升序返回当前缓冲区中所有值的列表,从最近访问到最近最少访问。 |
839| length: number | 代表当前缓冲区中值的总数,输出返回当前缓冲区中值的总数。 |
840| getCapacity(): number | 获取当前缓冲区的容量,输出返回当前缓冲区的容量。 |
841| clear(): void | 从当前缓冲区清除键值对,清除键值对后,调用afterRemoval()方法依次对其执行后续操作。 |
842| getCreateCount(): number | 获取createDefault()返回值的次数,输出返回createDefault()返回值的次数。 |
843| getMissCount(): number | 获取查询值不匹配的次数,输出返回查询值不匹配的次数。 |
844| getRemovalCount(): number | 获取从缓冲区中逐出值的次数,输出从缓冲区中驱逐的次数。 |
845| getMatchCount​(): number | 获取查询值匹配成功的次数,输出返回查询值匹配成功的次数。 |
846| getPutCount(): number | 获取将值添加到缓冲区的次数,输出返回将值添加到缓冲区的次数。 |
847| isEmpty(): boolean | 检查当前缓冲区是否为空,输出如果当前缓冲区不包含任何值,则返回 true 。 |
848| get(key: K) : V \| undefined | 表示要查询的键,输出如果指定的键存在于缓冲区中,则返回与键关联的值;否则返回undefined。 |
849| put(key: K , value: V): V | 将键值对添加到缓冲区,输出与添加的键关联的值;如果要添加的键已经存在,则返回原始值,如果键或值为空,则抛出此异常。 |
850| keys(): K[ ] | 获取当前缓冲区中值的键列表,输出返回从最近访问到最近最少访问排序的键列表。 |
851| remove​(key: K): V \| undefined |  从当前缓冲区中删除指定的键及其关联的值。 |
852| afterRemoval(isEvict: boolean, key: K, value : V, newValue : V):void | 删除值后执行后续操作。 |
853| contains(key: K): boolean | 检查当前缓冲区是否包含指定的键,输出如果缓冲区包含指定的键,则返回 true 。 |
854| createDefault(key: K): V | 如果未计算特定键的值,则执行后续操作,参数表示丢失的键,输出返回与键关联的值。 |
855| entries(): [K,V] | 允许迭代包含在这个对象中的所有键值对。每对的键和值都是对象。 |
856| \[Symbol.iterator\](): [K,V] | 返回以键值对得形式得一个二维数组。 |
857| constructor(lowerObj: ScopeType, upperObj : ScopeType) | 创建并返回一个Scope对象,用于创建指定下限和上限的作用域实例的构造函数。 |
858| toString(): string | 该字符串化方法返回一个包含当前范围的字符串表示形式。 |
859| intersect(range: Scope): Scope | 获取给定范围和当前范围的交集。 |
860| intersect(lowerObj: ScopeType, upperObj: ScopeType): Scope | 获取当前范围与给定下限和上限范围的交集。 |
861| getUpper(): ScopeType | 获取当前范围的上限。 |
862| getLower(): ScopeType | 获取当前范围的下限。 |
863| expand(lowerObj: ScopeType, upperObj:  ScopeType): Scope | 创建并返回包括当前范围和给定下限和上限的并集。 |
864| expand(range: Scope): Scope | 创建并返回包括当前范围和给定范围的并集。 |
865| expand(value: ScopeType): Scope | 创建并返回包括当前范围和给定值的并集。 |
866| contains(value: ScopeType): boolean | 检查给定value是否包含在当前范围内。 |
867| contains(range: Scope): boolean | 检查给定range是否在当前范围内。 |
868| clamp(value: ScopeType): ScopeType | 将给定value限定到当前范围内。 |
869| function printf(format: string, ...args: Object[]): string | printf()方法使用第一个参数作为格式字符串(其可以包含零个或多个格式说明符)来返回格式化的字符串。 |
870| function getErrorString(errno: number): string | getErrorString()方法使用一个系统的错误数字作为参数,用来返回系统的错误信息。 |
871| function callbackWrapper(original: Function): (err: Object, value: Object) => void | 参数为一个采用 async 函数(或返回 Promise 的函数)并返回遵循错误优先回调风格的函数,即将 (err, value) => ... 回调作为最后一个参数。 在回调中,第一个参数将是拒绝原因(如果 Promise 已解决,则为 null),第二个参数将是已解决的值。 |
872| function promiseWrapper(original: (err: Object, value: Object) => void): Object | 参数为采用遵循常见的错误优先的回调风格的函数(也就是将 (err, value) => ... 回调作为最后一个参数),并返回一个返回 promise 的版本。 |
873| isAnyArrayBuffer(value: Object): boolean | 检查输入的value是否是ArrayBuffer或SharedArrayBuffer类型。 |
874| 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类型。 |
875| isArgumentsObject(value: Object): boolean | 检查输入的value是否是一个arguments对象类型。 |
876| isArrayBuffer(value: Object): boolean | 检查输入的value是否是ArrayBuffer类型。 |
877| isAsyncFunction(value: Object): boolean | 检查输入的value是否是异步函数类型。 |
878| isBigInt64Array(value: Object): boolean | 检查输入的value是否是BigInt64Array数组类型。 |
879| isBigUint64Array(value: Object): boolean | 检查输入的value是否是BigUint64Array数组类型。 |
880| isBooleanObject(value: Object): boolean | 检查输入的value是否是一个布尔对象类型。 |
881| isBoxedPrimitive(value: Object): boolean | 检查输入的value是否是Boolean或Number或String或Symbol对象类型。 |
882| isDataView(value: Object): boolean | 检查输入的value是否是DataView类型。 |
883| isDate(value: Object): boolean | 检查输入的value是否是Date类型。 |
884| isExternal(value: Object): boolean | 检查输入的value是否是一个native External值类型。 |
885| isFloat32Array(value: Object): boolean | 检查输入的value是否是Float32Array数组类型。 |
886| isFloat64Array(value: Object): boolean | 检查输入的value是否是Float64Array数组类型。 |
887| isGeneratorFunction(value: Object): boolean | 检查输入的value是否是一个generator函数类型。 |
888| isGeneratorObject(value: Object): boolean | 检查输入的value是否是一个generator对象类型。 |
889| isInt8Array(value: Object): boolean | 检查输入的value是否是Int8Array数组类型。 |
890| isInt16Array(value: Object): boolean | 检查输入的value是否是Int16Array数组类型。 |
891| isInt32Array(value: Object): boolean | 检查输入的value是否是Int32Array数组类型。 |
892| isMap(value: Object): boolean | 检查输入的value是否是Map类型。 |
893| isMapIterator(value: Object): boolean | 检查输入的value是否是Map的iterator类型。 |
894| isModuleNamespaceObject(value: Object): boolean | 检查输入的value是否是Module Namespace Object对象类型。 |
895| isNativeError(value: Object): boolean | 检查输入的value是否是Error类型。 |
896| isNumberObject(value: Object): boolean | 检查输入的value是否是Number对象类型。 |
897| isPromise(value: Object): boolean | 检查输入的value是否是Promise类型。 |
898| isProxy(value: Object): boolean | 检查输入的value是否是Proxy类型。 |
899| isRegExp(value: Object): boolean | 检查输入的value是否是RegExp类型。 |
900| isSet(value: Object): boolean | 检查输入的value是否是Set类型。 |
901| isSetIterator(value: Object): boolean | 检查输入的value是否是Set的iterator类型。 |
902| isSharedArrayBuffer(value: Object): boolean | 检查输入的value是否是SharedArrayBuffer类型。 |
903| isStringObject(value: Object): boolean | 检查输入的value是否是一个String对象类型。 |
904| isSymbolObject(value: Object): boolean | 检查输入的value是否是一个Symbol对象类型。 |
905| isTypedArray(value: Object): boolean | 检查输入的value是否是TypedArray包含的类型。 |
906| isUint8Array(value: Object): boolean | 检查输入的value是否是Uint8Array数组类型。 |
907| isUint8ClampedArray(value: Object): boolean | 检查输入的value是否是Uint8ClampedArray数组类型。 |
908| isUint16Array(value: Object): boolean | 检查输入的value是否是Uint16Array数组类型。 |
909| isUint32Array(value: Object): boolean | 检查输入的value是否是Uint32Array数组类型。 |
910| isWeakMap(value: Object): boolean | 检查输入的value是否是WeakMap类型。 |
911| isWeakSet(value: Object): boolean | 检查输入的value是否是WeakSet类型。 |
912| add(element: T): boolean | 在ArrayList尾部插入元素。 |
913| insert(element: T, index: number): void | 在长度范围内任意位置插入指定元素。 |
914| has(element: T): boolean | 判断此ArrayList中是否含有该指定元素。 |
915| getIndexOf(element: T): number | 返回指定元素第一次出现时的下标值,查找失败返回-1。 |
916| removeByIndex(index: number): T | 根据元素的下标值查找元素,返回元素后将其删除。 |
917| remove(element: T): boolean | 删除查找到的第一个指定的元素。 |
918| getLastIndexOf(element: T): number | 返回指定元素最后一次出现时的下标值,查找失败返回-1。 |
919| removeByRange(fromIndex: number, toIndex: number): void | 从一段范围内删除元素,包括起始值但不包括终止值。 |
920| replaceAllElements(callbackFn: (value: T, index?: number, arrlist?: ArrayList<T>) => T,
921thisArg?: Object): void | 用户操作ArrayList中的元素,用操作后的元素替换原元素并返回操作后的元素。 |
922| forEach(callbackFn: (value: T, index?: number, arrlist?: ArrayList<T>) => void,
923  thisArg?: Object): void | 通过回调函数来遍历ArrayList实例对象上的元素以及元素对应的下标。 |
924| sort(comparator?: (firstValue: T, secondValue: T) => number): void | 对ArrayList中的元素排序。 |
925| subArrayList(fromIndex: number, toIndex: number): ArrayList<T> | 根据下标截取ArrayList中的一段元素,并返回这一段ArrayList实例,包括起始值但不包括终止值。 |
926| clear(): void | 清除ArrayList中的所有元素,并把length置为0。 |
927| clone(): ArrayList<T> | 克隆一个与ArrayList相同的实例,并返回克隆后的实例。修改克隆后的实例并不会影响原实例。 |
928| getCapacity(): number | 获取当前实例的容量大小。 |
929| convertToArray(): Array<T> | 把当前ArrayList实例转换成数组,并返回转换后的数组。 |
930| isEmpty(): boolean | 判断该ArrayList是否为空。 |
931| increaseCapacityTo(newCapacity: number): void | 如果传入的新容量大于或等于ArrayList中的元素个数,将容量变更为新容量。 |
932| trimToCurrentLength(): void | 把容量限制为当前的length大小。 |
933| insertFront(element: T): void | 在deque头部插入元素。 |
934| insertEnd(element: T): void | 在deque尾部插入元素。 |
935| has(element: T): boolean | 判断此Deque中是否含有该指定元素。 |
936| getFirst(): T | 获取Deque实例中的头元素。 |
937| getLast(): T | 获取Deque实例中的尾元素。 |
938| popFirst(): T | 删除并返回双端队列的首元素。 |
939| popLast(): T | 删除并返回双端队列的尾元素。 |
940| forEach(callbackFn: (value: T, index?: number, deque?: Deque<T>) => void,thisArg?: Object): void |
941通过回调函数来遍历Deque实例对象上的元素以及元素对应的下标。 |
942| isEmpty(): boolean | 判断该HashMap是否为空。 |
943| hasKey(key: K): boolean | 判断此HashMap中是否含有该指定key。 |
944| hasValue(value: V): boolean | 判断此HashMap中是否含有该指定value。 |
945| get(key: K): V | 获取指定key所对应的value。 |
946| setAll(map: HashMap<K, V>): void | 将一个HashMap中的所有元素组添加到另一个hashMap中。 |
947| set(key: K, value: V): Object | 向HashMap中添加一组数据。 |
948| remove(key: K): V | 删除指定key所对应元素。 |
949| clear(): void | 清除HashMap中的所有元素,并把length置为0。 |
950| keys(): IterableIterator<K> | 返回包含此映射中包含的键名的新迭代器对象。 |
951| values(): IterableIterator<V> | 返回包含此映射中包含的键值的新迭代器对象。 |
952| replace(key: K, newValue: V): boolean | 对HashMap中一组数据进行更新(替换)。 |
953| forEach(callbackFn: (value?: V, key?: K, map?: HashMap<K, V>) => void,thisArg?: Object): void |
954通过回调函数来遍历HashMap实例对象上的元素以及元素对应的下标。 |
955| entries(): IterableIterator<[K, V]> | 返回包含此映射中包含的键值对的新迭代器对象。 |
956| isEmpty(): boolean | 判断该HashSet是否为空。 |
957| has(value: T): boolean | 判断此HashSet中是否含有该指定元素。 |
958| add(value: T): boolean | 向HashSet中添加数据。 |
959| remove(value: T): boolean | 删除指定的元素。 |
960| clear(): void | 清除HashSet中的所有元素,并把length置为0。 |
961| forEach(callbackFn: (value?: T, key?: T, set?: HashSet<T>) => void,thisArg?: Object): void |
962通过回调函数来遍历实例对象上的元素以及元素对应的下标。 |
963| values(): IterableIterator<T> | 返回包含此映射中包含的键值的新迭代器对象。 |
964| entries(): IterableIterator<[T, T]> | 返回包含此映射中包含的键值对的新迭代器对象。 |
965| hasAll(map: LightWeightMap<K, V>): boolean | 判断此LightWeightMap中是否含有该指定map中的所有元素。 |
966| hasKey(key: K): boolean | 判断此LightWeightMap中是否含有该指定key。 |
967| hasValue(value: V): boolean | 判断此LightWeightMap中是否含有该指定value。 |
968| increaseCapacityTo(minimumCapacity: number): void | 将当前LightWeightMap扩容至可以容纳指定数量元素。 |
969| entries(): IterableIterator<[K, V]> | 返回包含此映射中包含的键值对的新迭代器对象。 |
970| get(key: K): V | 获取指定key所对应的value。 |
971| getIndexOfKey(key: K): number | 查找key元素第一次出现的下标值,如果没有找到该元素返回-1。 |
972| getIndexOfValue(value: V): number | 查找value元素第一次出现的下标值,如果没有找到该元素返回-1。 |
973| isEmpty(): boolean | 判断该LightWeightMap是否为空。 |
974| getKeyAt(index: number): K | 查找指定下标的元素键值对中key值,否则返回undefined。 |
975| keys(): IterableIterator<K> | 返回包含此映射中包含的键的新迭代器对象。 |
976| setAll(map: LightWeightMap<K, V>): void | 将一个LightWeightMap中的所有元素组添加到另一个lightWeightMap中。 |
977| set(key: K, value: V): Object | 向LightWeightMap中添加一组数据。 |
978| remove(key: K): V | 删除并返回指定key映射的元素。 |
979| removeAt(index: number): boolean | 删除指定下标对应的元素。 |
980| clear(): void | 清除LightWeightMap中的所有元素,并把length置为0。 |
981| setValueAt(index: number, newValue: V): boolean | 替换指定下标对应键值对中的元素。 |
982| forEach(callbackFn: (value?: V, key?: K, map?: LightWeightMap<K, V>) => void,thisArg?: Object): void |
983通过回调函数来遍历实例对象上的元素以及元素对应的下标。 |
984| [Symbol.iterator](): IterableIterator<[K, V]> | 返回一个迭代器,迭代器的每一项都是一个 JavaScript 对象,并返回该对象。 |
985| toString(): String | 将此映射中包含的键值对拼接成字符串,并返回字符串类型。 |
986| getValueAt(index: number): V | 获取指定下标对应键值对中的元素。 |
987| values(): IterableIterator<V> | 返回包含此映射中包含的键值的新迭代器对象。 |
988| add(obj: T): boolean | 向此容器中添加数据。 |
989| addAll(set: LightWeightSet<T>): boolean | 将另一个容器中的所有元素组添加到当前容器中。 |
990| hasAll(set: LightWeightSet<T>): boolean | 判断此容器中是否含有该指定set中的所有元素。 |
991| has(key: T): boolean | 判断此容器中是否含有该指定key。 |
992| equal(obj: Object): boolean | 判断此容器中是否含有该指定obj同类型的对象。 |
993| increaseCapacityTo(minimumCapacity: number): void | 将当前容器扩容至可以容纳指定数量元素。 |
994| getIndexOf(key: T): number | 获取指定key所对应的下标。 |
995| remove(key: T): T | 删除并返回指定key对应的元素。 |
996| removeAt(index: number): boolean | 删除指定下标所对应的元素。 |
997| clear(): void | 清除容器中的所有元素,并把length置为0。 |
998| forEach(callbackFn: (value?: T, key?: T, set?: LightWeightSet<T>) => void,thisArg?: Object): void |
999通过回调函数来遍历LightWeightSet实例对象上的元素以及元素对应的下标。 |
1000| [Symbol.iterator](): IterableIterator<T> | 返回一个迭代器,迭代器的每一项都是一个 JavaScript 对象,并返回该对象。 |
1001| toString(): String | 获取包含容器中所有键和值的字符串。 |
1002| toArray(): Array<T> | 获取包含此容器中所有对象的数组。 |
1003| getValueAt(index: number): T | 获取此容器中指定下标对应的元素。 |
1004| values(): IterableIterator<T> | 返回包含此映射中包含的键值的新迭代器对象。 |
1005| entries(): IterableIterator<[T, T]> | 返回包含此映射中包含的键值对的新迭代器对象。 |
1006| isEmpty(): boolean | 判断该容器是否为空。 |
1007| add(element: T): boolean | 在LinkedList尾部插入元素。 |
1008| insert(index: number, element: T): void | 在长度范围内任意插入指定元素。 |
1009| get(index: number): T | 根据下标获取LinkedList中的元素。 |
1010| addFirst(element: T): void | 在LinkedList头部插入元素。 |
1011| removeFirst(): T | 删除并返回LinkedList的第一个元素。 |
1012| removeLast(): T | 删除并返回LinkedList的最后一个元素。 |
1013| has(element: T): boolean | 判断此LinkedList中是否含有该指定元素。 |
1014| getIndexOf(element: T): number | 返回指定元素第一次出现时的下标值,查找失败返回-1。 |
1015| removeByIndex(index: number): T | 根据元素的下标值查找元素,返回元素后将其删除。 |
1016| remove(element: T): boolean | 删除查找到的第一个指定的元素。 |
1017| removeFirstFound(element: T): boolean | 删除第一次出现的指定元素。 |
1018| removeLastFound(element: T): boolean | 删除最后一次出现的指定元素。 |
1019| getLastIndexOf(element: T): number | 返回指定元素最后一次出现时的下标值,查找失败返回-1。 |
1020| getFirst(): T | 获取LinkedList实例中的第一个元素。 |
1021| getLast(): T | 获取LinkedList实例中的最后一个元素。 |
1022| set(index: number, element: T): T | 将此LinkedList中指定位置的元素替换为指定元素。 |
1023| forEach(callbackFn: (value: T, index?: number, LinkedList?: LinkedList<T>) => void,thisArg?: Object): void |
1024通过回调函数来遍历LinkedList实例对象上的元素以及元素对应的下标。 |
1025| clear(): void | 清除LinkedList中的所有元素,并把length置为0。 |
1026| clone(): LinkedList<T> | 克隆一个与LinkedList相同的实例,并返回克隆后的实例。修改克隆后的实例并不会影响原实例。 |
1027| convertToArray(): Array<T> | 把当前LinkedList实例转换成数组,并返回转换后的数组。 |
1028| [Symbol.iterator](): IterableIterator<T> | 返回一个迭代器,迭代器的每一项都是一个 JavaScript 对象,并返回该对象。 |
1029| add(element: T): boolean | 在List尾部插入元素。 |
1030| insert(element: T, index: number): void | 在长度范围内任意位置插入指定元素。 |
1031| get(index: number): T | 根据下标获取List中的元素。 |
1032| has(element: T): boolean | 判断此List中是否含有该指定元素。 |
1033| getIndexOf(element: T): number | 查找指定元素第一次出现的下标值,查找失败返回-1。 |
1034| removeByIndex(index: number): T | 根据元素的下标值查找元素,返回元素后将其删除。 |
1035| remove(element: T): boolean | 删除查找到的第一个指定的元素。 |
1036| getLastIndexOf(element: T): number | 查找指定元素最后一次出现的下标值,查找失败返回-1。 |
1037| getFirst(): T | 获取List实例中的第一个元素。 |
1038| getLast(): T | 获取List实例中的最后一个元素。 |
1039| set(index: number, element: T): T | 将此 List 中指定位置的元素替换为指定元素。 |
1040| equal(obj: Object): boolean | 比较指定对象与此List是否相等。 |
1041| forEach(callbackFn: (value: T, index?: number, List?: List<T>) => void,thisArg?: Object): void |
1042通过回调函数来遍历List实例对象上的元素以及元素对应的下标。 |
1043| sort(comparator: (firstValue: T, secondValue: T) => number): void | 对List中的元素进行一个排序操作。 |
1044| clear(): void | 清除List中的所有元素,并把length置为0。 |
1045| getSubList(fromIndex: number, toIndex: number): List<T> |
1046根据下标截取List中的一段元素,并返回这一段List实例,包括起始值但不包括终止值。 |
1047| replaceAllElements(callbackFn: (value: T, index?: number, list?: List<T>) => T,thisArg?: Object): void;T |
1048用户操作List中的元素,用操作后的元素替换原元素并返回操作后的元素。 |
1049| convertToArray(): Array<T> | 把当前List实例转换成数组,并返回转换后的数组。 |
1050| isEmpty(): boolean | 判断该List是否为空。 |
1051| [Symbol.iterator](): IterableIterator<T> | 返回一个迭代器,迭代器的每一项都是一个 JavaScript 对象,并返回该对象。 |
1052| add(key: number, value: T): void | 向容器中添加一组数据。 |
1053| clear(): void | 清除容器中的所有元素,并把length置为0。 |
1054| clone(): PlainArray<T> | 克隆一个实例,并返回克隆后的实例。修改克隆后的实例并不会影响原实例。 |
1055| has(key: number): boolean | 判断此容器中是否含有该指定key。 |
1056| get(key: number): T | 获取指定key所对应的value。 |
1057| getIndexOfKey(key: number): number | 查找指定key第一次出现的下标值,如果没有找到该key返回-1。 |
1058| getIndexOfValue(value: T): number | 查找指定value元素第一次出现的下标值,如果没有找到该value元素返回-1。 |
1059| isEmpty(): boolean | 判断该容器是否为空。 |
1060| getKeyAt(index: number): number | 查找指定下标元素键值对中的key值。 |
1061| remove(key: number): T | 删除指定key对应元素。 |
1062| removeAt(index: number): T | 删除指定下标对应的元素。 |
1063| removeRangeFrom(index: number, size: number): number | 删除一定范围内的元素。 |
1064| setValueAt(index: number, value: T): void | 替换容器中指定下标对应键值对中的键值。 |
1065| toString(): String | 获取包含容器中所有键和值的字符串。 |
1066| getValueAt(index: number): T | 查找指定下标元素键值对中的Value值,失败返回undefined。 |
1067| forEach(callbackFn: (value: T, index?: number, PlainArray?: PlainArray<T>) => void,thisArg?: Object): void |
1068通过回调函数来遍历实例对象上的元素以及元素对应的下标。 |
1069| [Symbol.iterator](): IterableIterator<[number, T]> | 返回一个包含key-value键值对的迭代器对象,其中key是number类型。 |
1070| add(element: T): boolean | 在队列尾部插入元素。 |
1071| getFirst(): T | 获取队列的头元素。 |
1072| pop(): T | 删除头元素并返回该删除元素。 |
1073| forEach(callbackFn: (value: T, index?: number, Queue?: Queue<T>) => void, thisArg?: Object): void; |
1074通过回调函数来遍历Queue实例对象上的元素以及元素对应的下标。 |
1075| [Symbol.iterator](): IterableIterator<T> | 返回一个迭代器,迭代器的每一项都是一个 JavaScript 对象,并返回该对象。 |
1076| isEmpty(): boolean | 判断该栈是否为空。 |
1077| peek(): T | 获取并返回栈顶元素。 |
1078| pop(): T | 删除栈顶元素并返回该删除元素。 |
1079| push(item: T): T | 在栈顶插入元素,并返回该元素。 |
1080| locate(element: T): number | 返回指定元素第一次出现时的下标值,查找失败返回-1。 |
1081| forEach(callbackFn: (value: T, index?: number, stack?: Stack<T>) => void,thisArg?: Object): void |
1082通过回调函数来遍历Stack实例对象上的元素以及元素对应的下标。 |
1083| [Symbol.iterator](): IterableIterator<T> | 返回一个迭代器,迭代器的每一项都是一个 JavaScript 对象,并返回该对象。 |
1084| isEmpty(): boolean | 判断该容器是否为空。 |
1085| hasKey(key: K): boolean | 判断此容器中是否含有该指定key。 |
1086| hasValue(value: V): boolean | 判断此容器中是否含有该指定value。 |
1087| get(key: K): V | 获取指定key所对应的value。 |
1088| getFirstKey(): K | 获取容器中排序第一的key。 |
1089| getLastKey(): K | 获取容器中排序最后的key。 |
1090| setAll(map: TreeMap<K, V>): void | 将一个TreeMap中的所有元素组添加到另一个TreeMap中。 |
1091| set(key: K, value: V): Object | 向容器中添加一组数据。 |
1092| remove(key: K): V | 删除指定key对应的元素。 |
1093| clear(): void | 清除容器中的所有元素,并把length置为0。 |
1094| getLowerKey(key: K): K | 获取容器中比传入key排序靠前一位的key。 |
1095| getHigherKey(key: K): K | 获取容器中比传入key排序靠后一位的key。 |
1096| keys(): IterableIterator<K> | 返回包含此映射中包含的键的新迭代器对象。 |
1097| values(): IterableIterator<V> | 返回包含此映射中键值对的新迭代器对象。 |
1098| replace(key: K, newValue: V): boolean | 对容器中一组数据进行更新(替换)。 |
1099| forEach(callbackFn: (value?: V, key?: K, map?: TreeMap<K, V>) => void, thisArg?: Object): void; |
1100通过回调函数来遍历实例对象上的元素以及元素对应的下标。 |
1101| entries(): IterableIterator<[K, V]> | 返回包含此映射中键值对的新迭代器对象。 |
1102| [Symbol.iterator](): IterableIterator<[K, V]> | 返回一个迭代器,迭代器的每一项都是一个JavaScript对象,并返回该对象。 |
1103| isEmpty(): boolean | 判断该容器是否为空。 |
1104| has(value: T): boolean | 判断此容器中是否含有该指定元素。 |
1105| add(value: T): boolean | 向容器中添加一组数据。 |
1106| remove(value: T): boolean | 删除指定的元素。 |
1107| clear(): void | 清除容器中的所有元素,并把length置为0。 |
1108| getFirstValue(): T | 获取容器中排序第一的数据。 |
1109| getLastValue(): T | 获取容器中排序最后的数据。 |
1110| getLowerValue(key: T): T | 获取容器中比传入元素排序靠前一位的元素。 |
1111| getHigherValue(key: T): T | 获取容器中比传入元素排序靠后一位的元素。 |
1112| popFirst(): T | 删除容器中排序最前的数据。 |
1113| popLast(): T | 删除容器中排序最后的数据。 |
1114| forEach(callbackFn: (value?: T, key?: T, set?: TreeSet<T>) => void, thisArg?: Object): void; |
1115通过回调函数来遍历实例对象上的元素以及元素对应的下标。 |
1116| values(): IterableIterator<T> | 返回包含此映射中键值对的新迭代器对象。 |
1117| entries(): IterableIterator<[T, T]> | 返回包含此映射中键值对的新迭代器对象。 |
1118| [Symbol.iterator](): IterableIterator<T> | 返回一个迭代器,迭代器的每一项都是一个JavaScript对象,并返回该对象。 |
1119
1120printf中每个说明符都替换为来自相应参数的转换后的值。 支持的说明符有:
1121| 式样化字符 | 式样要求 |
1122| -------- | -------- |
1123|    %s:  | String 将用于转换除 BigInt、Object 和 -0 之外的所有值。|
1124|    %d:  | Number 将用于转换除 BigInt 和 Symbol 之外的所有值。|
1125|    %i:  | parseInt(value, 10) 用于除 BigInt 和 Symbol 之外的所有值。|
1126|    %f:  | parseFloat(value) 用于除 Symbol 之外的所有值。|
1127|    %j:  | JSON。 如果参数包含循环引用,则替换为字符串 '[Circular]'。|
1128|    %o:  | Object. 具有通用 JavaScript 对象格式的对象的字符串表示形式。类似于具有选项 { showHidden: true, showProxy: true } 的 util.inspect()。这将显示完整的对象,包括不可枚举的属性和代理。|
1129|    %O:  | Object. 具有通用 JavaScript 对象格式的对象的字符串表示形式。类似于没有选项的 util.inspect()。 这将显示完整的对象,但不包括不可枚举的属性和代理。|
1130|    %c:  | 此说明符被忽略,将跳过任何传入的 CSS 。|
1131|    %%:  | 单个百分号 ('%')。 这不消耗待式样化参数。|
1132
1133#### 2.3.2. 使用说明
1134各接口使用方法如下:
1135
11361.readonly encoding()
1137
1138```
1139import util from '@ohos.util'
1140var textEncoder = new util.TextEncoder();
1141var getEncoding = textEncoder.encoding();
1142```
11432.encode()
1144```
1145import util from '@ohos.util'
1146var textEncoder = new util.TextEncoder();
1147var result = textEncoder.encode('abc');
1148```
11493.encodeInto()
1150```
1151import util from '@ohos.util'
1152var textEncoder = new util.TextEncoder();
1153var obj = textEncoder.encodeInto('abc', dest);
1154```
11554.textDecoder()
1156```
1157import util from '@ohos.util'
1158var textDecoder = new util.textDecoder("utf-16be", {fatal : true, ignoreBOM : false});
1159```
11605.readonly encoding()
1161```
1162import util from '@ohos.util'
1163var textDecoder = new util.textDecoder("utf-16be", {fatal : true, ignoreBOM : false});
1164var getEncoding = textDecoder.encoding();
1165```
11666.readonly fatal()
1167```
1168import util from '@ohos.util'
1169var textDecoder = new util.textDecoder("utf-16be", {fatal : true, ignoreBOM : false});
1170var fatalStr = textDecoder.fatal();
1171```
11727.readonly ignoreBOM()
1173```
1174import util from '@ohos.util'
1175var textDecoder = new util.textDecoder("utf-16be", {fatal : true, ignoreBOM : false});
1176var ignoreBom = textDecoder.ignoreBOM();
1177```
11788.decode()
1179```
1180import util from '@ohos.util'
1181var textDecoder = new util.textDecoder("utf-16be", {fatal : true, ignoreBOM : false});
1182var result = textDecoder.decode(input, {stream : true});
1183```
11849.decodeWithStream()
1185```
1186import util from '@ohos.util'
1187var textDecoder = new util.textDecoder("utf-16be", {fatal : true, ignoreBOM : false});
1188var result = textDecoder.decodeWithStream(input, {stream : true});
1189```
119010.printf()
1191```
1192import util from '@ohos.util'
1193var format = "%%%o%%%i%s";
1194var value =  function aa(){};
1195var value1 = 1.5;
1196var value2 = "qwer";
1197var result = util.printf(format,value,value1,value2);
1198```
119911.getErrorString()
1200```
1201import util from '@ohos.util'
1202var errnum = 13;
1203var result = util.getErrorString(errnum);
1204```
120512.callbackWrapper()
1206```
1207import util from '@ohos.util'
1208async function promiseFn() {
1209    return Promise.resolve('value');
1210};
1211var cb = util.callbackWrapper(promiseFn);
1212cb((err, ret) => {
1213    expect(err).strictEqual(null);
1214    expect(ret).strictEqual('value');
1215})
1216```
121713.promiseWrapper()
1218```
1219import util from '@ohos.util'
1220function aysnFun(str1, str2, callback) {
1221    if (typeof str1 === 'string' && typeof str1 === 'string') {
1222        callback(null, str1 + str2);
1223    } else {
1224        callback('type err');
1225    }
1226}
1227let newPromiseObj = util.promiseWrapper(aysnFun)("Hello", 'World');
1228newPromiseObj.then(res => {
1229    expect(res).strictEqual('HelloWorld');
1230})
1231```
123214.encodeSync()
1233```
1234import util from '@ohos.util'
1235var that = new util.Base64();
1236var array = new Uint8Array([115,49,51]);
1237var result = that.encodeSync(array);
1238```
123915.encodeToStringSync()
1240```
1241import util from '@ohos.util'
1242var that = new util.Base64();
1243var array = new Uint8Array([115,49,51]);
1244var result = that.encodeToStringSync(array);
1245```
124616.decodeSync()
1247```
1248import util from '@ohos.util'
1249var that = new util.Base64()
1250var buff = 'czEz';
1251var result = that.decodeSync(buff);
1252
1253```
125417.encode()
1255```
1256import util from '@ohos.util'
1257var that = new util.Base64()
1258var array = new Uint8Array([115,49,51]);
1259await that.encode(array).then(val=>{
1260})
1261done()
1262```
126318.encodeToString()
1264```
1265import util from '@ohos.util'
1266var that = new util.Base64()
1267var array = new Uint8Array([115,49,51]);
1268await that.encodeToString(array).then(val=>{
1269})
1270done()
1271```
127219.decode()
1273```
1274import util from '@ohos.util'
1275var that = new util.Base64()
1276var buff = 'czEz';
1277await that.decode(buff).then(val=>{
1278})
1279done()
1280```
128120.createRationalFromString()
1282```
1283import util from '@ohos.util'
1284var pro = new util.RationalNumber(0, 0);
1285var res = pro.createRationalFromString("-1:2");
1286var result1 = res.valueOf();
1287```
128821.compareTo()
1289```
1290import util from '@ohos.util'
1291var pro = new util.RationalNumber(2, 1);
1292var proc = new util.RationalNumber(3, 4);
1293var res = pro.compareTo(proc);
1294```
129522.equals()
1296```
1297import util from '@ohos.util'
1298var pro = new util.RationalNumber(2, 1);
1299var proc = new util.RationalNumber(3, 4);
1300var res = pro.equals(proc);
1301```
130223.valueOf()
1303```
1304import util from '@ohos.util'
1305var pro = new util.RationalNumber(2, 1);
1306var res = pro.valueOf();
1307```
130824.getCommonDivisor()
1309```
1310import util from '@ohos.util'
1311var pro = new util.RationalNumber(0, 0);
1312var res = pro.getCommonDivisor(4, 8);
1313```
131425.getDenominator()
1315```
1316import util from '@ohos.util'
1317var pro = new util.RationalNumber(2, 1);
1318var res = pro.getDenominator();
1319```
132026.getNumerator()
1321```
1322import util from '@ohos.util'
1323var pro = new util.RationalNumber(-2, 1);
1324var res = pro.getNumerator();
1325```
132627.isFinite()
1327```
1328import util from '@ohos.util'
1329var pro = new util.RationalNumber(-2, 1);
1330var res = pro.isFinite();
1331```
133228.isNaN()
1333```
1334import util from '@ohos.util'
1335var pro = new util.RationalNumber(-2, 1);
1336var res = pro.isNaN();
1337```
133829.isZero()
1339```
1340import util from '@ohos.util'
1341var pro = new util.RationalNumber(-2, 1);
1342var res = pro.isZero();
1343```
134430.toString()
1345```
1346import util from '@ohos.util'
1347var pro = new util.RationalNumber(-2, 1);
1348var res = pro.toString();
1349```
135031.updateCapacity()
1351```
1352import util from '@ohos.util'
1353var pro = new util.LruBuffer();
1354var result = pro.updateCapacity(100);
1355```
135632.toString()
1357```
1358import util from '@ohos.util'
1359var pro = new util.LruBuffer();
1360pro.put(2,10);
1361pro.get(2);
1362pro.remove(20);
1363var result = pro.toString();
1364```
136533.values()
1366```
1367import util from '@ohos.util'
1368var pro = new util.LruBuffer();
1369pro.put(2,10);
1370pro.put(2,"anhu");
1371pro.put("afaf","grfb");
1372var result = pro.values();
1373```
137434.length
1375```
1376import util from '@ohos.util'
1377var pro = new util.LruBuffer();
1378pro.put(2,10);
1379pro.put(1,8);
1380var result = pro.length;
1381```
138235.getCapacity()
1383```
1384import util from '@ohos.util'
1385var pro = new util.LruBuffer();
1386var result = pro.getCapacity();
1387```
138836.clear()
1389```
1390import util from '@ohos.util'
1391var pro = new util.LruBuffer();
1392pro.put(2,10);
1393pro.clear();
1394```
139537.getCreateCount()
1396```
1397import util from '@ohos.util'
1398var pro = new util.LruBuffer();
1399pro.put(1,8);
1400var result = pro.getCreateCount();
1401```
140238.getMissCount()
1403```
1404import util from '@ohos.util'
1405var pro = new util.LruBuffer();
1406pro.put(2,10);
1407pro.get(2)
1408var result = pro.getMissCount();
1409```
141039.getRemovalCount()
1411```
1412
1413import util from '@ohos.util'
1414var pro = new util.LruBuffer();
1415pro.put(2,10);
1416pro.updateCapacity(2);
1417pro.put(50,22);
1418var result = pro.getRemovalCount();
1419
1420```
142140.getMatchCount()
1422```
1423import util from '@ohos.util'
1424var pro = new util.LruBuffer();
1425pro.put(2,10);
1426pro.get(2);
1427var result = pro.getMatchCount();
1428```
142941.getPutCount()
1430```
1431import util from '@ohos.util'
1432var pro = new util.LruBuffer();
1433pro.put(2,10);
1434var result = pro.getPutCount();
1435```
143642.isEmpty()
1437```
1438import util from '@ohos.util'
1439var pro = new util.LruBuffer();
1440pro.put(2,10);
1441var result = pro.isEmpty();
1442```
144343.get()
1444
1445```
1446import util from '@ohos.util'
1447var pro = new util.LruBuffer();
1448pro.put(2,10);
1449var result = pro.get(2);
1450```
145144.put()
1452```
1453import util from '@ohos.util'
1454var pro = new util.LruBuffer();
1455var result = pro.put(2,10);
1456```
145745.keys()
1458```
1459import util from '@ohos.util'
1460var pro = new util.LruBuffer();
1461pro.put(2,10);
1462var result = pro.keys();
1463```
146446.remove()
1465```
1466import util from '@ohos.util'
1467var pro = new util.LruBuffer();
1468pro.put(2,10);
1469var result = pro.remove(20);
1470```
147147.contains()
1472```
1473import util from '@ohos.util'
1474var pro = new util.LruBuffer();
1475pro.put(2,10);
1476var result = pro.contains(20);
1477```
147848.createDefault()
1479```
1480import util from '@ohos.util'
1481var pro = new util.LruBuffer();
1482var result = pro.createDefault(50);
1483```
148449.entries()
1485```
1486import util from '@ohos.util'
1487var pro = new util.LruBuffer();
1488pro.put(2,10);
1489var result = pro.entries();
1490```
149150.\[Symbol.iterator\]()
1492```
1493import util from '@ohos.util'
1494var pro = new util.LruBuffer();
1495pro .put(2,10);
1496var result = pro[symbol.iterator]();
1497```
149851.afterRemoval()
1499```
1500import util from '@ohos.util'
1501var arr = [ ];
1502class ChildLruBuffer extends util.LruBuffer
1503{
1504    constructor()
1505    {
1506        super();
1507    }
1508    static getInstance()
1509    {
1510        if(this.instance ==  null)
1511        {
1512            this.instance = new ChildLruBuffer();
1513        }
1514        return this.instance;
1515    }
1516    afterRemoval(isEvict, key, value, newValue)
1517    {
1518        if (isEvict === false)
1519        {
1520            arr = [key, value, newValue];
1521        }
1522    }
1523}
1524ChildLruBuffer.getInstance().afterRemoval(false,10,30,null)
1525```
1526Scope接口中构造新类,实现compareTo方法。
1527
1528```
1529class Temperature {
1530    constructor(value) {
1531        this._temp = value;
1532    }
1533    compareTo(value) {
1534        return this._temp >= value.getTemp();
1535    }
1536    getTemp() {
1537        return this._temp;
1538    }
1539    toString() {
1540        return this._temp.toString();
1541    }
1542}
1543```
1544
154552.constructor()
1546
1547```
1548var tempLower = new Temperature(30);
1549var tempUpper = new Temperature(40);
1550var range = new Scope(tempLower, tempUpper);
1551```
1552
155353.toString()
1554
1555```
1556var tempLower = new Temperature(30);
1557var tempUpper = new Temperature(40);
1558var range = new Scope(tempLower, tempUpper);
1559var result = range.toString() // => [30,40]
1560```
1561
156254.intersect()
1563
1564```
1565var tempLower = new Temperature(30);
1566var tempUpper = new Temperature(40);
1567var range = new Scope(tempLower, tempUpper);
1568var tempMiDF = new Temperature(35);
1569var tempMidS = new Temperature(39);
1570var rangeFir = new Scope(tempMiDF, tempMidS);
1571var result = range.intersect(rangeFir)  // => [35,39]
1572```
1573
157455.intersect()
1575
1576```
1577var tempLower = new Temperature(30);
1578var tempUpper = new Temperature(40);
1579var tempMiDF = new Temperature(35);
1580var tempMidS = new Temperature(39);
1581var range = new Scope(tempLower, tempUpper);
1582var result = range.intersect(tempMiDF, tempMidS)  // => [35,39]
1583```
1584
158556.getUpper()
1586
1587```
1588var tempLower = new Temperature(30);
1589var tempUpper = new Temperature(40);
1590var range = new Scope(tempLower, tempUpper);
1591var result = range.getUpper() // => 40
1592```
1593
159457.getLower()
1595
1596```
1597var tempLower = new Temperature(30);
1598var tempUpper = new Temperature(40);
1599var range = new Scope(tempLower, tempUpper);
1600var result = range.getLower() // => 30
1601```
1602
160358.expand()
1604
1605```
1606var tempLower = new Temperature(30);
1607var tempUpper = new Temperature(40);
1608var tempMiDF = new Temperature(35);
1609var tempMidS = new Temperature(39);
1610var range = new Scope(tempLower, tempUpper);
1611var result = range.expand(tempMiDF, tempMidS)  // => [30,40]
1612```
1613
161459.expand()
1615
1616```
1617var tempLower = new Temperature(30);
1618var tempUpper = new Temperature(40);
1619var tempMiDF = new Temperature(35);
1620var tempMidS = new Temperature(39);
1621var range = new Scope(tempLower, tempUpper);
1622var rangeFir = new Scope(tempMiDF, tempMidS);
1623var result = range.expand(rangeFir) // => [30,40]
1624```
1625
162660.expand()
1627
1628```
1629var tempLower = new Temperature(30);
1630var tempUpper = new Temperature(40);
1631var tempMiDF = new Temperature(35);
1632var range = new Scope(tempLower, tempUpper);
1633var result = range.expand(tempMiDF)  // => [30,40]
1634```
1635
163661.contains()
1637
1638```
1639var tempLower = new Temperature(30);
1640var tempUpper = new Temperature(40);
1641var tempMiDF = new Temperature(35);
1642var range = new Scope(tempLower, tempUpper);
1643var result = range.contains(tempMiDF) // => true
1644```
1645
164662.contains()
1647
1648```
1649var tempLower = new Temperature(30);
1650var tempUpper = new Temperature(40);
1651var range = new Scope(tempLower, tempUpper);
1652var tempLess = new Temperature(20);
1653var tempMore = new Temperature(45);
1654var rangeSec = new Scope(tempLess, tempMore);
1655var result = range.contains(rangeSec) // => true
1656```
1657
165863.clamp()
1659
1660```
1661var tempLower = new Temperature(30);
1662var tempUpper = new Temperature(40);
1663var tempMiDF = new Temperature(35);
1664var range = new Scope(tempLower, tempUpper);
1665var result = range.clamp(tempMiDF) // => 35
1666```
166764.isAnyArrayBuffer()
1668```
1669import util from '@ohos.util'
1670var proc = new util.Types();
1671var result = proc.isAnyArrayBuffer(new ArrayBuffer([]))
1672```
167365.isArrayBufferView()
1674```
1675import util from '@ohos.util'
1676var proc = new util.Types();
1677var result = proc.isArrayBufferView(new DataView(new ArrayBuffer(16)));
1678```
167966.isArgumentsObject()
1680```
1681import util from '@ohos.util'
1682function foo() {
1683        var result = proc.isArgumentsObject(arguments);
1684    }
1685var f = foo();
1686```
168767.isArrayBuffer()
1688```
1689import util from '@ohos.util'
1690var proc = new util.Types();
1691var result = proc.isArrayBuffer(new ArrayBuffer([]));
1692```
169368.isAsyncFunction()
1694```
1695import util from '@ohos.util'
1696var proc = new util.Types();
1697var result = proc.isAsyncFunction(async function foo() {});
1698```
169969.isBigInt64Array()
1700```
1701import util from '@ohos.util'
1702var proc = new util.Types();
1703var result = proc.isBigInt64Array(new Int16Array([]));
1704```
170570.isBigUint64Array()
1706```
1707import util from '@ohos.util'
1708var proc = new util.Types();
1709var result = proc.isBigUint64Array(new Int16Array([]));
1710```
171171.isBooleanObject()
1712```
1713import util from '@ohos.util'
1714var proc = new util.Types();
1715var result = proc.isBooleanObject(new Boolean(false));
1716```
171772.isBoxedPrimitive()
1718```
1719import util from '@ohos.util'
1720var proc = new util.Types();
1721var result = proc.isBoxedPrimitive(new Boolean(false));
1722```
172373.isDataView()
1724```
1725import util from '@ohos.util'
1726var proc = new util.Types();
1727const ab = new ArrayBuffer(20);
1728var result = proc.isDataView(new DataView(ab));
1729```
173074.isDate()
1731```
1732import util from '@ohos.util'
1733var proc = new util.Types();
1734var result = proc.isDate(new Date());
1735```
173675.isExternal()
1737```
1738import util from '@ohos.util'
1739const data = util.createExternalType();
1740var reult13 = proc.isExternal(data);
1741```
174276.isFloat32Array()
1743```
1744import util from '@ohos.util'
1745var proc = new util.Types();
1746var result = proc.isFloat32Array(new Float32Array([]));
1747```
174877.isFloat64Array()
1749```
1750import util from '@ohos.util'
1751var proc = new util.Types();
1752var result = proc.isFloat64Array(new Float64Array([]));
1753```
175478.isGeneratorFunction()
1755```
1756import util from '@ohos.util'
1757var proc = new util.Types();
1758var result = proc.isGeneratorFunction(function* foo() {});
1759```
176079.isGeneratorObject()
1761```
1762import util from '@ohos.util'
1763var proc = new util.Types();
1764function* foo() {}
1765const generator = foo();
1766var result = proc.isGeneratorObject(generator);
1767```
176880.isInt8Array()
1769```
1770import util from '@ohos.util'
1771var proc = new util.Types();
1772var result = proc.isInt8Array(new Int8Array([]));
1773```
177481.isInt16Array()
1775```
1776import util from '@ohos.util'
1777var proc = new util.Types();
1778var result = proc.isInt16Array(new Int16Array([]));
1779```
178082.isInt32Array()
1781```
1782import util from '@ohos.util'
1783var proc = new util.Types();
1784var result = proc.isInt32Array(new Int32Array([]));
1785```
178683.isMap()
1787```
1788import util from '@ohos.util'
1789var proc = new util.Types();
1790var result = proc.isMap(new Map());
1791```
179284.isMapIterator()
1793```
1794import util from '@ohos.util'
1795var proc = new util.Types();
1796var result = proc.isMapIterator(map.keys());
1797```
179885.isModuleNamespaceObject()
1799```
1800import util from '@ohos.util'
1801var proc = new util.Types();
1802var result = proc.isModuleNamespaceObject(util);
1803```
180486.isNativeError()
1805```
1806import util from '@ohos.util'
1807var proc = new util.Types();
1808var result = proc.isNativeError(new TypeError());
1809```
181087.isNumberObject()
1811```
1812import util from '@ohos.util'
1813var proc = new util.Types();
1814var result = proc.isNumberObject(new Number(0));
1815```
181688.isPromise()
1817```
1818import util from '@ohos.util'
1819var proc = new util.Types();
1820var result = proc.isPromise(Promise.resolve(42));
1821```
182289.isProxy()
1823```
1824import util from '@ohos.util'
1825var proc = new util.Types();
1826const target = {};
1827const proxy = new Proxy(target, {});
1828var result = proc.isProxy(proxy);
1829```
183090.isRegExp()
1831```
1832import util from '@ohos.util'
1833var proc = new util.Types();
1834var result = proc.isRegExp(new RegExp('abc'));
1835```
183691.isSet()
1837```
1838import util from '@ohos.util'
1839var proc = new util.Types();
1840var result = proc.isSet(new Set());
1841```
184292.isSetIterator()
1843```
1844import util from '@ohos.util'
1845var proc = new util.Types();
1846const set = new Set();
1847var result = proc.isSetIterator(set.keys());
1848```
184993.isSharedArrayBuffer()
1850```
1851import util from '@ohos.util'
1852var proc = new util.Types();
1853var result = proc.isSharedArrayBuffer(new ArrayBuffer([]));
1854```
185594.isStringObject()
1856```
1857import util from '@ohos.util'
1858var proc = new util.Types();
1859var result = proc.isStringObject(new String('foo'));
1860```
186195.isSymbolObject()
1862```
1863import util from '@ohos.util'
1864var proc = new util.Types();
1865const symbols = Symbol('foo');
1866var result = proc.isSymbolObject(Object(symbols));
1867```
186896.isTypedArray()
1869```
1870import util from '@ohos.util'
1871var proc = new util.Types();
1872var result = proc.isTypedArray(new Float64Array([]));
1873```
187497.isUint8Array()
1875```
1876import util from '@ohos.util'
1877var proc = new util.Types();
1878var result = proc.isUint8Array(new Uint8Array([]));
1879```
188098.isUint8ClampedArray()
1881```
1882import util from '@ohos.util'
1883var proc = new util.Types();
1884var result = proc.isUint8ClampedArray(new Uint8ClampedArray([]));
1885```
188699.isUint16Array()
1887```
1888import util from '@ohos.util'
1889var proc = new util.Types();
1890var result = proc.isUint16Array(new Uint16Array([]));
1891```
1892100.isUint32Array()
1893```
1894import util from '@ohos.util'
1895var proc = new util.Types();
1896var result = proc.isUint32Array(new Uint32Array([]));
1897```
1898101.isWeakMap()
1899```
1900import util from '@ohos.util'
1901var proc = new util.Types();
1902var result = proc.isWeakMap(new WeakMap());
1903```
1904102.isWeakSet()
1905```
1906import util from '@ohos.util'
1907var proc = new util.Types();
1908var result = proc.isWeakSet(new WeakSet());
1909```
1910103.add()
1911```
1912import ArrayList from "@ohos.util.ArrayList"
1913let arrayList = new ArrayList();
1914let result = arrayList.add(8);
1915```
1916104.insert()
1917```
1918import ArrayList from "@ohos.util.ArrayList"
1919let arrayList = new ArrayList();
1920arrayList.add("四");
1921arrayList.add("三");
1922arrayList.add(1);
1923arrayList.add("a");
1924arrayList.insert(8, 2);
1925```
1926105.add()
1927```
1928import ArrayList from "@ohos.util.ArrayList"
1929let arrayList = new ArrayList();
1930arrayList.add("四");
1931arrayList.add("三");
1932arrayList.add(1);
1933arrayList.add("a");
1934arrayList.insert(8, 2);
1935let result = arrayList.has(8);
1936```
1937106.getIndexOf()
1938```
1939import ArrayList from "@ohos.util.ArrayList"
1940let arrayList = new ArrayList();
1941arrayList.add(1);
1942arrayList.add("三");
1943arrayList.add(1);
1944arrayList.add("a");
1945arrayList.insert(1, 2);
1946let result = arrayList.getIndexOf(1);
1947```
1948107.removeByIndex()
1949```
1950import ArrayList from "@ohos.util.ArrayList"
1951let arrayList = new ArrayList();
1952arrayList.add(1);
1953arrayList.add("三");
1954arrayList.add(1);
1955arrayList.add("a");
1956let result = arrayList.removeByIndex(2);
1957```
1958108.remove()
1959```
1960import ArrayList from "@ohos.util.ArrayList"
1961let arrayList = new ArrayList();
1962arrayList.add("四");
1963arrayList.add("三");
1964arrayList.add(1);
1965arrayList.add("a");
1966let result = arrayList.remove("三");
1967```
1968109.getLastIndexOf()
1969```
1970import ArrayList from "@ohos.util.ArrayList"
1971let arrayList = new ArrayList();
1972arrayList.add("四");
1973arrayList.add("三");
1974arrayList.add(1);
1975arrayList.add("a");
1976arrayList.add(1);
1977arrayList.add("b");
1978let result = arrayList.getLastIndexOf(1);
1979```
1980110.removeByRange()
1981```
1982import ArrayList from "@ohos.util.ArrayList"
1983let arrayList = new ArrayList();
1984arrayList.add("四");
1985arrayList.add("三");
1986arrayList.add("a");
1987arrayList.add("b");
1988arrayList.add("c");
1989arrayList.removeByRange(1, 3);
1990```
1991111.replaceAllElements()
1992```
1993import ArrayList from "@ohos.util.ArrayList"
1994let arrayList = new ArrayList();
1995arrayList.add(4);
1996arrayList.add(3);
1997arrayList.add(1);
1998arrayList.add(2);
1999arrayList.add(14);
2000arrayList.replaceAllElements((item, index) => {
2001    return (item = 2 * item);
2002});
2003```
2004112.forEach()
2005```
2006import ArrayList from "@ohos.util.ArrayList"
2007let arrayList = new ArrayList();
2008arrayList.add(4);
2009arrayList.add(3);
2010arrayList.add(1);
2011arrayList.add(2);
2012arrayList.add(14);
2013let arr = [];
2014arrayList.forEach((item, index) => {
2015    arr.push(item);
2016});
2017```
2018113.sort()
2019```
2020import ArrayList from "@ohos.util.ArrayList"
2021let arrayList = new ArrayList();
2022arrayList.add(4);
2023arrayList.add(3);
2024arrayList.add(1);
2025arrayList.add(2);
2026arrayList.add(14);
2027arrayList.sort((a, b) => a - b);
2028```
2029114.subArrayList()
2030```
2031import ArrayList from "@ohos.util.ArrayList"
2032let arrayList = new ArrayList();
2033arrayList.add(4);
2034arrayList.add(3);
2035arrayList.add(1);
2036arrayList.add(2);
2037arrayList.add(14);
2038let result = arrayList.subArrayList(0, 5);
2039```
2040115.clear()
2041```
2042import ArrayList from "@ohos.util.ArrayList"
2043let arrayList = new ArrayList();
2044arrayList.add(4);
2045arrayList.add(3);
2046arrayList.add(1);
2047arrayList.add(2);
2048arrayList.add(14);
2049arrayList.clear();
2050```
2051116.clone()
2052```
2053import ArrayList from "@ohos.util.ArrayList"
2054let arrayList = new ArrayList();
2055arrayList.add(4);
2056arrayList.add(3);
2057arrayList.add(1);
2058arrayList.add(2);
2059arrayList.add(14);
2060let res = arrayList.clone();
2061```
2062117.getCapacity()
2063```
2064import ArrayList from "@ohos.util.ArrayList"
2065let arrayList = new ArrayList();
2066arrayList.add(4);
2067arrayList.add(3);
2068arrayList.add(1);
2069arrayList.add(2);
2070arrayList.add(14);
2071let result = arrayList.getCapacity();
2072```
2073118.convertToArray()
2074```
2075import ArrayList from "@ohos.util.ArrayList"
2076let arrayList = new ArrayList();
2077arrayList.add(4);
2078arrayList.add(3);
2079arrayList.add(1);
2080arrayList.add(2);
2081arrayList.add(14);
2082let arr = arrayList.convertToArray();
2083```
2084119.isEmpty()
2085```
2086import ArrayList from "@ohos.util.ArrayList"
2087let arrayList = new ArrayList();
2088arrayList.add(4);
2089arrayList.add(3);
2090arrayList.add(1);
2091arrayList.clear();
2092let result = arrayList.isEmpty();
2093```
2094120.increaseCapacityTo()
2095```
2096import ArrayList from "@ohos.util.ArrayList"
2097let arrayList = new ArrayList();
2098arrayList.add(4);
2099arrayList.add(3);
2100arrayList.add(1);
2101arrayList.add(2);
2102arrayList.add(14);
2103arrayList.increaseCapacityTo(-1);
2104```
2105121.trimToCurrentLength()
2106```
2107import ArrayList from "@ohos.util.ArrayList"
2108let arrayList = new ArrayList();
2109arrayList.add(4);
2110arrayList.add(3);
2111arrayList.add(1);
2112arrayList.add(2);
2113arrayList.add(14);
2114arrayList.trimToCurrentLength();
2115```
2116122.insertFront()
2117```
2118import Deque from "@ohos.util.Deque"
2119let deque = new Deque();
2120deque.insertFront("一");
2121```
2122123.insertEnd()
2123```
2124import Deque from "@ohos.util.Deque"
2125let deque = new Deque();
2126let a = ["a", "b", "c"];
2127deque.insertEnd(a);
2128```
2129124.has()
2130```
2131import Deque from "@ohos.util.Deque"
2132let deque = new Deque();
2133deque.insertEnd(6);
2134let result = deque.has(6);
2135```
2136125.getFirst()
2137```
2138import Deque from "@ohos.util.Deque"
2139let deque = new Deque();
2140deque.insertFront("$");
2141let result = deque.getFirst();
2142```
2143126.getLast()
2144```
2145import Deque from "@ohos.util.Deque"
2146let deque = new Deque();
2147deque.insertFront("$");
2148let result = deque.getLast();
2149```
2150127.popFirst()
2151```
2152import Deque from "@ohos.util.Deque"
2153let deque = new Deque();
2154deque.insertFront(6);
2155let result = deque.popFirst();
2156```
2157128.popLast()
2158```
2159import Deque from "@ohos.util.Deque"
2160let deque = new Deque();
2161deque.insertFront(11);
2162let result = deque.popLast();
2163```
2164129.forEach()
2165```
2166import Deque from "@ohos.util.Deque"
2167let deque = new Deque();
2168deque.insertEnd(1);
2169deque.insertEnd(2);
2170deque.insertEnd(3);
2171let arr = [];
2172deque.forEach((item, index) => {
2173    arr.push(item);
2174});
2175```
2176130.isEmpty()
2177```
2178import HashMap from "@ohos.util.HashMap"
2179let hashMap = new HashMap();
2180hashMap.set(1, "A");
2181hashMap.set(2, "B");
2182let result = hashMap.isEmpty();
2183```
2184131.hasKey()
2185```
2186import HashMap from "@ohos.util.HashMap"
2187let hashMap = new HashMap();
2188hashMap.set(1, "A");
2189hashMap.set(2, "B");
2190hashMap.set(3, "C");
2191let result = hashMap.hasKey(3);
2192```
2193132.hasValue()
2194```
2195import HashMap from "@ohos.util.HashMap"
2196let hashMap = new HashMap();
2197hashMap.set(1, "A");
2198hashMap.set(2, "B");
2199hashMap.set(3, "C");
2200let result = hashMap.hasValue("C");
2201```
2202133.get()
2203```
2204import HashMap from "@ohos.util.HashMap"
2205let hashMap = new HashMap();
2206hashMap.set(1, "A");
2207hashMap.set(2, "B");
2208hashMap.set(3, "C");
2209let result = hashMap.get(3);
2210```
2211134.setAll()
2212```
2213import HashMap from "@ohos.util.HashMap"
2214let hashMap = new HashMap();
2215hashMap.set(1, "A");
2216hashMap.set(2, "B");
2217hashMap.set(3, "C");
2218let hashMap1 = new HashMap();
2219hashMap1.set(1, 1);
2220hashMap1.set(2, 2);
2221hashMap.setAll(hashMap1);
2222```
2223135.set()
2224```
2225import HashMap from "@ohos.util.HashMap"
2226let hashMap = new HashMap();
2227hashMap.set(1, "A");
2228hashMap.set(2, "B");
2229hashMap.set(3, "C");
2230```
2231136.remove()
2232```
2233import HashMap from "@ohos.util.HashMap"
2234let hashMap = new HashMap();
2235hashMap.set(1, "A");
2236hashMap.set(2, "B");
2237hashMap.set(3, "C");
2238let result = hashMap.remove(3);
2239```
2240137.clear()
2241```
2242import HashMap from "@ohos.util.HashMap"
2243let hashMap = new HashMap();
2244hashMap.set(1, "A");
2245hashMap.set(2, "B");
2246hashMap.set(3, "C");
2247hashMap.clear();
2248```
2249138.keys()
2250```
2251import HashMap from "@ohos.util.HashMap"
2252let hashMap = new HashMap();
2253hashMap.set(1, "A");
2254hashMap.set(2, "B");
2255hashMap.set(3, "C");
2256hashMap.set(4, "D");
2257hashMap.set(5, "E");
2258let result = hashMap.keys();
2259```
2260139.values()
2261```
2262import HashMap from "@ohos.util.HashMap"
2263let hashMap = new HashMap();
2264hashMap.set(1, "A");
2265hashMap.set(2, "B");
2266hashMap.set(3, "C");
2267hashMap.set(4, "D");
2268hashMap.set(5, "E");
2269let result = hashMap.values();
2270```
2271140.replace()
2272```
2273import HashMap from "@ohos.util.HashMap"
2274let hashMap = new HashMap();
2275hashMap.set(1, "A");
2276hashMap.set(2, "B");
2277hashMap.set(3, "C");
2278hashMap.set(4, "D");
2279hashMap.set(5, "E");
2280let result = hashMap.replace(2, "G");
2281```
2282141.forEach()
2283```
2284import HashMap from "@ohos.util.HashMap"
2285let hashMap = new HashMap();
2286hashMap.set(1, "A");
2287hashMap.set(2, "B");
2288hashMap.set(3, "C");
2289hashMap.set(4, "D");
2290hashMap.set(5, "E");
2291let vals = [];
2292let keys = [];
2293hashMap.forEach((value, key) => {
2294    keys.push(key);
2295    vals.push(value);
2296});
2297```
2298142.entries()
2299```
2300import HashMap from "@ohos.util.HashMap"
2301let hashMap = new HashMap();
2302hashMap.set(1, "A");
2303hashMap.set(2, "B");
2304hashMap.set(3, "C");
2305hashMap.set(4, "D");
2306hashMap.set(5, "E");
2307let result = hashMap.entries();
2308```
2309143.isEmpty()
2310```
2311import HashSet from "@ohos.util.HashSet"
2312let hashSet = new HashSet();
2313hashSet.add(1);
2314hashSet.add(2);
2315let result = hashSet.isEmpty();
2316```
2317144.has()
2318```
2319import HashSet from "@ohos.util.HashSet"
2320let hashSet = new HashSet();
2321hashSet.add(1);
2322hashSet.add(2);
2323let result = hashSet.has(1);
2324```
2325145.add()
2326```
2327import HashSet from "@ohos.util.HashSet"
2328let hashSet = new HashSet();
2329hashSet.add(1);
2330hashSet.add(2);
2331```
2332146.remove()
2333```
2334import HashSet from "@ohos.util.HashSet"
2335let hashSet = new HashSet();
2336hashSet.add(1);
2337hashSet.add(2);
2338let hashSet = hashSet.remove(1);
2339```
2340147.clear()
2341```
2342import HashSet from "@ohos.util.HashSet"
2343let hashSet = new HashSet();
2344hashSet.add(1);
2345hashSet.add(2);
2346hashSet.clear();
2347```
2348148.forEach()
2349```
2350import HashSet from "@ohos.util.HashSet"
2351let hashSet = new HashSet();
2352hashSet.add(1);
2353hashSet.add(2);
2354hashSet.add(3);
2355hashSet.add(4);
2356hashSet.add(5);
2357let arr = [];
2358hashSet.forEach((value, index) => {
2359    arr.push(value);
2360});
2361```
2362149.values()
2363```
2364import HashSet from "@ohos.util.HashSet"
2365let hashSet = new HashSet();
2366hashSet.add("A");
2367hashSet.add("B");
2368hashSet.add("C");
2369hashSet.add("D");
2370hashSet.add("E");
2371let res = hashSet.values();
2372```
2373150.entries()
2374```
2375import HashSet from "@ohos.util.HashSet"
2376let hashSet = new HashSet();
2377hashSet.add(1);
2378hashSet.add(2);
2379hashSet.add(3);
2380let res = hashSet.entries();
2381```
2382151.hasAll()
2383```
2384import LightWeightMap from "@ohos.util.LightWeightMap"
2385let lightWeightMap = new LightWeightMap();
2386lightWeightMap.set("a", "A");
2387lightWeightMap.set("b", "B");
2388lightWeightMap.set("c", "C");
2389lightWeightMap.set("d", "D");
2390lightWeightMap.set("e", "E");
2391let lightWeightMap1 = new LightWeightMap();
2392lightWeightMap1.set("a", "A");
2393lightWeightMap1.set("d", "D");
2394let res = lightWeightMap.hasAll(lightWeightMap1);
2395```
2396152.hasKey()
2397```
2398import LightWeightMap from "@ohos.util.LightWeightMap"
2399let lightWeightMap = new LightWeightMap();
2400lightWeightMap.set("a", "A");
2401lightWeightMap.set("b", "B");
2402lightWeightMap.set("c", "C");
2403let res = lightWeightMap.hasKey("a");
2404```
2405153.hasValue()
2406```
2407import LightWeightMap from "@ohos.util.LightWeightMap"
2408let lightWeightMap = new LightWeightMap();
2409lightWeightMap.set("a", "A");
2410lightWeightMap.set("b", "B");
2411lightWeightMap.set("c", "C");
2412let res = lightWeightMap.hasValue("A");
2413```
2414154.increaseCapacityTo()
2415```
2416import LightWeightMap from "@ohos.util.LightWeightMap"
2417let lightWeightMap = new LightWeightMap();
2418lightWeightMap.set("a", "A");
2419lightWeightMap.set("b", "B");
2420lightWeightMap.set("c", "C");
2421lightWeightMap.increaseCapacityTo(3);
2422```
2423155.entries()
2424```
2425import LightWeightMap from "@ohos.util.LightWeightMap"
2426let lightWeightMap = new LightWeightMap();
2427lightWeightMap.set(1, "A");
2428lightWeightMap.set(2, "B");
2429lightWeightMap.set(3, "C");
2430let res = lightWeightMap.entries();
2431```
2432156.get()
2433```
2434import LightWeightMap from "@ohos.util.LightWeightMap"
2435let lightWeightMap = new LightWeightMap();
2436lightWeightMap.set(1, "A");
2437lightWeightMap.set(2, "B");
2438lightWeightMap.set(3, "C");
2439let res = lightWeightMap.get(1);
2440```
2441157.getIndexOfKey()
2442```
2443import LightWeightMap from "@ohos.util.LightWeightMap"
2444let lightWeightMap = new LightWeightMap();
2445lightWeightMap.set(1, "A");
2446lightWeightMap.set(2, "B");
2447lightWeightMap.set(3, "C");
2448let res = lightWeightMap.getIndexOfKey(2);
2449```
2450158.getIndexOfValue()
2451```
2452import LightWeightMap from "@ohos.util.LightWeightMap"
2453let lightWeightMap = new LightWeightMap();
2454lightWeightMap.set(1, "A");
2455lightWeightMap.set(2, "B");
2456lightWeightMap.set(3, "C");
2457lightWeightMap.set(4, "D");
2458lightWeightMap.set(5, "E");
2459lightWeightMap.setValueAt(4, "F");
2460let res = lightWeightMap.getIndexOfValue("F");
2461```
2462159.isEmpty()
2463```
2464import LightWeightMap from "@ohos.util.LightWeightMap"
2465let lightWeightMap = new LightWeightMap();
2466lightWeightMap.set(1, "A");
2467lightWeightMap.set(2, "B");
2468let res = lightWeightMap.isEmpty();
2469```
2470160.getKeyAt()
2471```
2472import LightWeightMap from "@ohos.util.LightWeightMap"
2473let lightWeightMap = new LightWeightMap();
2474lightWeightMap.set(1, "A");
2475lightWeightMap.set(2, "B");
2476lightWeightMap.set(3, "C");
2477let res = lightWeightMap.getKeyAt(1);
2478```
2479161.keys()
2480```
2481import LightWeightMap from "@ohos.util.LightWeightMap"
2482let lightWeightMap = new LightWeightMap();
2483lightWeightMap.set(1, "A");
2484lightWeightMap.set(2, "B");
2485lightWeightMap.set(3, "C");
2486let res = lightWeightMap.keys();
2487```
2488161.setAll()
2489```
2490import LightWeightMap from "@ohos.util.LightWeightMap"
2491let lightWeightMap = new LightWeightMap();
2492lightWeightMap.set(1, "A");
2493lightWeightMap.set(2, "B");
2494lightWeightMap.set(3, "C");
2495lightWeightMap.set(4, "D");
2496lightWeightMap.set(5, "E");
2497let lightWeightMap1 = new LightWeightMap();
2498lightWeightMap1.set(6, "A");
2499lightWeightMap1.set(7, "B");
2500lightWeightMap.setAll(lightWeightMap1);
2501```
2502162.set()
2503```
2504import LightWeightMap from "@ohos.util.LightWeightMap"
2505let lightWeightMap = new LightWeightMap();
2506lightWeightMap.set(1, "A");
2507lightWeightMap.set(2, "B");
2508```
2509163.remove()
2510```
2511import LightWeightMap from "@ohos.util.LightWeightMap"
2512let lightWeightMap = new LightWeightMap();
2513lightWeightMap.set(1, "A");
2514lightWeightMap.set(2, "B");
2515let res = lightWeightMap.remove(2);
2516```
2517164.removeAt()
2518```
2519import LightWeightMap from "@ohos.util.LightWeightMap"
2520let lightWeightMap = new LightWeightMap();
2521lightWeightMap.set(1, "A");
2522lightWeightMap.set(2, "B");
2523let res = lightWeightMap.removeAt(1);
2524```
2525165.clear()
2526```
2527import LightWeightMap from "@ohos.util.LightWeightMap"
2528let lightWeightMap = new LightWeightMap();
2529lightWeightMap.set(1, "A");
2530lightWeightMap.set(2, "B");
2531lightWeightMap.clear();
2532```
2533166.setValueAt()
2534```
2535import LightWeightMap from "@ohos.util.LightWeightMap"
2536let lightWeightMap = new LightWeightMap();
2537lightWeightMap.set(1, "A");
2538lightWeightMap.set(2, "B");
2539lightWeightMap.setValueAt(0, "a");
2540```
2541167.forEach()
2542```
2543import LightWeightMap from "@ohos.util.LightWeightMap"
2544let lightWeightMap = new LightWeightMap();
2545lightWeightMap.set(1, "A");
2546lightWeightMap.set(2, "B");
2547lightWeightMap.set(3, "C");
2548lightWeightMap.set(4, "D");
2549lightWeightMap.set(5, "E");
2550let arr = [];
2551lightWeightMap.forEach((value, index) => {
2552    arr.push(value);
2553});
2554```
2555168.[Symbol.iterator]()
2556```
2557import LightWeightMap from "@ohos.util.LightWeightMap"
2558let lightWeightMap = new LightWeightMap();
2559lightWeightMap.set(1, "A");
2560lightWeightMap.set(2, "B");
2561lightWeightMap.set(3, "C");
2562lightWeightMap.set(4, "D");
2563lightWeightMap.set(5, "E");
2564let iters = lightWeightMap[Symbol.iterator]();
2565```
2566169.toString()
2567```
2568import LightWeightMap from "@ohos.util.LightWeightMap"
2569let lightWeightMap = new LightWeightMap();
2570lightWeightMap.set(1, "A");
2571lightWeightMap.set(2, "B");
2572lightWeightMap.set(3, "C");
2573let res = lightWeightMap.toString();
2574```
2575170.getValueAt()
2576```
2577import LightWeightMap from "@ohos.util.LightWeightMap"
2578let lightWeightMap = new LightWeightMap();
2579lightWeightMap.set(1, "A");
2580lightWeightMap.set(2, "B");
2581lightWeightMap.set(3, "C");
2582let res = lightWeightMap.getValueAt(1);
2583```
2584171.values()
2585```
2586import LightWeightMap from "@ohos.util.LightWeightMap"
2587let lightWeightMap = new LightWeightMap();
2588lightWeightMap.set(1, "A");
2589lightWeightMap.set(2, "B");
2590lightWeightMap.set(3, "C");
2591let res = lightWeightMap.values();
2592```
2593172.add()
2594```
2595import LightWeightSet from "@ohos.util.LightWeightSet"
2596let lightWeightSet = new LightWeightSet();
2597lightWeightSet.add(1);
2598```
2599173.addAll()
2600```
2601import LightWeightSet from "@ohos.util.LightWeightSet"
2602let lightWeightSet = new LightWeightSet();
2603lightWeightSet.add(1);
2604lightWeightSet.add(2);
2605lightWeightSet.add(3);
2606lightWeightSet.add(4);
2607lightWeightSet.add(5);
2608let lightWeightSet1 = new LightWeightSet();
2609lightWeightSet1.add(6);
2610lightWeightSet1.add(7);
2611let res1 = lightWeightSet.addAll(lightWeightSet1);
2612```
2613174.hasAll()
2614```
2615import LightWeightSet from "@ohos.util.LightWeightSet"
2616let lightWeightSet = new LightWeightSet();
2617lightWeightSet.add("a");
2618lightWeightSet.add("b");
2619lightWeightSet.add("c");
2620lightWeightSet.add("e");
2621let lightWeightSet1 = new LightWeightSet();
2622lightWeightSet1.add("a");
2623lightWeightSet1.add("d");
2624let res = lightWeightSet.hasAll(lightWeightSet1);
2625```
2626175.has()
2627```
2628import LightWeightSet from "@ohos.util.LightWeightSet"
2629let lightWeightSet = new LightWeightSet();
2630lightWeightSet.add("a");
2631lightWeightSet.add("b");
2632lightWeightSet.add("c");
2633let res = lightWeightSet.has("a");
2634```
2635176.equal()
2636```
2637import LightWeightSet from "@ohos.util.LightWeightSet"
2638let lightWeightSet = new LightWeightSet();
2639lightWeightSet.add(1);
2640lightWeightSet.add(2);
2641lightWeightSet.add(3);
2642let obj = [1,2,3];
2643let res = lightWeightSet.equal(obj);
2644```
2645177.increaseCapacityTo()
2646```
2647import LightWeightSet from "@ohos.util.LightWeightSet"
2648let lightWeightSet = new LightWeightSet();
2649lightWeightSet.add(1);
2650lightWeightSet.add(2);
2651lightWeightSet.add(3);
2652let res = lightWeightSet.increaseCapacityTo(20);
2653```
2654178.getIndexOf()
2655```
2656import LightWeightSet from "@ohos.util.LightWeightSet"
2657let lightWeightSet = new LightWeightSet();
2658lightWeightSet.add(1);
2659lightWeightSet.add(2);
2660lightWeightSet.add(3);
2661let res = lightWeightSet.getIndexOf(2);
2662```
2663179.remove()
2664```
2665import LightWeightSet from "@ohos.util.LightWeightSet"
2666let lightWeightSet = new LightWeightSet();
2667lightWeightSet.add(1);
2668lightWeightSet.add(2);
2669lightWeightSet.add(3);
2670let res = lightWeightSet.remove(1);
2671```
2672180.removeAt()
2673```
2674import LightWeightSet from "@ohos.util.LightWeightSet"
2675let lightWeightSet = new LightWeightSet();
2676lightWeightSet.add(1);
2677lightWeightSet.add(2);
2678lightWeightSet.add(3);
2679let res = lightWeightSet.removeAt(1);
2680```
2681181.clear()
2682```
2683import LightWeightSet from "@ohos.util.LightWeightSet"
2684let lightWeightSet = new LightWeightSet();
2685lightWeightSet.add(1);
2686lightWeightSet.add(2);
2687lightWeightSet.add(3);
2688lightWeightSet.clear();
2689```
2690182.forEach()
2691```
2692import LightWeightSet from "@ohos.util.LightWeightSet"
2693let lightWeightSet = new LightWeightSet();
2694lightWeightSet.add(1);
2695lightWeightSet.add(2);
2696lightWeightSet.add(3);
2697lightWeightSet.add(4);
2698lightWeightSet.add(5);
2699let arr = [];
2700lightWeightSet.forEach((value, index) => {
2701    arr.push(value);
2702});
2703```
2704183.[Symbol.iterator]()
2705```
2706import LightWeightSet from "@ohos.util.LightWeightSet"
2707let lightWeightSet = new LightWeightSet();
2708lightWeightSet.add(1);
2709lightWeightSet.add(2);
2710lightWeightSet.add(3);
2711let res = lightWeightSet[Symbol.iterator]();
2712```
2713184.toString()
2714```
2715import LightWeightSet from "@ohos.util.LightWeightSet"
2716let lightWeightSet = new LightWeightSet();
2717lightWeightSet.add(1);
2718lightWeightSet.add(2);
2719lightWeightSet.add(3);
2720let res = lightWeightSet.toString();
2721```
2722185.toArray()
2723```
2724import LightWeightSet from "@ohos.util.LightWeightSet"
2725let lightWeightSet = new LightWeightSet();
2726lightWeightSet.add(1);
2727lightWeightSet.add(2);
2728lightWeightSet.add(3);
2729let res = lightWeightSet.toArray();
2730```
2731186.getValueAt()
2732```
2733import LightWeightSet from "@ohos.util.LightWeightSet"
2734let lightWeightSet = new LightWeightSet();
2735lightWeightSet.add(1);
2736lightWeightSet.add(2);
2737lightWeightSet.add(3);
2738let res = lightWeightSet.getValueAt(1);
2739```
2740187.values()
2741```
2742import LightWeightSet from "@ohos.util.LightWeightSet"
2743let lightWeightSet = new LightWeightSet();
2744lightWeightSet.add(1);
2745lightWeightSet.add(2);
2746lightWeightSet.add(3);
2747let res = lightWeightSet.values();
2748```
2749188.entries()
2750```
2751import LightWeightSet from "@ohos.util.LightWeightSet"
2752let lightWeightSet = new LightWeightSet();
2753lightWeightSet.add(1);
2754lightWeightSet.add(2);
2755lightWeightSet.add(3);
2756let res = lightWeightSet.entries();
2757```
2758189.isEmpty()
2759```
2760import LightWeightSet from "@ohos.util.LightWeightSet"
2761let lightWeightSet = new LightWeightSet();
2762lightWeightSet.add(1);
2763lightWeightSet.add(2);
2764lightWeightSet.add(3);
2765let res = lightWeightSet.isEmpty();
2766```
2767190.add()
2768```
2769import LinkedList from "@ohos.util.LinkedList"
2770let linkedList = new LinkedList();
2771linkedList.add("四");
2772```
2773191.insert()
2774```
2775import LinkedList from "@ohos.util.LinkedList"
2776let linkedList = new LinkedList();
2777linkedList.add("a");
2778linkedList.add("b");
2779linkedList.add("c");
2780linkedList.add("a");
2781linkedList.add("b");
2782let res = linkedList.insert(3, "d");
2783```
2784192.get()
2785```
2786import LinkedList from "@ohos.util.LinkedList"
2787let linkedList = new LinkedList();
2788linkedList.add("a");
2789linkedList.add("b");
2790linkedList.add("c");
2791let res1 = linkedList.get(2);
2792```
2793193.addFirst()
2794```
2795import LinkedList from "@ohos.util.LinkedList"
2796let linkedList = new LinkedList();
2797linkedList.add("a");
2798linkedList.add("b");
2799linkedList.add("c");
2800linkedList.addFirst("e");
2801```
2802194.removeFirst()
2803```
2804import LinkedList from "@ohos.util.LinkedList"
2805let linkedList = new LinkedList();
2806linkedList.add("a");
2807linkedList.add("b");
2808linkedList.add("c");
2809let res = linkedList.removeFirst();
2810```
2811195.removeLast()
2812```
2813import LinkedList from "@ohos.util.LinkedList"
2814let linkedList = new LinkedList();
2815linkedList.add("a");
2816linkedList.add("b");
2817linkedList.add("c");
2818let res = linkedList.removeLast();
2819```
2820196.has()
2821```
2822import LinkedList from "@ohos.util.LinkedList"
2823let linkedList = new LinkedList();
2824linkedList.add("a");
2825linkedList.add("b");
2826linkedList.add("c");
2827let res = linkedList.has(1);
2828```
2829197.getIndexOf()
2830```
2831import LinkedList from "@ohos.util.LinkedList"
2832let linkedList = new LinkedList();
2833linkedList.add("a");
2834linkedList.add("b");
2835linkedList.add("c");
2836let res = linkedList.getIndexOf("b");
2837```
2838198.removeByIndex()
2839```
2840import LinkedList from "@ohos.util.LinkedList"
2841let linkedList = new LinkedList();
2842linkedList.add("a");
2843linkedList.add("b");
2844linkedList.add("c");
2845let res = linkedList.removeByIndex(2);
2846```
2847199.remove()
2848```
2849import LinkedList from "@ohos.util.LinkedList"
2850let linkedList = new LinkedList();
2851linkedList.add("a");
2852linkedList.add("b");
2853linkedList.add("c");
2854let res = linkedList.remove("a");
2855```
2856200.removeFirstFound()
2857```
2858import LinkedList from "@ohos.util.LinkedList"
2859let linkedList = new LinkedList();
2860linkedList.add("a");
2861linkedList.add("b");
2862linkedList.add("c");
2863let res = linkedList.removeFirstFound("b");
2864```
2865201.removeLastFound()
2866```
2867import LinkedList from "@ohos.util.LinkedList"
2868let linkedList = new LinkedList();
2869linkedList.add("a");
2870linkedList.add("b");
2871linkedList.add("c");
2872let res = linkedList.removeLastFound("b");
2873```
2874202.getLastIndexOf()
2875```
2876import LinkedList from "@ohos.util.LinkedList"
2877let linkedList = new LinkedList();
2878linkedList.add("a");
2879linkedList.add("b");
2880linkedList.add("c");
2881linkedList.add("a");
2882linkedList.add("b");
2883linkedList.add("b");
2884let res = linkedList.getLastIndexOf("a");
2885```
2886203.getFirst()
2887```
2888import LinkedList from "@ohos.util.LinkedList"
2889let linkedList = new LinkedList();
2890linkedList.add("a");
2891linkedList.add("b");
2892linkedList.add("c");
2893linkedList.add("a");
2894linkedList.add("b");
2895linkedList.add("b");
2896let res = linkedList.getFirst();
2897```
2898204.getLast()
2899```
2900import LinkedList from "@ohos.util.LinkedList"
2901let linkedList = new LinkedList();
2902linkedList.add("a");
2903linkedList.add("b");
2904linkedList.add("c");
2905linkedList.add("a");
2906linkedList.add("b");
2907linkedList.add("b");
2908let res = linkedList.getLast();
2909```
2910205.set()
2911```
2912import LinkedList from "@ohos.util.LinkedList"
2913let linkedList = new LinkedList();
2914linkedList.add("a");
2915linkedList.add("b");
2916linkedList.add("c");
2917let res = linkedList.set(2, "d");
2918```
2919206.forEach()
2920```
2921import LinkedList from "@ohos.util.LinkedList"
2922let linkedList = new LinkedList();
2923linkedList.add(8);
2924linkedList.add("一");
2925linkedList.add("二");
2926linkedList.add(5);
2927let c = [1, 2, 3, 4];
2928linkedList.add(c);
2929linkedList.add(6);
2930linkedList.add("三");
2931linkedList.add("四");
2932let arr = [];
2933linkedList.forEach((item, index) => {
2934    arr.push(item);
2935});
2936```
2937207.clear()
2938```
2939import LinkedList from "@ohos.util.LinkedList"
2940let linkedList = new LinkedList();
2941linkedList.add("a");
2942linkedList.add("b");
2943linkedList.add("c");
2944let res = linkedList.clear();
2945```
2946208.clone()
2947```
2948import LinkedList from "@ohos.util.LinkedList"
2949let linkedList = new LinkedList();
2950linkedList.add("a");
2951linkedList.add("b");
2952linkedList.add("c");
2953let linkedList1 = linkedList.clone();
2954```
2955209.convertToArray()
2956```
2957import LinkedList from "@ohos.util.LinkedList"
2958let linkedList = new LinkedList();
2959linkedList.add(4);
2960linkedList.add(3);
2961linkedList.add(1);
2962linkedList.add(2);
2963linkedList.add(14);
2964let res = linkedList.convertToArray();
2965```
2966210.[Symbol.iterator]()
2967```
2968import LinkedList from "@ohos.util.LinkedList"
2969let linkedList = new LinkedList();
2970linkedList.add("a");
2971linkedList.add("b");
2972linkedList.add("c");
2973linkedList.addFirst("e");
2974let itr = linkedList[Symbol.iterator]();
2975```
2976211.add()
2977```
2978import List from "@ohos.util.List"
2979let list = new List();
2980list.add("四");
2981```
2982212.insert()
2983```
2984import List from "@ohos.util.List"
2985let list = new List();
2986list.add("a");
2987list.add("b");
2988list.add("c");
2989list.add("a");
2990list.add("b");
2991let res = list.insert("d", 3);
2992```
2993213.get()
2994```
2995import List from "@ohos.util.List"
2996let list = new List();
2997list.add("a");
2998list.add("b");
2999list.add("c");
3000list.add("a");
3001let res = list.set(2, "d");
3002let res1 = list.get(2);
3003```
3004214.has()
3005```
3006import List from "@ohos.util.List"
3007let list = new List();
3008list.add("a");
3009list.add("b");
3010let res = list.has(1);
3011```
3012215.getIndexOf()
3013```
3014import List from "@ohos.util.List"
3015let list = new List();
3016list.add("a");
3017list.add("b");
3018list.add("c");
3019list.add("b");
3020let res = list.getIndexOf("b");
3021```
3022216.removeByIndex()
3023```
3024import List from "@ohos.util.List"
3025let list = new List();
3026list.add("a");
3027list.add("b");
3028list.add("c");
3029list.add("b");
3030let res = list.removeByIndex(2);
3031```
3032217.remove()
3033```
3034import List from "@ohos.util.List"
3035let list = new List();
3036list.add("a");
3037list.add("b");
3038list.add("c");
3039list.add("b");
3040let res = list.remove("a");
3041```
3042218.getLastIndexOf()
3043```
3044import List from "@ohos.util.List"
3045let list = new List();
3046list.add("a");
3047list.add("b");
3048list.add("c");
3049list.add("b");
3050let res = list.getLastIndexOf("F");
3051```
3052219.getFirst()
3053```
3054import List from "@ohos.util.List"
3055let list = new List();
3056list.add("a");
3057list.add("b");
3058list.add("c");
3059list.add("b");
3060let res = list.getFirst();
3061```
3062220.getLast()
3063```
3064import List from "@ohos.util.List"
3065let list = new List();
3066list.add("a");
3067list.add("b");
3068list.add("c");
3069list.add("b");
3070let res = list.getLast();
3071```
3072221.set()
3073```
3074import List from "@ohos.util.List"
3075let list = new List();
3076list.add("a");
3077list.add("b");
3078list.add("c");
3079list.add("a");
3080let res = list.set(2, "d");
3081```
3082222.equal()
3083```
3084import List from "@ohos.util.List"
3085let list = new List();
3086let list1 = new List();
3087let res = list.equal(list1);
3088```
3089223.forEach()
3090```
3091import List from "@ohos.util.List"
3092let list = new List();
3093let num = 0;
3094list.forEach((item, index) => {
3095    num++;
3096});
3097```
3098224.sort()
3099```
3100import List from "@ohos.util.List"
3101let list = new List();
3102list.add(4);
3103list.add(3);
3104list.add(1);
3105list.sort((a, b) => a - b);
3106```
3107225.clear()
3108```
3109import List from "@ohos.util.List"
3110let list = new List();
3111list.add(4);
3112list.add(3);
3113list.add(1);
3114list.clear();
3115```
3116226.getSubList()
3117```
3118import List from "@ohos.util.List"
3119let list = new List();
3120list.add(4);
3121list.add(3);
3122list.add(1);
3123list.add(2);
3124list.add(14);
3125let res = list.getSubList(2, 4);
3126```
3127227.replaceAllElements()
3128```
3129import List from "@ohos.util.List"
3130let list = new List();
3131let num = 0;
3132list.replaceAllElements((item, index) => {
3133    num++;
3134});
3135```
3136228.convertToArray()
3137```
3138import List from "@ohos.util.List"
3139let list = new List();
3140const res = list.convertToArray();
3141```
3142229.isEmpty()
3143```
3144import List from "@ohos.util.List"
3145let list = new List();
3146let res = list.isEmpty();
3147```
3148230.[Symbol.iterator]()
3149```
3150import List from "@ohos.util.List"
3151let list = new List();
3152list.add("a");
3153list.add("b");
3154list.add("c");
3155let itr = list[Symbol.iterator]();
3156```
3157231.add()
3158```
3159import PlainArray from "@ohos.util.PlainArray"
3160let plainArray = new PlainArray();
3161plainArray.add(1, "A");
3162```
3163232.clear()
3164```
3165import PlainArray from "@ohos.util.PlainArray"
3166let plainArray = new PlainArray();
3167plainArray.add(1, "A");
3168plainArray.add(2, "B");
3169plainArray.add(3, "C");
3170plainArray.clear();
3171```
3172233.clone()
3173```
3174import PlainArray from "@ohos.util.PlainArray"
3175let plainArray = new PlainArray();
3176plainArray.add(1, "A");
3177plainArray.add(2, "B");
3178plainArray.add(3, "C");
3179let clonePlainarray = plainArray.clone();
3180```
3181234.has()
3182```
3183import PlainArray from "@ohos.util.PlainArray"
3184let plainArray = new PlainArray();
3185plainArray.add(1, "A");
3186plainArray.add(2, "B");
3187plainArray.add(3, "C");
3188let res = plainArray.has(6);
3189```
3190235.get()
3191```
3192import PlainArray from "@ohos.util.PlainArray"
3193let plainArray = new PlainArray();
3194plainArray.add(1, "A");
3195plainArray.add(2, "B");
3196plainArray.add(3, "C");
3197let value = plainArray.get(2);
3198```
3199236.getIndexOfKey()
3200```
3201import PlainArray from "@ohos.util.PlainArray"
3202let plainArray = new PlainArray();
3203plainArray.add(1, "A");
3204plainArray.add(2, "B");
3205plainArray.add(3, "C");
3206let res = plainArray.getIndexOfKey(9);
3207```
3208237.getIndexOfValue()
3209```
3210import PlainArray from "@ohos.util.PlainArray"
3211let plainArray = new PlainArray();
3212plainArray.add(1, "A");
3213plainArray.add(2, "B");
3214plainArray.add(3, "C");
3215let res = plainArray.getIndexOfValue("Asad");
3216```
3217238.isEmpty()
3218```
3219import PlainArray from "@ohos.util.PlainArray"
3220let plainArray = new PlainArray();
3221plainArray.add(1, "A");
3222plainArray.add(2, "B");
3223plainArray.add(3, "C");
3224let res = plainArray.isEmpty();
3225```
3226239.getKeyAt()
3227```
3228import PlainArray from "@ohos.util.PlainArray"
3229let plainArray = new PlainArray();
3230plainArray.add(1, "A");
3231plainArray.add(2, "B");
3232plainArray.add(3, "C");
3233let res = plainArray.getKeyAt(2);
3234```
3235240.remove()
3236```
3237import PlainArray from "@ohos.util.PlainArray"
3238let plainArray = new PlainArray();
3239plainArray.add(1, "A");
3240plainArray.add(2, "B");
3241plainArray.add(3, "C");
3242let res = plainArray.remove(2);
3243```
3244241.removeAt()
3245```
3246import PlainArray from "@ohos.util.PlainArray"
3247let plainArray = new PlainArray();
3248plainArray.add(1, "A");
3249plainArray.add(2, "B");
3250plainArray.add(3, "C");
3251let res = plainArray.removeAt(2);
3252```
3253242.removeRangeFrom()
3254```
3255import PlainArray from "@ohos.util.PlainArray"
3256let plainArray = new PlainArray();
3257plainArray.add(1, "A");
3258plainArray.add(2, "B");
3259plainArray.add(3, "C");
3260plainArray.removeRangeFrom(2, 2);
3261```
3262243.setValueAt()
3263```
3264import PlainArray from "@ohos.util.PlainArray"
3265let plainArray = new PlainArray();
3266plainArray.add(1, "A");
3267plainArray.add(2, "B");
3268plainArray.add(3, "C");
3269plainArray.setValueAt(2, "V");
3270```
3271244.toString()
3272```
3273import PlainArray from "@ohos.util.PlainArray"
3274let plainArray = new PlainArray();
3275plainArray.add(1, "A");
3276plainArray.add(2, "B");
3277plainArray.add(3, "C");
3278let res1 = plainArray.toString();
3279```
3280245.getValueAt()
3281```
3282import PlainArray from "@ohos.util.PlainArray"
3283let plainArray = new PlainArray();
3284plainArray.add(1, "A");
3285plainArray.add(2, "B");
3286plainArray.add(3, "C");
3287let res = plainArray.getValueAt(2);
3288```
3289246.forEach()
3290```
3291import PlainArray from "@ohos.util.PlainArray"
3292let plainArray = new PlainArray();
3293plainArray.add(1, "A");
3294plainArray.add(2, "B");
3295plainArray.add(3, "C");
3296let arr = [];
3297res.forEach((value, index) => {
3298    arr.push(value);
3299});
3300```
3301247.[Symbol.iterator]()
3302```
3303import PlainArray from "@ohos.util.PlainArray"
3304let plainArray = new PlainArray();
3305plainArray.add(1, "A");
3306plainArray.add(2, "B");
3307plainArray.add(3, "C");
3308let iters = plainArray[Symbol.iterator]();
3309```
3310248.add()
3311```
3312import Queue from "@ohos.util.Queue"
3313let queue = new Queue();
3314queue.add("四");
3315```
3316249.getFirst()
3317```
3318import Queue from "@ohos.util.Queue"
3319let queue = new Queue();
3320queue.add("四");
3321let res = queue.getFirst();
3322```
3323250.pop()
3324```
3325import Queue from "@ohos.util.Queue"
3326let queue = new Queue();
3327queue.add("四");
3328let res = queue.pop();
3329```
3330251.forEach()
3331```
3332import Queue from "@ohos.util.Queue"
3333let queue = new Queue();
3334queue.add(1);
3335queue.add(2);
3336queue.add(3);
3337queue.add(4);
3338queue.forEach((item, index) => {
3339    arr.push(item);
3340});
3341```
3342252.[Symbol.iterator]()
3343```
3344import Queue from "@ohos.util.Queue"
3345let queue = new Queue();
3346queue.add("四");
3347let itr = queue[Symbol.iterator]();
3348```
3349253.isEmpty()
3350```
3351import Stack from "@ohos.util.Stack"
3352let stack = new Stack();
3353stack.push(8);
3354stack.push(5);
3355let res = stack.isEmpty();
3356```
3357254.peek()
3358```
3359import Stack from "@ohos.util.Stack"
3360let stack = new Stack();
3361stack.push(1234);
3362let res = stack.peek();
3363```
3364255.pop()
3365```
3366import Stack from "@ohos.util.Stack"
3367let stack = new Stack();
3368stack.push(1234);
3369let res = stack.pop();
3370```
3371256.push()
3372```
3373import Stack from "@ohos.util.Stack"
3374let stack = new Stack();
3375stack.push(12);
3376```
3377257.locate()
3378```
3379import Stack from "@ohos.util.Stack"
3380let stack = new Stack();
3381stack.push("A");
3382stack.push("B");
3383stack.push(1);
3384let res = stack.locate("A");
3385```
3386258.forEach()
3387```
3388import Stack from "@ohos.util.Stack"
3389let stack = new Stack();
3390stack.push(8);
3391stack.push(5);
3392stack.push(c);
3393stack.push(6);
3394stack.forEach((item, index) => {
3395    arr.push(item);
3396});
3397```
3398259.[Symbol.iterator]()
3399```
3400import Stack from "@ohos.util.Stack"
3401let stack = new Stack();
3402stack.push("A");
3403stack.push("B");
3404stack.push(1);
3405let itr = stack[Symbol.iterator]();
3406```
3407260.isEmpty()
3408```
3409import TreeMap from "@ohos.util.TreeMap"
3410let treeMap = new TreeMap();
3411treeMap.set(0, "a");
3412treeMap.set(1, "b");
3413let res = treeMap.isEmpty();
3414```
3415261.hasKey()
3416```
3417import TreeMap from "@ohos.util.TreeMap"
3418let treeMap = new TreeMap();
3419treeMap.set(0, "a");
3420treeMap.set(1, "b");
3421let res = treeMap.hasKey(1);
3422```
3423262.hasValue()
3424```
3425import TreeMap from "@ohos.util.TreeMap"
3426let treeMap = new TreeMap();
3427treeMap.set(0, "a");
3428treeMap.set(1, "b");
3429let res = treeMap.hasValue("a");
3430```
3431263.get()
3432```
3433import TreeMap from "@ohos.util.TreeMap"
3434let treeMap = new TreeMap();
3435treeMap.set(0, "a");
3436treeMap.set(1, "b");
3437let res = treeMap.get(1);
3438```
3439264.getFirstKey()
3440```
3441import TreeMap from "@ohos.util.TreeMap"
3442let treeMap = new TreeMap();
3443treeMap.set(0, "a");
3444treeMap.set(1, "b");
3445let res = treeMap.getFirstKey();
3446```
3447265.getLastKey()
3448```
3449import TreeMap from "@ohos.util.TreeMap"
3450let treeMap = new TreeMap();
3451treeMap.set(0, "a");
3452treeMap.set(1, "b");
3453let res = treeMap.getLastKey();
3454```
3455266.setAll()
3456```
3457import TreeMap from "@ohos.util.TreeMap"
3458let treeMap = new TreeMap();
3459treeMap.set(0, "a");
3460treeMap.set(1, "b");
3461let treeMap1 = new TreeMap();
3462treeMap1.set(0, "a");
3463treeMap1.set(1, "b");
3464treeMap1.set(2, "c");
3465treeMap.setAll(treeMap1);
3466```
3467267.set()
3468```
3469import TreeMap from "@ohos.util.TreeMap"
3470let treeMap = new TreeMap();
3471treeMap.set(0, "a");
3472treeMap.set(1, "b");
3473```
3474268.remove()
3475```
3476import TreeMap from "@ohos.util.TreeMap"
3477let treeMap = new TreeMap();
3478treeMap.set(0, "a");
3479treeMap.set(1, "b");
3480let res = treeMap.remove(1);
3481```
3482269.clear()
3483```
3484import TreeMap from "@ohos.util.TreeMap"
3485let treeMap = new TreeMap();
3486treeMap.set(0, "a");
3487treeMap.set(1, "b");
3488treeMap.clear();
3489```
3490270.getLowerKey()
3491```
3492import TreeMap from "@ohos.util.TreeMap"
3493let treeMap = new TreeMap();
3494treeMap.set(0, "a");
3495treeMap.set(1, "b");
3496let res = treeMap.getLowerKey(1);
3497```
3498271.getHigherKey()
3499```
3500import TreeMap from "@ohos.util.TreeMap"
3501let treeMap = new TreeMap();
3502treeMap.set(0, "a");
3503treeMap.set(1, "b");
3504let res = treeMap.getHigherKey(1);
3505```
3506272.keys()
3507```
3508import TreeMap from "@ohos.util.TreeMap"
3509let treeMap = new TreeMap();
3510treeMap.set(0, "a");
3511treeMap.set(1, "b");
3512let res = treeMap.keys();
3513```
3514273.values()
3515```
3516import TreeMap from "@ohos.util.TreeMap"
3517let treeMap = new TreeMap();
3518treeMap.set(0, "a");
3519treeMap.set(1, "b");
3520let res = treeMap.values();
3521```
3522274.replace()
3523```
3524import TreeMap from "@ohos.util.TreeMap"
3525let treeMap = new TreeMap();
3526treeMap.set(0, "a");
3527treeMap.set(1, "b");
3528let res = treeMap.replace(1, "B");
3529```
3530275.forEach()
3531```
3532import TreeMap from "@ohos.util.TreeMap"
3533let treeMap = new TreeMap();
3534treeMap.set(0, "a");
3535treeMap.set(1, "b");
3536treeMap.set(2, "c");
3537treeMap.set(3, "d");
3538treeMap.set(4, "g");
3539let arr1 = [];
3540treeMap.forEach((value, key) => {
3541    arr1.push(value);
3542});
3543```
3544276.entries()
3545```
3546import TreeMap from "@ohos.util.TreeMap"
3547let treeMap = new TreeMap();
3548treeMap.set(0, "a");
3549treeMap.set(1, "b");
3550treeMap.set(2, "c");
3551let entries = treeMap.entries();
3552```
3553277.[Symbol.iterator]()
3554```
3555import TreeMap from "@ohos.util.TreeMap"
3556let treeMap = new TreeMap();
3557treeMap.set(0, "a");
3558treeMap.set(1, "b");
3559treeMap.set(2, "c");
3560let iters = treeMap[Symbol.iterator]();
3561```
3562278.isEmpty()
3563```
3564import TreeSet from "@ohos.util.TreeSet"
3565let treeSet = new TreeSet();
3566treeSet.add("a");
3567let res = treeSet.isEmpty();
3568```
3569279.has()
3570```
3571import TreeSet from "@ohos.util.TreeSet"
3572let treeSet = new TreeSet();
3573treeSet.add("a");
3574treeSet.add("b");
3575treeSet.add("c");
3576let res = treeSet.has("c");
3577```
3578280.add()
3579```
3580import TreeSet from "@ohos.util.TreeSet"
3581let treeSet = new TreeSet();
3582treeSet.add("a");
3583treeSet.add("b");
3584treeSet.add("c");
3585```
3586281.remove()
3587```
3588import TreeSet from "@ohos.util.TreeSet"
3589let treeSet = new TreeSet();
3590treeSet.add("a");
3591treeSet.add("b");
3592treeSet.add("c");
3593let res = treeSet.remove("c");
3594```
3595282.clear()
3596```
3597import TreeSet from "@ohos.util.TreeSet"
3598let treeSet = new TreeSet();
3599treeSet.add("a");
3600treeSet.add("b");
3601treeSet.add("c");
3602treeSet.clear();
3603```
3604283.getFirstValue()
3605```
3606import TreeSet from "@ohos.util.TreeSet"
3607let treeSet = new TreeSet();
3608treeSet.add("a");
3609treeSet.add("b");
3610treeSet.add("c");
3611let res = treeSet.getFirstValue();
3612```
3613284.getLastValue()
3614```
3615import TreeSet from "@ohos.util.TreeSet"
3616let treeSet = new TreeSet();
3617treeSet.add("a");
3618treeSet.add("b");
3619treeSet.add("c");
3620let res = treeSet.getLastValue();
3621```
3622285.getLowerValue()
3623```
3624import TreeSet from "@ohos.util.TreeSet"
3625let treeSet = new TreeSet();
3626treeSet.add(0);
3627treeSet.add(1);
3628treeSet.add(2);
3629treeSet.add(3);
3630let res = treeSet.getLowerValue(2);
3631```
3632286.getHigherValue()
3633```
3634import TreeSet from "@ohos.util.TreeSet"
3635let treeSet = new TreeSet();
3636treeSet.add(0);
3637treeSet.add(1);
3638treeSet.add(2);
3639treeSet.add(3);
3640let res = treeSet.getHigherValue(3);
3641```
3642287.popFirst()
3643```
3644import TreeSet from "@ohos.util.TreeSet"
3645let treeSet = new TreeSet();
3646treeSet.add(0);
3647treeSet.add(1);
3648treeSet.add(2);
3649treeSet.add(3);
3650let res = treeSet.popFirst();
3651```
3652288.popLast()
3653```
3654import TreeSet from "@ohos.util.TreeSet"
3655let treeSet = new TreeSet();
3656treeSet.add(0);
3657treeSet.add(1);
3658treeSet.add(2);
3659treeSet.add(3);
3660let res = treeSet.popLast();
3661```
3662289.forEach()
3663```
3664import TreeSet from "@ohos.util.TreeSet"
3665let treeSet = new TreeSet();
3666treeSet.add(0);
3667treeSet.add(1);
3668treeSet.add(2);
3669treeSet.add(3);
3670treeSet.add(4);
3671let arr1 = [];
3672treeSet.forEach((value, key) => {
3673    arr1.push(value);
3674});
3675```
3676290.values()
3677```
3678import TreeSet from "@ohos.util.TreeSet"
3679let treeSet = new TreeSet();
3680treeSet.add("a");
3681treeSet.add("b");
3682treeSet.add("c");
3683let res = treeSet.values();
3684```
3685291.entries()
3686```
3687import TreeSet from "@ohos.util.TreeSet"
3688let treeSet = new TreeSet();
3689treeSet.add("a");
3690treeSet.add("b");
3691treeSet.add("c");
3692let res = treeSet.entries();
3693```
3694292.[Symbol.iterator]()
3695```
3696import TreeSet from "@ohos.util.TreeSet"
3697let treeSet = new TreeSet();
3698treeSet.add("a");
3699treeSet.add("b");
3700treeSet.add("c");
3701let res = treeSet[Symbol.iterator]();
3702```
3703
3704## 3. js_sys_module子模块
3705### 3.1. 简介
3706进程主要用于获取进程的相关ID,获取和修改进程的工作目录,退出和关闭进程。 childprocess 对象可用于创建新进程。 主进程可以获取子进程的标准输入输出,发送信号,关闭子进程。
3707### 3.2. 目录
3708
3709```
3710commomlibrary/ets_utils/js_sys_module/
3711├── Class:PROCESS                   # PROCESS类
3712├── Uid                             # Uid属性
3713├── Gid                             # Gid属性
3714├── EUid                            # EUid属性
3715├── EGid                            # EGid属性
3716├── Groups                          # Groups属性
3717├── Pid                             # Pid属性
3718├── Ppid                            # Ppid属性
3719├── chdir()                         # chdir方法
3720├── uptime()                        # uptime方法
3721├── kill()                          # kill方法
3722├── abort()                         # abort方法
3723├── on()                            # on方法
3724├── tid                             # tid方法
3725├── getStartRealtime()              # getStartRealtime方法
3726├── getAvailableCores()             # getAvailableCores方法
3727├── getPastCputime()                # getPastCputime方法
3728├── isIsolatedProcess()             # isIsolatedProcess方法
3729├── is64Bit()                       # is64Bit方法
3730├── isAppUid()                      # isAppUid方法
3731├── getUidForName()                 # getUidForName方法
3732├── getThreadPriority()             # getThreadPriority方法
3733├── getSystemConfig()               # getSystemConfig方法
3734├── getEnvironmentVar()             # getEnvironmentVar方法
3735├── exit()                          # exit方法
3736├── cwd()                           # cwd方法
3737├── off()                           # off方法
3738├── runCmd()                        # runCmd方法
3739└─── Class:CHILDPROCESS             # class of CHILDPROCESS类
3740    ├── close()                     # close方法
3741    ├── kill()                      # kill方法
3742    ├── getOutput()                 # getOutput方法
3743    ├── getErrorOutput()            # getErrorOutput方法
3744    ├── wait()                      # wait方法
3745    ├── killed                      # killed属性
3746    ├── pid                         # pid属性
3747    ├── ppid                        # ppid属性
3748    └── exitCode                    # exitCode属性
3749```
3750
3751### 3.3. 说明
3752
3753#### 3.3.1. 接口说明
3754| 接口名 | 说明 |
3755| -------- | -------- |
3756| const uid :number | 返回进程的数字用户 ID。 |
3757| const gid :number | 返回进程的数字组 ID。 |
3758| const euid :number | 返回进程的数字有效用户身份。 |
3759| const egid :number | 返回 node.js 进程的数字有效组 ID。 |
3760| const groups :number[] |  返回具有补充组 ID 的数组。 |
3761| const pid :number | 返回进程的PID。 |
3762| const ppid :number |  返回当前进程的父进程的PID。 |
3763| chdir(dir:string) :void | 更改 node.js 进程的当前工作目录。 |
3764| uptime() :number |  返回当前系统已经运行的秒数。 |
3765| Kill(pid:number, signal:number) :boolean | 将信号发送到识别的进程PID,true表示发送成功。 |
3766| abort() :void | 导致 node.js 进程立即退出并生成核心文件。 |
3767| on(type:string ,listener:EventListener) :void | 用于存储用户触发的事件。 |
3768| exit(code:number):void | 导致 node.js 进程立即退出。 |
3769| cwd():string |  返回 node.js 进程的当前工作目录。 |
3770| off(type: string): boolean | 清除用户存储的事件。 True 表示清算成功。 |
3771| 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 大小。 |
3772| wait(): Promise\<number> | 用于等待子进程运行并返回promise对象,其值为子进程的退出码。 |
3773| getOutput(): Promise\<Uint8Array> |  用于获取子进程的标准输出。 |
3774| getErrorOutput(): Promise\<Uint8Array> | 用于获取子进程的标准错误输出。 |
3775| const tid:number | 返回进程的 TID。 |
3776| getStartRealtime() :number | 获取从系统启动到进程启动所经过的实时时间(以毫秒为单位)。 |
3777| getAvailableCores() :number[] | 获取多核设备上当前进程可用的 CPU 内核。 |
3778| getPastCputime() :number | 获取从进程开始到当前时间的 CPU 时间(以毫秒为单位)。 |
3779| isIsolatedProcess(): boolean | 检查进程是否被隔离。 |
3780| is64Bit(): boolean | 检查进程是否在 64 位环境中运行。 |
3781| isAppUid(v:number): boolean | 检查指定的 uid 是否属于特定应用程序。 |
3782| getUidForName(v:string): number | 根据用户名获取用户所属的用户组ID |
3783| getThreadPriority(v:number): number | 根据指定的 TID 获取线程优先级。 |
3784| getSystemConfig(name:number): number | 根据指定的系统配置名称获取系统的配置。 |
3785| getEnvironmentVar(name:string): string | 根据环境变量的名称获取对应的值。 |
3786| close(): void | 用于关闭正在运行的子进程。 |
3787| kill(signal: number \| string): void |  用于向子进程发送信号。 |
3788| readonly killed: boolean | 表示信号是否发送成功,true表示信号发送成功。 |
3789| readonly exitCode: number | 表示子进程的退出代码。 |
3790| readonly pid: number | 表示子进程ID。 |
3791| readonly ppid: number | 代表主进程ID。 |
3792
3793#### 3.3.2. 使用说明
3794
3795各接口使用方法如下:
37961.uid()
3797```
3798uid(){
3799    var res =  Process.uid;
3800}
3801```
38022.gid()
3803```
3804gid(){
3805    var result = Process.gid;
3806}
3807```
38083.euid()
3809```
3810euid(){
3811    var and = Process.euid;
3812}
3813```
38144.egid()
3815```
3816egid(){
3817    var resb = Process.egid;
3818}
3819```
38205.groups()
3821```
3822groups(){
3823    var answer = Process.groups;
3824}
3825```
38266.pid()
3827```
3828pid(){
3829    var result = Process.pid;
3830}
3831```
38327.ppid()
3833```
3834ppid(){
3835    var result = Process.ppid;
3836}
3837```
38388.chdir()
3839```
3840chdir(){
3841    Process.chdir("123456");
3842}
3843```
38449.uptime()
3845```
3846uptime(){
3847    var num = Process.uptime();
3848}
3849```
385010.kill()
3851```
3852kill(){
3853    var ansu = Process.kill(5,23);
3854}
3855```
385611.abort()
3857```
3858abort(){
3859    Process.abort();
3860}
3861```
386212.on()
3863```
3864on(){
3865    function add(num){
3866        var value = num + 5;
3867        return value;
3868    }
3869    Process.on("add",add);
3870}
3871```
387213.exit()
3873```
3874exit(){
3875    Process.exit(15);
3876}
3877```
387814.Cwd()
3879```
3880Cwd(){
3881    var result = Process.cwd();
3882}
3883```
388415.off()
3885
3886```
3887off(){
3888    var result =  Process.off("add");
3889}
3890```
389116.runCmd()
3892```
3893runCmd(){
3894    var child = process.runCmd('echo abc')
3895    // killSignal can be a number or a string
3896    var child = process.runCmd('echo abc;', {killSignal : 'SIGKILL'});
3897    var child = process.runCmd('sleep 5; echo abc;', {timeout : 1, killSignal : 9, maxBuffer : 2})
3898}
3899```
390017.wait()
3901```
3902wait()
3903{
3904    var child = process.runCmd('ls')
3905    var status = child.wait();
3906    status.then(val => {
3907        console.log(val);
3908    })
3909}
3910```
391118.getOutput()
3912```
3913getOutput(){
3914    var child = process.runCmd('echo bcd;');
3915    var res = child.getOutput();
3916    child.wait();
3917    res.then(val => {
3918        console.log(val);
3919    })
3920}
3921```
392219.getErrorOutput()
3923```
3924getErrorOutput(){
3925    var child = process.runCmd('makdir 1.txt'); // execute an error command
3926    var res = child.getErrorOutput();
3927    child.wait();
3928    res.then(val => {
3929        console.log(val);
3930    })
3931}
3932```
393320.close()
3934```
3935close(){
3936    var child =  process.runCmd('ls; sleep 5s;')
3937    var result = child.close()
3938}
3939```
394021.kill()
3941```
3942kill(){
3943    var child =  process.runCmd('ls; sleep 5s;')
3944    var result = child.kill('SIGHUP');
3945    child.wait();
3946    var temp = child.killed;
3947}
3948```
394922.killed
3950```
3951{
3952    var child = process.runCmd('ls; sleep 5;')
3953    child.kill(3);
3954    var killed_ = child.killed;
3955    child.wait();
3956}
3957```
395823.exitCode
3959```
3960{
3961    var child = process.runCmd('ls; sleep 5;')
3962    child.kill(9);
3963    child.wait();
3964    var exitCode_ = child.exitCode;
3965}
3966```
396724.pid
3968```
3969pid
3970{
3971    var child = process.runCmd('ls; sleep 5;')
3972    var pid_ = child.pid;
3973    child.wait();
3974}
3975```
397625.ppid
3977```
3978ppid
3979{
3980    var child = process.runCmd('ls; sleep 5;')
3981    var ppid_ = child.ppid;
3982    child.wait();
3983}
3984```
398526.tid
3986```
3987tid(){
3988    var ansu = Process.tid;
3989}
3990```
399127.isIsolatedProcess()
3992```
3993isIsolatedProcess(){
3994    var ansu = Process.isIsolatedProcess()();
3995}
3996```
399728.isAppUid()
3998```
3999isAppUid(){
4000    var ansu = Process.isAppUid(10000);
4001}
4002```
400329.is64Bit()
4004```
4005is64Bit(){
4006    var ansu = Process.is64Bit();
4007}
4008```
400930.getUidForName()
4010```
4011getUidForName(){
4012    var buf = "root";
4013    var ansu = Process.getUidForName(buf);
4014}
4015```
401631.getEnvironmentVar()
4017```
4018getEnvironmentVar(){
4019    var ansu = Process.getEnvironmentVar('USER');
4020}
4021```
402232.getAvailableCores()
4023```
4024getAvailableCores(){
4025    var ansu = Process.getAvailableCores();
4026}
4027```
402833.getThreadPriority()
4029```
4030getThreadPriority(){
4031    var result = Process.getTid();
4032    var ansu = getThreadPriority(result);
4033}
4034```
403534.getStartRealtime()
4036```
4037getStartRealtime(){
4038    var ansu = Process.getStartRealtime();
4039}
4040```
404135.getPastCputime()
4042```
4043getPastCputime(){
4044    var ansu = Process.getPastCputime();
4045}
4046```
404736.getSystemConfig()
4048```
4049getSystemConfig(){
4050    var _SC_ARG_MAX = 0;
4051    var ansu = Process.getSystemConfig(_SC_ARG_MAX)
4052}
4053```
4054
4055## 4. js_concurrent_module子模块
4056
4057### 4.1. 简介
4058
4059worker能够让js拥有多线程的能力,通过postMessage完成worker线程与宿主线程通信。
4060
4061### 4.2. 接口说明
4062接口实现详见:js_concurrent_module/worker
4063
4064#### 4.2.1. Worker对象描述
4065
4066宿主线程用于与worker线程通信的Object对象。
4067
4068##### 4.2.1.1. 接口
4069
40701.
4071
4072- 接口名
4073
4074|constructor(scriptURL:string, options?:WorkerOptions) | 构造函数 |
4075|---|---|
4076
4077- 使用示例
4078
4079通过判断存放worker.ts的workers目录是否与pages目录同级(以下简称目录同级)和创建项目的模型类别,共有以下四种新建Worker的方式:
4080
4081(1) FA模型: 目录同级
4082```
4083import worker from "@ohos.worker";
4084const workerInstance = new worker.Worker("workers/worker.js", {name:"first worker"});
4085```
4086(2) FA模型: 目录不同级(以workers目录放置pages目录前一级为例)
4087```
4088import worker from "@ohos.worker";
4089const workerInstance = new worker.Worker("../workers/worker.js", {name:"first worker"});
4090```
4091(3)  Stage模型: 目录同级
4092```
4093import worker from "@ohos.worker";
4094const workerInstance = new worker.Worker('entry/ets/workers/worker.ts');
4095```
4096(4) Stage模型: 目录不同级(以workers目录放置pages目录后一级为例)
4097```
4098import worker from "@ohos.worker";
4099const workerInstance = new worker.Worker('entry/ets/pages/workers/worker.ts');
4100```
4101对于Stage模型中scriptURL——"entry/ets/workers/worker.ts"的解释:
4102- entry: 为module.json5中module中name属性的值;
4103- ets: 表明当前工程使用的语言;
4104- worker.ts: 创建worker.ts文件或者worker.js文件都可以。
4105
4106另外,需在工程的模块级build-profile.json5文件的buildOption属性中添加配置信息,主要分为下面两种情况:
4107
4108(1) 目录同级(**此情况不添加亦可**)
4109
4110FA模型:
4111```
4112  "buildOption": {
4113    "sourceOption": {
4114      "workers": [
4115        "./src/main/ets/MainAbility/workers/worker.js"
4116      ]
4117    }
4118  }
4119```
4120Stage模型:
4121```
4122  "buildOption": {
4123    "sourceOption": {
4124      "workers": [
4125        "./src/main/ets/workers/worker.ts"
4126      ]
4127    }
4128  }
4129```
4130(2) 目录不同级(**此情况必须添加**)
4131
4132FA模型:
4133```
4134  "buildOption": {
4135    "sourceOption": {
4136      "workers": [
4137        "./src/main/ets/workers/worker.js"
4138      ]
4139    }
4140  }
4141```
4142Stage模型(workers目录放在pages目录里为例):
4143```
4144  "buildOption": {
4145    "sourceOption": {
4146      "workers": [
4147        "./src/main/ets/pages/workers/worker.ts"
4148      ]
4149    }
4150  }
4151```
41522.
4153
4154- 接口名
4155
4156| postMessage(message:Object, options?:PostMessageOptions)  | 向worker线程发送消息  |
4157|---|---|
4158| postMessage(message:Object, transfer:ArrayBuffer[])  | 向worker线程发送消息  |
4159
4160- 使用示例
4161
4162```
4163// 示例一
4164import worker from "@ohos.worker"
4165const worker = new worker.Worker("workers/worker.js");
4166worker.postMessage("hello world");
4167
4168// 示例二
4169import worker from "@ohos.worker"
4170const worker = new worker.Worker("workers/worker.js");
4171var buffer = new ArrayBuffer(8);
4172worker.postMessage(buffer, [buffer]);
4173```
4174
41753.
4176
4177- 接口名
4178
4179| on(type:string, listener:EventListener)  | 向worker添加一个事件监听  |
4180|---|---|
4181
4182- 使用示例
4183
4184```
4185import worker from "@ohos.worker"
4186const worker = new worker.Worker("workers/worker.js");
4187worker.on("alert", (e)=>{
4188     console.log("worker on...");
4189});
4190```
4191
41924.
4193
4194- 接口名
4195
4196| once(type:string, listener:EventListener)  | 向worker添加一个事件监听, 事件监听只执行一次便自动删除  |
4197|---|---|
4198
4199- 使用示例
4200
4201```
4202import worker from "@ohos.worker"
4203const worker = new worker.Worker("workers/worker.js");
4204worker.once("alert", (e)=>{
4205    console.log("worker once...");
4206});
4207```
4208
42095.
4210
4211- 接口名
4212
4213| off(type:string, listener?:EventListener)  | 删除worker的事件监听  |
4214|---|---|
4215
4216- 使用示例
4217
4218```
4219import worker from "@ohos.worker"
4220const worker = new worker.Worker("workers/worker.js");
4221worker.off("alert");
4222```
4223
42246.
4225
4226- 接口名
4227
4228| terminate()  | 关闭worker线程,终止worker发送消息  |
4229|---|---|
4230
4231- 使用示例
4232
4233```
4234import worker from "@ohos.worker"
4235const worker = new worker.Worker("workers/worker.js");
4236worker.terminate();
4237```
4238
42397.
4240
4241- 接口名
4242
4243| removeEventListener(type:string, listener?:EventListener)  | 删除worker的事件监听  |
4244|---|---|
4245
4246- 使用示例
4247
4248```
4249import worker from "@ohos.worker"
4250const worker = new worker.Worker("workers/worker.js");
4251worker.removeEventListener("alert", (e)=>{
4252    console.log("worker removeEventListener...");
4253});
4254```
4255
42568.
4257
4258- 接口名
4259
4260| dispatchEvent(event: Event)  | 分发定义在worker的事件  |
4261|---|---|
4262
4263- 使用示例
4264
4265```
4266import worker from "@ohos.worker"
4267const worker = new worker.Worker("workers/worker.js");
4268worker.dispatchEvent({type:"alert"});
4269```
4270
42719.
4272
4273- 接口名
4274
4275| removeAllListener()  | 删除worker的所有事件监听  |
4276|---|---|
4277
4278- 使用示例
4279
4280```
4281import worker from "@ohos.worker"
4282const worker = new worker.Worker("workers/worker.js");
4283worker.removeAllListener();
4284```
4285
4286##### 4.2.1.2. 属性
4287
42881.
4289
4290- 属性名
4291
4292| onexit?:(code:number)=>void  | worker退出时被调用的事件处理程序,处理程序在宿主线程中执行  |
4293|---|---|
4294
4295- 使用示例
4296
4297```
4298import worker from "@ohos.worker"
4299const worker = new worker.Worker("workers/worker.js");
4300worker.onexit = function(e) {
4301    console.log("onexit...");
4302}
4303```
4304
43052.
4306
4307- 属性名
4308
4309| onerror?:(ev:ErrorEvent)=>void  | worker在执行过程中发生异常被调用的事件处理程序,处理程序在宿主线程中执行  |
4310|---|---|
4311
4312- 使用示例
4313
4314```
4315import worker from "@ohos.worker"
4316const worker = new worker.Worker("workers/worker.js");
4317worker.onerror = function(e) {
4318    console.log("onerror...");
4319}
4320```
4321
43223.
4323
4324- 属性名
4325
4326| onmessage?:(ev:MessageEvent)=>void  | 宿主线程收到来自其创建的worker通过parentPort.postMessage接口发送的消息时被调用的事件处理程序, 处理程序在宿主线程中执行 |
4327|---|---|
4328
4329- 使用示例
4330
4331```
4332import worker from "@ohos.worker"
4333const worker = new worker.Worker("workers/worker.js");
4334worker.onmessage = function(e) {
4335    console.log("onmessage...");
4336}
4337```
4338
43394.
4340
4341- 属性名
4342
4343| onmessageerror?:(event:MessageEvent)=>void  | worker对象接收到一条无法序列化的消息时被调用的事件处理程序, 处理程序在宿主线程中执行 |
4344|---|---|
4345
4346- 使用示例
4347
4348```
4349import worker from "@ohos.worker"
4350const worker = new worker.Worker("workers/worker.js");
4351worker.onmessageerror = function(e) {
4352    console.log("onmessageerror...");
4353}
4354```
4355
4356#### 4.2.2. parentPort对象描述
4357
4358worker线程用于与宿主线程通信的Object对象。
4359
4360##### 4.2.2.1. 接口
4361
43621.
4363
4364- 接口名
4365
4366| postMessage(message:Object, options?:PostMessageOptions)  | 向宿主线程发送消息 |
4367|---|---|
4368| postMessage(message:Object, transfer:ArrayBuffer[])  | 向宿主线程发送消息  |
4369
4370- 使用示例
4371
4372```
4373// main.js
4374import worker from "@ohos.worker"
4375const worker = new worker.Worker("workers/worker.js");
4376worker.postMessage("hello world");
4377
4378// worker.js
4379import worker from "@ohos.worker"
4380const parentPort = worker.parentPort;
4381parentPort.onmessage = function(e) {
4382    parentPort.postMessage("hello world from worker.js");
4383}
4384```
4385
43862.
4387
4388- 接口名
4389
4390| close()  | 关闭worker线程,终止worker接收消息  |
4391|---|---|
4392
4393- 使用示例
4394
4395```
4396// main.js
4397import worker from "@ohos.worker"
4398const worker = new worker.Worker("workers/worker.js");
4399worker.postMessage("hello world");
4400
4401// worker.js
4402import worker from "@ohos.worker"
4403const parentPort = worker.parentPort;
4404parentPort.onmessage = function(e) {
4405    parentPort.close();
4406}
4407```
4408
4409##### 4.2.2.2. 属性
4410
44111.
4412
4413- 属性名
4414
4415| onmessage?:(event:MessageEvent)=>void  | 宿主线程收到来自其创建的worker通过worker.postMessage接口发送的消息时被调用的事件处理程序,处理程序在worker线程中执行  |
4416|---|---|
4417
4418- 使用示例
4419
4420```
4421// main.js
4422import worker from "@ohos.worker"
4423const worker = new worker.Worker("workers/worker.js");
4424worker.postMessage("hello world");
4425
4426// worker.js
4427import worker from "@ohos.worker"
4428const parentPort = worker.parentPort;
4429parentPort.onmessage = function(e) {
4430    console.log("receive main.js message");
4431}
4432```
4433
44342.
4435
4436- 属性名
4437
4438| onerror?:(ev: ErrorEvent)=>void  | worker在执行过程中发生异常被调用的事件处理程序,处理程序在worker线程中执行  |
4439|---|---|
4440
4441- 使用示例
4442
4443```
4444// main.js
4445import worker from "@ohos.worker"
4446const worker = new worker.Worker("workers/worker.js");
4447worker.postMessage("hello world");
4448
4449// worker.js
4450import worker from "@ohos.worker"
4451const parentPort = worker.parentPort;
4452parentPort.onerror = function(e) {
4453    console.log("onerror...");
4454}
4455
4456```
4457
44583.
4459
4460- 属性名
4461
4462| onmessageerror?:(event: MessageEvent)=>void  | worker对象接收到一条无法被反序列化的消息时被调用的事件处理程序, 处理程序在worker线程中执行  |
4463|---|---|
4464
4465- 使用示例
4466
4467```
4468// main.js
4469import worker from "@ohos.worker"
4470const worker = new worker.Worker("workers/worker.js");
4471worker.postMessage("hello world");
4472
4473// worker.js
4474import worker from "@ohos.worker"
4475const parentPort = worker.parentPort;
4476parentPort.onmessageerror = function(e) {
4477    console.log("onmessageerror...");
4478}
4479```
4480
4481### 4.3. 涉及仓
4482
4483[arkcompiler_ets_runtime](https://gitee.com/openharmony/arkcompiler_ets_runtime/blob/master/README_zh.md)
4484[arkui_ace_engine](https://gitee.com/openharmony/arkui_ace_engine/blob/master/README_zh.md)
4485[arkui_napi](https://gitee.com/openharmony/arkui_napi/blob/master/README_zh.md)
4486
4487
4488# 相关仓
4489
4490[ets_utils子系统](https://gitee.com/openharmony/commonlibrary_ets_utils/blob/master/README.md)
4491
4492# 许可证
4493
4494js_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)4495
4496js_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)4497
4498js_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)4499