• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15/**
16 * TextDecoder support full encoding in ICU data utf-8 utf-16 iso8859 must support in all device, TextEncoder takes a
17 * stream of code points as input and emits a stream of UTF-8 bytes, and system help function.
18 * @since 7
19 * @syscap SystemCapability.Utils.Lang
20 * @permission N/A
21 */
22declare namespace util {
23    /**
24     * %s: String will be used to convert all values except BigInt, Object and -0. BigInt values will be represented
25     * with an n and Objects that have no user defined toString function are inspected using util.inspect() with
26     * options { depth: 0, colors: false, compact: 3 }.
27     * %d: Number will be used to convert all values except BigInt and Symbol.
28     * %i: parseInt(value, 10) is used for all values except BigInt and Symbol.
29     * %f: parseFloat(value) is used for all values except Bigint and Symbol.
30     * %j: JSON. Replaced with the string '[Circular]' if the argument contains circular references.
31     * %o: Object. A string representation of an object with generic JavaScript object formatting.Similar to
32     * util.inspect() with options { showHidden: true, showProxy: true}. This will show the full object including
33     * non-enumerable properties and proxies.
34     * %O: Object. A string representation of an object with generic JavaScript object formatting.
35     * %O: Object. A string representation of an object with generic JavaScript object formatting.Similar to
36     * util.inspect() without options. This will show the full object not including non-enumerable properties and
37     * proxies.
38     * %c: CSS. This specifier is ignored and will skip any CSS passed in.
39     * %%: single percent sign ('%'). This does not consume an argument.Returns: <string> The formatted string.
40     * @since 7
41     * @deprecated since 9
42     * @useinstead ohos.util.format
43     * @syscap SystemCapability.Utils.Lang
44     * @param format Styled string
45     * @param args Data to be formatted
46     * @returns Return the character string formatted in a specific format
47     */
48    function printf(format: string, ...args: Object[]): string;
49
50    /**
51     * %s: String will be used to convert all values except BigInt, Object and -0. BigInt values will be represented
52     * with an n and Objects that have no user defined toString function are inspected using util.inspect() with
53     * options { depth: 0, colors: false, compact: 3 }.
54     * %d: Number will be used to convert all values except BigInt and Symbol.
55     * %i: parseInt(value, 10) is used for all values except BigInt and Symbol.
56     * %f: parseFloat(value) is used for all values except Bigint and Symbol.
57     * %j: JSON. Replaced with the string '[Circular]' if the argument contains circular references.
58     * %o: Object. A string representation of an object with generic JavaScript object formatting.Similar to
59     * util.inspect() with options { showHidden: true, showProxy: true}. This will show the full object including
60     * non-enumerable properties and proxies.
61     * %O: Object. A string representation of an object with generic JavaScript object formatting.
62     * %O: Object. A string representation of an object with generic JavaScript object formatting.Similar to
63     * util.inspect() without options. This will show the full object not including non-enumerable properties and
64     * proxies.
65     * %c: CSS. This specifier is ignored and will skip any CSS passed in.
66     * %%: single percent sign ('%'). This does not consume an argument.Returns: <string> The formatted string.
67     * @since 9
68     * @syscap SystemCapability.Utils.Lang
69     * @param format Styled string
70     * @param args Data to be formatted
71     * @returns Return the character string formatted in a specific format
72     * @throws {BusinessError} 401 - if the input parameters are invalid.
73     */
74    function format(format: string, ...args: Object[]): string;
75
76    /**
77     * Get the string name of the system errno.
78     * @since 7
79     * @deprecated since 9
80     * @useinstead ohos.util.errnoToString
81     * @syscap SystemCapability.Utils.Lang
82     * @param errno The error code generated by an error in the system
83     * @returns Return the string name of a system errno
84     */
85    function getErrorString(errno: number): string;
86
87    /**
88     * Get the string name of the system errno.
89     * @since 9
90     * @syscap SystemCapability.Utils.Lang
91     * @param errno The error code generated by an error in the system
92     * @returns Return the string name of a system errno
93     * @throws {BusinessError} 401 - The type of errno must be number.
94     */
95    function errnoToString(errno: number): string;
96
97    /**
98     * Takes an async function (or a function that returns a Promise) and returns a function following the
99     * error-first callback style.
100     * @since 7
101     * @syscap SystemCapability.Utils.Lang
102     * @param original Asynchronous function
103     * @throws {BusinessError} 401 - The type of original must be Function.
104     */
105    function callbackWrapper(original: Function): (err: Object, value: Object) => void;
106
107    /**
108     * Takes a function following the common error-first callback style, i.e taking an (err, value) =>
109     * callback as the last argument, and return a function that returns promises.
110     * @since 9
111     * @syscap SystemCapability.Utils.Lang
112     * @param original Asynchronous function
113     * @returns Return a function that returns promises
114     * @throws {BusinessError} 401 - The type of original must be Function.
115     */
116    function promisify(original: (err: Object, value: Object) => void): Function;
117
118    /**
119     * Takes a function following the common error-first callback style, i.e taking an (err, value) =>
120     * callback as the last argument, and return a version that returns promises.
121     * @since 7
122     * @deprecated since 9
123     * @useinstead ohos.util.promisify
124     * @syscap SystemCapability.Utils.Lang
125     * @param original Asynchronous function
126     * @returns Return a version that returns promises
127     */
128    function promiseWrapper(original: (err: Object, value: Object) => void): Object;
129
130    /**
131     * Generate a random RFC 4122 version 4 UUID using a cryptographically secure random number generator.
132     * @since 9
133     * @syscap SystemCapability.Utils.Lang
134     * @param entropyCache Whether to generate the UUID with using the cache. Default: true.
135     * @returns Return a string representing this UUID.
136     * @throws {BusinessError} 401 - The type of entropyCache must be boolean.
137     */
138    function generateRandomUUID(entropyCache?: boolean): string;
139
140    /**
141     * Generate a random RFC 4122 version 4 binary UUID using a cryptographically secure random number generator.
142     * @since 9
143     * @syscap SystemCapability.Utils.Lang
144     * @param entropyCache Whether to generate the UUID with using the cache. Default: true.
145     * @returns Return a Uint8Array representing this UUID.
146     * @throws {BusinessError} 401 - The type of entropyCache must be boolean.
147     */
148    function generateRandomBinaryUUID(entropyCache?: boolean): Uint8Array;
149
150    /**
151     * Parse a UUID from the string standard representation as described in the RFC 4122 version 4.
152     * @since 9
153     * @syscap SystemCapability.Utils.Lang
154     * @param uuid String that specifies a UUID
155     * @returns Return a Uint8Array representing this UUID. Throw SyntaxError if parsing fails.
156     * @throws {BusinessError} 401 - The type of uuid must be string.
157     */
158    function parseUUID(uuid: string): Uint8Array;
159
160    /**
161     * The TextEncoder represents a text encoder that accepts a string as input,
162     * encodes it in UTF-8 format, and outputs UTF-8 byte stream.
163     * @syscap SystemCapability.Utils.Lang
164     * @since 7
165     */
166    class TextDecoder {
167        /**
168         * The source encoding's name, lowercased.
169         * @since 7
170         * @syscap SystemCapability.Utils.Lang
171         */
172        readonly encoding: string;
173
174        /**
175         * Returns `true` if error mode is "fatal", and `false` otherwise.
176         * @since 7
177         * @syscap SystemCapability.Utils.Lang
178         */
179        readonly fatal: boolean;
180
181        /**
182         * Returns `true` if ignore BOM flag is set, and `false` otherwise.
183         * @since 7
184         * @syscap SystemCapability.Utils.Lang
185         */
186        readonly ignoreBOM = false;
187
188        /**
189         * The textEncoder constructor.
190         * @since 7
191         * @deprecated since 9
192         * @useinstead ohos.util.TextDecoder.create
193         * @syscap SystemCapability.Utils.Lang
194         * @param encoding Decoding format
195         */
196        constructor(
197            encoding?: string,
198            options?: { fatal?: boolean; ignoreBOM?: boolean },
199        );
200
201        /**
202         * The textEncoder constructor.
203         * @since 9
204         * @syscap SystemCapability.Utils.Lang
205         */
206        constructor();
207
208        /**
209         * Replaces the original constructor to process arguments and return a textDecoder object.
210         * @since 9
211         * @syscap SystemCapability.Utils.Lang
212         * @param encoding Decoding format
213         * @throws {BusinessError} 401 - if the input parameters are invalid.
214         */
215        static create(
216            encoding?: string,
217            options?: { fatal?: boolean; ignoreBOM?: boolean }
218        ): TextDecoder;
219
220        /**
221         * Returns the result of running encoding's decoder.
222         * @since 7
223         * @deprecated since 9
224         * @useinstead ohos.util.decodeWithStream
225         * @syscap SystemCapability.Utils.Lang
226         * @param input Decoded numbers in accordance with the format
227         * @returns Return decoded text
228         */
229        decode(input: Uint8Array, options?: { stream?: false }): string;
230
231        /**
232         * Decodes the input and returns a string. If options.stream is true, any incomplete byte sequences occurring
233         * at the end of the input are buffered internally and emitted after the next call to textDecoder.decode().
234         * If textDecoder.fatal is true, decoding errors that occur will result in a TypeError being thrown.
235         * @since 9
236         * @syscap SystemCapability.Utils.Lang
237         * @param input Decoded numbers in accordance with the format
238         * @returns Return decoded text
239         * @throws {BusinessError} 401 - if the input parameters are invalid.
240         */
241        decodeWithStream(input: Uint8Array, options?: { stream?: boolean }): string;
242    }
243
244    /**
245     * The TextDecoder interface represents a text decoder.
246     * The decoder takes the byte stream as the input and outputs the String string.
247     * @syscap SystemCapability.Utils.Lang
248     * @since 7
249     */
250    class TextEncoder {
251        /**
252         * Encoding format.
253         * @since 7
254         * @syscap SystemCapability.Utils.Lang
255         */
256        readonly encoding = "utf-8";
257
258        /**
259         * The textEncoder constructor.
260         * @since 7
261         * @syscap SystemCapability.Utils.Lang
262         */
263        constructor();
264
265        /**
266         * The textEncoder constructor.
267         * @since 9
268         * @syscap SystemCapability.Utils.Lang
269         * @param encoding The string for encoding format.
270         * @throws {BusinessError} 401 - The type of encoding must be string.
271         */
272        constructor(encoding?: string);
273
274        /**
275         * Returns the result of encoder.
276         * @since 7
277         * @deprecated since 9
278         * @useinstead ohos.util.encodeInto
279         * @syscap SystemCapability.Utils.Lang
280         * @param input The string to be encoded.
281         * @returns Returns the encoded text.
282         */
283        encode(input?: string): Uint8Array;
284
285        /**
286         * UTF-8 encodes the input string and returns a Uint8Array containing the encoded bytes.
287         * @since 9
288         * @syscap SystemCapability.Utils.Lang
289         * @param input The string to be encoded.
290         * @returns Returns the encoded text.
291         * @throws {BusinessError} 401 - The type of input must be string.
292         */
293        encodeInto(input?: string): Uint8Array;
294
295        /**
296         * Encode string, write the result to dest array.
297         * @since 7
298         * @deprecated since 9
299         * @useinstead ohos.util.encodeIntoUint8Array
300         * @syscap SystemCapability.Utils.Lang
301         * @param input The string to be encoded.
302         * @param dest Decoded numbers in accordance with the format
303         * @returns Returns Returns the object, where read represents
304         * the number of characters that have been encoded, and written
305         * represents the number of bytes occupied by the encoded characters.
306         */
307        encodeInto(
308            input: string,
309            dest: Uint8Array,
310        ): { read: number; written: number };
311
312        /**
313         * Encode string, write the result to dest array.
314         * @since 9
315         * @syscap SystemCapability.Utils.Lang
316         * @param input The string to be encoded.
317         * @param dest Decoded numbers in accordance with the format
318         * @returns Returns Returns the object, where read represents
319         * the number of characters that have been encoded, and written
320         * represents the number of bytes occupied by the encoded characters.
321         * @throws {BusinessError} 401 - if the input parameters are invalid.
322         */
323        encodeIntoUint8Array(
324            input: string,
325            dest: Uint8Array,
326        ): { read: number; written: number };
327    }
328
329    /**
330     * The rational number is mainly to compare rational numbers and obtain the numerator and denominator.
331     * @syscap SystemCapability.Utils.Lang
332     * @since 8
333     */
334    class RationalNumber {
335        /**
336         * A constructor used to create a RationalNumber instance with a given numerator and denominator.
337         * @since 8
338         * @deprecated since 9
339         * @useinstead ohos.util.RationalNumber.parseRationalNumber
340         * @syscap SystemCapability.Utils.Lang
341         * @param numerator An integer number
342         * @param denominator An integer number
343         */
344        constructor(numerator: number, denominator: number);
345
346        /**
347         * A constructor used to create a RationalNumber instance with a given numerator and denominator.
348         * @since 9
349         * @syscap SystemCapability.Utils.Lang
350         */
351        constructor();
352
353        /**
354         * Used to create a RationalNumber instance with a given numerator and denominator.
355         * @since 9
356         * @syscap SystemCapability.Utils.Lang
357         * @param numerator An integer number
358         * @param denominator An integer number
359         * @throws {BusinessError} 401 - if the input parameters are invalid.
360         */
361        static parseRationalNumber(numerator: number, denominator: number): RationalNumber;
362
363        /**
364         * Creates a RationalNumber object based on a given string.
365         * @since 8
366         * @syscap SystemCapability.Utils.Lang
367         * @param rationalString String Expression of Rational Numbers
368         * @returns Returns a RationalNumber object generated based on the given string.
369         * @throws {BusinessError} 401 - The type of rationalString must be string.
370         */
371        static createRationalFromString(rationalString: string): RationalNumber​;
372
373        /**
374         * Compares the current RationalNumber object to the given object.
375         * @since 8
376         * @deprecated since 9
377         * @useinstead ohos.util.compare
378         * @syscap SystemCapability.Utils.Lang
379         * @param another An object of other rational numbers
380         * @returns Returns 0 or 1, or -1, depending on the comparison.
381         */
382        compareTo(another :RationalNumber): number;
383
384        /**
385         * Compares the current RationalNumber object to the given object.
386         * @since 9
387         * @syscap SystemCapability.Utils.Lang
388         * @param another An object of other rational numbers
389         * @returns Returns 0 or 1, or -1, depending on the comparison.
390         * @throws {BusinessError} 401 - The type of another must be RationalNumber.
391         */
392        compare(another :RationalNumber): number;
393
394        /**
395         * Compares two objects for equality.
396         * @since 8
397         * @syscap SystemCapability.Utils.Lang
398         * @param obj An object
399         * @returns Returns true if the given object is the same as the current object; Otherwise, false is returned.
400         */
401        equals(obj: Object): boolean;
402
403        /**
404         * Gets integer and floating-point values of a rational number object.
405         * @since 8
406         * @syscap SystemCapability.Utils.Lang
407         * @returns Returns the integer and floating-point values of a rational number object.
408         */
409        valueOf(): number;
410
411        /**
412         * Get the greatest common divisor of two integers.
413         * @since 8
414         * @deprecated since 9
415         * @useinstead ohos.util.getCommonFactor
416         * @syscap SystemCapability.Utils.Lang
417         * @param number1 Is an integer.
418         * @param number2 Is an integer.
419         * @returns Returns the greatest common divisor of two integers, integer type.
420         */
421        static getCommonDivisor(number1: number, number2: number): number;
422
423        /**
424         * Get the greatest common factor of two integers.
425         * @since 9
426         * @syscap SystemCapability.Utils.Lang
427         * @param number1 Is an integer.
428         * @param number2 Is an integer.
429         * @returns Returns the greatest common factor of two integers, integer type.
430         * @throws {BusinessError} 401 - if the input parameters are invalid.
431         */
432        static getCommonFactor(number1: number, number2: number): number;
433
434        /**
435         * Gets the denominator of the current object.
436         * @since 8
437         * @syscap SystemCapability.Utils.Lang
438         * @returns Returns the denominator of the current object.
439         */
440        getDenominator(): number;
441
442        /**
443         * Gets the numerator​ of the current object.
444         * @since 8
445         * @syscap SystemCapability.Utils.Lang
446         * @returns Returns the numerator​ of the current object.
447         */
448        getNumerator(): number;
449
450        /**
451         * Checks whether the current RationalNumber object represents an infinite value.
452         * @since 8
453         * @syscap SystemCapability.Utils.Lang
454         * @returns If the denominator is not 0, true is returned. Otherwise, false is returned.
455         */
456        isFinite(): boolean;
457
458        /**
459         * Checks whether the current RationalNumber object represents a Not-a-Number (NaN) value.
460         * @since 8
461         * @syscap SystemCapability.Utils.Lang
462         * @returns If both the denominator and numerator are 0, true is returned. Otherwise, false is returned.
463         */
464        isNaN(): boolean;
465
466        /**
467         * Checks whether the current RationalNumber object represents the value 0.
468         * @since 8
469         * @syscap SystemCapability.Utils.Lang
470         * @returns If the value represented by the current object is 0, true is returned. Otherwise, false is returned.
471         */
472        isZero(): boolean;
473
474        /**
475         * Obtains a string representation of the current RationalNumber object.
476         * @since 8
477         * @syscap SystemCapability.Utils.Lang
478         * @returns Returns a string representation of the current RationalNumber object.
479         */
480        toString(): string;
481    }
482
483    /**
484     * The LruBuffer algorithm replaces the least used data with new data when the buffer space is insufficient.
485     * @syscap SystemCapability.Utils.Lang
486     * @since 8
487     * @deprecated since 9
488     * @useinstead ohos.util.LRUCache
489     */
490    class LruBuffer<K, V> {
491        /**
492         * Default constructor used to create a new LruBuffer instance with the default capacity of 64.
493         * @since 8
494         * @deprecated since 9
495         * @useinstead ohos.util.LRUCache.constructor
496         * @syscap SystemCapability.Utils.Lang
497         * @param capacity Indicates the capacity to customize for the buffer.
498         */
499        constructor(capacity?: number);
500
501        /**
502         * Updates the buffer capacity to a specified capacity.
503         * @since 8
504         * @deprecated since 9
505         * @useinstead ohos.util.LRUCache.updateCapacity
506         * @syscap SystemCapability.Utils.Lang
507         * @param newCapacity Indicates the new capacity to set.
508         */
509        updateCapacity(newCapacity: number):void
510
511        /**
512         * Returns a string representation of the object.
513         * @since 8
514         * @deprecated since 9
515         * @useinstead ohos.util.LRUCache.toString
516         * @syscap SystemCapability.Utils.Lang
517         * @returns Returns the string representation of the object and outputs the string representation of the object.
518         */
519        toString(): string
520
521        /**
522         * Obtains a list of all values in the current buffer.
523         * @since 8
524         * @deprecated since 9
525         * @useinstead ohos.util.LRUCache.length
526         * @syscap SystemCapability.Utils.Lang
527         * @returns Returns the total number of values in the current buffer.
528         */
529        length: number
530
531        /**
532         * Obtains the capacity of the current buffer.
533         * @since 8
534         * @deprecated since 9
535         * @useinstead ohos.util.LRUCache.getCapacity
536         * @syscap SystemCapability.Utils.Lang
537         * @returns Returns the capacity of the current buffer.
538         */
539        getCapacity(): number;
540
541        /**
542         * Clears key-value pairs from the current buffer.
543         * @since 8
544         * @deprecated since 9
545         * @useinstead ohos.util.LRUCache.clear
546         * @syscap SystemCapability.Utils.Lang
547         */
548        clear(): void;
549
550        /**
551         * Obtains the number of times createDefault(Object) returned a value.
552         * @since 8
553         * @deprecated since 9
554         * @useinstead ohos.util.LRUCache.getCreateCount
555         * @syscap SystemCapability.Utils.Lang
556         * @returns Returns the number of times createDefault(java.lang.Object) returned a value.
557         */
558        getCreateCount(): number;
559
560        /**
561         * Obtains the number of times that the queried values are not matched.
562         * @since 8
563         * @deprecated since 9
564         * @useinstead ohos.util.LRUCache.getMissCount
565         * @syscap SystemCapability.Utils.Lang
566         * @returns Returns the number of times that the queried values are not matched.
567         */
568        getMissCount(): number;
569
570        /**
571         * Obtains the number of times that values are evicted from the buffer.
572         * @since 8
573         * @deprecated since 9
574         * @useinstead ohos.util.LRUCache.getRemovalCount
575         * @syscap SystemCapability.Utils.Lang
576         * @returns Returns the number of times that values are evicted from the buffer.
577         */
578        getRemovalCount(): number;
579
580        /**
581         * Obtains the number of times that the queried values are successfully matched.
582         * @since 8
583         * @deprecated since 9
584         * @useinstead ohos.util.LRUCache.getMatchCount
585         * @syscap SystemCapability.Utils.Lang
586         * @returns Returns the number of times that the queried values are successfully matched.
587         */
588        getMatchCount(): number;
589
590        /**
591         * Obtains the number of times that values are added to the buffer.
592         * @since 8
593         * @deprecated since 9
594         * @useinstead ohos.util.LRUCache.getPutCount
595         * @syscap SystemCapability.Utils.Lang
596         * @returns Returns the number of times that values are added to the buffer.
597         */
598        getPutCount(): number;
599
600        /**
601         * Checks whether the current buffer is empty.
602         * @since 8
603         * @deprecated since 9
604         * @useinstead ohos.util.LRUCache.isEmpty
605         * @syscap SystemCapability.Utils.Lang
606         * @returns Returns true if the current buffer contains no value.
607         */
608        isEmpty(): boolean;
609
610        /**
611         * Obtains the value associated with a specified key.
612         * @since 8
613         * @deprecated since 9
614         * @useinstead ohos.util.LRUCache.get
615         * @syscap SystemCapability.Utils.Lang
616         * @param key Indicates the key to query.
617         * @returns Returns the value associated with the key if the specified key is present in the buffer; returns null otherwise.
618         */
619        get(key: K): V | undefined;
620
621        /**
622         * Adds a key-value pair to the buffer.
623         * @since 8
624         * @deprecated since 9
625         * @useinstead ohos.util.LRUCache.put
626         * @syscap SystemCapability.Utils.Lang
627         * @param key Indicates the key to add.
628         * @param value Indicates the value associated with the key to add.
629         * @returns Returns the value associated with the added key; returns the original value if the key to add already exists.
630         */
631        put(key: K, value: V): V;
632
633        /**
634         * Obtains a list of all values in the current buffer.
635         * @since 8
636         * @deprecated since 9
637         * @useinstead ohos.util.LRUCache.values
638         * @syscap SystemCapability.Utils.Lang
639         * @returns Returns the list of all values in the current buffer in ascending order, from the most recently accessed to least recently accessed.
640         */
641        values(): V[];
642
643        /**
644         * Obtains a list of keys for the values in the current buffer.
645         * @since 8
646         * @deprecated since 9
647         * @useinstead ohos.util.LRUCache.keys
648         * @syscap SystemCapability.Utils.Lang
649         * @returns Returns a list of keys sorted from most recently accessed to least recently accessed.
650         */
651        keys(): K[];
652
653        /**
654         * Deletes a specified key and its associated value from the current buffer.
655         * @since 8
656         * @deprecated since 9
657         * @useinstead ohos.util.LRUCache.remove
658         * @syscap SystemCapability.Utils.Lang
659         * @param key Indicates the key to delete.
660         * @returns Returns an Optional object containing the deleted key-value pair; returns an empty Optional object if the key does not exist.
661         */
662        remove(key: K): V | undefined;
663
664        /**
665         * Executes subsequent operations after a value is deleted.
666         * @since 8
667         * @deprecated since 9
668         * @useinstead ohos.util.LRUCache.afterRemoval
669         * @syscap SystemCapability.Utils.Lang
670         * @param isEvict The parameter value is true if this method is called due to insufficient capacity, and the parameter value is false in other cases.
671         * @param key Indicates the deleted key.
672         * @param value Indicates the deleted value.
673         * @param newValue The parameter value is the new value associated if the put(java.lang.Object,java.lang.Object) method is called and the key to add already exists. The parameter value is null in other cases.
674         */
675        afterRemoval(isEvict: boolean, key: K, value: V, newValue: V): void;
676
677        /**
678         * Checks whether the current buffer contains a specified key.
679         * @since 8
680         * @deprecated since 9
681         * @useinstead ohos.util.LRUCache.contains
682         * @syscap SystemCapability.Utils.Lang
683         * @param key Indicates the key to check.
684         * @returns Returns true if the buffer contains the specified key.
685         */
686        contains(key: K): boolean;
687
688        /**
689         * Called after a cache miss to compute a value for the corresponding key.
690         * @since 8
691         * @deprecated since 9
692         * @useinstead ohos.util.LRUCache.createDefault
693         * @syscap SystemCapability.Utils.Lang
694         * @param key Indicates the missed key.
695         * @returns Returns the value associated with the key.
696         */
697        createDefault(key: K): V;
698
699        /**
700         * Returns an array of key-value pairs of enumeratable properties of a given object.
701         * @since 8
702         * @deprecated since 9
703         * @useinstead ohos.util.LRUCache.entries
704         * @syscap SystemCapability.Utils.Lang
705         * @returns Returns an array of key-value pairs for the enumeratable properties of the given object itself.
706         */
707        entries(): IterableIterator<[K, V]>;
708
709        /**
710         * Specifies the default iterator for an object.
711         * @since 8
712         * @deprecated since 9
713         * @useinstead ohos.util.LRUCache.[Symbol.iterator]
714         * @syscap SystemCapability.Utils.Lang
715         * @returns Returns a two - dimensional array in the form of key - value pairs.
716         */
717        [Symbol.iterator](): IterableIterator<[K, V]>;
718    }
719
720    /**
721     * The LRUCache algorithm replaces the least used data with new data when the buffer space is insufficient.
722     * @syscap SystemCapability.Utils.Lang
723     * @since 9
724     */
725    class LRUCache<K, V> {
726        /**
727         * Default constructor used to create a new LruBuffer instance with the default capacity of 64.
728         * @since 9
729         * @syscap SystemCapability.Utils.Lang
730         * @param capacity Indicates the capacity to customize for the buffer.
731         */
732        constructor(capacity?: number);
733
734        /**
735         * Updates the buffer capacity to a specified capacity.
736         * @since 9
737         * @syscap SystemCapability.Utils.Lang
738         * @param newCapacity Indicates the new capacity to set.
739         * @throws {BusinessError} 401 - The type of newCapacity must be number.
740         */
741        updateCapacity(newCapacity: number):void
742
743        /**
744         * Returns a string representation of the object.
745         * @since 9
746         * @syscap SystemCapability.Utils.Lang
747         * @returns Returns the string representation of the object and outputs the string representation of the object.
748         */
749        toString(): string
750
751        /**
752         * Obtains a list of all values in the current buffer.
753         * @since 9
754         * @syscap SystemCapability.Utils.Lang
755         * @returns Returns the total number of values in the current buffer.
756         */
757        length: number
758
759        /**
760         * Obtains the capacity of the current buffer.
761         * @since 9
762         * @syscap SystemCapability.Utils.Lang
763         * @returns Returns the capacity of the current buffer.
764         */
765        getCapacity(): number;
766
767        /**
768         * Clears key-value pairs from the current buffer.
769         * @since 9
770         * @syscap SystemCapability.Utils.Lang
771         */
772        clear(): void;
773
774        /**
775         * Obtains the number of times createDefault(Object) returned a value.
776         * @since 9
777         * @syscap SystemCapability.Utils.Lang
778         * @returns Returns the number of times createDefault(java.lang.Object) returned a value.
779         */
780        getCreateCount(): number;
781
782        /**
783         * Obtains the number of times that the queried values are not matched.
784         * @since 9
785         * @syscap SystemCapability.Utils.Lang
786         * @returns Returns the number of times that the queried values are not matched.
787         */
788        getMissCount(): number;
789
790        /**
791         * Obtains the number of times that values are evicted from the buffer.
792         * @since 9
793         * @syscap SystemCapability.Utils.Lang
794         * @returns Returns the number of times that values are evicted from the buffer.
795         */
796        getRemovalCount(): number;
797
798        /**
799         * Obtains the number of times that the queried values are successfully matched.
800         * @since 9
801         * @syscap SystemCapability.Utils.Lang
802         * @returns Returns the number of times that the queried values are successfully matched.
803         */
804        getMatchCount(): number;
805
806        /**
807         * Obtains the number of times that values are added to the buffer.
808         * @since 9
809         * @syscap SystemCapability.Utils.Lang
810         * @returns Returns the number of times that values are added to the buffer.
811         */
812        getPutCount(): number;
813
814        /**
815         * Checks whether the current buffer is empty.
816         * @since 9
817         * @syscap SystemCapability.Utils.Lang
818         * @returns Returns true if the current buffer contains no value.
819         */
820        isEmpty(): boolean;
821
822        /**
823         * Obtains the value associated with a specified key.
824         * @since 9
825         * @syscap SystemCapability.Utils.Lang
826         * @param key Indicates the key to query.
827         * @returns Returns the value associated with the key if the specified key is present in the buffer; returns null otherwise.
828         * @throws {BusinessError} 401 - The type of key must be object.
829         */
830        get(key: K): V | undefined;
831
832        /**
833         * Adds a key-value pair to the buffer.
834         * @since 9
835         * @syscap SystemCapability.Utils.Lang
836         * @param key Indicates the key to add.
837         * @param value Indicates the value associated with the key to add.
838         * @returns Returns the value associated with the added key; returns the original value if the key to add already exists.
839         * @throws {BusinessError} 401 - if the input parameters are invalid.
840         */
841        put(key: K, value: V): V;
842
843        /**
844         * Obtains a list of all values in the current buffer.
845         * @since 9
846         * @syscap SystemCapability.Utils.Lang
847         * @returns Returns the list of all values in the current buffer in ascending order, from the most recently accessed to least recently accessed.
848         */
849        values(): V[];
850
851        /**
852         * Obtains a list of keys for the values in the current buffer.
853         * since 9
854         * @syscap SystemCapability.Utils.Lang
855         * @returns Returns a list of keys sorted from most recently accessed to least recently accessed.
856         */
857        keys(): K[];
858
859        /**
860         * Deletes a specified key and its associated value from the current buffer.
861         * @since 9
862         * @syscap SystemCapability.Utils.Lang
863         * @param key Indicates the key to delete.
864         * @returns Returns an Optional object containing the deleted key-value pair; returns an empty Optional object if the key does not exist.
865         * @throws {BusinessError} 401 - The type of key must be object.
866         */
867        remove(key: K): V | undefined;
868
869        /**
870         * Executes subsequent operations after a value is deleted.
871         * @since 9
872         * @syscap SystemCapability.Utils.Lang
873         * @param isEvict The parameter value is true if this method is called due to insufficient capacity, and the parameter value is false in other cases.
874         * @param key Indicates the deleted key.
875         * @param value Indicates the deleted value.
876         * @param newValue The parameter value is the new value associated if the put(java.lang.Object,java.lang.Object) method is called and the key to add already exists. The parameter value is null in other cases.
877         * @throws {BusinessError} 401 - if the input parameters are invalid.
878         */
879        afterRemoval(isEvict: boolean, key: K, value: V, newValue: V): void;
880
881        /**
882         * Checks whether the current buffer contains a specified key.
883         * @since 9
884         * @syscap SystemCapability.Utils.Lang
885         * @param key Indicates the key to check.
886         * @returns Returns true if the buffer contains the specified key.
887         * @throws {BusinessError} 401 - The type of key must be object.
888         */
889        contains(key: K): boolean;
890
891        /**
892         * Executes subsequent operations if miss to compute a value for the specific key.
893         * @since 9
894         * @syscap SystemCapability.Utils.Lang
895         * @param key Indicates the missed key.
896         * @returns Returns the value associated with the key.
897         * @throws {BusinessError} 401 - The type of key must be object.
898         */
899        createDefault(key: K): V;
900
901        /**
902         * Returns an array of key-value pairs of enumeratable properties of a given object.
903         * @since 9
904         * @syscap SystemCapability.Utils.Lang
905         * @returns Returns an array of key-value pairs for the enumeratable properties of the given object itself.
906         */
907        entries(): IterableIterator<[K, V]>;
908
909        /**
910         * Specifies the default iterator for an object.
911         * @since 9
912         * @syscap SystemCapability.Utils.Lang
913         * @returns Returns a two - dimensional array in the form of key - value pairs.
914         */
915        [Symbol.iterator](): IterableIterator<[K, V]>;
916    }
917
918    interface ScopeComparable {
919        /**
920         * The comparison function is used by the scope.
921         * @since 8
922         * @syscap SystemCapability.Utils.Lang
923         * @returns Returns whether the current object is greater than or equal to the input object.
924         */
925        compareTo(other: ScopeComparable): boolean;
926    }
927
928    /**
929     * A type used to denote ScopeComparable or number.
930     * @since 8
931     * @syscap SystemCapability.Utils.Lang
932     */
933    type ScopeType = ScopeComparable | number;
934
935    /**
936     * The Scope interface is used to describe the valid range of a field.
937     * @syscap SystemCapability.Utils.Lang
938     * @since 8
939     * @deprecated since 9
940     * @useinstead ohos.util.ScopeHelper
941     */
942    class Scope {
943        /**
944         * A constructor used to create a Scope instance with the lower and upper bounds specified.
945         * @since 8
946         * @deprecated since 9
947         * @useinstead ohos.util.ScopeHelper.constructor
948         * @syscap SystemCapability.Utils.Lang
949         * @param lowerObj A ScopeType value
950         * @param upperObj A ScopeType value
951         */
952        constructor(lowerObj: ScopeType, upperObj: ScopeType);
953
954        /**
955         * Obtains a string representation of the current range.
956         * @since 8
957         * @deprecated since 9
958         * @useinstead ohos.util.ScopeHelper.toString
959         * @syscap SystemCapability.Utils.Lang
960         * @returns Returns a string representation of the current range object.
961         */
962        toString(): string;
963
964        /**
965         * Returns the intersection of a given range and the current range.
966         * @since 8
967         * @deprecated since 9
968         * @useinstead ohos.util.ScopeHelper.intersect
969         * @syscap SystemCapability.Utils.Lang
970         * @param range A Scope range object
971         * @returns Returns the intersection of a given range and the current range.
972         */
973        intersect(range: Scope): Scope;
974
975        /**
976         * Returns the intersection of the current range and the range specified by the given lower and upper bounds.
977         * @since 8
978         * @deprecated since 9
979         * @useinstead ohos.util.ScopeHelper.intersect
980         * @syscap SystemCapability.Utils.Lang
981         * @param lowerObj A ScopeType value
982         * @param upperObj A ScopeType value
983         * @returns Returns the intersection of the current range and the range specified by the given lower and upper bounds.
984         */
985        intersect(lowerObj: ScopeType, upperObj: ScopeType): Scope;
986
987        /**
988         * Obtains the upper bound of the current range.
989         * @since 8
990         * @deprecated since 9
991         * @useinstead ohos.util.ScopeHelper.getUpper
992         * @syscap SystemCapability.Utils.Lang
993         * @returns Returns the upper bound of the current range.
994         */
995        getUpper(): ScopeType;
996
997        /**
998         * Obtains the lower bound of the current range.
999         * @since 8
1000         * @deprecated since 9
1001         * @useinstead ohos.util.ScopeHelper.getLower
1002         * @syscap SystemCapability.Utils.Lang
1003         * @returns Returns the lower bound of the current range.
1004         */
1005        getLower(): ScopeType;
1006
1007        /**
1008         * Creates the smallest range that includes the current range and the given lower and upper bounds.
1009         * @since 8
1010         * @deprecated since 9
1011         * @useinstead ohos.util.ScopeHelper.expand
1012         * @syscap SystemCapability.Utils.Lang
1013         * @param lowerObj A ScopeType value
1014         * @param upperObj A ScopeType value
1015         * @returns Returns the smallest range that includes the current range and the given lower and upper bounds.
1016         */
1017        expand(lowerObj: ScopeType, upperObj: ScopeType): Scope;
1018
1019        /**
1020         * Creates the smallest range that includes the current range and a given range.
1021         * @since 8
1022         * @deprecated since 9
1023         * @useinstead ohos.util.ScopeHelper.expand
1024         * @syscap SystemCapability.Utils.Lang
1025         * @param range A Scope range object
1026         * @returns Returns the smallest range that includes the current range and a given range.
1027         */
1028        expand(range: Scope): Scope;
1029
1030        /**
1031         * Creates the smallest range that includes the current range and a given value.
1032         * @since 8
1033         * @deprecated since 9
1034         * @useinstead ohos.util.ScopeHelper.expand
1035         * @syscap SystemCapability.Utils.Lang
1036         * @param value A ScopeType value
1037         * @returns Returns the smallest range that includes the current range and a given value.
1038         */
1039        expand(value: ScopeType): Scope;
1040
1041        /**
1042         * Checks whether a given value is within the current range.
1043         * @since 8
1044         * @deprecated since 9
1045         * @useinstead ohos.util.ScopeHelper.contains
1046         * @syscap SystemCapability.Utils.Lang
1047         * @param value A ScopeType value
1048         * @returns If the value is within the current range return true,otherwise return false.
1049         */
1050        contains(value: ScopeType): boolean;
1051
1052        /**
1053         * Checks whether a given range is within the current range.
1054         * @since 8
1055         * @deprecated since 9
1056         * @useinstead ohos.util.ScopeHelper.contains
1057         * @syscap SystemCapability.Utils.Lang
1058         * @param range A Scope range
1059         * @returns If the current range is within the given range return true,otherwise return false.
1060         */
1061        contains(range: Scope): boolean;
1062
1063        /**
1064         * Clamps a given value to the current range.
1065         * @since 8
1066         * @deprecated since 9
1067         * @useinstead ohos.util.ScopeHelper.clamp
1068         * @syscap SystemCapability.Utils.Lang
1069         * @param value A ScopeType value
1070         * @returns Returns a ScopeType object that a given value is clamped to the current range..
1071         */
1072        clamp(value: ScopeType): ScopeType;
1073    }
1074
1075     /**
1076     * The ScopeHelper interface is used to describe the valid range of a field.
1077     * @syscap SystemCapability.Utils.Lang
1078     * @since 9
1079     */
1080    class ScopeHelper {
1081        /**
1082         * A constructor used to create a Scope instance with the lower and upper bounds specified.
1083         * @since 9
1084         * @syscap SystemCapability.Utils.Lang
1085         * @param lowerObj A ScopeType value
1086         * @param upperObj A ScopeType value
1087         * @throws {BusinessError} 401 - if the input parameters are invalid.
1088         */
1089        constructor(lowerObj: ScopeType, upperObj: ScopeType);
1090
1091        /**
1092         * Obtains a string representation of the current range.
1093         * @since 9
1094         * @syscap SystemCapability.Utils.Lang
1095         * @returns Returns a string representation of the current range object.
1096         */
1097        toString(): string;
1098
1099        /**
1100         * Returns the intersection of a given range and the current range.
1101         * @since 9
1102         * @syscap SystemCapability.Utils.Lang
1103         * @param range A Scope range object
1104         * @returns Returns the intersection of a given range and the current range.
1105         * @throws {BusinessError} 401 - The type of range must be ScopeHelper.
1106         */
1107        intersect(range: ScopeHelper): ScopeHelper;
1108
1109        /**
1110         * Returns the intersection of the current range and the range specified by the given lower and upper bounds.
1111         * @since 9
1112         * @syscap SystemCapability.Utils.Lang
1113         * @param lowerObj A ScopeType value
1114         * @param upperObj A ScopeType value
1115         * @returns Returns the intersection of the current range and the range specified by the given lower and upper bounds.
1116         * @throws {BusinessError} 401 - if the input parameters are invalid.
1117         */
1118        intersect(lowerObj: ScopeType, upperObj: ScopeType): ScopeHelper;
1119
1120        /**
1121         * Obtains the upper bound of the current range.
1122         * @since 9
1123         * @syscap SystemCapability.Utils.Lang
1124         * @returns Returns the upper bound of the current range.
1125         */
1126        getUpper(): ScopeType;
1127
1128        /**
1129         * Obtains the lower bound of the current range.
1130         * @since 9
1131         * @syscap SystemCapability.Utils.Lang
1132         * @returns Returns the lower bound of the current range.
1133         */
1134        getLower(): ScopeType;
1135
1136        /**
1137         * Creates the smallest range that includes the current range and the given lower and upper bounds.
1138         * @since 9
1139         * @syscap SystemCapability.Utils.Lang
1140         * @param lowerObj A ScopeType value
1141         * @param upperObj A ScopeType value
1142         * @returns Returns the smallest range that includes the current range and the given lower and upper bounds.
1143         * @throws {BusinessError} 401 - if the input parameters are invalid.
1144         */
1145        expand(lowerObj: ScopeType, upperObj: ScopeType): ScopeHelper;
1146
1147        /**
1148         * Creates the smallest range that includes the current range and a given range.
1149         * @since 9
1150         * @syscap SystemCapability.Utils.Lang
1151         * @param range A Scope range object
1152         * @returns Returns the smallest range that includes the current range and a given range.
1153         * @throws {BusinessError} 401 - The type of range must be ScopeHelper.
1154         */
1155        expand(range: ScopeHelper): ScopeHelper;
1156
1157        /**
1158         * Creates the smallest range that includes the current range and a given value.
1159         * @since 9
1160         * @syscap SystemCapability.Utils.Lang
1161         * @param value A ScopeType value
1162         * @returns Returns the smallest range that includes the current range and a given value.
1163         * @throws {BusinessError} 401 - The type of value must be object.
1164         */
1165        expand(value: ScopeType): ScopeHelper;
1166
1167        /**
1168         * Checks whether a given value is within the current range.
1169         * @since 9
1170         * @syscap SystemCapability.Utils.Lang
1171         * @param value A ScopeType value
1172         * @returns If the value is within the current range return true,otherwise return false.
1173         * @throws {BusinessError} 401 - The type of value must be object.
1174         */
1175        contains(value: ScopeType): boolean;
1176
1177        /**
1178         * Checks whether a given range is within the current range.
1179         * @since 9
1180         * @syscap SystemCapability.Utils.Lang
1181         * @param range A Scope range
1182         * @returns If the current range is within the given range return true,otherwise return false.
1183         * @throws {BusinessError} 401 - The type of range must be ScopeHelper.
1184         */
1185        contains(range: ScopeHelper): boolean;
1186
1187        /**
1188         * Clamps a given value to the current range.
1189         * @since 9
1190         * @syscap SystemCapability.Utils.Lang
1191         * @param value A ScopeType value
1192         * @returns Returns a ScopeType object that a given value is clamped to the current range.
1193         * @throws {BusinessError} 401 - The type of value must be object.
1194         */
1195        clamp(value: ScopeType): ScopeType;
1196    }
1197
1198    /**
1199     * Decodes a Base64 encoded String or input u8 array into a newly-allocated
1200     * u8 array using the Base64 encoding scheme.
1201     * @syscap SystemCapability.Utils.Lang
1202     * @since 8
1203     * @deprecated since 9
1204     * @useinstead ohos.util.Base64Helper
1205     */
1206    class Base64 {
1207        /**
1208         * Constructor for creating base64 encoding and decoding
1209         * @since 8
1210         * @deprecated since 9
1211         * @useinstead ohos.util.Base64Helper.constructor
1212         * @syscap SystemCapability.Utils.Lang
1213         * @param No input parameter is required.
1214         * @returns No return value.
1215         */
1216        constructor();
1217
1218        /**
1219         * Encodes all bytes from the specified u8 array into a newly-allocated u8 array using the Base64 encoding scheme.
1220         * @since 8
1221         * @deprecated since 9
1222         * @useinstead ohos.util.Base64Helper.encodeSync
1223         * @syscap SystemCapability.Utils.Lang
1224         * @param src A Uint8Array value
1225         * @returns Return the encoded new Uint8Array.
1226         */
1227        encodeSync(src: Uint8Array): Uint8Array;
1228
1229        /**
1230         * Encodes the specified byte array into a String using the Base64 encoding scheme.
1231         * @since 8
1232         * @deprecated since 9
1233         * @useinstead ohos.util.Base64Helper.encodeToStringSync
1234         * @syscap SystemCapability.Utils.Lang
1235         * @param src A Uint8Array value
1236         * @returns Return the encoded string.
1237         */
1238        encodeToStringSync(src: Uint8Array): string;
1239
1240        /**
1241         * Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 array using the Base64 encoding scheme.
1242         * @since 8
1243         * @deprecated since 9
1244         * @useinstead ohos.util.Base64Helper.decodeSync
1245         * @syscap SystemCapability.Utils.Lang
1246         * @param src A Uint8Array value or value A string value
1247         * @returns Return the decoded Uint8Array.
1248         */
1249        decodeSync(src: Uint8Array | string): Uint8Array;
1250
1251        /**
1252         * Asynchronously encodes all bytes in the specified u8 array into the newly allocated u8 array using the Base64 encoding scheme.
1253         * @since 8
1254         * @deprecated since 9
1255         * @useinstead ohos.util.Base64Helper.encode
1256         * @syscap SystemCapability.Utils.Lang
1257         * @param src A Uint8Array value
1258         * @returns Return the encodes asynchronous new Uint8Array.
1259         */
1260        encode(src: Uint8Array): Promise<Uint8Array>;
1261
1262        /**
1263         * Asynchronously encodes the specified byte array into a String using the Base64 encoding scheme.
1264         * @since 8
1265         * @deprecated since 9
1266         * @useinstead ohos.util.Base64Helper.encodeToString
1267         * @syscap SystemCapability.Utils.Lang
1268         * @param src A Uint8Array value
1269         * @returns Returns the encoded asynchronous string.
1270         */
1271        encodeToString(src: Uint8Array): Promise<string>;
1272
1273        /**
1274         * Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 array into a newly allocated u8 array.
1275         * @since 8
1276         * @deprecated since 9
1277         * @useinstead ohos.util.Base64Helper.decode
1278         * @syscap SystemCapability.Utils.Lang
1279         * @param src A Uint8Array value or value A string value
1280         * @returns Return the decoded asynchronous Uint8Array.
1281         */
1282        decode(src: Uint8Array | string): Promise<Uint8Array>;
1283    }
1284
1285    /**
1286     * Decodes a Base64 encoded String or input u8 array into a newly-allocated
1287     * u8 array using the Base64 encoding scheme.
1288     * @syscap SystemCapability.Utils.Lang
1289     * @since 9
1290     */
1291    class Base64Helper {
1292        /**
1293         * Constructor for creating base64 encoding and decoding
1294         * @since 9
1295         * @syscap SystemCapability.Utils.Lang
1296         * @param No input parameter is required.
1297         * @returns No return value.
1298         */
1299        constructor();
1300
1301        /**
1302         * Encodes all bytes from the specified u8 array into a newly-allocated u8 array using the Base64 encoding scheme.
1303         * @since 9
1304         * @syscap SystemCapability.Utils.Lang
1305         * @param src A Uint8Array value
1306         * @returns Return the encoded new Uint8Array.
1307         * @throws {BusinessError} 401 - The type of src must be Uint8Array.
1308         */
1309        encodeSync(src: Uint8Array): Uint8Array;
1310
1311        /**
1312         * Encodes the specified byte array into a String using the Base64 encoding scheme.
1313         * @since 9
1314         * @syscap SystemCapability.Utils.Lang
1315         * @param src A Uint8Array value
1316         * @returns Return the encoded string.
1317         * @throws {BusinessError} 401 - The type of src must be Uint8Array.
1318         */
1319        encodeToStringSync(src: Uint8Array): string;
1320
1321        /**
1322         * Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 array using the Base64 encoding scheme.
1323         * @since 9
1324         * @syscap SystemCapability.Utils.Lang
1325         * @param src A Uint8Array value or value A string value
1326         * @returns Return the decoded Uint8Array.
1327         * @throws {BusinessError} 401 - The type of src must be Uint8Array or string.
1328         */
1329        decodeSync(src: Uint8Array | string): Uint8Array;
1330
1331        /**
1332         * Asynchronously encodes all bytes in the specified u8 array into the newly allocated u8 array using the Base64 encoding scheme.
1333         * @since 9
1334         * @syscap SystemCapability.Utils.Lang
1335         * @param src A Uint8Array value
1336         * @returns Return the encodes asynchronous new Uint8Array.
1337         * @throws {BusinessError} 401 - The type of src must be Uint8Array.
1338         */
1339        encode(src: Uint8Array): Promise<Uint8Array>;
1340
1341        /**
1342         * Asynchronously encodes the specified byte array into a String using the Base64 encoding scheme.
1343         * @since 9
1344         * @syscap SystemCapability.Utils.Lang
1345         * @param src A Uint8Array value
1346         * @returns Returns the encoded asynchronous string.
1347         * @throws {BusinessError} 401 - The type of src must be Uint8Array.
1348         */
1349        encodeToString(src: Uint8Array): Promise<string>;
1350
1351        /**
1352         * Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or
1353         * input u8 array into a newly allocated u8 array.
1354         * @since 9
1355         * @syscap SystemCapability.Utils.Lang
1356         * @param src A Uint8Array value or value A string value
1357         * @returns Return the decoded asynchronous Uint8Array.
1358         * @throws {BusinessError} 401 - The type of src must be Uint8Array or string.
1359         */
1360        decode(src: Uint8Array | string): Promise<Uint8Array>;
1361    }
1362
1363    /**
1364     * Check the type of parameter.
1365     * @syscap SystemCapability.Utils.Lang
1366     * @since 8
1367     */
1368    class types{
1369        /**
1370         * The types constructor
1371         * @since 8
1372         * @syscap SystemCapability.Utils.Lang
1373         * @param No input parameter is required.
1374         * @returns No return value.
1375         */
1376        constructor();
1377        /**
1378         * Check whether the entered value is of arraybuffer or sharedarraybuffer type.
1379         * @since 8
1380         * @syscap SystemCapability.Utils.Lang
1381         * @param value A ArrayBuffer or SharedArrayBuffer value
1382         * @returns Returns true if the value is a built-in ArrayBuffer or SharedArrayBuffer instance.
1383         */
1384        isAnyArrayBuffer(value: Object): boolean;
1385        /**
1386         * Check whether the type is included in the isAnyArrayBuffer.
1387         * @since 8
1388         * @syscap SystemCapability.Utils.Lang
1389         * @param value A included in the isAnyArrayBuffer value
1390         * @returns Returns true if the value is an instance of one of the ArrayBuffer views, such as typed array objects or DataView. Equivalent to ArrayBuffer.isView().
1391         */
1392        isArrayBufferView(value: Object): boolean;
1393        /**
1394         * Check whether the entered value is an arguments object type.
1395         * @since 8
1396         * @syscap SystemCapability.Utils.Lang
1397         * @param value A arguments value
1398         * @returns Returns true if the value is an arguments object.
1399         */
1400        isArgumentsObject(value: Object): boolean;
1401        /**
1402         * Check whether the entered value is of arraybuffer type.
1403         * @since 8
1404         * @syscap SystemCapability.Utils.Lang
1405         * @param value A arraybuffer value
1406         * @returns Returns true if the value is a built-in ArrayBuffer instance. This does not include SharedArrayBuffer instances. Usually, it is desirable to test for both; See isAnyArrayBuffer() for that.
1407         */
1408        isArrayBuffer(value: Object): boolean;
1409        /**
1410         * Check whether the value entered is an asynchronous function type.
1411         * @since 8
1412         * @syscap SystemCapability.Utils.Lang
1413         * @param value A async function value
1414         * @returns Returns true if the value is an async function. This only reports back what the JavaScript engine is seeing; in particular, the return value may not match the original source code if a transpilation tool was used.
1415         */
1416        isAsyncFunction(value: Object): boolean;
1417        /**
1418         * Check whether the entered value is of bigint64array array type.
1419         * @since 8
1420         * @syscap SystemCapability.Utils.Lang
1421         * @param value A BigInt64Array value
1422         * @returns Returns true if the value is a BigInt64Array instance.
1423         */
1424        isBigInt64Array(value: Object): boolean;
1425        /**
1426         * Check whether the entered value is of biguint64array array array type.
1427         * @since 8
1428         * @syscap SystemCapability.Utils.Lang
1429         * @param value A BigUint64Array value
1430         * @returns Returns true if the value is a BigUint64Array instance.
1431         */
1432        isBigUint64Array(value: Object): boolean;
1433        /**
1434         * Check whether the entered value is a Boolean object type.
1435         * @since 8
1436         * @syscap SystemCapability.Utils.Lang
1437         * @param value A boolean object value
1438         * @returns Returns true if the value is a boolean object, e.g. created by new Boolean().
1439         */
1440        isBooleanObject(value: Object): boolean;
1441        /**
1442         * Check whether the entered value is a Boolean or number or string or symbol object type.
1443         * @since 8
1444         * @syscap SystemCapability.Utils.Lang
1445         * @param value A boxed primitive object value
1446         * @returns Returns true if the value is any boxed primitive object, e.g. created by new Boolean(), new String() or Object(Symbol()).
1447         */
1448        isBoxedPrimitive(value: Object): boolean;
1449        /**
1450         * Check whether the entered value is of DataView type.
1451         * @since 8
1452         * @syscap SystemCapability.Utils.Lang
1453         * @param value A DataView value
1454         * @returns Returns true if the value is a built-in DataView instance.
1455         */
1456        isDataView(value: Object): boolean;
1457        /**
1458         * Check whether the entered value is of type date.
1459         * @since 8
1460         * @syscap SystemCapability.Utils.Lang
1461         * @param value A Date value
1462         * @returns Returns true if the value is a built-in Date instance.
1463         */
1464        isDate(value: Object): boolean;
1465        /**
1466         * Check whether the entered value is a native external value type.
1467         * @since 8
1468         * @syscap SystemCapability.Utils.Lang
1469         * @param value A External value
1470         * @returns Returns true if the value is a native External value.
1471         */
1472        isExternal(value: Object): boolean;
1473        /**
1474         * Check whether the entered value is of float32array array type.
1475         * @since 8
1476         * @syscap SystemCapability.Utils.Lang
1477         * @param value A Float32Array value
1478         * @returns Returns true if the value is a built-in Float32Array instance.
1479         */
1480        isFloat32Array(value: Object): boolean;
1481        /**
1482         * Check whether the entered value is of float64array array type.
1483         * @since 8
1484         * @syscap SystemCapability.Utils.Lang
1485         * @param value A Float64Array value
1486         * @returns Returns true if the value is a built-in Float64Array instance.
1487         */
1488        isFloat64Array(value: Object): boolean;
1489        /**
1490         * Check whether the input value is a generator function type.
1491         * @since 8
1492         * @syscap SystemCapability.Utils.Lang
1493         * @param value A generator function value
1494         * @returns Returns true if the value is a generator function. This only reports back what the JavaScript engine is seeing; in particular, the return value may not match the original source code if a transpilation tool was used.
1495         */
1496        isGeneratorFunction(value: Object): boolean;
1497        /**
1498         * Check whether the entered value is a generator object type.
1499         * @since 8
1500         * @syscap SystemCapability.Utils.Lang
1501         * @param value A generator object value
1502         * @returns Returns true if the value is a generator object as returned from a built-in generator function. This only reports back what the JavaScript engine is seeing; in particular, the return value may not match the original source code if a transpilation tool was used.
1503         */
1504        isGeneratorObject(value: Object): boolean;
1505        /**
1506         * Check whether the entered value is of int8array array type.
1507         * @since 8
1508         * @syscap SystemCapability.Utils.Lang
1509         * @param value A Int8Array value
1510         * @returns Returns true if the value is a built-in Int8Array instance.
1511         */
1512        isInt8Array(value: Object): boolean;
1513        /**
1514         * Check whether the entered value is the int16array type.
1515         * @since 8
1516         * @syscap SystemCapability.Utils.Lang
1517         * @param value A Int16Array value
1518         * @returns Returns true if the value is a built-in Int16Array instance.
1519         */
1520        isInt16Array(value: Object): boolean;
1521        /**
1522         * Check whether the entered value is the int32array array type.
1523         * @since 8
1524         * @syscap SystemCapability.Utils.Lang
1525         * @param value A Int32Array value
1526         * @returns Returns true if the value is a built-in Int32Array instance.
1527         */
1528        isInt32Array(value: Object): boolean;
1529        /**
1530         * Check whether the entered value is of map type.
1531         * @since 8
1532         * @syscap SystemCapability.Utils.Lang
1533         * @param value A Map value
1534         * @returns Returns true if the value is a built-in Map instance.
1535         */
1536        isMap(value: Object): boolean;
1537        /**
1538         * Check whether the entered value is the iterator type of map.
1539         * @since 8
1540         * @syscap SystemCapability.Utils.Lang
1541         * @param value A Map iterator value
1542         * @returns Returns true if the value is an iterator returned for a built-in Map instance.
1543         */
1544        isMapIterator(value: Object): boolean;
1545        /**
1546         * Check whether the entered value is the module namespace object object type.
1547         * @since 8
1548         * @syscap SystemCapability.Utils.Lang
1549         * @param value A Module Namespace Object value
1550         * @returns Returns true if the value is an instance of a Module Namespace Object.
1551         */
1552        isModuleNamespaceObject(value: Object): boolean;
1553        /**
1554         * Check whether the value entered is of type error.
1555         * @since 8
1556         * @syscap SystemCapability.Utils.Lang
1557         * @param value A Error value
1558         * @returns Returns true if the value is an instance of a built-in Error type.
1559         */
1560        isNativeError(value: Object): boolean;
1561        /**
1562         * Check whether the entered value is of the number object type.
1563         * @since 8
1564         * @syscap SystemCapability.Utils.Lang
1565         * @param value A number object value
1566         * @returns Returns true if the value is a number object, e.g. created by new Number().
1567         */
1568        isNumberObject(value: Object): boolean;
1569        /**
1570         * Check whether the entered value is of promise type.
1571         * @since 8
1572         * @syscap SystemCapability.Utils.Lang
1573         * @param value A Promise value
1574         * @returns Returns true if the value is a built-in Promise.
1575         */
1576        isPromise(value: Object): boolean;
1577        /**
1578         * Check whether the value entered is of proxy type.
1579         * @since 8
1580         * @syscap SystemCapability.Utils.Lang
1581         * @param value A Proxy value
1582         * @returns Returns true if the value is a Proxy instance.
1583         */
1584        isProxy(value: Object): boolean;
1585        /**
1586         * Check whether the entered value is of type regexp.
1587         * @since 8
1588         * @syscap SystemCapability.Utils.Lang
1589         * @param value A regular expression object value
1590         * @returns Returns true if the value is a regular expression object.
1591         */
1592        isRegExp(value: Object): boolean;
1593        /**
1594         * Check whether the entered value is of type set.
1595         * @since 8
1596         * @syscap SystemCapability.Utils.Lang
1597         * @param value A Set instance value
1598         * @returns Returns true if the value is a built-in Set instance.
1599         */
1600        isSet(value: Object): boolean;
1601        /**
1602         * Check whether the entered value is the iterator type of set.
1603         * @since 8
1604         * @syscap SystemCapability.Utils.Lang
1605         * @param value A Set iterator value
1606         * @returns Returns true if the value is an iterator returned for a built-in Set instance.
1607         */
1608        isSetIterator(value: Object): boolean;
1609        /**
1610         * Check whether the entered value is of type sharedarraybuffer.
1611         * @since 8
1612         * @syscap SystemCapability.Utils.Lang
1613         * @param value A SharedArrayBuffer instance value
1614         * @returns Returns true if the value is a built-in SharedArrayBuffer instance. This does not include ArrayBuffer instances. Usually, it is desirable to test for both; See isAnyArrayBuffer() for that.
1615         */
1616        isSharedArrayBuffer(value: Object): boolean;
1617        /**
1618         * Check whether the entered value is a string object type.
1619         * @since 8
1620         * @syscap SystemCapability.Utils.Lang
1621         * @param value A String object value
1622         * @returns Returns true if the value is a string object, e.g. created by new String().
1623         */
1624        isStringObject(value: Object): boolean;
1625        /**
1626         * Check whether the entered value is a symbol object type.
1627         * @since 8
1628         * @syscap SystemCapability.Utils.Lang
1629         * @param value A symbol object value
1630         * @returns Returns true if the value is a symbol object, created by calling Object() on a Symbol primitive.
1631         */
1632        isSymbolObject(value: Object): boolean;
1633        /**
1634         * Check whether the entered value is a type contained in typedarray.
1635         * @since 8
1636         * @syscap SystemCapability.Utils.Lang
1637         * @param value A TypedArray instance value
1638         * @returns Returns true if the value is a built-in TypedArray instance.
1639         */
1640        isTypedArray(value: Object): boolean;
1641        /**
1642         * Check whether the entered value is the uint8array array type.
1643         * @since 8
1644         * @syscap SystemCapability.Utils.Lang
1645         * @param value A Uint8Array value
1646         * @returns Returns true if the value is a built-in Uint8Array instance.
1647         */
1648        isUint8Array(value: Object): boolean;
1649        /**
1650         * Check whether the entered value is the uint8clapedarray array type.
1651         * @since 8
1652         * @syscap SystemCapability.Utils.Lang
1653         * @param value A Uint8ClampedArray value
1654         * @returns Returns true if the value is a built-in Uint8ClampedArray instance.
1655         */
1656        isUint8ClampedArray(value: Object): boolean;
1657        /**
1658         * Check whether the entered value is the uint16array array array type.
1659         * @since 8
1660         * @syscap SystemCapability.Utils.Lang
1661         * @param value A Uint16Array value
1662         * @returns Returns true if the value is a built-in Uint16Array instance.
1663         */
1664        isUint16Array(value: Object): boolean;
1665        /**
1666         * Check whether the entered value is the uint32array array type.
1667         * @since 8
1668         * @syscap SystemCapability.Utils.Lang
1669         * @param value A Uint32Array value
1670         * @returns Returns true if the value is a built-in Uint32Array instance.
1671         */
1672        isUint32Array(value: Object): boolean;
1673        /**
1674         * Check whether the entered value is of type weakmap.
1675         * @since 8
1676         * @syscap SystemCapability.Utils.Lang
1677         * @param value A WeakMap value
1678         * @returns Returns true if the value is a built-in WeakMap instance.
1679         */
1680        isWeakMap(value: Object): boolean;
1681        /**
1682         * Check whether the entered value is of type weakset.
1683         * @since 8
1684         * @syscap SystemCapability.Utils.Lang
1685         * @param value A WeakSet value
1686         * @returns Returns true if the value is a built-in WeakSet instance.
1687         */
1688        isWeakSet(value: Object): boolean;
1689    }
1690}
1691export default util;
1692