How to override a function from an external library on nodejs

60 Views Asked by At

I want to override the .exec function on workerpool but it's calls my console.log twice, can't figure out why :

export const queues = workerpool.pool({
  maxWorkers: require("os").cpus().length,
});
const originalExec = queues.exec;
queues.exec = function (method, params, options) {
  console.log("task started");

  return originalExec.call(queues, method, params, options);
};

Tryed to change the "this" argument on the call, also the .apply() function, the results are the same.

0

There are 0 best solutions below