promise-try.mjs
sha256:8915fe406161f95c1681f9469375e7bae5b28c884f00bedbdef65e4b0cd0738d
docs(flow): commit FLOW-V0-SPEC.md hygiene for 7A-INT merge
Human
10 hours ago
| 1 | /** |
| 2 | * PDF.js (via unpdf) uses Promise.try (ES2024). Node 20 does not implement it; bridge/CI use Node 20. |
| 3 | * The standard signature is `Promise.try(fn, ...args)` and invokes `fn` with `args` (e.g. worker |
| 4 | * `Promise.try(handler, e.data)`). A no-arg `fn => resolve(fn())` polyfill breaks PDF import in CI. |
| 5 | * @see https://github.com/tc39/proposal-promise-try |
| 6 | */ |
| 7 | if (typeof Promise.try !== 'function') { |
| 8 | Promise.try = (fn, ...args) => { |
| 9 | try { |
| 10 | return Promise.resolve(fn.call(undefined, ...args)); |
| 11 | } catch (e) { |
| 12 | return Promise.reject(e); |
| 13 | } |
| 14 | }; |
| 15 | } |
File History
1 commit
sha256:8915fe406161f95c1681f9469375e7bae5b28c884f00bedbdef65e4b0cd0738d
docs(flow): commit FLOW-V0-SPEC.md hygiene for 7A-INT merge
Human
10 hours ago