@zuplo/core 5.1952.0 → 5.1956.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +6 -5
- package/index.minified.js +251 -251
- package/package.json +2 -2
- package/polyfills/diagnostics_channel.js +0 -155
package/package.json
CHANGED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
// Source: https://github.com/simon-id/diagnostics_channel-polyfill/tree/master
|
|
3
|
-
|
|
4
|
-
// Port from node core lib/internal/errors.js
|
|
5
|
-
class ERR_INVALID_ARG_TYPE extends TypeError {
|
|
6
|
-
constructor(message, actual) {
|
|
7
|
-
super();
|
|
8
|
-
|
|
9
|
-
if (actual == null) {
|
|
10
|
-
message += `. Received ${actual}`;
|
|
11
|
-
} else if (typeof actual === "function" && actual.name) {
|
|
12
|
-
message += `. Received function ${actual.name}`;
|
|
13
|
-
} else if (typeof actual === "object") {
|
|
14
|
-
if (actual.constructor && actual.constructor.name) {
|
|
15
|
-
message += `. Received an instance of ${actual.constructor.name}`;
|
|
16
|
-
} else {
|
|
17
|
-
const inspected = util.inspect(actual, { depth: -1 });
|
|
18
|
-
message += `. Received ${inspected}`;
|
|
19
|
-
}
|
|
20
|
-
} else {
|
|
21
|
-
let inspected = util.inspect(actual, { colors: false });
|
|
22
|
-
if (inspected.length > 25) {
|
|
23
|
-
inspected = `${inspected.slice(0, 25)}...`;
|
|
24
|
-
}
|
|
25
|
-
message += `. Received type ${typeof actual} (${inspected})`;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
this.code = this.constructor.name;
|
|
29
|
-
|
|
30
|
-
Object.defineProperties(this, {
|
|
31
|
-
message: {
|
|
32
|
-
value: message,
|
|
33
|
-
enumerable: false,
|
|
34
|
-
writable: true,
|
|
35
|
-
configurable: true,
|
|
36
|
-
},
|
|
37
|
-
toString: {
|
|
38
|
-
value() {
|
|
39
|
-
return `${this.name} [${this.code}]: ${this.message}`;
|
|
40
|
-
},
|
|
41
|
-
enumerable: false,
|
|
42
|
-
writable: true,
|
|
43
|
-
configurable: true,
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
class ActiveChannel {
|
|
50
|
-
subscribe(subscription) {
|
|
51
|
-
if (typeof subscription !== "function") {
|
|
52
|
-
throw new ERR_INVALID_ARG_TYPE(
|
|
53
|
-
'The "subscription" argument must be of type function',
|
|
54
|
-
subscription
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
this._subscribers.push(subscription);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
unsubscribe(subscription) {
|
|
61
|
-
const index = this._subscribers.indexOf(subscription);
|
|
62
|
-
if (index === -1) return false;
|
|
63
|
-
|
|
64
|
-
this._subscribers.splice(index, 1);
|
|
65
|
-
|
|
66
|
-
// When there are no more active subscribers, restore to fast prototype.
|
|
67
|
-
if (!this._subscribers.length) {
|
|
68
|
-
// eslint-disable-next-line no-use-before-define
|
|
69
|
-
Object.setPrototypeOf(this, Channel.prototype);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return true;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
get hasSubscribers() {
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
publish(data) {
|
|
80
|
-
for (let i = 0; i < this._subscribers.length; i++) {
|
|
81
|
-
try {
|
|
82
|
-
const onMessage = this._subscribers[i];
|
|
83
|
-
onMessage(data, this.name);
|
|
84
|
-
} catch (err) {
|
|
85
|
-
process.nextTick(() => {
|
|
86
|
-
throw err;
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export class Channel {
|
|
94
|
-
constructor(name) {
|
|
95
|
-
this._subscribers = undefined;
|
|
96
|
-
this.name = name;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
static [Symbol.hasInstance](instance) {
|
|
100
|
-
const prototype = Object.getPrototypeOf(instance);
|
|
101
|
-
return (
|
|
102
|
-
prototype === Channel.prototype || prototype === ActiveChannel.prototype
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
subscribe(subscription) {
|
|
107
|
-
Object.setPrototypeOf(this, ActiveChannel.prototype);
|
|
108
|
-
this._subscribers = [];
|
|
109
|
-
this.subscribe(subscription);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
unsubscribe() {
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
get hasSubscribers() {
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
publish() {}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const channels = {};
|
|
124
|
-
|
|
125
|
-
export function channel(name) {
|
|
126
|
-
const channel = channels[name];
|
|
127
|
-
if (channel) return channel;
|
|
128
|
-
|
|
129
|
-
if (typeof name !== "string" && typeof name !== "symbol") {
|
|
130
|
-
throw new ERR_INVALID_ARG_TYPE(
|
|
131
|
-
'The "channel" argument must be one of type string or symbol',
|
|
132
|
-
name
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return (channels[name] = new Channel(name));
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export function hasSubscribers(name) {
|
|
140
|
-
const channel = channels[name];
|
|
141
|
-
if (!channel) {
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return channel.hasSubscribers;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export function deleteChannel(name) {
|
|
149
|
-
if (channels[name]) {
|
|
150
|
-
channels[name] = null;
|
|
151
|
-
return true;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return false;
|
|
155
|
-
}
|