(promise, timeoutMs, label)
| 5511 | } |
| 5512 | |
| 5513 | function 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 | |
| 5526 | function indexOfBytes(haystack, needle, start = 0) { |
| 5527 | outer: for (let i = start; i <= haystack.length - needle.length; i++) { |
no outgoing calls
no test coverage detected