UNPKG

dropkiq

Version:

Liquid Expressions Simplified

1 lines 1.01 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var underscore_1=require("./underscore");function mkResolve(e){var n={then:function(n){return n(e)},catch:function(){return n}};return n}function mkReject(e){var n={then:function(t,r){return r?r(e):n},catch:function(n){return n(e)}};return n}function isThenable(e){return e&&underscore_1.isFunction(e.then)}function isCustomIterable(e){return e&&underscore_1.isFunction(e.next)&&underscore_1.isFunction(e.throw)&&underscore_1.isFunction(e.return)}function toThenable(e){return isThenable(e)?e:isCustomIterable(e)?function n(t){var r;try{r=e.next(t)}catch(e){return mkReject(e)}return r.done?mkResolve(r.value):toThenable(r.value).then(n,(function(t){var r;try{r=e.throw(t)}catch(e){return mkReject(e)}return r.done?mkResolve(r.value):n(r.value)}))}():mkResolve(e)}function toValue(e){var n;return toThenable(e).then((function(e){return mkResolve(n=e)})).catch((function(e){throw e})),n}exports.toThenable=toThenable,exports.toValue=toValue;