UNPKG

typescript-dotnet-amd

Version:

A JavaScript-Friendly .NET Based TypeScript Library.

6 lines 1.88 kB
/*! * @author electricessence / https://github.com/electricessence/ * Licensing: MIT */ define(["require","exports","./Promise","../Threading/defer","../Exceptions/ArgumentNullException","../../extends"],function(e,t,o,n,r,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var s=i["default"],u=void 0,l=function(e){function t(t){var o=e.call(this)||this;if(o._resolver=t,!t)throw new r.ArgumentNullException("resolver");return o._resolvedCalled=!0,o}return s(t,e),t.prototype._onDispose=function(){e.prototype._onDispose.call(this),this._resolver=u},t.prototype._onThen=function(){var e=this._resolver;e&&(this._resolver=u,this._resolvedCalled=!1,this.resolveUsing(e))},t.prototype.thenSynchronous=function(t,o){return this._onThen(),e.prototype.thenSynchronous.call(this,t,o)},t.prototype.doneNow=function(t,o){this._onThen(),e.prototype.doneNow.call(this,t,o)},t.prototype.delayFromNow=function(o){var r=this;if(void 0===o&&(o=0),this.throwIfDisposed(),!this._resolver||this.isSettled)return e.prototype.delayFromNow.call(this,o);var i,s=!1,l=n.defer(function(){s=!0,i&&i()},o);return new t(function(e,t){i=function(){r.doneNow(function(t){return e(t)},function(e){return t(e)}),l.dispose(),l=u,i=u},s&&i()})},t.prototype.delayAfterResolve=function(o){var r=this;if(void 0===o&&(o=0),this.throwIfDisposed(),!this._resolver||this.isSettled)return e.prototype.delayAfterResolve.call(this,o);var i,s,l=function(){s&&(s.dispose(),s=u),i&&i(),l=u},f=function(){l&&(s=n.defer(l,o))};return e.prototype.doneNow.call(this,f,f),f=null,new t(function(e,t){r.isPending?(r.doneNow(function(t){return n.defer(function(){return e(t)},o)},function(e){return n.defer(function(){return t(e)},o)}),l()):(i=function(){r.doneNow(function(t){return e(t)},function(e){return t(e)})},l||i())})},t}(o.TSDNPromise);t.LazyPromise=l,t["default"]=l}); //# sourceMappingURL=LazyPromise.js.map