forked from Reactive-Extensions/RxJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rx.async.compat.min.js
1 lines (1 loc) · 3.64 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,o=e[typeof module]&&module&&!module.nodeType&&module,i=(o&&o.exports===r&&r,e[typeof global]&&global);!i||i.global!==i&&i.window!==i||(n=i),"function"==typeof define&&define.amd?define(["rx.binding","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(e){var n=function(){this.cancelBubble=!0},r=function(){if(this.bubbledKeyCode=this.keyCode,this.ctrlKey)try{this.keyCode=0}catch(t){}this.defaultPrevented=!0,this.returnValue=!1,this.modified=!0};if(e||(e=t.event),!e.target)switch(e.target=e.target||e.srcElement,"mouseover"==e.type&&(e.relatedTarget=e.fromElement),"mouseout"==e.type&&(e.relatedTarget=e.toElement),e.stopPropagation||(e.stopPropagation=n,e.preventDefault=r),e.type){case"keypress":var o="charCode"in e?e.charCode:e.keyCode;10==o?(o=0,e.keyCode=13):13==o||27==o?o=0:3==o&&(o=99),e.charCode=o,e.keyChar=e.charCode?String.fromCharCode(e.charCode):""}return e}function o(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 o=function(t){n(r(t))};return t.attachEvent("on"+e,o),h(function(){t.detachEvent("on"+e,o)})}return t["on"+e]=n,h(function(){t["on"+e]=null})}function i(t,e,n){var r=new f;if("function"==typeof t.item&&"number"==typeof t.length)for(var s=0,u=t.length;u>s;s++)r.add(i(t.item(s),e,n));else t&&r.add(o(t,e,n));return r}var s=n.Observable,u=(s.prototype,s.fromPromise),c=s.throwException,a=n.AnonymousObservable,l=n.AsyncSubject,h=n.Disposable.create,f=n.CompositeDisposable,p=n.Scheduler.immediate,d=n.Scheduler.timeout,b=Array.prototype.slice;s.start=function(t,e,n){return v(t,e,n)()};var v=s.toAsync=function(t,e,n){return e||(e=d),function(){var r=arguments,o=new l;return e.schedule(function(){var e;try{e=t.apply(n,r)}catch(i){return o.onError(i),undefined}o.onNext(e),o.onCompleted()}),o.asObservable()}};s.fromCallback=function(t,e,n,r){return e||(e=p),function(){var o=b.call(arguments,0);return new a(function(i){return e.schedule(function(){function e(t){var e=t;if(r)try{e=r(arguments)}catch(n){return i.onError(n),undefined}else 1===e.length&&(e=e[0]);i.onNext(e),i.onCompleted()}o.push(e),t.apply(n,o)})})}},s.fromNodeCallback=function(t,e,n,r){return e||(e=p),function(){var o=b.call(arguments,0);return new a(function(i){return e.schedule(function(){function e(t){if(t)return i.onError(t),undefined;var e=b.call(arguments,1);if(r)try{e=r(e)}catch(n){return i.onError(n),undefined}else 1===e.length&&(e=e[0]);i.onNext(e),i.onCompleted()}o.push(e),t.apply(n,o)})})}};var m=t.angular&&angular.element?angular.element:t.jQuery?t.jQuery:t.Zepto?t.Zepto:null,y=!!t.Ember&&"function"==typeof t.Ember.addListener;s.fromEvent=function(t,e,n){if(y)return g(function(){Ember.addListener(t,e)},function(){Ember.removeListener(t,e)},n);if(m){var r=m(t);return g(function(t){r.on(e,t)},function(t){r.off(e,t)},n)}return new a(function(r){return i(t,e,function(t){var e=t;if(n)try{e=n(arguments)}catch(o){return r.onError(o),undefined}r.onNext(e)})}).publish().refCount()};var g=s.fromEventPattern=function(t,e,n){return new a(function(r){function o(t){var e=t;if(n)try{e=n(arguments)}catch(o){return r.onError(o),undefined}r.onNext(e)}var i=t(o);return h(function(){e&&e(o,i)})}).publish().refCount()};return s.startAsync=function(t){var e;try{e=t()}catch(n){return c(n)}return u(e)},n});