* Retrieves the contents of a file from the main thread. * @param {string} url * @param {function} cb
(url, cb)
| 227 | * @param {function} cb |
| 228 | */ |
| 229 | function getFile(url, cb) { |
| 230 | const id = Number.parseInt(Date.now() + Math.random() * 1000000); |
| 231 | resolvers[id] = cb; |
| 232 | self.postMessage({ |
| 233 | action: "get-file", |
| 234 | data: url, |
| 235 | id, |
| 236 | }); |
| 237 | } |
| 238 | |
| 239 | /** |
| 240 | * Sends a message to the main thread to indicate that the worker is done searching |