3 lines
5.7 KiB
JavaScript
3 lines
5.7 KiB
JavaScript
/* Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.*/
|
|
(function(a){var b={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},c=b[typeof window]&&window||this,d=b[typeof exports]&&exports&&!exports.nodeType&&exports,e=b[typeof module]&&module&&!module.nodeType&&module,f=(e&&e.exports===d&&d,b[typeof global]&&global);!f||f.global!==f&&f.window!==f||(c=f),"function"==typeof define&&define.amd?define(["rx.binding","exports"],function(b,d){return c.Rx=a(c,d,b),c.Rx}):"object"==typeof module&&module&&module.exports===d?module.exports=a(c,module.exports,require("./rx")):c.Rx=a(c,{},c.Rx)}).call(this,function(a,b,c,d){function e(a,b){return Array.isArray(a)?f.call(b,a):j(a)?C(a.call(b)):k(a)?C(a):i(a)?g(a):isPromise(a)?h(a):typeof a===z?a:B(a)||Array.isArray(a)?f.call(b,a):a}function f(a){var b=this;return function(c){function d(a,d){if(!f)try{if(a=e(a,b),typeof a!==z)return i[d]=a,--h||c(null,i);a.call(b,function(a,b){if(!f){if(a)return f=!0,c(a);i[d]=b,--h||c(null,i)}})}catch(g){f=!0,c(g)}}var f,g=Object.keys(a),h=g.length,i=new a.constructor;if(!h)return void x.schedule(function(){c(null,i)});for(var j=0,k=g.length;k>j;j++)d(a[g[j]],g[j])}}function g(a){return function(b){var c,d=!1;a.subscribe(function(a){c=a,d=!0},b,function(){d&&b(null,c)})}}function h(a){return function(b){a.then(function(a){b(null,a)},b)}}function i(a){return a&&typeof a.subscribe===z}function j(a){return a&&a.constructor&&"GeneratorFunction"===a.constructor.name}function k(a){return a&&typeof a.next===z&&typeof a[A]===z}function l(a){a&&x.schedule(function(){throw a})}function m(a){return window.StaticNodeList?a instanceof window.StaticNodeList||a instanceof window.NodeList:"[object NodeList]"==Object.prototype.toString.call(a)}function n(b){var c=function(){this.cancelBubble=!0},d=function(){if(this.bubbledKeyCode=this.keyCode,this.ctrlKey)try{this.keyCode=0}catch(a){}this.defaultPrevented=!0,this.returnValue=!1,this.modified=!0};if(b||(b=a.event),!b.target)switch(b.target=b.target||b.srcElement,"mouseover"==b.type&&(b.relatedTarget=b.fromElement),"mouseout"==b.type&&(b.relatedTarget=b.toElement),b.stopPropagation||(b.stopPropagation=c,b.preventDefault=d),b.type){case"keypress":var e="charCode"in b?b.charCode:b.keyCode;10==e?(e=0,b.keyCode=13):13==e||27==e?e=0:3==e&&(e=99),b.charCode=e,b.keyChar=b.charCode?String.fromCharCode(b.charCode):""}return b}function o(a,b,c){if(a.addEventListener)return a.addEventListener(b,c,!1),v(function(){a.removeEventListener(b,c,!1)});if(a.attachEvent){var d=function(a){c(n(a))};return a.attachEvent("on"+b,d),v(function(){a.detachEvent("on"+b,d)})}return a["on"+b]=c,v(function(){a["on"+b]=null})}function p(a,b,c){var d=new w;if(m(a)||"[object HTMLCollection]"===Object.prototype.toString.call(a))for(var e=0,f=a.length;f>e;e++)d.add(p(a.item(e),b,c));else a&&d.add(o(a,b,c));return d}var q=c.Observable,r=(q.prototype,q.fromPromise),s=q.throwError,t=c.AnonymousObservable,u=c.AsyncSubject,v=c.Disposable.create,w=c.CompositeDisposable,x=(c.Scheduler.immediate,c.Scheduler["default"]),y=c.Scheduler.isScheduler,z=(Array.prototype.slice,"function"),A="throw",B=c.internals.isObject,C=c.spawn=function(a){var b=j(a);return function(c){function d(a,b){x.schedule(c.bind(g,a,b))}function f(a,b){var c;if(arguments.length>2)for(var b=[],i=1,j=arguments.length;j>i;i++)b.push(arguments[i]);if(a)try{c=h[A](a)}catch(k){return d(k)}if(!a)try{c=h.next(b)}catch(k){return d(k)}if(c.done)return d(null,c.value);if(c.value=e(c.value,g),typeof c.value!==z)f(new TypeError("Rx.spawn only supports a function, Promise, Observable, Object or Array."));else{var l=!1;try{c.value.call(g,function(){l||(l=!0,f.apply(g,arguments))})}catch(k){x.schedule(function(){l||(l=!0,f.call(g,k))})}}}var g=this,h=a;if(b){for(var i=[],j=0,k=arguments.length;k>j;j++)i.push(arguments[j]);var k=i.length,m=k&&typeof i[k-1]===z;c=m?i.pop():l,h=a.apply(this,i)}else c=c||l;f()}};q.start=function(a,b,c){return D(a,b,c)()};var D=q.toAsync=function(a,b,c){return y(c)||(c=x),function(){var d=arguments,e=new u;return c.schedule(function(){var c;try{c=a.apply(b,d)}catch(f){return void e.onError(f)}e.onNext(c),e.onCompleted()}),e.asObservable()}};q.fromCallback=function(a,b,c){return function(){for(var d=arguments.length,e=new Array(d),f=0;d>f;f++)e[f]=arguments[f];return new t(function(d){function f(){for(var a=arguments.length,e=new Array(a),f=0;a>f;f++)e[f]=arguments[f];if(c){try{e=c.apply(b,e)}catch(g){return d.onError(g)}d.onNext(e)}else e.length<=1?d.onNext.apply(d,e):d.onNext(e);d.onCompleted()}e.push(f),a.apply(b,e)}).publishLast().refCount()}},q.fromNodeCallback=function(a,b,c){return function(){for(var d=arguments.length,e=new Array(d),f=0;d>f;f++)e[f]=arguments[f];return new t(function(d){function f(a){if(a)return void d.onError(a);for(var e=arguments.length,f=[],g=1;e>g;g++)f[g-1]=arguments[g];if(c){try{f=c.apply(b,f)}catch(h){return d.onError(h)}d.onNext(f)}else f.length<=1?d.onNext.apply(d,f):d.onNext(f);d.onCompleted()}e.push(f),a.apply(b,e)}).publishLast().refCount()}},c.config.useNativeEvents=!1,q.fromEvent=function(a,b,d){return a.addListener?E(function(c){a.addListener(b,c)},function(c){a.removeListener(b,c)},d):c.config.useNativeEvents||"function"!=typeof a.on||"function"!=typeof a.off?new t(function(c){return p(a,b,function(a){var b=a;if(d)try{b=d(arguments)}catch(e){return c.onError(e)}c.onNext(b)})}).publish().refCount():E(function(c){a.on(b,c)},function(c){a.off(b,c)},d)};var E=q.fromEventPattern=function(a,b,c){return new t(function(d){function e(a){var b=a;if(c)try{b=c(arguments)}catch(e){return d.onError(e)}d.onNext(b)}var f=a(e);return v(function(){b&&b(e,f)})}).publish().refCount()};return q.startAsync=function(a){var b;try{b=a()}catch(c){return s(c)}return r(b)},c});
|
|
//# sourceMappingURL=rx.async.compat.map
|