()
| 8 | }); |
| 9 | |
| 10 | function installAsyncHook () { |
| 11 | let id; |
| 12 | let destroyed; |
| 13 | let hook; |
| 14 | const events = []; |
| 15 | return new Promise((resolve, reject) => { |
| 16 | const interval = setInterval(() => { |
| 17 | if (destroyed) { |
| 18 | hook.disable(); |
| 19 | clearInterval(interval); |
| 20 | resolve(events); |
| 21 | } |
| 22 | }, 10); |
| 23 | |
| 24 | hook = asyncHook |
| 25 | .createHook({ |
| 26 | init (asyncId, type, triggerAsyncId, resource) { |
| 27 | if (id === undefined && type === 'func_ref_resources') { |
| 28 | id = asyncId; |
| 29 | events.push({ eventName: 'init', type, triggerAsyncId, resource }); |
| 30 | } |
| 31 | }, |
| 32 | before (asyncId) { |
| 33 | if (asyncId === id) { |
| 34 | events.push({ eventName: 'before' }); |
| 35 | } |
| 36 | }, |
| 37 | after (asyncId) { |
| 38 | if (asyncId === id) { |
| 39 | events.push({ eventName: 'after' }); |
| 40 | } |
| 41 | }, |
| 42 | destroy (asyncId) { |
| 43 | if (asyncId === id) { |
| 44 | events.push({ eventName: 'destroy' }); |
| 45 | destroyed = true; |
| 46 | } |
| 47 | } |
| 48 | }) |
| 49 | .enable(); |
| 50 | }); |
| 51 | } |
| 52 | |
| 53 | function canConstructRefFromExistingRef (binding) { |
| 54 | const testFunc = () => 240; |
no outgoing calls
no test coverage detected