Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
mod[name] = function (...args) {
if (!_.isFunction(_.last(args))) return func.call(this, ...args);
const cb = args.pop();
const callback = function (err, ...args2) {
if (err)
newrelic.noticeError(err);
cb.call(this, err, ...args2);
};
newrelic.startSegment(`api/api/${ns}/${name}`, true, cb => {
func.call(this, ...args, cb);
}, callback);
};
});