| 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 | // This file is used as temporary storage for modules generated in Flight tests. |
| 11 | let moduleIdx = 0; |
| 12 | const modules: Map<string, Function> = new Map(); |
| 13 | |
| 14 | // This simulates what the compiler will do when it replaces render functions with server blocks. |
| 15 | export function saveModule(render: Function): string { |
| 16 | const idx = '' + moduleIdx++; |
| 17 | modules.set(idx, render); |
| 18 | return idx; |
| 19 | } |
| 20 | |
| 21 | export function readModule(idx: string): Function { |
| 22 | return modules.get(idx); |
| 23 | } |