MCPcopy Create free account
hub / github.com/bigskysoftware/_hyperscript / getProxy

Method getProxy

www/js/_hyperscript-max.js:11341–11388  ·  view source on GitHub ↗
(timeout)

Source from the content-addressed store, hash-verified

11339 }
11340 var socket = new WebSocket(parseUrl(url.evalStatically()));
11341 function getProxy(timeout) {
11342 return new Proxy(
11343 {},
11344 {
11345 get: function(obj, property) {
11346 if (PROXY_BLACKLIST.includes(property)) {
11347 return null;
11348 } else if (property === "noTimeout") {
11349 return getProxy(-1);
11350 } else if (property === "timeout") {
11351 return function(i) {
11352 return getProxy(parseInt(i));
11353 };
11354 } else {
11355 return function() {
11356 var uuid = genUUID();
11357 var args = [];
11358 for (var i = 0; i < arguments.length; i++) {
11359 args.push(arguments[i]);
11360 }
11361 var rpcInfo = {
11362 iid: uuid,
11363 function: property,
11364 args
11365 };
11366 socket = socket ? socket : new WebSocket(parseUrl(url.evalStatically()));
11367 socket.send(JSON.stringify(rpcInfo));
11368 var promise = new Promise(function(resolve, reject) {
11369 promises[uuid] = {
11370 resolve,
11371 reject
11372 };
11373 });
11374 if (timeout >= 0) {
11375 setTimeout(function() {
11376 if (promises[uuid]) {
11377 promises[uuid].reject("Timed out");
11378 }
11379 delete promises[uuid];
11380 }, timeout);
11381 }
11382 return promise;
11383 };
11384 }
11385 }
11386 }
11387 );
11388 }
11389 var rpcProxy = getProxy(defaultTimeout);
11390 var socketObject = {
11391 raw: socket,

Callers

nothing calls this directly

Calls 4

genUUIDFunction · 0.70
parseUrlFunction · 0.70
setTimeoutFunction · 0.50
evalStaticallyMethod · 0.45

Tested by

no test coverage detected