Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApiProxy = void 0;
var crypto_1 = require("../utils/crypto");
var ApiProxy = /** @class */ (function () {
function ApiProxy(apiConfig) {
var _this = this;
this.proxy = {};
this.promiseMap = new Map();
var _loop_1 = function (prop) {
this_1.proxy[prop] = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var uuid = (0, crypto_1.randomUUID)();
return new Promise(function (res, rej) {
_this.promiseMap.set(uuid, {
res: res,
rej: rej
});
_this.getOutboundFn()({
uuid: uuid,
propertyToCall: prop,
args: args
});
});
};
};
var this_1 = this;
for (var _i = 0, _a = apiConfig.props; _i < _a.length; _i++) {
var prop = _a[_i];
_loop_1(prop);
}
}
ApiProxy.prototype.getOutboundFn = function () {
return this.outboundFn;
};
ApiProxy.prototype.get = function () {
return this.proxy;
};
ApiProxy.prototype.getInboundFn = function () {
var _this = this;
return function (payload) {
//TODO: see how to reject
//TODO: should remove promise from map?
if (_this.promiseMap.has(payload.uuid)) {
_this.promiseMap.get(payload.uuid).res(payload.returnValue);
}
};
};
ApiProxy.prototype.setOutboundFn = function (outboundFn) {
this.outboundFn = outboundFn;
};
return ApiProxy;
}());
exports.ApiProxy = ApiProxy;
//# sourceMappingURL=ApiProxy.js.map |