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) · 2.92 KB
/
rx.async.compat.min.js
1
(function(t,e){var n="object"==typeof exports&&exports,r=("object"==typeof module&&module&&module.exports==n&&module,"object"==typeof global&&global);r.global===r&&(window=r),"function"==typeof define&&define.amd?define(["rx","exports"],function(n,r){return t.Rx=e(t,r,n),t.Rx}):"object"==typeof module&&module&&module.exports===n?module.exports=e(t,module.exports,require("./rx")):t.Rx=e(t,{},t.Rx)})(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),a(function(){t.removeListener(e,n)});if(t.addEventListener)return t.addEventListener(e,n,!1),a(function(){t.removeEventListener(e,n,!1)});if(t.attachEvent){var i=function(t){n(r(t))};return t.attachEvent("on"+e,i),a(function(){t.detachEvent("on"+e,i)})}return t["on"+e]=n,a(function(){t["on"+e]=null})}function o(t,e,n){var r=new h;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=n.Internals.AnonymousObservable,c=n.AsyncSubject,a=n.Disposable.create,h=n.CompositeDisposable,c=n.AsyncSubject;timeoutScheduler=n.Scheduler.timeout,slice=Array.prototype.slice,s.start=function(t,e,n){return l(t,e,n)()};var l=s.toAsync=function(t,e,n){return e||(e=timeoutScheduler),function(){var r=arguments,i=new c;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){return e||(e=timeoutScheduler),function(){var r=slice.call(arguments,0),i=new c;return e.schedule(function(){function e(){i.onNext(arguments),i.onCompleted()}r.push(e),t.apply(n,r)}),i.asObservable()}},s.fromNodeCallback=function(t,e,n){return e||(e=timeoutScheduler),function(){var r=slice.call(arguments,0),i=new c;return e.schedule(function(){function e(t){var e=slice.call(arguments,1);return t?(i.onError(t),undefined):(i.onNext(e),i.onCompleted(),undefined)}r.push(e),t.apply(n,r)}),i.asObservable()}},s.fromEvent=function(t,e){return new u(function(n){return o(t,e,function(t){n.onNext(t)})}).publish().refCount()},s.fromEventPattern=function(t,e){return new u(function(n){function r(t){n.onNext(t)}var i=t(r);return a(function(){e&&e(r,i)})}).publish().refCount()},s.fromPromise=function(t){var e=new c;return t.then(function(t){e.onNext(t),e.onCompleted()},function(t){e.onError(t)}),e.asObservable()},n});