• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Util Subsystem Changelog
2
3Compared with OpenHarmony 3.2 Beta4, OpenHarmony 3.2.10.7(MR) has the following API changes in the util subsystem.
4
5## cl.util.1. randomUUID Name Changed
6The **randomUUID** function name is changed to **generateRandomUUID**.
7
8Before change: function randomUUID(entropyCache?: boolean): string <br>After change: function generateRandomUUID(entropyCache?: boolean): string
9
10You need to adapt your application.
11
12**Change Impact**
13
14JS APIs in API version 9 are affected. Your application needs to adapt these APIs so that it can properly implement features in the SDK environment of the new version.
15
16**Key API/Component Changes**
17
18| Module     | Method/Attribute/Enum/Constant  | Change Type|
19| :---------- | -------------------   | -------  |
20| @ohos.util  | function randomUUID(entropyCache?: boolean): string        | Deleted |
21| @ohos.util  | function generateRandomUUID(entropyCache?: boolean): string| Added |
22
23**Adaptation Guide**
24
25Refer to the code snippet below to call **generateRandomUUID** in your application.
26
27Example:
28
29```ts
30import util from '@ohos.util'
31let uuid = util.generateRandomUUID(true);
32console.log("RFC 4122 Version 4 UUID:" + uuid);
33// Output:
34// RFC 4122 Version 4 UUID:88368f2a-d5db-47d8-a05f-534fab0a0045
35```
36
37## cl.util.2 randomBinaryUUID Name Changed
38The **randomBinaryUUID** function name is changed to **generateRandomBinaryUUID**.
39
40Before change: function randomBinaryUUID(entropyCache?: boolean): Uint8Array<br>After change: function generateRandomBinaryUUID(entropyCache?: boolean): Uint8Array
41
42You need to adapt your application.
43
44**Change Impact**
45
46JS APIs in API version 9 are affected. Your application needs to adapt these APIs so that it can properly implement features in the SDK environment of the new version.
47
48**Key API/Component Changes**
49
50| Module     | Method/Attribute/Enum/Constant  | Change Type|
51| :---------- | -------------------   | -------  |
52| @ohos.util  | function randomBinaryUUID(entropyCache?: boolean): Uint8Array;       | Deleted |
53| @ohos.util  | function generateRandomBinaryUUID(entropyCache?: boolean): Uint8Array| Added |
54
55**Adaptation Guide**
56
57Refer to the code snippet below to call **generateRandomBinaryUUID** in your application.
58
59Example:
60
61```ts
62import util from '@ohos.util'
63let uuid = util.generateRandomBinaryUUID(true);
64console.log(JSON.stringify(uuid));
65// Output:
66// 138,188,43,243,62,254,70,119,130,20,235,222,199,164,140,150
67```
68
69## cl.util.3. contains Parameter Type in the LRUCache Class Changed
70The **contains** parameter type in the LRUCache class is changed from **object** to **K**.
71
72Before change: contains(key: object): boolean <br>After change: contains(key: K): boolean
73
74You need to adapt your application.
75
76**Change Impact**
77
78JS APIs in API version 9 are affected. Your application needs to adapt these APIs so that it can properly implement features in the SDK environment of the new version.
79
80**Key API/Component Changes**
81
82| Module    | Class    | Method/Attribute/Enum/Constant             | Change Type|
83| :--------  | ---------| -------------------------------- | -------- |
84| @ohos.util | LRUCache |  contains(key: object): boolean  | Deleted    |
85| @ohos.util | LRUCache |  contains(key: K): boolean       | Added    |
86
87**Adaptation Guide**
88
89Follow the code snippet to use the **contains** function in your application.
90
91Example:
92
93```ts
94import util from '@ohos.util'
95let pro = new util.LRUCache();
96pro.put(2,10);
97let obj = {1:"key"};
98let result = pro.contains(obj);
99```
100