(context, args)
| 397 | let timeout = null |
| 398 | let lastPromiseSrc = new PromiseSource() |
| 399 | const applyFn = function (context, args) { |
| 400 | let result = undefined |
| 401 | try { |
| 402 | result = func.apply(context, args) |
| 403 | } catch (err) { |
| 404 | lastPromiseSrc.reject(err) |
| 405 | } |
| 406 | if (result instanceof Promise) { |
| 407 | result.then(lastPromiseSrc.resolve, lastPromiseSrc.reject) |
| 408 | } else { |
| 409 | lastPromiseSrc.resolve(result) |
| 410 | } |
| 411 | } |
| 412 | return function (...args) { |
| 413 | const callNow = Boolean(immediate && !timeout) |
| 414 | const context = this |