mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
Looks like this version removed `Object.prototype` although I didn't see that in the changelog. This is fine for this code here.
21 lines
516 B
JavaScript
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);
|
|
}
|