@gitpod/gitpod-protocol 0.1.5-test.6 → 0.1.5-tweak-workspaceconfig-origin-docs-fork.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/data/builtin-theia-plugins.json +28 -18
- package/data/gitpod-schema.json +17 -17
- package/lib/accounting-protocol.d.ts +155 -0
- package/lib/accounting-protocol.d.ts.map +1 -0
- package/lib/accounting-protocol.js +109 -0
- package/lib/accounting-protocol.js.map +1 -0
- package/lib/admin-protocol.d.ts +22 -5
- package/lib/admin-protocol.d.ts.map +1 -1
- package/lib/admin-protocol.js +16 -1
- package/lib/admin-protocol.js.map +1 -1
- package/lib/analytics.d.ts +45 -0
- package/lib/analytics.d.ts.map +1 -0
- package/lib/analytics.js +10 -0
- package/lib/analytics.js.map +1 -0
- package/lib/auth.d.ts +25 -0
- package/lib/auth.d.ts.map +1 -0
- package/lib/auth.js +16 -0
- package/lib/auth.js.map +1 -0
- package/lib/context-url.d.ts +18 -0
- package/lib/context-url.d.ts.map +1 -0
- package/lib/context-url.js +49 -0
- package/lib/context-url.js.map +1 -0
- package/lib/context-url.spec.d.ts +12 -0
- package/lib/context-url.spec.d.ts.map +1 -0
- package/lib/context-url.spec.js +73 -0
- package/lib/context-url.spec.js.map +1 -0
- package/lib/email-protocol.d.ts +2 -2
- package/lib/email-protocol.d.ts.map +1 -1
- package/lib/email-protocol.js +6 -5
- package/lib/email-protocol.js.map +1 -1
- package/lib/encryption/container-module.d.ts +1 -1
- package/lib/encryption/container-module.js +7 -5
- package/lib/encryption/container-module.js.map +1 -1
- package/lib/encryption/encryption-engine.d.ts +1 -1
- package/lib/encryption/encryption-engine.js +21 -21
- package/lib/encryption/encryption-engine.js.map +1 -1
- package/lib/encryption/encryption-engine.spec.d.ts +2 -2
- package/lib/encryption/encryption-engine.spec.d.ts.map +1 -1
- package/lib/encryption/encryption-engine.spec.js +31 -37
- package/lib/encryption/encryption-engine.spec.js.map +1 -1
- package/lib/encryption/encryption-service.d.ts +1 -1
- package/lib/encryption/encryption-service.js +31 -44
- package/lib/encryption/encryption-service.js.map +1 -1
- package/lib/encryption/key-provider.d.ts +2 -2
- package/lib/encryption/key-provider.d.ts.map +1 -1
- package/lib/encryption/key-provider.js +27 -31
- package/lib/encryption/key-provider.js.map +1 -1
- package/lib/env.d.ts +2 -3
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +21 -21
- package/lib/env.js.map +1 -1
- package/lib/gitpod-file-parser.d.ts +1 -1
- package/lib/gitpod-file-parser.js +27 -42
- package/lib/gitpod-file-parser.js.map +1 -1
- package/lib/gitpod-file-parser.spec.d.ts +1 -1
- package/lib/gitpod-file-parser.spec.js +117 -117
- package/lib/gitpod-file-parser.spec.js.map +1 -1
- package/lib/gitpod-service.d.ts +186 -34
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +239 -116
- package/lib/gitpod-service.js.map +1 -1
- package/lib/headless-workspace-log.d.ts +9 -12
- package/lib/headless-workspace-log.d.ts.map +1 -1
- package/lib/headless-workspace-log.js +5 -7
- package/lib/headless-workspace-log.js.map +1 -1
- package/lib/ide-frontend-service.d.ts +26 -0
- package/lib/ide-frontend-service.d.ts.map +1 -0
- package/lib/ide-frontend-service.js +8 -0
- package/lib/ide-frontend-service.js.map +1 -0
- package/lib/ide-protocol.d.ts +81 -0
- package/lib/ide-protocol.d.ts.map +1 -0
- package/lib/{util/without.js → ide-protocol.js} +2 -2
- package/lib/ide-protocol.js.map +1 -0
- package/lib/index.d.ts +5 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +25 -12
- package/lib/index.js.map +1 -1
- package/lib/license-protocol.d.ts +1 -1
- package/lib/license-protocol.js +2 -1
- package/lib/license-protocol.js.map +1 -1
- package/lib/messaging/browser/connection.d.ts +6 -4
- package/lib/messaging/browser/connection.d.ts.map +1 -1
- package/lib/messaging/browser/connection.js +188 -48
- package/lib/messaging/browser/connection.js.map +1 -1
- package/lib/messaging/browser/window-connection.d.ts +26 -0
- package/lib/messaging/browser/window-connection.d.ts.map +1 -0
- package/lib/messaging/browser/window-connection.js +68 -0
- package/lib/messaging/browser/window-connection.js.map +1 -0
- package/lib/messaging/client-call-metrics.d.ts +35 -0
- package/lib/messaging/client-call-metrics.d.ts.map +1 -0
- package/lib/messaging/client-call-metrics.js +83 -0
- package/lib/messaging/client-call-metrics.js.map +1 -0
- package/lib/messaging/connection-error-handler.js +12 -23
- package/lib/messaging/connection-error-handler.js.map +1 -1
- package/lib/messaging/error.d.ts +6 -2
- package/lib/messaging/error.d.ts.map +1 -1
- package/lib/messaging/error.js +13 -4
- package/lib/messaging/error.js.map +1 -1
- package/lib/messaging/handler.d.ts +10 -0
- package/lib/messaging/handler.d.ts.map +1 -1
- package/lib/messaging/handler.js +1 -0
- package/lib/messaging/handler.js.map +1 -1
- package/lib/messaging/node/connection.js +23 -22
- package/lib/messaging/node/connection.js.map +1 -1
- package/lib/messaging/proxy-factory.d.ts +2 -0
- package/lib/messaging/proxy-factory.d.ts.map +1 -1
- package/lib/messaging/proxy-factory.js +75 -169
- package/lib/messaging/proxy-factory.js.map +1 -1
- package/lib/payment-protocol.d.ts +18 -0
- package/lib/payment-protocol.d.ts.map +1 -0
- package/lib/payment-protocol.js +13 -0
- package/lib/payment-protocol.js.map +1 -0
- package/lib/permission.d.ts +14 -12
- package/lib/permission.d.ts.map +1 -1
- package/lib/permission.js +21 -19
- package/lib/permission.js.map +1 -1
- package/lib/plans.d.ts +210 -0
- package/lib/plans.d.ts.map +1 -0
- package/lib/plans.js +570 -0
- package/lib/plans.js.map +1 -0
- package/lib/protocol.d.ts +123 -30
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +121 -117
- package/lib/protocol.js.map +1 -1
- package/lib/snapshot-url.d.ts +14 -0
- package/lib/snapshot-url.d.ts.map +1 -0
- package/lib/snapshot-url.js +26 -0
- package/lib/snapshot-url.js.map +1 -0
- package/{src/util/without.ts → lib/snapshot-url.spec.d.ts} +3 -4
- package/lib/snapshot-url.spec.d.ts.map +1 -0
- package/lib/snapshot-url.spec.js +41 -0
- package/lib/snapshot-url.spec.js.map +1 -0
- package/lib/team-subscription-protocol.d.ts +73 -0
- package/lib/team-subscription-protocol.d.ts.map +1 -0
- package/lib/team-subscription-protocol.js +63 -0
- package/lib/team-subscription-protocol.js.map +1 -0
- package/lib/teams-projects-protocol.d.ts +103 -0
- package/lib/teams-projects-protocol.d.ts.map +1 -0
- package/lib/teams-projects-protocol.js +23 -0
- package/lib/teams-projects-protocol.js.map +1 -0
- package/lib/theia-plugins.d.ts +1 -1
- package/lib/theia-plugins.js +1 -1
- package/lib/typings/globals.d.ts +12 -0
- package/lib/typings/globals.d.ts.map +1 -0
- package/lib/typings/globals.js +7 -0
- package/lib/typings/globals.js.map +1 -0
- package/lib/util/analytics.d.ts +8 -0
- package/lib/util/analytics.d.ts.map +1 -0
- package/lib/util/analytics.js +79 -0
- package/lib/util/analytics.js.map +1 -0
- package/lib/util/async-iterator.d.ts +1 -1
- package/lib/util/async-iterator.js +57 -134
- package/lib/util/async-iterator.js.map +1 -1
- package/lib/util/cancelable.d.ts +1 -1
- package/lib/util/cancelable.js +19 -60
- package/lib/util/cancelable.js.map +1 -1
- package/lib/util/date-time.d.ts +1 -1
- package/lib/util/date-time.js +10 -9
- package/lib/util/date-time.js.map +1 -1
- package/lib/util/deep-partial.d.ts +1 -1
- package/lib/util/deep-partial.js +1 -1
- package/lib/util/deferred.d.ts +1 -1
- package/lib/util/deferred.js +12 -13
- package/lib/util/deferred.js.map +1 -1
- package/lib/util/disposable.d.ts +2 -2
- package/lib/util/disposable.d.ts.map +1 -1
- package/lib/util/disposable.js +27 -39
- package/lib/util/disposable.js.map +1 -1
- package/lib/util/event.d.ts +1 -1
- package/lib/util/event.d.ts.map +1 -1
- package/lib/util/event.js +59 -74
- package/lib/util/event.js.map +1 -1
- package/lib/util/garbage-collected-cache.d.ts +1 -1
- package/lib/util/garbage-collected-cache.js +24 -47
- package/lib/util/garbage-collected-cache.js.map +1 -1
- package/lib/util/generate-workspace-id.d.ts +4 -0
- package/lib/util/generate-workspace-id.d.ts.map +1 -0
- package/lib/util/generate-workspace-id.js +470 -0
- package/lib/util/generate-workspace-id.js.map +1 -0
- package/lib/util/generate-workspace-id.spec.d.ts +7 -0
- package/lib/util/generate-workspace-id.spec.d.ts.map +1 -0
- package/lib/util/generate-workspace-id.spec.js +63 -0
- package/lib/util/generate-workspace-id.spec.js.map +1 -0
- package/lib/util/gitpod-cookie.d.ts +20 -0
- package/lib/util/gitpod-cookie.d.ts.map +1 -0
- package/lib/util/gitpod-cookie.js +44 -0
- package/lib/util/gitpod-cookie.js.map +1 -0
- package/lib/util/gitpod-host-url.d.ts +8 -3
- package/lib/util/gitpod-host-url.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.js +106 -76
- package/lib/util/gitpod-host-url.js.map +1 -1
- package/lib/util/gitpod-host-url.spec.d.ts +16 -0
- package/lib/util/gitpod-host-url.spec.d.ts.map +1 -0
- package/lib/util/gitpod-host-url.spec.js +124 -0
- package/lib/util/gitpod-host-url.spec.js.map +1 -0
- package/lib/util/grpc.d.ts +15 -0
- package/lib/util/grpc.d.ts.map +1 -0
- package/lib/util/grpc.js +18 -0
- package/lib/util/grpc.js.map +1 -0
- package/lib/util/logging.d.ts +57 -34
- package/lib/util/logging.d.ts.map +1 -1
- package/lib/util/logging.js +119 -110
- package/lib/util/logging.js.map +1 -1
- package/lib/util/make-link.d.ts +1 -1
- package/lib/util/make-link.js +4 -3
- package/lib/util/make-link.js.map +1 -1
- package/lib/util/parse-workspace-id.d.ts +14 -4
- package/lib/util/parse-workspace-id.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.js +39 -8
- package/lib/util/parse-workspace-id.js.map +1 -1
- package/lib/util/parse-workspace-id.spec.d.ts +9 -1
- package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.spec.js +129 -48
- package/lib/util/parse-workspace-id.spec.js.map +1 -1
- package/lib/util/queue.d.ts +1 -1
- package/lib/util/queue.js +18 -56
- package/lib/util/queue.js.map +1 -1
- package/lib/util/queue.spec.d.ts +1 -1
- package/lib/util/queue.spec.js +145 -287
- package/lib/util/queue.spec.js.map +1 -1
- package/lib/util/repeater.d.ts +1 -1
- package/lib/util/repeater.js +37 -89
- package/lib/util/repeater.js.map +1 -1
- package/lib/util/safe-promise.d.ts +1 -1
- package/lib/util/safe-promise.js +11 -13
- package/lib/util/safe-promise.js.map +1 -1
- package/lib/util/semaphore.d.ts +1 -1
- package/lib/util/semaphore.js +17 -47
- package/lib/util/semaphore.js.map +1 -1
- package/lib/util/skip-if.d.ts +1 -1
- package/lib/util/skip-if.js +8 -7
- package/lib/util/skip-if.js.map +1 -1
- package/lib/util/timeutil.d.ts +1 -1
- package/lib/util/timeutil.d.ts.map +1 -1
- package/lib/util/timeutil.js +30 -17
- package/lib/util/timeutil.js.map +1 -1
- package/lib/util/timeutil.spec.d.ts +1 -1
- package/lib/util/timeutil.spec.js +23 -25
- package/lib/util/timeutil.spec.js.map +1 -1
- package/lib/util/tracing.d.ts +15 -2
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +86 -51
- package/lib/util/tracing.js.map +1 -1
- package/lib/util/workspace-port-authentication.d.ts +1 -1
- package/lib/util/workspace-port-authentication.d.ts.map +1 -1
- package/lib/util/workspace-port-authentication.js +5 -3
- package/lib/util/workspace-port-authentication.js.map +1 -1
- package/lib/workspace-cluster.d.ts +74 -0
- package/lib/workspace-cluster.d.ts.map +1 -0
- package/lib/workspace-cluster.js +16 -0
- package/lib/workspace-cluster.js.map +1 -0
- package/lib/workspace-instance.d.ts +10 -4
- package/lib/workspace-instance.d.ts.map +1 -1
- package/lib/workspace-instance.js +1 -1
- package/lib/wsready.d.ts +1 -1
- package/lib/wsready.js +3 -2
- package/lib/wsready.js.map +1 -1
- package/package.json +32 -16
- package/pkg-yarn.lock +18 -9
- package/src/accounting-protocol.ts +229 -0
- package/src/admin-protocol.ts +41 -6
- package/src/analytics.ts +54 -0
- package/src/auth.ts +27 -0
- package/src/context-url.spec.ts +39 -0
- package/src/context-url.ts +51 -0
- package/src/email-protocol.ts +3 -4
- package/src/encryption/container-module.ts +1 -1
- package/src/encryption/encryption-engine.spec.ts +1 -1
- package/src/encryption/encryption-engine.ts +1 -1
- package/src/encryption/encryption-service.ts +1 -1
- package/src/encryption/key-provider.ts +1 -1
- package/src/env.ts +11 -11
- package/src/gitpod-file-parser.spec.ts +1 -1
- package/src/gitpod-file-parser.ts +1 -1
- package/src/gitpod-service.ts +386 -52
- package/src/headless-workspace-log.ts +8 -12
- package/src/ide-frontend-service.ts +28 -0
- package/src/ide-protocol.ts +92 -0
- package/src/index.ts +6 -2
- package/src/license-protocol.ts +1 -1
- package/src/messaging/browser/connection.ts +201 -23
- package/src/messaging/browser/window-connection.ts +72 -0
- package/src/messaging/client-call-metrics.ts +97 -0
- package/src/messaging/error.ts +16 -4
- package/src/messaging/handler.ts +12 -0
- package/src/messaging/node/connection.ts +2 -2
- package/src/messaging/proxy-factory.ts +16 -14
- package/src/payment-protocol.ts +20 -0
- package/src/permission.ts +9 -8
- package/src/plans.ts +632 -0
- package/src/protocol.ts +204 -61
- package/src/snapshot-url.spec.ts +25 -0
- package/src/snapshot-url.ts +27 -0
- package/src/team-subscription-protocol.ts +113 -0
- package/src/teams-projects-protocol.ts +132 -0
- package/src/theia-plugins.ts +1 -1
- package/src/typings/globals.ts +12 -0
- package/src/util/analytics.ts +87 -0
- package/src/util/async-iterator.ts +1 -1
- package/src/util/cancelable.ts +1 -1
- package/src/util/date-time.ts +1 -1
- package/src/util/deep-partial.ts +1 -1
- package/src/util/deferred.ts +2 -2
- package/src/util/garbage-collected-cache.ts +3 -3
- package/src/util/generate-workspace-id.spec.ts +31 -0
- package/src/util/generate-workspace-id.ts +457 -0
- package/src/util/gitpod-cookie.ts +39 -0
- package/src/util/gitpod-host-url.spec.ts +49 -0
- package/src/util/gitpod-host-url.ts +58 -14
- package/src/util/grpc.ts +15 -0
- package/src/util/jaeger-client.d.ts +1 -1
- package/src/util/logging.ts +111 -39
- package/src/util/make-link.ts +1 -1
- package/src/util/parse-workspace-id.spec.ts +46 -5
- package/src/util/parse-workspace-id.ts +39 -8
- package/src/util/queue.spec.ts +2 -2
- package/src/util/queue.ts +1 -1
- package/src/util/repeater.ts +1 -1
- package/src/util/safe-promise.ts +1 -1
- package/src/util/semaphore.ts +3 -3
- package/src/util/skip-if.ts +2 -2
- package/src/util/timeutil.spec.ts +1 -1
- package/src/util/timeutil.ts +5 -5
- package/src/util/tracing.ts +66 -4
- package/src/util/workspace-port-authentication.ts +1 -1
- package/src/workspace-cluster.ts +96 -0
- package/src/workspace-instance.ts +38 -16
- package/src/wsready.ts +2 -2
- package/lib/util/without.d.ts +0 -7
- package/lib/util/without.d.ts.map +0 -1
- package/lib/util/without.js.map +0 -1
package/lib/util/queue.spec.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Copyright (c) 2020
|
|
3
|
+
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
|
|
4
4
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
5
5
|
* See License-AGPL.txt in the project root for license information.
|
|
6
6
|
*/
|
|
@@ -22,312 +22,170 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
22
22
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
26
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
27
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
28
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
29
|
-
function step(op) {
|
|
30
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
31
|
-
while (_) try {
|
|
32
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
33
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
34
|
-
switch (op[0]) {
|
|
35
|
-
case 0: case 1: t = op; break;
|
|
36
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
37
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
38
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
39
|
-
default:
|
|
40
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
41
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
42
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
43
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
44
|
-
if (t[2]) _.ops.pop();
|
|
45
|
-
_.trys.pop(); continue;
|
|
46
|
-
}
|
|
47
|
-
op = body.call(thisArg, _);
|
|
48
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
49
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
var __values = (this && this.__values) || function(o) {
|
|
53
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
54
|
-
if (m) return m.call(o);
|
|
55
|
-
if (o && typeof o.length === "number") return {
|
|
56
|
-
next: function () {
|
|
57
|
-
if (o && i >= o.length) o = void 0;
|
|
58
|
-
return { value: o && o[i++], done: !o };
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
62
|
-
};
|
|
63
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
64
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
65
|
-
if (!m) return o;
|
|
66
|
-
var i = m.call(o), r, ar = [], e;
|
|
67
|
-
try {
|
|
68
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
69
|
-
}
|
|
70
|
-
catch (error) { e = { error: error }; }
|
|
71
|
-
finally {
|
|
72
|
-
try {
|
|
73
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
74
|
-
}
|
|
75
|
-
finally { if (e) throw e.error; }
|
|
76
|
-
}
|
|
77
|
-
return ar;
|
|
78
|
-
};
|
|
79
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
26
|
+
const mocha_typescript_1 = require("mocha-typescript");
|
|
27
|
+
const chai = require("chai");
|
|
28
|
+
const chaiSubset = require('chai-subset');
|
|
83
29
|
chai.use(chaiSubset);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
QueueSpec.prototype.before = function () {
|
|
30
|
+
const __1 = require("..");
|
|
31
|
+
const assert_1 = require("assert");
|
|
32
|
+
const deferred_1 = require("./deferred");
|
|
33
|
+
const expect = chai.expect;
|
|
34
|
+
let QueueSpec = class QueueSpec {
|
|
35
|
+
before() {
|
|
92
36
|
this.queue = new __1.Queue();
|
|
93
37
|
this.seq = [];
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
switch (_a.label) {
|
|
106
|
-
case 0:
|
|
107
|
-
push = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
108
|
-
var _this = this;
|
|
109
|
-
return __generator(this, function (_a) {
|
|
110
|
-
if (sleep > 0)
|
|
111
|
-
return [2 /*return*/, new Promise(function (resolve) {
|
|
112
|
-
setTimeout(function () {
|
|
113
|
-
_this.seq.push(seqNr);
|
|
114
|
-
resolve();
|
|
115
|
-
}, sleep);
|
|
116
|
-
})];
|
|
117
|
-
else
|
|
118
|
-
this.seq.push(seqNr);
|
|
119
|
-
return [2 /*return*/];
|
|
120
|
-
});
|
|
121
|
-
}); };
|
|
122
|
-
if (!nextTick) return [3 /*break*/, 1];
|
|
123
|
-
return [2 /*return*/, new Promise(function (resolve) {
|
|
124
|
-
process.nextTick(function () {
|
|
125
|
-
push().then(resolve);
|
|
126
|
-
});
|
|
127
|
-
})];
|
|
128
|
-
case 1: return [4 /*yield*/, push()];
|
|
129
|
-
case 2:
|
|
130
|
-
_a.sent();
|
|
131
|
-
_a.label = 3;
|
|
132
|
-
case 3: return [2 /*return*/];
|
|
133
|
-
}
|
|
38
|
+
}
|
|
39
|
+
exec(seqNr, nextTick = false, sleep = 0) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
return this.queue.enqueue(() => __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
const push = () => __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
if (sleep > 0)
|
|
44
|
+
return new Promise((resolve) => {
|
|
45
|
+
setTimeout(() => {
|
|
46
|
+
this.seq.push(seqNr);
|
|
47
|
+
resolve(undefined);
|
|
48
|
+
}, sleep);
|
|
134
49
|
});
|
|
135
|
-
|
|
136
|
-
|
|
50
|
+
else
|
|
51
|
+
this.seq.push(seqNr);
|
|
52
|
+
});
|
|
53
|
+
if (nextTick)
|
|
54
|
+
return new Promise((resolve) => {
|
|
55
|
+
process.nextTick(() => {
|
|
56
|
+
push().then(resolve);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
else
|
|
60
|
+
yield push();
|
|
61
|
+
}));
|
|
137
62
|
});
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
throw new Error('test error');
|
|
146
|
-
});
|
|
147
|
-
}); }).then(function () {
|
|
63
|
+
}
|
|
64
|
+
execError(seqNr) {
|
|
65
|
+
const deferred = new deferred_1.Deferred();
|
|
66
|
+
this.queue.enqueue(() => __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
this.seq.push(seqNr);
|
|
68
|
+
throw new Error('test error');
|
|
69
|
+
})).then(() => {
|
|
148
70
|
deferred.reject(false);
|
|
149
|
-
}).catch(
|
|
71
|
+
}).catch(() => {
|
|
150
72
|
deferred.resolve(true);
|
|
151
73
|
});
|
|
152
74
|
return deferred;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
var e_1, _a;
|
|
75
|
+
}
|
|
76
|
+
expectArray(actual, expected) {
|
|
156
77
|
expect(actual).to.have.lengthOf(expected.length);
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
var _b = __read(expIt.next().value, 2), exp = _b[1];
|
|
162
|
-
expect(act).to.deep.equal(exp);
|
|
163
|
-
}
|
|
78
|
+
const expIt = expected.entries();
|
|
79
|
+
for (const act of actual) {
|
|
80
|
+
const { value: [, exp] } = expIt.next();
|
|
81
|
+
expect(act).to.deep.equal(exp);
|
|
164
82
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
QueueSpec.prototype.isExecutedInOrder = function () {
|
|
174
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
175
|
-
return __generator(this, function (_a) {
|
|
176
|
-
switch (_a.label) {
|
|
177
|
-
case 0:
|
|
178
|
-
this.exec(1);
|
|
179
|
-
return [4 /*yield*/, this.exec(2)];
|
|
180
|
-
case 1:
|
|
181
|
-
_a.sent();
|
|
182
|
-
this.expectArray(this.seq, [1, 2]);
|
|
183
|
-
return [2 /*return*/];
|
|
184
|
-
}
|
|
185
|
-
});
|
|
83
|
+
}
|
|
84
|
+
isExecutedInOrder() {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
this.exec(1);
|
|
87
|
+
yield this.exec(2);
|
|
88
|
+
this.expectArray(this.seq, [1, 2]);
|
|
186
89
|
});
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
this.exec(1, true);
|
|
194
|
-
return [4 /*yield*/, this.exec(2)];
|
|
195
|
-
case 1:
|
|
196
|
-
_a.sent();
|
|
197
|
-
this.expectArray(this.seq, [1, 2]);
|
|
198
|
-
return [2 /*return*/];
|
|
199
|
-
}
|
|
200
|
-
});
|
|
90
|
+
}
|
|
91
|
+
isExecutedInOrderSkipTick() {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
this.exec(1, true);
|
|
94
|
+
yield this.exec(2);
|
|
95
|
+
this.expectArray(this.seq, [1, 2]);
|
|
201
96
|
});
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
this.exec(1, false, 2000);
|
|
209
|
-
return [4 /*yield*/, this.exec(2)];
|
|
210
|
-
case 1:
|
|
211
|
-
_a.sent();
|
|
212
|
-
this.expectArray(this.seq, [1, 2]);
|
|
213
|
-
return [2 /*return*/];
|
|
214
|
-
}
|
|
215
|
-
});
|
|
97
|
+
}
|
|
98
|
+
isExecutedInOrderSleep() {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
this.exec(1, false, 2000);
|
|
101
|
+
yield this.exec(2);
|
|
102
|
+
this.expectArray(this.seq, [1, 2]);
|
|
216
103
|
});
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
return [4 /*yield*/, this.exec(3)];
|
|
227
|
-
case 1:
|
|
228
|
-
_b.sent();
|
|
229
|
-
expect(receivedError.isResolved).to.equal(true);
|
|
230
|
-
_a = expect;
|
|
231
|
-
return [4 /*yield*/, receivedError.promise];
|
|
232
|
-
case 2:
|
|
233
|
-
_a.apply(void 0, [_b.sent()]).to.equal(true);
|
|
234
|
-
this.expectArray(this.seq, [1, 2, 3]);
|
|
235
|
-
return [2 /*return*/];
|
|
236
|
-
}
|
|
237
|
-
});
|
|
104
|
+
}
|
|
105
|
+
continueDespiteError() {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
this.exec(1);
|
|
108
|
+
const receivedError = this.execError(2);
|
|
109
|
+
yield this.exec(3);
|
|
110
|
+
expect(receivedError.isResolved).to.equal(true);
|
|
111
|
+
expect(yield receivedError.promise).to.equal(true);
|
|
112
|
+
this.expectArray(this.seq, [1, 2, 3]);
|
|
238
113
|
});
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
return __generator(this, function (_a) {
|
|
245
|
-
f = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
246
|
-
return __generator(this, function (_a) {
|
|
247
|
-
throw new Error();
|
|
248
|
-
});
|
|
249
|
-
}); };
|
|
250
|
-
try {
|
|
251
|
-
p = this.queue.enqueue(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
252
|
-
return __generator(this, function (_a) {
|
|
253
|
-
return [2 /*return*/, f()];
|
|
254
|
-
});
|
|
255
|
-
}); });
|
|
256
|
-
p.catch(function (err) {
|
|
257
|
-
// Silence unhandled promise rejection messages
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
catch (err) {
|
|
261
|
-
assert_1.fail("We expect to catch no error");
|
|
262
|
-
}
|
|
263
|
-
return [2 /*return*/];
|
|
114
|
+
}
|
|
115
|
+
mustCatchError() {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
const f = () => __awaiter(this, void 0, void 0, function* () {
|
|
118
|
+
throw new Error();
|
|
264
119
|
});
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
var _this = this;
|
|
271
|
-
return __generator(this, function (_a) {
|
|
272
|
-
f = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
273
|
-
return __generator(this, function (_a) {
|
|
274
|
-
throw new Error();
|
|
275
|
-
});
|
|
276
|
-
}); };
|
|
277
|
-
p = this.queue.enqueue(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
278
|
-
return __generator(this, function (_a) {
|
|
279
|
-
return [2 /*return*/, f()];
|
|
280
|
-
});
|
|
281
|
-
}); });
|
|
282
|
-
p.then(function (r) {
|
|
283
|
-
assert_1.fail("Expected to catch error!");
|
|
284
|
-
}).catch(function (err) {
|
|
120
|
+
try {
|
|
121
|
+
const p = this.queue.enqueue(() => __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
return f();
|
|
123
|
+
}));
|
|
124
|
+
p.catch((err) => {
|
|
285
125
|
// Silence unhandled promise rejection messages
|
|
286
126
|
});
|
|
287
|
-
|
|
127
|
+
}
|
|
128
|
+
catch (err) {
|
|
129
|
+
(0, assert_1.fail)("We expect to catch no error");
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
expectUncaughtError() {
|
|
134
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
135
|
+
const f = () => __awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
throw new Error();
|
|
137
|
+
});
|
|
138
|
+
const p = this.queue.enqueue(() => __awaiter(this, void 0, void 0, function* () {
|
|
139
|
+
return f();
|
|
140
|
+
}));
|
|
141
|
+
p.then((r) => {
|
|
142
|
+
(0, assert_1.fail)("Expected to catch error!");
|
|
143
|
+
}).catch((err) => {
|
|
144
|
+
// Silence unhandled promise rejection messages
|
|
288
145
|
});
|
|
289
146
|
});
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
__decorate([
|
|
150
|
+
mocha_typescript_1.test,
|
|
151
|
+
__metadata("design:type", Function),
|
|
152
|
+
__metadata("design:paramtypes", []),
|
|
153
|
+
__metadata("design:returntype", Promise)
|
|
154
|
+
], QueueSpec.prototype, "isExecutedInOrder", null);
|
|
155
|
+
__decorate([
|
|
156
|
+
mocha_typescript_1.test,
|
|
157
|
+
__metadata("design:type", Function),
|
|
158
|
+
__metadata("design:paramtypes", []),
|
|
159
|
+
__metadata("design:returntype", Promise)
|
|
160
|
+
], QueueSpec.prototype, "isExecutedInOrderSkipTick", null);
|
|
161
|
+
__decorate([
|
|
162
|
+
mocha_typescript_1.test,
|
|
163
|
+
(0, mocha_typescript_1.timeout)(3000),
|
|
164
|
+
(0, mocha_typescript_1.slow)(3000),
|
|
165
|
+
__metadata("design:type", Function),
|
|
166
|
+
__metadata("design:paramtypes", []),
|
|
167
|
+
__metadata("design:returntype", Promise)
|
|
168
|
+
], QueueSpec.prototype, "isExecutedInOrderSleep", null);
|
|
169
|
+
__decorate([
|
|
170
|
+
mocha_typescript_1.test,
|
|
171
|
+
__metadata("design:type", Function),
|
|
172
|
+
__metadata("design:paramtypes", []),
|
|
173
|
+
__metadata("design:returntype", Promise)
|
|
174
|
+
], QueueSpec.prototype, "continueDespiteError", null);
|
|
175
|
+
__decorate([
|
|
176
|
+
mocha_typescript_1.test,
|
|
177
|
+
__metadata("design:type", Function),
|
|
178
|
+
__metadata("design:paramtypes", []),
|
|
179
|
+
__metadata("design:returntype", Promise)
|
|
180
|
+
], QueueSpec.prototype, "mustCatchError", null);
|
|
181
|
+
__decorate([
|
|
182
|
+
mocha_typescript_1.test,
|
|
183
|
+
__metadata("design:type", Function),
|
|
184
|
+
__metadata("design:paramtypes", []),
|
|
185
|
+
__metadata("design:returntype", Promise)
|
|
186
|
+
], QueueSpec.prototype, "expectUncaughtError", null);
|
|
187
|
+
QueueSpec = __decorate([
|
|
188
|
+
mocha_typescript_1.suite
|
|
189
|
+
], QueueSpec);
|
|
332
190
|
module.exports = new QueueSpec();
|
|
333
191
|
//# sourceMappingURL=queue.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.spec.js","sourceRoot":"","sources":["../../src/util/queue.spec.ts"],"names":[],"mappings":";AAAA;;;;GAIG
|
|
1
|
+
{"version":3,"file":"queue.spec.js","sourceRoot":"","sources":["../../src/util/queue.spec.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;AAEH,uDAA6D;AAC7D,6BAA4B;AAC5B,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAC1C,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AAErB,0BAA2B;AAC3B,mCAA8B;AAC9B,yCAAsC;AAEtC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;AAEnB,IAAM,SAAS,GAAf,M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,CAAA,CAAA;YACD,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAS,EAAE;gBACpC,OAAO,CAAC,EAAE,CAAC;YACf,CAAC,CAAA,CAAC,CAAC;YACH,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;gBACT,IAAA,aAAI,EAAC,0BAA0B,CAAC,CAAC;YACrC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;gBACb,+CAA+C;YACnD,CAAC,CAAC,CAAC;QACP,CAAC;KAAA;CACJ,CAAA;AA9DS;IAAL,uBAAI;;;;kDAKJ;AAEK;IAAL,uBAAI;;;;0DAKJ;AAEgC;IAAhC,uBAAI;IAAE,IAAA,0BAAO,EAAC,IAAI,CAAC;IAAE,IAAA,uBAAI,EAAC,IAAI,CAAC;;;;uDAK/B;AAGK;IAAL,uBAAI;;;;qDAQJ;AAEK;IAAL,uBAAI;;;;+CAeJ;AAEK;IAAL,uBAAI;;;;oDAYJ;AAtHQ,SAAS;IAArB,wBAAK;GAAO,SAAS,CAuHrB;AACD,MAAM,CAAC,OAAO,GAAG,IAAI,SAAS,EAAE,CAAC"}
|
package/lib/util/repeater.d.ts
CHANGED
package/lib/util/repeater.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Copyright (c) 2020
|
|
3
|
+
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
|
|
4
4
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
5
5
|
* See License-AGPL.txt in the project root for license information.
|
|
6
6
|
*/
|
|
@@ -13,105 +13,53 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
17
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
18
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
19
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
20
|
-
function step(op) {
|
|
21
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
22
|
-
while (_) try {
|
|
23
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
24
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
25
|
-
switch (op[0]) {
|
|
26
|
-
case 0: case 1: t = op; break;
|
|
27
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
28
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
29
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
30
|
-
default:
|
|
31
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
32
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
33
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
34
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
35
|
-
if (t[2]) _.ops.pop();
|
|
36
|
-
_.trys.pop(); continue;
|
|
37
|
-
}
|
|
38
|
-
op = body.call(thisArg, _);
|
|
39
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
40
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
-
|
|
45
|
-
|
|
17
|
+
exports.Repeater = void 0;
|
|
18
|
+
const deferred_1 = require("./deferred");
|
|
19
|
+
const logging_1 = require("./logging");
|
|
46
20
|
/**
|
|
47
21
|
* Repeats a given function until it is stopped
|
|
48
22
|
*/
|
|
49
|
-
|
|
50
|
-
|
|
23
|
+
class Repeater {
|
|
24
|
+
constructor(fn, timeout) {
|
|
51
25
|
this.fn = fn;
|
|
52
26
|
this.timeout = timeout;
|
|
53
27
|
}
|
|
54
|
-
|
|
55
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
56
|
-
|
|
57
|
-
this.run();
|
|
58
|
-
return [2 /*return*/];
|
|
59
|
-
});
|
|
28
|
+
start() {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
this.run();
|
|
60
31
|
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (!this.shouldRun) return [3 /*break*/, 7];
|
|
73
|
-
_a.label = 2;
|
|
74
|
-
case 2:
|
|
75
|
-
_a.trys.push([2, 4, , 5]);
|
|
76
|
-
return [4 /*yield*/, this.fn()];
|
|
77
|
-
case 3:
|
|
78
|
-
_a.sent();
|
|
79
|
-
return [3 /*break*/, 5];
|
|
80
|
-
case 4:
|
|
81
|
-
err_1 = _a.sent();
|
|
82
|
-
logging_1.log.error(err_1);
|
|
83
|
-
return [3 /*break*/, 5];
|
|
84
|
-
case 5: return [4 /*yield*/, this.sleep(this.timeout)];
|
|
85
|
-
case 6:
|
|
86
|
-
_a.sent();
|
|
87
|
-
return [3 /*break*/, 1];
|
|
88
|
-
case 7:
|
|
89
|
-
this.finished.resolve();
|
|
90
|
-
return [2 /*return*/];
|
|
32
|
+
}
|
|
33
|
+
run() {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
this.shouldRun = true;
|
|
36
|
+
this.finished = new deferred_1.Deferred();
|
|
37
|
+
while (this.shouldRun) {
|
|
38
|
+
try {
|
|
39
|
+
yield this.fn();
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
logging_1.log.error(err);
|
|
91
43
|
}
|
|
92
|
-
|
|
44
|
+
yield this.sleep(this.timeout);
|
|
45
|
+
}
|
|
46
|
+
this.finished.resolve();
|
|
93
47
|
});
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
97
|
-
|
|
98
|
-
return __generator(this, function (_a) {
|
|
99
|
-
return [2 /*return*/, new Promise(function (resolve) { return _this.timer = setTimeout(resolve, timeout); })];
|
|
100
|
-
});
|
|
48
|
+
}
|
|
49
|
+
sleep(timeout) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
return new Promise(resolve => this.timer = setTimeout(resolve, timeout));
|
|
101
52
|
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
return [2 /*return*/, this.finished.promise];
|
|
111
|
-
});
|
|
53
|
+
}
|
|
54
|
+
stop() {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
this.shouldRun = false;
|
|
57
|
+
if (this.timer) {
|
|
58
|
+
clearTimeout(this.timer);
|
|
59
|
+
}
|
|
60
|
+
return this.finished.promise;
|
|
112
61
|
});
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
}());
|
|
62
|
+
}
|
|
63
|
+
}
|
|
116
64
|
exports.Repeater = Repeater;
|
|
117
65
|
//# sourceMappingURL=repeater.js.map
|