| 679 | // `.copySync()` to get the real value. Numbers/strings/booleans are |
| 680 | // supported; anything exotic falls back to `undefined`. |
| 681 | const unwrapPrimitive = (v) => { |
| 682 | if (v === null || v === undefined) return v |
| 683 | const t = typeof v |
| 684 | if (t === 'number' || t === 'string' || t === 'boolean') return v |
| 685 | if (v && typeof v.copySync === 'function') { |
| 686 | try { |
| 687 | return v.copySync() |
| 688 | } catch { |
| 689 | return undefined |
| 690 | } |
| 691 | } |
| 692 | return v |
| 693 | } |
| 694 | |
| 695 | const setTimeoutRef = new ivm.Reference((fnRef, msRef) => { |
| 696 | const id = nextTimerId++ |