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

Method getProxy

www/js/ext/socket.esm.js:123–170  ·  view source on GitHub ↗
(timeout)

Source from the content-addressed store, hash-verified

121 }
122 var socket = new WebSocket(parseUrl(url.evalStatically()));
123 function getProxy(timeout) {
124 return new Proxy(
125 {},
126 {
127 get: function(obj, property) {
128 if (PROXY_BLACKLIST.includes(property)) {
129 return null;
130 } else if (property === "noTimeout") {
131 return getProxy(-1);
132 } else if (property === "timeout") {
133 return function(i) {
134 return getProxy(parseInt(i));
135 };
136 } else {
137 return function() {
138 var uuid = genUUID();
139 var args = [];
140 for (var i = 0; i < arguments.length; i++) {
141 args.push(arguments[i]);
142 }
143 var rpcInfo = {
144 iid: uuid,
145 function: property,
146 args
147 };
148 socket = socket ? socket : new WebSocket(parseUrl(url.evalStatically()));
149 socket.send(JSON.stringify(rpcInfo));
150 var promise = new Promise(function(resolve, reject) {
151 promises[uuid] = {
152 resolve,
153 reject
154 };
155 });
156 if (timeout >= 0) {
157 setTimeout(function() {
158 if (promises[uuid]) {
159 promises[uuid].reject("Timed out");
160 }
161 delete promises[uuid];
162 }, timeout);
163 }
164 return promise;
165 };
166 }
167 }
168 }
169 );
170 }
171 var rpcProxy = getProxy(defaultTimeout);
172 var socketObject = {
173 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