@contrast/deadzones
Advanced tools
Comparing version 1.2.3 to 1.2.4
@@ -18,2 +18,26 @@ /* | ||
// module.exports = function(core) { | ||
// return core.deadzones.bsonInstrumentation = { | ||
// install() {}, | ||
// uninstall() {} | ||
// }; | ||
// }; | ||
// the following is being left in place in case we need to instrument bson | ||
// in the future. Notes: | ||
// - v1 the export is a constructor. | ||
// - has no dependencies. | ||
// - v4-6 the export is an object with serialize and deserialize methods | ||
// - v4 - has one dependency: buffer | ||
// - buffer has two dependencies: base64-js, ieee754. neither has deps. | ||
// - base64-js could be deadzoned, but does most manipulation via | ||
// charCodeAt(), so minimal impact of rewriting. | ||
// - ieee754 reads/write FP numbers in buffers. minimal impact. | ||
// - v5,6 - no dependencies | ||
// - starting with v5, it's no longer possible to require('bson/package.json') | ||
// - there is no performance improvement from this runtime deadzoning for any | ||
// version. 100% of the improvement comes from not-rewriting the bson | ||
// module. | ||
//* | ||
const { patchType } = require('../common'); | ||
@@ -30,5 +54,6 @@ | ||
install() { | ||
const moduleName = 'bson'; | ||
depHooks.resolve({ name: moduleName }, (xport) => { | ||
depHooks.resolve({ name: moduleName, version: '>=4.0.0' }, (xport) => { | ||
[ | ||
@@ -47,2 +72,26 @@ 'serialize', | ||
}); | ||
depHooks.resolve({ name: moduleName, version: '>1.0.0 <2.0.0' }, (xport) => | ||
// the xport is a constructor which returns an object with serialize | ||
// and deserialize methods. | ||
patcher.patch(xport, { | ||
name: `${moduleName}.constructor`, | ||
patchType, | ||
post({ result: bson }) { | ||
// the constructor returns undefined if called without `new` | ||
if (!bson) { | ||
return; | ||
} | ||
['serialize', 'deserialize'].forEach((methodName) => { | ||
const patchName = `${moduleName}.${methodName}`; | ||
const store = { lock: true, name: patchName }; | ||
patcher.patch(bson, methodName, { | ||
name: patchName, | ||
patchType, | ||
around: createAroundHook(store), | ||
}); | ||
}); | ||
} | ||
}) | ||
); | ||
}, | ||
@@ -52,1 +101,2 @@ uninstall() { } | ||
}; | ||
// */ |
{ | ||
"name": "@contrast/deadzones", | ||
"version": "1.2.3", | ||
"version": "1.2.4", | ||
"description": "Configures Contrast agent services and instrumentation within an application", | ||
@@ -5,0 +5,0 @@ "license": "SEE LICENSE IN LICENSE", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23517
597