Files
react/packages/internal-test-utils/enqueueTask.js
Jan Kassens d260b0d8b8 Update Flow to 0.265 (#34270)
Looks like this version removed `Object.prototype` although I didn't see
that in the changelog. This is fine for this code here.
2025-08-22 15:22:22 -04:00

21 lines
516 B
JavaScript

/**
* 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();
// $FlowFixMe[prop-missing]
channel.port1.onmessage = () => {
channel.port1.close();
task();
};
channel.port2.postMessage(undefined);
}