MCPcopy Create free account
hub / github.com/cmliu/CF-Workers-CheckProxyIP / withTimeout

Function withTimeout

_worker.js:5513–5524  ·  view source on GitHub ↗
(promise, timeoutMs, label)

Source from the content-addressed store, hash-verified

5511}
5512
5513function withTimeout(promise, timeoutMs, label) {
5514 let timer;
5515 return Promise.race([
5516 promise,
5517 new Promise((_, reject) => {
5518 timer = setTimeout(
5519 () => reject(new Error(`${label} timeout after ${timeoutMs}ms`)),
5520 timeoutMs
5521 );
5522 }),
5523 ]).finally(() => clearTimeout(timer));
5524}
5525
5526function indexOfBytes(haystack, needle, start = 0) {
5527 outer: for (let i = start; i <= haystack.length - needle.length; i++) {

Callers 1

handleCheckProxyRequestFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected