Skip to content

Commit 2e2823a

Browse files
committed
Use Map instread of object to fix 'Property storage exceeds 196607 properties' error
1 parent 6ce8982 commit 2e2823a

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

packages/react-native/Libraries/Blob/BlobRegistry.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,32 @@
88
* @format
99
*/
1010

11-
const registry: {[key: string]: number, ...} = {};
11+
const registry: Map<string, number> = new Map();
1212

1313
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);
1618
} else {
17-
registry[id] = 1;
19+
registry.set(id, 1);
1820
}
1921
};
2022

2123
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);
2631
}
2732
}
2833
};
2934

3035
const has = (id: string): number | boolean => {
31-
return registry[id] && registry[id] > 0;
36+
return registry.get(id) || false;
3237
};
3338

3439
module.exports = {

0 commit comments

Comments
 (0)