{"versions":{"0.3.1":{"name":"diagnostic-channel","version":"0.3.1","main":"./dist/src/channel.js","types":"./dist/src/channel.d.ts","scripts":{"build":"tsc","lint":"tslint -c tslint.json -p tsconfig.json","clean":"rimraf ./dist","test":"mocha ./dist/tests/**/*.js"},"homepage":"https://github.com/Microsoft/node-diagnostic-channel","bugs":{"url":"https://github.com/Microsoft/node-diagnostic-channel/issues"},"repository":{"type":"git","url":"git+https://github.com/Microsoft/node-diagnostic-channel.git"},"description":"Provides a context-saving pub/sub channel to connect diagnostic event publishers and subscribers","dependencies":{"semver":"^5.3.0"},"devDependencies":{"@types/mocha":"^2.2.40","@types/node":"^7.0.12","mocha":"^3.2.0","rimraf":"^2.6.1","tslint":"^5.0.0","typescript":"^2.2.1"},"license":"MIT","_id":"diagnostic-channel@0.3.1","_nodeVersion":"11.10.0","_npmVersion":"6.7.0","dist":{"shasum":"7faa143e107f861be3046539eb4908faab3f53fd","size":5583,"noattachment":false,"tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/diagnostic-channel/-/diagnostic-channel-0.3.1.tgz"},"maintainers":[{"name":"anonymous","email":"jackpeterhorton@gmail.com"},{"name":"anonymous","email":"jithomso@microsoft.com"},{"name":"anonymous","email":"josh.gavant@outlook.com"},{"name":"anonymous","email":"npmjs@microsoft.com"},{"name":"anonymous","email":"mkaufman@microsoft.com"},{"name":"anonymous","email":"osvaldo@osvaldojr.com"}],"_npmUser":{"name":"anonymous","email":"appinsightssdk@microsoft.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/diagnostic-channel_0.3.1_1572547475404_0.8233597228135112"},"_hasShrinkwrap":false,"publish_time":1572547475526,"_cnpm_publish_time":1572547475526,"contributors":[]},"0.3.0":{"name":"diagnostic-channel","version":"0.3.0","main":"./dist/src/channel.js","types":"./dist/src/channel.d.ts","scripts":{"build":"tsc","lint":"tslint -c tslint.json -p tsconfig.json","clean":"rimraf ./dist","test":"mocha ./dist/tests/**/*.js"},"homepage":"https://github.com/Microsoft/node-diagnostic-channel","bugs":{"url":"https://github.com/Microsoft/node-diagnostic-channel/issues"},"repository":{"type":"git","url":"git+https://github.com/Microsoft/node-diagnostic-channel.git"},"description":"Provides a context-saving pub/sub channel to connect diagnostic event publishers and subscribers","dependencies":{"semver":"^5.3.0"},"devDependencies":{"@types/mocha":"^2.2.40","@types/node":"^7.0.12","mocha":"^3.2.0","rimraf":"^2.6.1","tslint":"^5.0.0","typescript":"^2.2.1"},"license":"MIT","_id":"diagnostic-channel@0.3.0","_nodeVersion":"11.10.0","_npmVersion":"6.7.0","dist":{"shasum":"7a3cdcefe9caa50ca7e8075be889029f8affb352","size":5644,"noattachment":false,"tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/diagnostic-channel/-/diagnostic-channel-0.3.0.tgz"},"maintainers":[{"name":"anonymous","email":"jackpeterhorton@gmail.com"},{"name":"anonymous","email":"jithomso@microsoft.com"},{"name":"anonymous","email":"josh.gavant@outlook.com"},{"name":"anonymous","email":"npmjs@microsoft.com"},{"name":"anonymous","email":"mkaufman@microsoft.com"},{"name":"anonymous","email":"osvaldo@osvaldojr.com"}],"_npmUser":{"name":"anonymous","email":"appinsightssdk@microsoft.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/diagnostic-channel_0.3.0_1572377414409_0.9670192371999604"},"_hasShrinkwrap":false,"publish_time":1572377414572,"_cnpm_publish_time":1572377414572,"contributors":[]},"0.2.0":{"name":"diagnostic-channel","version":"0.2.0","main":"./dist/src/channel.js","types":"./dist/src/channel.d.ts","scripts":{"build":"tsc","lint":"tslint -c tslint.json -p tsconfig.json","clean":"rimraf ./dist","test":"mocha ./dist/tests/**/*.js"},"homepage":"https://github.com/Microsoft/node-diagnostic-channel","bugs":{"url":"https://github.com/Microsoft/node-diagnostic-channel/issues"},"repository":{"type":"git","url":"git+https://github.com/Microsoft/node-diagnostic-channel.git"},"description":"Provides a context-saving pub/sub channel to connect diagnostic event publishers and subscribers","dependencies":{"semver":"^5.3.0"},"devDependencies":{"@types/mocha":"^2.2.40","@types/node":"^7.0.12","mocha":"^3.2.0","rimraf":"^2.6.1","tslint":"^5.0.0","typescript":"^2.2.1"},"files":["dist/src/**/*.d.ts","dist/src/**/*.js","LICENSE","README.md","package.json"],"license":"MIT","_id":"diagnostic-channel@0.2.0","_shasum":"cc99af9612c23fb1fff13612c72f2cbfaa8d5a17","_resolved":"file:diagnostic-channel-0.2.0.tgz","_from":"diagnostic-channel-0.2.0.tgz","_npmVersion":"3.10.10","_nodeVersion":"6.11.1","_npmUser":{"name":"anonymous","email":"jackpeterhorton@gmail.com"},"dist":{"shasum":"cc99af9612c23fb1fff13612c72f2cbfaa8d5a17","size":5492,"noattachment":false,"tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/diagnostic-channel/-/diagnostic-channel-0.2.0.tgz"},"maintainers":[{"name":"anonymous","email":"jackpeterhorton@gmail.com"},{"name":"anonymous","email":"jithomso@microsoft.com"},{"name":"anonymous","email":"josh.gavant@outlook.com"},{"name":"anonymous","email":"npmjs@microsoft.com"},{"name":"anonymous","email":"mkaufman@microsoft.com"},{"name":"anonymous","email":"osvaldo@osvaldojr.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/diagnostic-channel-0.2.0.tgz_1503437530539_0.09619695995934308"},"directories":{},"publish_time":1503437530671,"_hasShrinkwrap":false,"_cnpm_publish_time":1503437530671,"contributors":[]},"0.1.0":{"name":"diagnostic-channel","version":"0.1.0","main":"./.dist/channel.js","types":"./.dist/channel.d.ts","scripts":{"build":"tsc --outDir ./.dist","lint":"tslint -c tslint.json -p tsconfig.json","clean":"rimraf ./.dist","prepublish":"npm run lint && npm run build","test":"npm run build && mocha ./.dist/tests/**/*.js"},"dependencies":{"semver":"^5.3.0"},"devDependencies":{"@types/mocha":"^2.2.40","@types/node":"^7.0.12","mocha":"^3.2.0","rimraf":"^2.6.1","tslint":"^5.0.0","typescript":"^2.2.1"},"files":[".dist/*.d.ts",".dist/*.js","LICENSE","README.md","package.json"],"license":"MIT","description":"This package is intended to connect event 'publishers' to event 'subscribers' in such a way that the 'context' of the event is preserved. The exact nature of 'context' is deliberately left unspecified.","_id":"diagnostic-channel@0.1.0","_shasum":"7a6ad8ad5066bac544da0a379ba174ba362a57cf","_resolved":"file:diagnostic-channel-0.1.0.tgz","_from":"diagnostic-channel-0.1.0.tgz","_npmVersion":"4.1.2","_nodeVersion":"7.7.4","_npmUser":{"name":"anonymous","email":"jithomso@microsoft.com"},"dist":{"shasum":"7a6ad8ad5066bac544da0a379ba174ba362a57cf","size":5579,"noattachment":false,"tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/diagnostic-channel/-/diagnostic-channel-0.1.0.tgz"},"maintainers":[{"name":"anonymous","email":"jackpeterhorton@gmail.com"},{"name":"anonymous","email":"jithomso@microsoft.com"},{"name":"anonymous","email":"josh.gavant@outlook.com"},{"name":"anonymous","email":"npmjs@microsoft.com"},{"name":"anonymous","email":"mkaufman@microsoft.com"},{"name":"anonymous","email":"osvaldo@osvaldojr.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/diagnostic-channel-0.1.0.tgz_1493939395456_0.8265960759017617"},"directories":{},"publish_time":1493939396763,"_hasShrinkwrap":false,"_cnpm_publish_time":1493939396763,"contributors":[]},"0.0.0":{"name":"diagnostic-channel","version":"0.0.0","main":"index.js","license":"MIT","gitHead":"90891f134683e693d9023de10fcb80295255ced5","_id":"diagnostic-channel@0.0.0","scripts":{},"_shasum":"3ce0992261abadf62eb78ac9519cba26bdb63a14","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.9.4","_npmUser":{"name":"anonymous","email":"npmjs@microsoft.com"},"dist":{"shasum":"3ce0992261abadf62eb78ac9519cba26bdb63a14","size":225,"noattachment":false,"tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/diagnostic-channel/-/diagnostic-channel-0.0.0.tgz"},"maintainers":[{"name":"anonymous","email":"jackpeterhorton@gmail.com"},{"name":"anonymous","email":"jithomso@microsoft.com"},{"name":"anonymous","email":"josh.gavant@outlook.com"},{"name":"anonymous","email":"npmjs@microsoft.com"},{"name":"anonymous","email":"mkaufman@microsoft.com"},{"name":"anonymous","email":"osvaldo@osvaldojr.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/diagnostic-channel-0.0.0.tgz_1493938186152_0.9742514376994222"},"directories":{},"publish_time":1493938186415,"_hasShrinkwrap":false,"_cnpm_publish_time":1493938186415,"contributors":[]},"1.0.0":{"name":"diagnostic-channel","version":"1.0.0","main":"./dist/src/channel.js","types":"./dist/src/channel.d.ts","scripts":{"build":"tsc","lint":"tslint -c tslint.json -p tsconfig.json","clean":"rimraf ./dist","test":"mocha ./dist/tests/**/*.js"},"homepage":"https://github.com/Microsoft/node-diagnostic-channel","bugs":{"url":"https://github.com/Microsoft/node-diagnostic-channel/issues"},"repository":{"type":"git","url":"git+https://github.com/Microsoft/node-diagnostic-channel.git"},"description":"","dependencies":{"semver":"^5.3.0"},"devDependencies":{"@types/mocha":"^2.2.40","@types/node":"~8.0.0","mocha":"^3.2.0","rimraf":"^2.6.1","tslint":"^5.0.0","typescript":"4.1.2"},"license":"MIT","_id":"diagnostic-channel@1.0.0","_nodeVersion":"14.16.1","_npmVersion":"6.14.12","_npmUser":{"name":"anonymous","email":"appinsightssdk@microsoft.com"},"maintainers":[{"name":"anonymous","email":"appinsights@microsoft.com"}],"dist":{"shasum":"6d5611784ddb3d48086dd45a07d7431a945200aa","size":5657,"noattachment":false,"tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/diagnostic-channel/-/diagnostic-channel-1.0.0.tgz"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/diagnostic-channel_1.0.0_1620672018357_0.611400362826042"},"_hasShrinkwrap":false,"publish_time":1620672018739,"_cnpm_publish_time":1620672018739,"contributors":[]},"1.1.0":{"name":"diagnostic-channel","version":"1.1.0","main":"./dist/src/channel.js","types":"./dist/src/channel.d.ts","scripts":{"build":"tsc","lint":"tslint -c tslint.json -p tsconfig.json","clean":"rimraf ./dist","test":"mocha ./dist/tests/**/*.js","debug":"mocha --inspect-brk ./dist/tests/**/*.js"},"homepage":"https://github.com/Microsoft/node-diagnostic-channel","bugs":{"url":"https://github.com/Microsoft/node-diagnostic-channel/issues"},"repository":{"type":"git","url":"git+https://github.com/Microsoft/node-diagnostic-channel.git"},"description":"Provides a context-saving pub/sub channel to connect diagnostic event publishers and subscribers","dependencies":{"semver":"^5.3.0"},"devDependencies":{"@types/mocha":"^2.2.40","@types/node":"~8.0.0","mocha":"^3.2.0","rimraf":"^2.6.1","sinon":"1.17.6","tslint":"^5.0.0","typescript":"4.1.2"},"license":"MIT","gitHead":"e3176c0c9dd371e9eaea6f9c103a9b49c9742538","_id":"diagnostic-channel@1.1.0","_nodeVersion":"16.13.2","_npmVersion":"8.1.2","dist":{"integrity":"sha512-fwujyMe1gj6rk6dYi9hMZm0c8Mz8NDMVl2LB4iaYh3+LIAThZC8RKFGXWG0IML2OxAit/ZFRgZhMkhQ3d/bobQ==","shasum":"6985e9dfedfbc072d91dc4388477e4087147756e","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/diagnostic-channel/-/diagnostic-channel-1.1.0.tgz","fileCount":7,"unpackedSize":20817,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh+FeTCRA9TVsSAnZWagAAD78P/AknYDciuKkOOUKVr7n5\ndbmBIP3PoFylc6y2XFHEB0ZGmUqBYHGXwdgJH7RRQYfRYdQAvjXiWZkx3Dru\nDOFSv77a8jGxEOknRbx0yXb+vA+s0Pa/2gDLs3uNZbSQLhkGZZ5R2A2QwrHg\nCELdVPjNfCD/DaCrH9NLY0LmyldDctVxxdAV6tgMZiFgXYWvMF58PChU5/Rf\nx6pCQ1V3/R4odly0vUl25DY7ja2zShJTjlw4u9Fwy81my6KNf88rbJ1KvdVW\nnJMDXC0bRIlbarU6Jgnqel1BNuBGvnWHyT6PpOGJoKwcJ1P8gg1KJSJoJOBM\n7gVsacISytXpCFUPCZL95T3NlT26hjRddlwzg1lb2aYQLAZR4hvdMXODi5Ox\nyaZMMx9sy4FPESHAXNnMl0vqt2l2O3qk0icVghTjL1IV+eVFoQeao9THa1KI\ntEt4acRQ3Jfpgb7ApaSNfOy9m3nMg6vdVhow+GwZImp2SDjNucDXJtQaKnKP\nSpZwQvkjRAkP3JFNuIMEk2txDB81E1oy40W1McQhMc3w1D8f5JrLZrf6Nnyd\n4Bz9eO/7WenvKMNwnv6QI6R15H9jnQzg+CFug28y9AVU+7zNYxnO3cPDRpRw\n74/0/f8EkRRDsZRjjIifS5iaeLnWCfpCmWTbOQqqHilzWY44FssVeZb8KT+F\niT39\r\n=ZkCR\r\n-----END PGP SIGNATURE-----\r\n","size":6092},"_npmUser":{"name":"anonymous","email":"appinsightssdk@microsoft.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"appinsightssdk@microsoft.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/diagnostic-channel_1.1.0_1643665299843_0.6998975054800174"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-01-31T21:41:45.274Z","contributors":[]},"1.1.1":{"name":"diagnostic-channel","version":"1.1.1","main":"./dist/src/channel.js","types":"./dist/src/channel.d.ts","scripts":{"build":"tsc","lint":"eslint ./ --fix","clean":"rimraf ./dist","test":"mocha ./dist/tests/**/*.js","debug":"mocha --inspect-brk ./dist/tests/**/*.js"},"homepage":"https://github.com/Microsoft/node-diagnostic-channel","bugs":{"url":"https://github.com/Microsoft/node-diagnostic-channel/issues"},"repository":{"type":"git","url":"git+https://github.com/Microsoft/node-diagnostic-channel.git"},"description":"Provides a context-saving pub/sub channel to connect diagnostic event publishers and subscribers","dependencies":{"semver":"^7.5.3"},"devDependencies":{"@types/mocha":"^2.2.40","@types/node":"~8.0.0","mocha":"^3.2.0","rimraf":"^2.6.1","sinon":"1.17.6","typescript":"4.1.2"},"license":"MIT","gitHead":"fe33522877421c63502fb66485cce27954fc28fa","_id":"diagnostic-channel@1.1.1","_nodeVersion":"18.17.0","_npmVersion":"9.6.7","dist":{"integrity":"sha512-r2HV5qFkUICyoaKlBEpLKHjxMXATUf/l+h8UZPGBHGLy4DDiY2sOLcIctax4eRnTw5wH2jTMExLntGPJ8eOJxw==","shasum":"44b60972de9ee055c16216535b0e9db3f6a0efd0","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/diagnostic-channel/-/diagnostic-channel-1.1.1.tgz","fileCount":7,"unpackedSize":23315,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIC+o4LOoapsi0/fy6HGH160Mv8atUnHqenVE6H3A1O/0AiBJS6gdJ6hR/Y7cjpDjMPqQN/7KB1GSvisVvRVexHxvbQ=="}]},"_npmUser":{"name":"anonymous","email":"appinsightssdk@microsoft.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"appinsightssdk@microsoft.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/diagnostic-channel_1.1.1_1691530673917_0.02187845789911269"},"_hasShrinkwrap":false,"contributors":[]}},"dist-tags":{"latest":"1.1.1"},"name":"diagnostic-channel","time":{"modified":"2026-04-23T03:26:26.846Z","created":"2022-01-27T15:54:19.195Z","0.3.1":"2019-10-31T18:44:35.526Z","0.3.0":"2019-10-29T19:30:14.572Z","0.2.0":"2017-08-22T21:32:10.671Z","0.1.0":"2017-05-04T23:09:56.763Z","0.0.0":"2017-05-04T22:49:46.415Z","1.0.0":"2021-05-10T18:40:18.739Z","1.1.0":"2022-01-31T21:41:39.967Z","1.1.1":"2023-08-08T21:37:54.052Z"},"readme":"# diagnostic-channel\r\n\r\nThis package provides a channel to connect diagnostic event publishers and subscribers. It includes a way to preserve context for the published event too. What that context is and contains is deliberately left unspecified.\r\n\r\n## Usage\r\n\r\n### Subscribe to an event:\r\n\r\n```js\r\nconst channel = require('diagnostic-channel').channel;\r\n\r\nchannel.subscribe('someEvent', function (event) {\r\n    // do something about the event\r\n});\r\n```\r\n\r\nThe properties of the `event` object passed to the subscriber handler function\r\nare determined by the publisher.\r\n\r\n### Publish an event\r\n\r\n```js\r\nvar someData = { myField: \"myData\" };\r\nconst channel = require('diagnostic-channel').channel;\r\n\r\nchannel.publish('someEvent', someData);\r\n```\r\n\r\n### Publish an event with context\r\n\r\nPreserving context on publication may require some additional effort. A\r\ncorrelation handler can be added with the `addContextPreservation` method, and\r\nthen the `bindToContext` method can be used to set up context using the\r\nprovided handler before calling its received function.\r\n\r\n```js\r\nchannel.addContextPreservation((callback) => {\r\n    return Zone.current.wrap(callback);\r\n});\r\n\r\nfunction doWork(args, callback) {\r\n    // In some context...\r\n    doBatchedAsyncWork(args, channel.bindToContext((result) => {\r\n        channel.publish('someEvent', {result: result});\r\n        callback(result);\r\n    }))\r\n}\r\n```\r\n\r\n## API\r\n\r\n### subscribe\r\n\r\n`channel.subscribe(name: string, callback: (event: any) => void): void`\r\n\r\nRegister the callback to be called when `publish` is invoked with a matching name. The callback will be given the object that is passed to the `publish` call.\r\n\r\nIf the callback throws an error, it will be silently ignored. If the callback modifies the event object, any subsequent subscribers will see the modified object, and it may also impact the original code's execution.\r\n\r\n### publish\r\n\r\n`channel.publish(name: string, event: any): void`\r\n\r\nTrigger each subscribed callback for the same named event, passing the `event` object to each.\r\n\r\nSubscribers may modify the event object.\r\n\r\n### unsubscribe\r\n\r\n`channel.unsubscribe(name: string, callback: (event: any) => void): void`\r\n\r\nRemove a previously registered callback from the named event. This uses function equality so it must be a reference to the same function, not an equivalent function.\r\n\r\n### addContextPreservation\r\n\r\n`channel.addContextPreservation(preserver: (callback: Function) => Function)`\r\n\r\nPushes the provided context preservation function onto a 'stack' of functions to preserve context.\r\n\r\nThe context preservation function `preserver` is expected to capture the current context and return a function that when invoked restores this preserved context and only then calls the provided callback with the originally provided arguments. Before returning, this second function should also restore the previous context.\r\n\r\nA simple example preserving the Zone.js context:\r\n\r\n```js\r\nchannel.addContextPreservation((callback) => {\r\n    return Zone.current.wrap(callback);\r\n});\r\n```\r\n\r\nA more general, but somewhat contrived, example, where the 'context' is a global object called `context`:\r\n\r\n```js\r\nvar context = { value: 1 };\r\n\r\nchannel.addContextPreservation((callback) => {\r\n    var preservedContext = context;\r\n    return function () {\r\n        var priorContext = context;\r\n        context = preservedContext;\r\n        var result = callback.apply(this, arguments);\r\n        context = priorContext;\r\n        return result;\r\n    }\r\n});\r\n```\r\n\r\n### bindToContext\r\n\r\n`channel.bindToContext(callback: Function)`\r\n\r\nReturns a function which will call the callback after applying each of the registered context preservation functions, and return the result of the callback after unwinding each of the context preservation functions.\r\n\r\nFor example, when using Zone.js:\r\n\r\n```js\r\nchannel.addContextPreservation((callback) => Zone.current.wrap(callback));\r\n\r\nvar z1 = Zone.current.fork({name: 'zone 1'});\r\nvar z2 = Zone.current.fork({name: 'zone 2'});\r\n\r\nvar z1BoundFunc = z1.run(() => channel.bindToContext(() => Zone.current.name));\r\n\r\nvar result = z2.run(() => z1BoundFunc());\r\n```\r\n\r\nBecause the function was bound in `zone 1`, `result` will be `zone 1`.\r\n\r\n### registerMonkeyPatch\r\n\r\n`channel.registerMonkeyPatch(packageName: string, patcher: {versionSpecifier: string, patch: (any, path: string) => any})`;\r\n\r\nIn order to inject publishing and context preservation behavior into third party libraries, we support monkey patching libraries as they are `require`'d.\r\n\r\nCalling this function will register a candidate monkey patcher to be applied when a future `require(packageName)` is called. If the package's version is a semver match for the `versionSpecifier` range, then the original object for that package is passed to the `patch` function, along with the path to the module, and the `patch` function should return a patched version which will end up as the result of the `require`.\r\n\r\nFor a simple example where we patch a `doSomethingAsync` method of the `foo` module to preserve the current context when invoking a callback:\r\n\r\n```js\r\nfunction patchFunction(originalPackage, packagePath) {\r\n    var originalFooAsync = foo.doSomethingAsync;\r\n    foo.doSomethingAsync = function () {\r\n        var callback = arguments[arguments.length-1];\r\n        if (callback && typeof callback == 'function') {\r\n            arguments[arguments.length-1] = channel.bindToContext(callback);\r\n        }\r\n        return originalFooAsync.apply(this, arguments);\r\n    }\r\n    return originalPackage;\r\n}\r\n\r\nvar patcher = {\r\n    versionSpecifier: \">= 1.0.0 < 2.0.0\",\r\n    patch: patchFunction\r\n};\r\n\r\nchannel.registerMonkeyPatch('foo', patcher);\r\n\r\nvar foo = require('foo');\r\n// Now foo.doSomethingAsync will be the patched version, assuming that the version of the foo package found by require() falls within the 1.0.0 - 2.0.0 range.\r\n```\r\n\r\n## Contributing\r\n\r\nThis project welcomes contributions and suggestions. Most contributions require you to\r\nagree to a Contributor License Agreement (CLA) declaring that you have the right to,\r\nand actually do, grant us the rights to use your contribution. For details, visit\r\nhttps://cla.microsoft.com.\r\n\r\nWhen you submit a pull request, a CLA-bot will automatically determine whether you need\r\nto provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the\r\ninstructions provided by the bot. You will only need to do this once across all repositories using our CLA.\r\n\r\nThis project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).\r\nFor more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)\r\nor contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.\r\n\r\n## Data Collection\r\n\r\nAs this SDK is designed to enable applications to perform data collection which is sent to the Microsoft collection endpoints the following is required to identify our privacy statement.\r\n\r\nThe software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft’s privacy statement. Our privacy statement is located at https://go.microsoft.com/fwlink/?LinkID=824704. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.\r\n\r\n## Trademarks\r\n\r\nThis project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow [Microsoft’s Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general). Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party’s policies.\r\n\r\n## License\r\n\r\n[MIT](LICENSE)","users":{}}