File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed
packages/react-native/Libraries/Blob Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change 8
8
* @format
9
9
*/
10
10
11
- const registry : { [ key : string ] : number , ... } = { } ;
11
+ const registry : Map < string , number > = new Map ( ) ;
12
12
13
13
const register = ( id : string ) => {
14
- if ( registry [ id ] ) {
15
- registry [ id ] ++ ;
14
+ const used = registry . get ( id ) ;
15
+
16
+ if ( used != null ) {
17
+ registry . set ( id , used + 1 ) ;
16
18
} else {
17
- registry [ id ] = 1 ;
19
+ registry . set ( id , 1 ) ;
18
20
}
19
21
} ;
20
22
21
23
const unregister = ( id : string ) => {
22
- if ( registry [ id ] ) {
23
- registry [ id ] -- ;
24
- if ( registry [ id ] <= 0 ) {
25
- delete registry [ id ] ;
24
+ const used = registry . get ( id ) ;
25
+
26
+ if ( used != null ) {
27
+ if ( used <= 1 ) {
28
+ registry . delete ( id ) ;
29
+ } else {
30
+ registry . set ( id , used - 1 ) ;
26
31
}
27
32
}
28
33
} ;
29
34
30
35
const has = ( id : string ) : number | boolean => {
31
- return registry [ id ] && registry [ id ] > 0 ;
36
+ return registry . get ( id ) || false ;
32
37
} ;
33
38
34
39
module . exports = {
You can’t perform that action at this time.
0 commit comments