ncjsm/utils/pass-thru.js
raw| 1 | // Promise-like mock, to be used for sync resolution of modules |
| 2 | |
| 3 | "use strict"; |
| 4 | |
| 5 | const PassThru = (module.exports = function (value) { this.value = value; }); |
| 6 | |
| 7 | PassThru.prototype.then = function (fn) { |
| 8 | const result = fn(this.value); |
| 9 | if (result instanceof PassThru) return result; |
| 10 | return new PassThru(result); |
| 11 | }; |