/
githubmr
/
facebook-react
Обзор
Документация
Войти
/
githubmr
/
facebook-react
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
v19.0.0
packages/internal-test-utils/enqueueTask.js
19 строк
486 B
Andrew Clark
[Internal tests] Close MessageChannel port to prevent leak (#26357)
09 мар 2023, 19:20
Не верифицирован
09 мар 2023, 19:20
39d4b93
Код
Авторство
О чём код?
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ const {MessageChannel} = require('node:worker_threads'); export default function enqueueTask(task: () => void): void { const channel = new MessageChannel(); channel.port1.onmessage = () => { channel.port1.close(); task(); }; channel.port2.postMessage(undefined); }