forked from Reactive-Extensions/RxJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrx.async.compat.min.js
1 lines (1 loc) · 3.45 KB
/
rx.async.compat.min.js
1
(function(t){var e={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},n=e[typeof window]&&window||this,r=e[typeof exports]&&exports&&!exports.nodeType&&exports,i=e[typeof module]&&module&&!module.nodeType&&module,o=(i&&i.exports===r&&r,e[typeof global]&&global);!o||o.global!==o&&o.window!==o||(n=o),"function"==typeof define&&define.amd?define(["rx","exports"],function(e,r){return n.Rx=t(n,r,e),n.Rx}):"object"==typeof module&&module&&module.exports===r?module.exports=t(n,module.exports,require("./rx")):n.Rx=t(n,{},n.Rx)}).call(this,function(t,e,n){function r(t){var e=function(){this.cancelBubble=!0},n=function(){if(this.bubbledKeyCode=this.keyCode,this.ctrlKey)try{this.keyCode=0}catch(t){}this.defaultPrevented=!0,this.returnValue=!1,this.modified=!0};if(t||(t=window.event),!t.target)switch(t.target=t.target||t.srcElement,"mouseover"==t.type&&(t.relatedTarget=t.fromElement),"mouseout"==t.type&&(t.relatedTarget=t.toElement),t.stopPropagation||(t.stopPropagation=e,t.preventDefault=n),t.type){case"keypress":var r="charCode"in t?t.charCode:t.keyCode;10==r?(r=0,t.keyCode=13):13==r||27==r?r=0:3==r&&(r=99),t.charCode=r,t.keyChar=t.charCode?String.fromCharCode(t.charCode):""}return t}function i(t,e,n){if(t.addListener)return t.addListener(e,n),h(function(){t.removeListener(e,n)});if(t.addEventListener)return t.addEventListener(e,n,!1),h(function(){t.removeEventListener(e,n,!1)});if(t.attachEvent){var i=function(t){n(r(t))};return t.attachEvent("on"+e,i),h(function(){t.detachEvent("on"+e,i)})}return t["on"+e]=n,h(function(){t["on"+e]=null})}function o(t,e,n){var r=new f;if(t&&t.length)for(var s=0,u=t.length;u>s;s++)r.add(o(t[s],e,n));else t&&r.add(i(t,e,n));return r}var s=n.Observable,u=s.prototype,c=n.Internals.AnonymousObservable,a=n.AsyncSubject,h=n.Disposable.create,f=n.CompositeDisposable,l=n.Scheduler.immediate,p=Array.prototype.slice;s.start=function(t,e,n){return d(t,e,n)()};var d=s.toAsync=function(t,e,n){return e||(e=timeoutScheduler),function(){var r=arguments,i=new a;return e.schedule(function(){var e;try{e=t.apply(n,r)}catch(o){return i.onError(o),undefined}i.onNext(e),i.onCompleted()}),i.asObservable()}};return s.fromCallback=function(t,e,n,r){return e||(e=l),function(){var i=p.call(arguments,0);return new c(function(o){return e.schedule(function(){function e(t){var e=t;if(r)try{e=r(arguments)}catch(n){return o.onError(n),undefined}else 1===e.length&&(e=e[0]);o.onNext(e),o.onCompleted()}i.push(e),t.apply(n,i)})})}},s.fromNodeCallback=function(t,e,n,r){return e||(e=l),function(){var i=p.call(arguments,0);return new c(function(o){return e.schedule(function(){function e(t){if(t)return o.onError(t),undefined;var e=p.call(arguments,1);if(r)try{e=r(e)}catch(n){return o.onError(n),undefined}else 1===e.length&&(e=e[0]);o.onNext(e),o.onCompleted()}i.push(e),t.apply(n,i)})})}},s.fromEvent=function(t,e,n){return new c(function(r){return o(t,e,function(t){var e=t;if(n)try{e=n(arguments)}catch(i){return r.onError(i),undefined}r.onNext(e)})}).publish().refCount()},s.fromEventPattern=function(t,e,n){return new c(function(r){function i(t){var e=t;if(n)try{e=n(arguments)}catch(i){return r.onError(i),undefined}r.onNext(e)}var o=t(i);return h(function(){e&&e(i,o)})}).publish().refCount()},s.fromPromise=function(t){return new c(function(e){t.then(function(t){e.onNext(t),e.onCompleted()},function(t){e.onError(t)})})},u.toPromise=function(t){var e=this;return new t(function(t,n){var r,i=!1;e.subscribe(function(t){r=t,i=!0},function(t){n(t)},function(){i&&t(r)})})},n});