Skip to content

Commit e94eb08

Browse files
committed
Switch from WeakMap to Map
1 parent 73a20fe commit e94eb08

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

fluent-bundle/src/bundle.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { FluentResource } from "./resource.js";
44
import { FluentValue, FluentNone, FluentFunction } from "./types.js";
55
import { Message, Term, Pattern } from "./ast.js";
66
import { NUMBER, DATETIME } from "./builtins.js";
7-
import { getMemoizerForLocale } from "./memoizer.js";
7+
import { getMemoizerForLocale, IntlCache } from "./memoizer.js";
88

99
export type TextTransform = (text: string) => string;
1010

@@ -23,12 +23,7 @@ export class FluentBundle {
2323
public _functions: Record<string, FluentFunction>;
2424
public _useIsolating: boolean;
2525
public _transform: TextTransform;
26-
public _intls = new WeakMap<
27-
| typeof Intl.NumberFormat
28-
| typeof Intl.DateTimeFormat
29-
| typeof Intl.PluralRules,
30-
Record<string, Intl.NumberFormat | Intl.DateTimeFormat | Intl.PluralRules>
31-
>();
26+
public _intls: IntlCache;
3227

3328
/**
3429
* Create an instance of `FluentBundle`.

fluent-bundle/src/memoizer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
type IntlCache = WeakMap<
1+
export type IntlCache = Map<
22
| typeof Intl.NumberFormat
33
| typeof Intl.DateTimeFormat
44
| typeof Intl.PluralRules,
@@ -11,7 +11,7 @@ export function getMemoizerForLocale(locales: string | string[]): IntlCache {
1111
const stringLocale = Array.isArray(locales) ? locales.join(" ") : locales;
1212
let memoizer = cache.get(stringLocale);
1313
if (memoizer === undefined) {
14-
memoizer = new WeakMap();
14+
memoizer = new Map();
1515
cache.set(stringLocale, memoizer);
1616
}
1717

0 commit comments

Comments
 (0)