(getServe)
| 64 | } |
| 65 | |
| 66 | function buildDestroy(getServe) { |
| 67 | const transactions = new Map(); |
| 68 | const server = createServer(getServe(getCLS, setCLS)); |
| 69 | const hook = createHook({ init, destroy }); |
| 70 | hook.enable(); |
| 71 | |
| 72 | return { |
| 73 | server, |
| 74 | close, |
| 75 | }; |
| 76 | |
| 77 | function getCLS() { |
| 78 | const asyncId = executionAsyncId(); |
| 79 | return transactions.has(asyncId) ? transactions.get(asyncId) : null; |
| 80 | } |
| 81 | |
| 82 | function setCLS(value) { |
| 83 | const asyncId = executionAsyncId(); |
| 84 | transactions.set(asyncId, value); |
| 85 | } |
| 86 | |
| 87 | function init(asyncId, type, triggerAsyncId, resource) { |
| 88 | transactions.set(asyncId, getCLS()); |
| 89 | } |
| 90 | |
| 91 | function destroy(asyncId) { |
| 92 | transactions.delete(asyncId); |
| 93 | } |
| 94 | |
| 95 | function close() { |
| 96 | hook.disable(); |
| 97 | server.close(); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | function buildAsyncLocalStorage(getServe) { |
| 102 | const asyncLocalStorage = new AsyncLocalStorage(); |
nothing calls this directly
no test coverage detected