main
js 31 lines 703 Bytes
Raw
1 /**
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 * @flow
8 */
9
10 interface Reference {}
11
12 export opaque type TemporaryReferenceSet = Map<string, Reference | symbol>;
13
14 export function createTemporaryReferenceSet(): TemporaryReferenceSet {
15 return new Map();
16 }
17
18 export function writeTemporaryReference(
19 set: TemporaryReferenceSet,
20 reference: string,
21 object: Reference | symbol,
22 ): void {
23 set.set(reference, object);
24 }
25
26 export function readTemporaryReference<T>(
27 set: TemporaryReferenceSet,
28 reference: string,
29 ): T {
30 return set.get(reference) as any;
31 }