Skip to content

Commit b2aa025

Browse files
committed
Switch from WeakMap to Map
1 parent f846488 commit b2aa025

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

fluent-bundle/src/bundle.ts

Lines changed: 2 additions & 2 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,7 +23,7 @@ export class FluentBundle {
2323
public _functions: Record<string, FluentFunction>;
2424
public _useIsolating: boolean;
2525
public _transform: TextTransform;
26-
public _intls: WeakMap<object, Record<string, object>>;
26+
public _intls: IntlCache;
2727

2828
/**
2929
* 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,12 +1,12 @@
1-
type IntlCache = WeakMap<object, Record<string, object>>;
1+
export type IntlCache = Map<object, Record<string, object>>;
22

33
const cache = new Map<string, IntlCache>();
44

55
export function getMemoizerForLocale(locales: string | string[]): IntlCache {
66
const stringLocale = Array.isArray(locales) ? locales.join(" ") : locales;
77
let memoizer = cache.get(stringLocale);
88
if (memoizer === undefined) {
9-
memoizer = new WeakMap();
9+
memoizer = new Map();
1010
cache.set(stringLocale, memoizer);
1111
}
1212

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy