MCPcopy Index your code
hub / github.com/RisingStack/trace-nodejs / wrapCallback

Function wrapCallback

lib/instrumentations/utils/wrapQuery.js:73–92  ·  view source on GitHub ↗
(original, args, reporter)

Source from the content-addressed store, hash-verified

71}
72
73function wrapCallback (original, args, reporter) {
74 var cs
75 var wrappedCallback = function (original) {
76 return function (err) {
77 reporter.reportReceive(err, cs)
78 return original.apply(this, arguments)
79 }
80 }
81 var last = args[args.length - 1]
82 if (last && typeof last === 'function') {
83 args[args.length - 1] = wrappedCallback(last)
84 } else if (Array.isArray(last) && typeof last[last.length - 1] === 'function') {
85 var lastOfLast = last.length - 1
86 args[args.length - 1][lastOfLast] = wrappedCallback(last[lastOfLast])
87 } else {
88 args.push(wrappedCallback(function () { }))
89 }
90 cs = reporter.reportSend()
91 return original.apply(this, args)
92}
93
94function wrapPromise (original, args, reporter) {
95 var originalPromise = original.apply(this, args)

Callers

nothing calls this directly

Calls 1

wrappedCallbackFunction · 0.70

Tested by

no test coverage detected