-
Notifications
You must be signed in to change notification settings - Fork 0
/
acquire-channel-registry.js
33 lines (29 loc) · 1.06 KB
/
acquire-channel-registry.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* This file allows for a global shared channels registry
* across multiple installed versions of this package.
*
* Without such a registry, if someone were to have versions
* 1.0.0 and 1.0.1 both installed in their node_modules directory,
* then there would be two unrelated channel collections. This
* would thus not allow the two collections to communicate
* across each others channels.
*
* Of course, when using the built-in diagnostics_channel, this
* isn't a problem, as the different versions of this package all
* share the same internal channels registry.
*
* We're attaching this to process instead of global as there are
* test suites which make sure globals don't get polluted between
* test runs.
*/
const { ObjectDefineProperty, SymbolFor } = require('./primordials.js');
const REGISTRY_SYMBOL = SymbolFor('dc-polyfill-v1');
if (!process[REGISTRY_SYMBOL]) {
ObjectDefineProperty(process, REGISTRY_SYMBOL, {
configurable: false,
enumerable: false,
writable: false,
value: {},
});
}
module.exports = process[REGISTRY_SYMBOL];