worker-timers-broker 6.0.76 → 6.0.78
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/build/es5/bundle.js +7 -25
- package/package.json +19 -19
package/build/es5/bundle.js
CHANGED
|
@@ -15,25 +15,19 @@
|
|
|
15
15
|
var load = function load(url) {
|
|
16
16
|
// Prefilling the Maps with a function indexed by zero is necessary to be compliant with the specification.
|
|
17
17
|
var scheduledIntervalFunctions = new Map([[0, function () {}]]); // tslint:disable-line no-empty
|
|
18
|
-
|
|
19
18
|
var scheduledTimeoutFunctions = new Map([[0, function () {}]]); // tslint:disable-line no-empty
|
|
20
|
-
|
|
21
19
|
var unrespondedRequests = new Map();
|
|
22
20
|
var worker = new Worker(url);
|
|
23
21
|
worker.addEventListener('message', function (_ref) {
|
|
24
22
|
var data = _ref.data;
|
|
25
|
-
|
|
26
23
|
if (isCallNotification(data)) {
|
|
27
24
|
var _data$params = data.params,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
timerId = _data$params.timerId,
|
|
26
|
+
timerType = _data$params.timerType;
|
|
31
27
|
if (timerType === 'interval') {
|
|
32
28
|
var idOrFunc = scheduledIntervalFunctions.get(timerId);
|
|
33
|
-
|
|
34
29
|
if (typeof idOrFunc === 'number') {
|
|
35
30
|
var timerIdAndTimerType = unrespondedRequests.get(idOrFunc);
|
|
36
|
-
|
|
37
31
|
if (timerIdAndTimerType === undefined || timerIdAndTimerType.timerId !== timerId || timerIdAndTimerType.timerType !== timerType) {
|
|
38
32
|
throw new Error('The timer is in an undefined state.');
|
|
39
33
|
}
|
|
@@ -44,17 +38,14 @@
|
|
|
44
38
|
}
|
|
45
39
|
} else if (timerType === 'timeout') {
|
|
46
40
|
var _idOrFunc = scheduledTimeoutFunctions.get(timerId);
|
|
47
|
-
|
|
48
41
|
if (typeof _idOrFunc === 'number') {
|
|
49
42
|
var _timerIdAndTimerType = unrespondedRequests.get(_idOrFunc);
|
|
50
|
-
|
|
51
43
|
if (_timerIdAndTimerType === undefined || _timerIdAndTimerType.timerId !== timerId || _timerIdAndTimerType.timerType !== timerType) {
|
|
52
44
|
throw new Error('The timer is in an undefined state.');
|
|
53
45
|
}
|
|
54
46
|
} else if (typeof _idOrFunc !== 'undefined') {
|
|
55
|
-
_idOrFunc();
|
|
56
|
-
|
|
57
|
-
|
|
47
|
+
_idOrFunc();
|
|
48
|
+
// A timeout can be savely deleted because it is only called once.
|
|
58
49
|
scheduledTimeoutFunctions["delete"](timerId);
|
|
59
50
|
} else {
|
|
60
51
|
throw new Error('The timer is in an undefined state.');
|
|
@@ -62,17 +53,13 @@
|
|
|
62
53
|
}
|
|
63
54
|
} else if (isClearResponse(data)) {
|
|
64
55
|
var id = data.id;
|
|
65
|
-
|
|
66
56
|
var _timerIdAndTimerType2 = unrespondedRequests.get(id);
|
|
67
|
-
|
|
68
57
|
if (_timerIdAndTimerType2 === undefined) {
|
|
69
58
|
throw new Error('The timer is in an undefined state.');
|
|
70
59
|
}
|
|
71
|
-
|
|
72
60
|
var _timerId = _timerIdAndTimerType2.timerId,
|
|
73
|
-
|
|
61
|
+
_timerType = _timerIdAndTimerType2.timerType;
|
|
74
62
|
unrespondedRequests["delete"](id);
|
|
75
|
-
|
|
76
63
|
if (_timerType === 'interval') {
|
|
77
64
|
scheduledIntervalFunctions["delete"](_timerId);
|
|
78
65
|
} else {
|
|
@@ -83,7 +70,6 @@
|
|
|
83
70
|
throw new Error(message);
|
|
84
71
|
}
|
|
85
72
|
});
|
|
86
|
-
|
|
87
73
|
var clearInterval = function clearInterval(timerId) {
|
|
88
74
|
var id = fastUniqueNumbers.generateUniqueNumber(unrespondedRequests);
|
|
89
75
|
unrespondedRequests.set(id, {
|
|
@@ -100,7 +86,6 @@
|
|
|
100
86
|
}
|
|
101
87
|
});
|
|
102
88
|
};
|
|
103
|
-
|
|
104
89
|
var clearTimeout = function clearTimeout(timerId) {
|
|
105
90
|
var id = fastUniqueNumbers.generateUniqueNumber(unrespondedRequests);
|
|
106
91
|
unrespondedRequests.set(id, {
|
|
@@ -117,12 +102,11 @@
|
|
|
117
102
|
}
|
|
118
103
|
});
|
|
119
104
|
};
|
|
120
|
-
|
|
121
105
|
var setInterval = function setInterval(func, delay) {
|
|
122
106
|
var timerId = fastUniqueNumbers.generateUniqueNumber(scheduledIntervalFunctions);
|
|
123
107
|
scheduledIntervalFunctions.set(timerId, function () {
|
|
124
|
-
func();
|
|
125
|
-
|
|
108
|
+
func();
|
|
109
|
+
// Doublecheck if the interval should still be rescheduled because it could have been cleared inside of func().
|
|
126
110
|
if (typeof scheduledIntervalFunctions.get(timerId) === 'function') {
|
|
127
111
|
worker.postMessage({
|
|
128
112
|
id: null,
|
|
@@ -148,7 +132,6 @@
|
|
|
148
132
|
});
|
|
149
133
|
return timerId;
|
|
150
134
|
};
|
|
151
|
-
|
|
152
135
|
var setTimeout = function setTimeout(func, delay) {
|
|
153
136
|
var timerId = fastUniqueNumbers.generateUniqueNumber(scheduledTimeoutFunctions);
|
|
154
137
|
scheduledTimeoutFunctions.set(timerId, func);
|
|
@@ -164,7 +147,6 @@
|
|
|
164
147
|
});
|
|
165
148
|
return timerId;
|
|
166
149
|
};
|
|
167
|
-
|
|
168
150
|
return {
|
|
169
151
|
clearInterval: clearInterval,
|
|
170
152
|
clearTimeout: clearTimeout,
|
package/package.json
CHANGED
|
@@ -9,30 +9,30 @@
|
|
|
9
9
|
}
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@babel/runtime": "^7.
|
|
13
|
-
"fast-unique-numbers": "^6.0.
|
|
14
|
-
"tslib": "^2.4.
|
|
15
|
-
"worker-timers-worker": "^7.0.
|
|
12
|
+
"@babel/runtime": "^7.20.1",
|
|
13
|
+
"fast-unique-numbers": "^6.0.23",
|
|
14
|
+
"tslib": "^2.4.1",
|
|
15
|
+
"worker-timers-worker": "^7.0.44"
|
|
16
16
|
},
|
|
17
17
|
"description": "The broker which is used by the worker-timers package.",
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@babel/core": "^7.19.
|
|
19
|
+
"@babel/core": "^7.19.6",
|
|
20
20
|
"@babel/plugin-external-helpers": "^7.18.6",
|
|
21
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
22
|
-
"@babel/preset-env": "^7.19.
|
|
23
|
-
"@commitlint/cli": "^17.
|
|
24
|
-
"@commitlint/config-angular": "^17.
|
|
21
|
+
"@babel/plugin-transform-runtime": "^7.19.6",
|
|
22
|
+
"@babel/preset-env": "^7.19.4",
|
|
23
|
+
"@commitlint/cli": "^17.2.0",
|
|
24
|
+
"@commitlint/config-angular": "^17.2.0",
|
|
25
25
|
"@rollup/plugin-babel": "^5.3.1",
|
|
26
26
|
"chai": "^4.3.6",
|
|
27
27
|
"commitizen": "^4.2.5",
|
|
28
28
|
"cz-conventional-changelog": "^3.3.0",
|
|
29
|
-
"eslint": "^8.
|
|
30
|
-
"eslint-config-holy-grail": "^52.0.
|
|
29
|
+
"eslint": "^8.26.0",
|
|
30
|
+
"eslint-config-holy-grail": "^52.0.33",
|
|
31
31
|
"grunt": "^1.5.3",
|
|
32
32
|
"grunt-cli": "^1.4.3",
|
|
33
33
|
"grunt-sh": "^0.2.0",
|
|
34
34
|
"husky": "^8.0.1",
|
|
35
|
-
"karma": "^6.4.
|
|
35
|
+
"karma": "^6.4.1",
|
|
36
36
|
"karma-chrome-launcher": "^3.1.1",
|
|
37
37
|
"karma-firefox-launcher": "^2.1.2",
|
|
38
38
|
"karma-mocha": "^2.0.1",
|
|
@@ -41,18 +41,18 @@
|
|
|
41
41
|
"karma-sinon-chai": "^2.0.2",
|
|
42
42
|
"karma-webpack": "^5.0.0",
|
|
43
43
|
"load-grunt-config": "^4.0.1",
|
|
44
|
-
"mocha": "^10.
|
|
44
|
+
"mocha": "^10.1.0",
|
|
45
45
|
"prettier": "^2.7.1",
|
|
46
46
|
"pretty-quick": "^3.1.3",
|
|
47
47
|
"rimraf": "^3.0.2",
|
|
48
|
-
"rollup": "^2.79.
|
|
49
|
-
"sinon": "^14.0.
|
|
48
|
+
"rollup": "^2.79.1",
|
|
49
|
+
"sinon": "^14.0.1",
|
|
50
50
|
"sinon-chai": "^3.7.0",
|
|
51
|
-
"ts-loader": "^9.
|
|
51
|
+
"ts-loader": "^9.4.1",
|
|
52
52
|
"tsconfig-holy-grail": "^11.1.36",
|
|
53
53
|
"tslint": "^6.1.3",
|
|
54
|
-
"tslint-config-holy-grail": "^53.2.
|
|
55
|
-
"typescript": "^4.8.
|
|
54
|
+
"tslint-config-holy-grail": "^53.2.34",
|
|
55
|
+
"typescript": "^4.8.4",
|
|
56
56
|
"webpack": "^5.74.0"
|
|
57
57
|
},
|
|
58
58
|
"files": [
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"test": "grunt lint && grunt test"
|
|
76
76
|
},
|
|
77
77
|
"types": "build/es2019/module.d.ts",
|
|
78
|
-
"version": "6.0.
|
|
78
|
+
"version": "6.0.78"
|
|
79
79
|
}
|