@wix/duplexer-js 2.0.5
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/README.md +239 -0
- package/dist/src/_external-types.d.ts +1 -0
- package/dist/src/authenticator.d.ts +22 -0
- package/dist/src/authenticator.js +42 -0
- package/dist/src/authenticator.js.map +1 -0
- package/dist/src/channels/channel.d.ts +29 -0
- package/dist/src/channels/channel.js +159 -0
- package/dist/src/channels/channel.js.map +1 -0
- package/dist/src/channels/channels.d.ts +13 -0
- package/dist/src/channels/channels.js +41 -0
- package/dist/src/channels/channels.js.map +1 -0
- package/dist/src/channels/subscription-error.d.ts +6 -0
- package/dist/src/channels/subscription-error.js +3 -0
- package/dist/src/channels/subscription-error.js.map +1 -0
- package/dist/src/connection-manager.d.ts +62 -0
- package/dist/src/connection-manager.js +228 -0
- package/dist/src/connection-manager.js.map +1 -0
- package/dist/src/constants.d.ts +5 -0
- package/dist/src/constants.js +9 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/domain.d.ts +3 -0
- package/dist/src/domain.js +3 -0
- package/dist/src/domain.js.map +1 -0
- package/dist/src/duplexer.d.ts +41 -0
- package/dist/src/duplexer.js +125 -0
- package/dist/src/duplexer.js.map +1 -0
- package/dist/src/environments/core/environment.d.ts +13 -0
- package/dist/src/environments/core/environment.js +25 -0
- package/dist/src/environments/core/environment.js.map +1 -0
- package/dist/src/environments/core/network.d.ts +6 -0
- package/dist/src/environments/core/network.js +32 -0
- package/dist/src/environments/core/network.js.map +1 -0
- package/dist/src/environments/react-native/environment.d.ts +7 -0
- package/dist/src/environments/react-native/environment.js +27 -0
- package/dist/src/environments/react-native/environment.js.map +1 -0
- package/dist/src/environments/react-native/network.d.ts +6 -0
- package/dist/src/environments/react-native/network.js +54 -0
- package/dist/src/environments/react-native/network.js.map +1 -0
- package/dist/src/environments/react-native/transports.d.ts +8 -0
- package/dist/src/environments/react-native/transports.js +31 -0
- package/dist/src/environments/react-native/transports.js.map +1 -0
- package/dist/src/environments/web/environment.d.ts +8 -0
- package/dist/src/environments/web/environment.js +19 -0
- package/dist/src/environments/web/environment.js.map +1 -0
- package/dist/src/environments/web/network.d.ts +4 -0
- package/dist/src/environments/web/network.js +38 -0
- package/dist/src/environments/web/network.js.map +1 -0
- package/dist/src/environments/web/transports.d.ts +8 -0
- package/dist/src/environments/web/transports.js +51 -0
- package/dist/src/environments/web/transports.js.map +1 -0
- package/dist/src/errors/is-transport-error.d.ts +1 -0
- package/dist/src/errors/is-transport-error.js +7 -0
- package/dist/src/errors/is-transport-error.js.map +1 -0
- package/dist/src/index.d.ts +11 -0
- package/dist/src/index.js +25 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/instance-updater.d.ts +5 -0
- package/dist/src/instance-updater.js +3 -0
- package/dist/src/instance-updater.js.map +1 -0
- package/dist/src/keep-alive.d.ts +18 -0
- package/dist/src/keep-alive.js +66 -0
- package/dist/src/keep-alive.js.map +1 -0
- package/dist/src/ready-state.d.ts +6 -0
- package/dist/src/ready-state.js +10 -0
- package/dist/src/ready-state.js.map +1 -0
- package/dist/src/strategies/strategy-builder.d.ts +11 -0
- package/dist/src/strategies/strategy-builder.js +34 -0
- package/dist/src/strategies/strategy-builder.js.map +1 -0
- package/dist/src/strategies/strategy-presets.d.ts +4 -0
- package/dist/src/strategies/strategy-presets.js +20 -0
- package/dist/src/strategies/strategy-presets.js.map +1 -0
- package/dist/src/strategies/strategy.d.ts +25 -0
- package/dist/src/strategies/strategy.js +153 -0
- package/dist/src/strategies/strategy.js.map +1 -0
- package/dist/src/timeline/noop-timeline.d.ts +5 -0
- package/dist/src/timeline/noop-timeline.js +15 -0
- package/dist/src/timeline/noop-timeline.js.map +1 -0
- package/dist/src/timeline/timeline.d.ts +7 -0
- package/dist/src/timeline/timeline.js +3 -0
- package/dist/src/timeline/timeline.js.map +1 -0
- package/dist/src/transport/http-polling.d.ts +27 -0
- package/dist/src/transport/http-polling.js +245 -0
- package/dist/src/transport/http-polling.js.map +1 -0
- package/dist/src/transport/http.d.ts +14 -0
- package/dist/src/transport/http.js +106 -0
- package/dist/src/transport/http.js.map +1 -0
- package/dist/src/transport/params.d.ts +3 -0
- package/dist/src/transport/params.js +70 -0
- package/dist/src/transport/params.js.map +1 -0
- package/dist/src/transport/transport-error.d.ts +8 -0
- package/dist/src/transport/transport-error.js +3 -0
- package/dist/src/transport/transport-error.js.map +1 -0
- package/dist/src/transport/transport-params.d.ts +3 -0
- package/dist/src/transport/transport-params.js +3 -0
- package/dist/src/transport/transport-params.js.map +1 -0
- package/dist/src/transport/transport.d.ts +50 -0
- package/dist/src/transport/transport.js +120 -0
- package/dist/src/transport/transport.js.map +1 -0
- package/dist/src/transport/transports-manager.d.ts +42 -0
- package/dist/src/transport/transports-manager.js +248 -0
- package/dist/src/transport/transports-manager.js.map +1 -0
- package/dist/src/transport/unrecoverable.d.ts +1 -0
- package/dist/src/transport/unrecoverable.js +8 -0
- package/dist/src/transport/unrecoverable.js.map +1 -0
- package/dist/src/transport/websocket.d.ts +18 -0
- package/dist/src/transport/websocket.js +155 -0
- package/dist/src/transport/websocket.js.map +1 -0
- package/dist/src/utils/assert.d.ts +1 -0
- package/dist/src/utils/assert.js +34 -0
- package/dist/src/utils/assert.js.map +1 -0
- package/dist/src/utils/cancel-token.d.ts +10 -0
- package/dist/src/utils/cancel-token.js +28 -0
- package/dist/src/utils/cancel-token.js.map +1 -0
- package/dist/src/utils/deferred.d.ts +9 -0
- package/dist/src/utils/deferred.js +27 -0
- package/dist/src/utils/deferred.js.map +1 -0
- package/dist/src/utils/event-emitter.d.ts +15 -0
- package/dist/src/utils/event-emitter.js +106 -0
- package/dist/src/utils/event-emitter.js.map +1 -0
- package/dist/src/utils/on.d.ts +4 -0
- package/dist/src/utils/on.js +10 -0
- package/dist/src/utils/on.js.map +1 -0
- package/dist/src/utils/request.d.ts +20 -0
- package/dist/src/utils/request.js +164 -0
- package/dist/src/utils/request.js.map +1 -0
- package/dist/src/utils/timer.d.ts +8 -0
- package/dist/src/utils/timer.js +17 -0
- package/dist/src/utils/timer.js.map +1 -0
- package/dist/src/utils/utils.d.ts +1 -0
- package/dist/src/utils/utils.js +8 -0
- package/dist/src/utils/utils.js.map +1 -0
- package/dist/src/virtual-socket.d.ts +42 -0
- package/dist/src/virtual-socket.js +199 -0
- package/dist/src/virtual-socket.js.map +1 -0
- package/dist/statics/duplexer.bundle.js +982 -0
- package/dist/statics/duplexer.bundle.js.map +1 -0
- package/dist/statics/duplexer.bundle.min.js +2 -0
- package/dist/statics/duplexer.bundle.min.js.map +1 -0
- package/dist/statics/manifest.json +3 -0
- package/dist/statics/manifest.min.json +3 -0
- package/dist/test/_external-types.d.ts +2 -0
- package/dist/test/_global-types.d.ts +10 -0
- package/dist/test/_setup-global-hooks.spec.d.ts +1 -0
- package/dist/test/_setup-global-hooks.spec.js +13 -0
- package/dist/test/_setup-global-hooks.spec.js.map +1 -0
- package/dist/test/client-events.it.d.ts +1 -0
- package/dist/test/client-events.it.js +33 -0
- package/dist/test/client-events.it.js.map +1 -0
- package/dist/test/connect.spec.d.ts +1 -0
- package/dist/test/connect.spec.js +71 -0
- package/dist/test/connect.spec.js.map +1 -0
- package/dist/test/connection-manager.spec.d.ts +1 -0
- package/dist/test/connection-manager.spec.js +523 -0
- package/dist/test/connection-manager.spec.js.map +1 -0
- package/dist/test/duplexer.it.d.ts +1 -0
- package/dist/test/duplexer.it.js +243 -0
- package/dist/test/duplexer.it.js.map +1 -0
- package/dist/test/duplexer.spec.d.ts +1 -0
- package/dist/test/duplexer.spec.js +337 -0
- package/dist/test/duplexer.spec.js.map +1 -0
- package/dist/test/environments/web.it.d.ts +1 -0
- package/dist/test/environments/web.it.js +30 -0
- package/dist/test/environments/web.it.js.map +1 -0
- package/dist/test/environments/web.spec.d.ts +1 -0
- package/dist/test/environments/web.spec.js +92 -0
- package/dist/test/environments/web.spec.js.map +1 -0
- package/dist/test/event-emitter.spec.d.ts +1 -0
- package/dist/test/event-emitter.spec.js +182 -0
- package/dist/test/event-emitter.spec.js.map +1 -0
- package/dist/test/helpers/as-promised.d.ts +7 -0
- package/dist/test/helpers/as-promised.js +38 -0
- package/dist/test/helpers/as-promised.js.map +1 -0
- package/dist/test/helpers/assertions.d.ts +8 -0
- package/dist/test/helpers/assertions.js +43 -0
- package/dist/test/helpers/assertions.js.map +1 -0
- package/dist/test/helpers/auth-server.d.ts +10 -0
- package/dist/test/helpers/auth-server.js +61 -0
- package/dist/test/helpers/auth-server.js.map +1 -0
- package/dist/test/helpers/http-polling-environment.d.ts +2 -0
- package/dist/test/helpers/http-polling-environment.js +20 -0
- package/dist/test/helpers/http-polling-environment.js.map +1 -0
- package/dist/test/helpers/in-memory-environemnt.d.ts +15 -0
- package/dist/test/helpers/in-memory-environemnt.js +39 -0
- package/dist/test/helpers/in-memory-environemnt.js.map +1 -0
- package/dist/test/helpers/in-memory-network.d.ts +5 -0
- package/dist/test/helpers/in-memory-network.js +37 -0
- package/dist/test/helpers/in-memory-network.js.map +1 -0
- package/dist/test/helpers/in-memory-timeline.d.ts +8 -0
- package/dist/test/helpers/in-memory-timeline.js +24 -0
- package/dist/test/helpers/in-memory-timeline.js.map +1 -0
- package/dist/test/helpers/in-memory-transport.d.ts +68 -0
- package/dist/test/helpers/in-memory-transport.js +271 -0
- package/dist/test/helpers/in-memory-transport.js.map +1 -0
- package/dist/test/helpers/server-interceptor.d.ts +10 -0
- package/dist/test/helpers/server-interceptor.js +138 -0
- package/dist/test/helpers/server-interceptor.js.map +1 -0
- package/dist/test/helpers/setup-global-mock-navigator.d.ts +4 -0
- package/dist/test/helpers/setup-global-mock-navigator.js +22 -0
- package/dist/test/helpers/setup-global-mock-navigator.js.map +1 -0
- package/dist/test/helpers/window.d.ts +1 -0
- package/dist/test/helpers/window.js +17 -0
- package/dist/test/helpers/window.js.map +1 -0
- package/dist/test/keep-alive.it.spec.d.ts +1 -0
- package/dist/test/keep-alive.it.spec.js +42 -0
- package/dist/test/keep-alive.it.spec.js.map +1 -0
- package/dist/test/keep-alive.spec.d.ts +1 -0
- package/dist/test/keep-alive.spec.js +140 -0
- package/dist/test/keep-alive.spec.js.map +1 -0
- package/dist/test/ng/channel-support.d.ts +39 -0
- package/dist/test/ng/channel-support.js +178 -0
- package/dist/test/ng/channel-support.js.map +1 -0
- package/dist/test/ng/channels.spec.d.ts +1 -0
- package/dist/test/ng/channels.spec.js +79 -0
- package/dist/test/ng/channels.spec.js.map +1 -0
- package/dist/test/ng/client-events.it.d.ts +1 -0
- package/dist/test/ng/client-events.it.js +75 -0
- package/dist/test/ng/client-events.it.js.map +1 -0
- package/dist/test/ng/connect.it.d.ts +1 -0
- package/dist/test/ng/connect.it.js +128 -0
- package/dist/test/ng/connect.it.js.map +1 -0
- package/dist/test/ng/corvid-environment.d.ts +22 -0
- package/dist/test/ng/corvid-environment.js +44 -0
- package/dist/test/ng/corvid-environment.js.map +1 -0
- package/dist/test/ng/environment.d.ts +49 -0
- package/dist/test/ng/environment.js +250 -0
- package/dist/test/ng/environment.js.map +1 -0
- package/dist/test/ng/setup.d.ts +54 -0
- package/dist/test/ng/setup.js +256 -0
- package/dist/test/ng/setup.js.map +1 -0
- package/dist/test/ng/subscribe.it.d.ts +1 -0
- package/dist/test/ng/subscribe.it.js +354 -0
- package/dist/test/ng/subscribe.it.js.map +1 -0
- package/dist/test/ng/unsubscribe.it.d.ts +1 -0
- package/dist/test/ng/unsubscribe.it.js +73 -0
- package/dist/test/ng/unsubscribe.it.js.map +1 -0
- package/dist/test/ng/util-functions.d.ts +7 -0
- package/dist/test/ng/util-functions.js +73 -0
- package/dist/test/ng/util-functions.js.map +1 -0
- package/dist/test/proto/client/index.d.ts +2852 -0
- package/dist/test/proto/index.d.ts +1421 -0
- package/dist/test/proto/server/index.d.ts +2832 -0
- package/dist/test/restore-overrides.it.d.ts +1 -0
- package/dist/test/restore-overrides.it.js +38 -0
- package/dist/test/restore-overrides.it.js.map +1 -0
- package/dist/test/setup.d.ts +1 -0
- package/dist/test/setup.js +5 -0
- package/dist/test/setup.js.map +1 -0
- package/dist/test/strategy.spec.d.ts +1 -0
- package/dist/test/strategy.spec.js +209 -0
- package/dist/test/strategy.spec.js.map +1 -0
- package/dist/test/subscribe.it.d.ts +1 -0
- package/dist/test/subscribe.it.js +216 -0
- package/dist/test/subscribe.it.js.map +1 -0
- package/dist/test/subscribe.spec.d.ts +1 -0
- package/dist/test/subscribe.spec.js +86 -0
- package/dist/test/subscribe.spec.js.map +1 -0
- package/dist/test/transporters/http-polling.it.d.ts +1 -0
- package/dist/test/transporters/http-polling.it.js +118 -0
- package/dist/test/transporters/http-polling.it.js.map +1 -0
- package/dist/test/transporters/http-polling.spec.d.ts +1 -0
- package/dist/test/transporters/http-polling.spec.js +354 -0
- package/dist/test/transporters/http-polling.spec.js.map +1 -0
- package/dist/test/transporters/transporter.spec.d.ts +1 -0
- package/dist/test/transporters/transporter.spec.js +46 -0
- package/dist/test/transporters/transporter.spec.js.map +1 -0
- package/dist/test/transporters/websocket.spec.d.ts +1 -0
- package/dist/test/transporters/websocket.spec.js +26 -0
- package/dist/test/transporters/websocket.spec.js.map +1 -0
- package/dist/test/transports-manager.spec.d.ts +1 -0
- package/dist/test/transports-manager.spec.js +346 -0
- package/dist/test/transports-manager.spec.js.map +1 -0
- package/dist/test/utils/request.spec.d.ts +1 -0
- package/dist/test/utils/request.spec.js +274 -0
- package/dist/test/utils/request.spec.js.map +1 -0
- package/dist/test/virtual-socket.it.d.ts +1 -0
- package/dist/test/virtual-socket.it.js +153 -0
- package/dist/test/virtual-socket.it.js.map +1 -0
- package/package.json +131 -0
- package/react-native.d.ts +1 -0
- package/react-native.js +1 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
var uuid_1 = __importDefault(require("uuid"));
|
|
43
|
+
var chai_1 = require("chai");
|
|
44
|
+
var environment_1 = require("./environment");
|
|
45
|
+
var util_functions_1 = require("./util-functions");
|
|
46
|
+
var setup_1 = require("./setup");
|
|
47
|
+
(0, setup_1.iterateTransports)(function (transport) {
|
|
48
|
+
describe('unsubscribe', function () {
|
|
49
|
+
beforeEach(function () {
|
|
50
|
+
environment_1.environment.cleanup();
|
|
51
|
+
environment_1.environment.initJsdomWithoutUrl();
|
|
52
|
+
});
|
|
53
|
+
var setup = environment_1.environment.setup(transport);
|
|
54
|
+
it('respects given resource id', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
55
|
+
var channel, awaitEvent;
|
|
56
|
+
return __generator(this, function (_a) {
|
|
57
|
+
switch (_a.label) {
|
|
58
|
+
case 0: return [4 /*yield*/, setup.subscribe({ resourceId: (0, uuid_1.default)() })];
|
|
59
|
+
case 1:
|
|
60
|
+
channel = _a.sent();
|
|
61
|
+
return [4 /*yield*/, channel.unsubscribe()];
|
|
62
|
+
case 2:
|
|
63
|
+
_a.sent();
|
|
64
|
+
return [4 /*yield*/, channel.publish()];
|
|
65
|
+
case 3:
|
|
66
|
+
awaitEvent = (_a.sent()).awaitEvent;
|
|
67
|
+
return [2 /*return*/, (0, chai_1.expect)((0, util_functions_1.timeoutOrReject)(awaitEvent(), 2000)).to.be.fulfilled];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}); });
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
//# sourceMappingURL=unsubscribe.it.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unsubscribe.it.js","sourceRoot":"","sources":["../../../test/ng/unsubscribe.it.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAwB;AACxB,6BAAoC;AACpC,6CAA4C;AAC5C,mDAAmD;AACnD,iCAA4C;AAE5C,IAAA,yBAAiB,EAAC,UAAC,SAAS;IAC1B,QAAQ,CAAC,aAAa,EAAE;QACtB,UAAU,CAAC;YACT,yBAAW,CAAC,OAAO,EAAE,CAAC;YACtB,yBAAW,CAAC,mBAAmB,EAAE,CAAC;QACpC,CAAC,CAAC,CAAC;QAEH,IAAM,KAAK,GAAG,yBAAW,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAE3C,EAAE,CAAC,4BAA4B,EAAE;;;;4BACf,qBAAM,KAAK,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,IAAA,cAAI,GAAE,EAAE,CAAC,EAAA;;wBAAvD,OAAO,GAAG,SAA6C;wBAC7D,qBAAM,OAAO,CAAC,WAAW,EAAE,EAAA;;wBAA3B,SAA2B,CAAC;wBACL,qBAAM,OAAO,CAAC,OAAO,EAAE,EAAA;;wBAAtC,UAAU,GAAK,CAAA,SAAuB,CAAA,WAA5B;wBAElB,sBAAO,IAAA,aAAM,EAAC,IAAA,gCAAe,EAAC,UAAU,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,EAAC;;;aACpE,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="chance" />
|
|
2
|
+
export declare const chance: Chance.Chance;
|
|
3
|
+
export declare function invertPromise<T>(promise: Promise<T>): Promise<T>;
|
|
4
|
+
export declare function timeoutOrReject(promise: Promise<any>, ms: number): Promise<any>;
|
|
5
|
+
export declare function delay(ms: number): Promise<unknown>;
|
|
6
|
+
export declare function timeout(ms: number): any;
|
|
7
|
+
export declare function rejectOnUnhandledError(): Promise<unknown>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.rejectOnUnhandledError = exports.timeout = exports.delay = exports.timeoutOrReject = exports.invertPromise = exports.chance = void 0;
|
|
43
|
+
var chance_1 = __importDefault(require("chance"));
|
|
44
|
+
exports.chance = new chance_1.default();
|
|
45
|
+
function invertPromise(promise) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
47
|
+
return __generator(this, function (_a) {
|
|
48
|
+
return [2 /*return*/, promise.then(function (data) { return Promise.reject(data); }, function (data) { return Promise.resolve(data); })];
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
exports.invertPromise = invertPromise;
|
|
53
|
+
function timeoutOrReject(promise, ms) {
|
|
54
|
+
return Promise.race([delay(ms), invertPromise(promise)]);
|
|
55
|
+
}
|
|
56
|
+
exports.timeoutOrReject = timeoutOrReject;
|
|
57
|
+
function delay(ms) {
|
|
58
|
+
return new Promise(function (resolve) { return setTimeout(resolve, ms); });
|
|
59
|
+
}
|
|
60
|
+
exports.delay = delay;
|
|
61
|
+
function timeout(ms) {
|
|
62
|
+
return invertPromise(delay(ms));
|
|
63
|
+
}
|
|
64
|
+
exports.timeout = timeout;
|
|
65
|
+
function rejectOnUnhandledError() {
|
|
66
|
+
return new Promise(function (_, reject) {
|
|
67
|
+
window.addEventListener('error', function (ev) { return reject(ev); });
|
|
68
|
+
window.addEventListener('unhandledrejection', function (ev) { return reject(ev); });
|
|
69
|
+
process.on('unhandledRejection', function (ev) { return reject(ev); });
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
exports.rejectOnUnhandledError = rejectOnUnhandledError;
|
|
73
|
+
//# sourceMappingURL=util-functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util-functions.js","sourceRoot":"","sources":["../../../test/ng/util-functions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA4B;AAEf,QAAA,MAAM,GAAG,IAAI,gBAAM,EAAE,CAAC;AAEnC,SAAsB,aAAa,CAAI,OAAmB;;;YACxD,sBAAO,OAAO,CAAC,IAAI,CACjB,UAAC,IAAI,IAAK,OAAA,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,EAApB,CAAoB,EAC9B,UAAC,IAAI,IAAK,OAAA,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAArB,CAAqB,CAChC,EAAC;;;CACH;AALD,sCAKC;AAED,SAAgB,eAAe,CAAC,OAAqB,EAAE,EAAU;IAC/D,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAC3D,CAAC;AAFD,0CAEC;AAED,SAAgB,KAAK,CAAC,EAAU;IAC9B,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,IAAK,OAAA,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,EAAvB,CAAuB,CAAC,CAAC;AAC3D,CAAC;AAFD,sBAEC;AAED,SAAgB,OAAO,CAAC,EAAU;IAChC,OAAO,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;AAClC,CAAC;AAFD,0BAEC;AAED,SAAgB,sBAAsB;IACpC,OAAO,IAAI,OAAO,CAAC,UAAC,CAAC,EAAE,MAAM;QAC3B,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,UAAC,EAAE,IAAK,OAAA,MAAM,CAAC,EAAE,CAAC,EAAV,CAAU,CAAC,CAAC;QACrD,MAAM,CAAC,gBAAgB,CAAC,oBAAoB,EAAE,UAAC,EAAE,IAAK,OAAA,MAAM,CAAC,EAAE,CAAC,EAAV,CAAU,CAAC,CAAC;QAClE,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,UAAC,EAAE,IAAK,OAAA,MAAM,CAAC,EAAE,CAAC,EAAV,CAAU,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;AACL,CAAC;AAND,wDAMC"}
|