{"version":3,"sources":["jsdelivr-header.js","/npm/express-apm@1.1.1/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,MAAM,KAAO,QAAQ,WAAR,CAAoB,OAC3B,OAAS,QAAQ,gBASvB,OAAO,QAAW,GACP,CAAC,EAAK,EAAK,KACd,IAAI,EAAY,IAAI,KAAK,KACrB,EAAa,KAAK,MAClB,EAAc,QAAQ,cAAc,SAGxC,EAAI,KAAK,UAAU,KACf,IAAI,EAAa,EAAU,OACvB,EAAe,QAAQ,cAAc,SACzC,EAAW,KAAO,KAAK,MAAQ,EAC/B,EAAW,WAAa,EAAc,EAGnC,EAAW,WAAa,IACvB,EAAW,WAAa,GAIzB,EAAW,WAAa,IACvB,EAAW,WAAa,GAIzB,EAAW,WAAa,IACvB,EAAW,WAAa,GAIzB,EAAW,SAAW,IACrB,EAAW,SAAW,GAIvB,QAEC,EAAQ,KAAK,OAAQ,GAErB,QAAQ,IAAI,aAChB,IAGJ,GAAM,EAKd,OAAO,QAAQ,KAAO,KAAK,KAE3B,OAAO,QAAQ,OAAS","file":"/npm/express-apm@1.1.1/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/express-apm@1.1.1/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const heap = require('bindings')('apm');\nconst server = require('./src/server');\n\n/*\n  Express middleware\n  app.use(MODULE_NAME);\n\n  emitter: event emitter for when a request has finished\n           null if unwanted\n*/\nmodule.exports = (emitter) => {\n    return (req, res, next) => {\n        let startHeap = new heap.Heap();\n        let startTime =  Date.now();\n        let startMemory = process.memoryUsage().heapUsed;\n\n        // once the request has finished, deal with the result.\n        res.once('finish', () => {\n            let finishHeap = startHeap.stop();\n            let finishMemory = process.memoryUsage().heapUsed;\n            finishHeap.time = Date.now() - startTime; // delta time is in milliseconds\n            finishHeap.memoryUsed = startMemory - finishMemory;\n\n            // garbage collection happened during the request\n            if(finishHeap.numStrings < 0){\n                finishHeap.numStrings = 0;\n            }\n            \n            // garbage collection happened during the request\n            if(finishHeap.numClasses < 0){\n                finishHeap.numClasses = 0;\n            }\n\n            // garbage collection happened during the request\n            if(finishHeap.memoryUsed < 0){\n                finishHeap.memoryUsed = 0;\n            }\n\n            // garbage collection happened during the request\n            if(finishHeap.numNodes < 0){\n                finishHeap.numNodes = 0;\n            }\n            \n            // null is supposed to be used, but catch undefined too\n            if(emitter !== undefined && emitter !== null){\n                // announce the finished heap's data\n                emitter.emit('heap', finishHeap);\n            } else {\n                console.log(finishedHeap);\n            }\n        });\n\n        next();\n    }\n}\n\n/*independant heap class*/\nmodule.exports.Heap = heap.Heap;\n\nmodule.exports.server = server;\n"]}