MCPcopy Create free account
hub / github.com/ptmt/react-native-macos / wrapWorkerFn

Function wrapWorkerFn

packager/src/ModuleGraph/worker/wrap-worker-fn.js:33–60  ·  view source on GitHub ↗
(
  workerFunction: WorkerFn<Options>,
)

Source from the content-addressed store, hash-verified

31) => void;
32
33function wrapWorkerFn<Options>(
34 workerFunction: WorkerFn<Options>,
35): WorkerFnWithIO<Options> {
36 return (
37 infile: Path,
38 outfile: Path,
39 options: Options,
40 callback: Callback<>,
41 ) => {
42 const contents = fs.readFileSync(infile);
43 workerFunction(contents, options, (error, result) => {
44 if (error) {
45 callback(error);
46 return;
47 }
48
49 try {
50 mkdirp.sync(dirname(outfile));
51 fs.writeFileSync(outfile, JSON.stringify(result), 'utf8');
52 } catch (writeError) {
53 callback(writeError);
54 return;
55 }
56
57 callback(null);
58 });
59 };
60}
61
62module.exports = wrapWorkerFn;

Callers 2

worker.jsFile · 0.85

Calls 1

callbackFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…