@art-ws/common 2.0.2 → 2.0.4
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/dist/es/heart-beat/heart-beat.class.js +1 -1
- package/dist/es/index.d.ts +4 -5
- package/dist/es/index.js +4 -5
- package/dist/es/managed-pool/managed-pool.js +1 -1
- package/dist/es/mem-cache/memory-cache.js +1 -1
- package/package.json +2 -2
- package/dist/es/node-zone.d.ts +0 -22
- package/dist/es/node-zone.js +0 -120
@@ -3,7 +3,7 @@ import { EventEmitter } from "events";
|
|
3
3
|
const TICK_EVENT = "TICK_EVENT";
|
4
4
|
const DEFAULT_INTERVAL = 5 * 1000;
|
5
5
|
export class HeartBeatBase {
|
6
|
-
logger = getLogger(
|
6
|
+
logger = getLogger(HeartBeatBase);
|
7
7
|
id = 0;
|
8
8
|
interval = DEFAULT_INTERVAL;
|
9
9
|
active = false;
|
package/dist/es/index.d.ts
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
export * from "./cancellation";
|
2
2
|
export * from "./heart-beat";
|
3
|
-
export * from "./managed-pool";
|
4
|
-
export * from "./mem-cache";
|
5
|
-
export * from "./object-hash";
|
6
|
-
export * from "./shared";
|
7
3
|
export * from "./hr-time";
|
8
4
|
export * from "./interpolate";
|
9
5
|
export * from "./json-file-loader";
|
10
6
|
export * from "./json-refs-resolver";
|
7
|
+
export * from "./managed-pool";
|
11
8
|
export * from "./managed-promise";
|
12
|
-
export * from "./
|
9
|
+
export * from "./mem-cache";
|
10
|
+
export * from "./object-hash";
|
11
|
+
export * from "./shared";
|
package/dist/es/index.js
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
// created from 'create-ts-index'
|
2
2
|
export * from "./cancellation";
|
3
3
|
export * from "./heart-beat";
|
4
|
-
export * from "./managed-pool";
|
5
|
-
export * from "./mem-cache";
|
6
|
-
export * from "./object-hash";
|
7
|
-
export * from "./shared";
|
8
4
|
export * from "./hr-time";
|
9
5
|
export * from "./interpolate";
|
10
6
|
export * from "./json-file-loader";
|
11
7
|
export * from "./json-refs-resolver";
|
8
|
+
export * from "./managed-pool";
|
12
9
|
export * from "./managed-promise";
|
13
|
-
export * from "./
|
10
|
+
export * from "./mem-cache";
|
11
|
+
export * from "./object-hash";
|
12
|
+
export * from "./shared";
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@art-ws/common",
|
3
|
-
"version": "2.0.
|
3
|
+
"version": "2.0.4",
|
4
4
|
"description": "common",
|
5
5
|
"license": "UNLICENSED",
|
6
6
|
"type": "module",
|
@@ -20,7 +20,7 @@
|
|
20
20
|
"reflect-metadata": "^0.2.2",
|
21
21
|
"rxjs": "^7.8.2",
|
22
22
|
"tslib": "^2.8.1",
|
23
|
-
"@art-ws/slf": "2.0.
|
23
|
+
"@art-ws/slf": "2.0.2"
|
24
24
|
},
|
25
25
|
"devDependencies": {
|
26
26
|
"@types/bluebird": "^3.5.42",
|
package/dist/es/node-zone.d.ts
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
export interface ZoneSpec {
|
2
|
-
name: string;
|
3
|
-
properties?: Record<string, any>;
|
4
|
-
}
|
5
|
-
export declare class Zone {
|
6
|
-
private readonly zoneData;
|
7
|
-
private readonly zoneName;
|
8
|
-
private readonly zoneParent;
|
9
|
-
uid: number;
|
10
|
-
constructor(parent: Zone | null, spec: string | ZoneSpec | null);
|
11
|
-
get data(): Record<string, any>;
|
12
|
-
get name(): string;
|
13
|
-
get parent(): Zone | null;
|
14
|
-
fork(spec: ZoneSpec): Zone;
|
15
|
-
run<T>(callback: () => T, thisArg?: any, args?: any[]): T;
|
16
|
-
static isEnabled(): boolean;
|
17
|
-
static enable(): void;
|
18
|
-
static disable(): void;
|
19
|
-
get<T>(key: string): T | null;
|
20
|
-
getZoneWith(key: string): Zone | null;
|
21
|
-
static get current(): Zone;
|
22
|
-
}
|
package/dist/es/node-zone.js
DELETED
@@ -1,120 +0,0 @@
|
|
1
|
-
import asyncHooks from "async_hooks";
|
2
|
-
// inspired by https://raw.githubusercontent.com/JsCommunity/node-zone/master/index.js
|
3
|
-
// https://nodejs.org/api/async_hooks.html#async_hooks_init_asyncid_type_triggerasyncid_resource
|
4
|
-
// https://dzone.com/articles/beware-the-performance-cost-of-async-hooks-node-8
|
5
|
-
// https://github.com/bmeurer/async-hooks-performance-impact
|
6
|
-
const zones = Object.create(null);
|
7
|
-
let current;
|
8
|
-
const asyncHook = asyncHooks.createHook({
|
9
|
-
init(uid) {
|
10
|
-
zones[uid] = current;
|
11
|
-
if (current) {
|
12
|
-
current.uid = uid;
|
13
|
-
}
|
14
|
-
},
|
15
|
-
before(uid) {
|
16
|
-
current = zones[uid];
|
17
|
-
// it appears `init` is not called when using the `cluster` module,
|
18
|
-
// therefore `zones[uid]` might not exist in `before`
|
19
|
-
//
|
20
|
-
// Work-around: set the current zone to the root zone, it's incorrect but it
|
21
|
-
// allows using root data and create new zones by forking.
|
22
|
-
//
|
23
|
-
// see https://github.com/JsCommunity/node-zone/issues/3
|
24
|
-
if (current === undefined) {
|
25
|
-
current = root;
|
26
|
-
}
|
27
|
-
},
|
28
|
-
destroy(uid) {
|
29
|
-
delete zones[uid];
|
30
|
-
},
|
31
|
-
});
|
32
|
-
let asyncHooksEnabled = null;
|
33
|
-
const toggleAsyncHooks = (value) => {
|
34
|
-
if (value === asyncHooksEnabled) {
|
35
|
-
return;
|
36
|
-
}
|
37
|
-
asyncHooksEnabled = value;
|
38
|
-
if (asyncHooksEnabled) {
|
39
|
-
asyncHook.enable();
|
40
|
-
}
|
41
|
-
else {
|
42
|
-
asyncHook.disable();
|
43
|
-
}
|
44
|
-
};
|
45
|
-
export class Zone {
|
46
|
-
zoneData = Object.create(null);
|
47
|
-
zoneName = "root";
|
48
|
-
zoneParent = null;
|
49
|
-
uid = 0;
|
50
|
-
constructor(parent, spec) {
|
51
|
-
toggleAsyncHooks(true);
|
52
|
-
if (parent !== null) {
|
53
|
-
const data = (this.zoneData = Object.create(parent.data));
|
54
|
-
this.zoneParent = parent;
|
55
|
-
let name = "";
|
56
|
-
if (typeof spec === "string") {
|
57
|
-
name = spec;
|
58
|
-
}
|
59
|
-
else if (spec !== null) {
|
60
|
-
name = spec.name;
|
61
|
-
const { properties } = spec;
|
62
|
-
if (properties) {
|
63
|
-
for (const key in properties) {
|
64
|
-
if (properties.hasOwnProperty(key)) {
|
65
|
-
;
|
66
|
-
data[key] = properties[key];
|
67
|
-
}
|
68
|
-
}
|
69
|
-
}
|
70
|
-
}
|
71
|
-
this.zoneName = name || `${parent.name} child`;
|
72
|
-
}
|
73
|
-
}
|
74
|
-
get data() {
|
75
|
-
return this.zoneData;
|
76
|
-
}
|
77
|
-
get name() {
|
78
|
-
return this.zoneName;
|
79
|
-
}
|
80
|
-
get parent() {
|
81
|
-
return this.zoneParent;
|
82
|
-
}
|
83
|
-
fork(spec) {
|
84
|
-
return new Zone(this, spec);
|
85
|
-
}
|
86
|
-
run(callback, thisArg, args) {
|
87
|
-
const previous = current;
|
88
|
-
try {
|
89
|
-
current = this;
|
90
|
-
return callback.apply(thisArg ?? null, (args ?? []));
|
91
|
-
}
|
92
|
-
finally {
|
93
|
-
current = previous;
|
94
|
-
}
|
95
|
-
}
|
96
|
-
static isEnabled() {
|
97
|
-
return !!asyncHooksEnabled;
|
98
|
-
}
|
99
|
-
static enable() {
|
100
|
-
toggleAsyncHooks(true);
|
101
|
-
}
|
102
|
-
static disable() {
|
103
|
-
toggleAsyncHooks(false);
|
104
|
-
}
|
105
|
-
// minimal zone.js compatibility
|
106
|
-
get(key) {
|
107
|
-
return this.zoneData[key] ?? null;
|
108
|
-
}
|
109
|
-
getZoneWith(key) {
|
110
|
-
if (Object.prototype.hasOwnProperty.call(this.zoneData, key)) {
|
111
|
-
return this;
|
112
|
-
}
|
113
|
-
const parent = this.zoneParent;
|
114
|
-
return parent && parent.getZoneWith(key);
|
115
|
-
}
|
116
|
-
static get current() {
|
117
|
-
return current;
|
118
|
-
}
|
119
|
-
}
|
120
|
-
const root = (current = new Zone(null, null));
|