rx.async.compat.min.js 6.2 KB

123
  1. /* Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.*/
  2. (function(a){function b(a){return a&&a.Object===Object?a:null}var c={"function":!0,object:!0},d=c[typeof exports]&&exports&&!exports.nodeType?exports:null,e=c[typeof module]&&module&&!module.nodeType?module:null,f=b(d&&e&&"object"==typeof global&&global),g=b(c[typeof self]&&self),h=b(c[typeof window]&&window),i=(e&&e.exports===d?d:null,b(c[typeof this]&&this)),j=f||h!==(i&&i.window)&&h||g||i||Function("return this")();"function"==typeof define&&define.amd?define(["./rx.binding","exports"],function(b,c){return j.Rx=a(j,c,b),j.Rx}):"object"==typeof module&&module&&module.exports===d?module.exports=a(j,module.exports,require("./rx")):j.Rx=a(j,{},j.Rx)}).call(this,function(a,b,c,d){function e(a){return function(){try{return a.apply(this,arguments)}catch(b){return H.e=b,H}}}function f(a){return a?t.isObservable(a)?a:D(a)?t.fromPromise(a):k(a)||j(a)?J.call(this,a):E(a)?i.call(this,a):G(a)||F(a)?g.call(this,a):l(a)?h.call(this,a):a:a}function g(a){return t.from(a).concatMap(function(a){return t.isObservable(a)||l(a)?f.call(null,a):c.Observable.just(a)}).toArray()}function h(a){function b(a,b){c[b]=d,g.push(a.map(function(a){c[b]=a}))}for(var c=new a.constructor,e=Object.keys(a),g=[],h=0,i=e.length;i>h;h++){var j=e[h],k=f.call(this,a[j]);k&&t.isObservable(k)?b(k,j):c[j]=a[j]}return t.forkJoin.apply(t,g).map(function(){return c})}function i(a){var b=this;return new w(function(c){a.call(b,function(){var a=arguments[0],b=arguments[1];if(a)return c.onError(a);if(arguments.length>2){for(var d=[],e=1,f=arguments.length;f>e;e++)d.push(arguments[e]);b=d}c.onNext(b),c.onCompleted()})})}function j(a){return E(a.next)&&E(a["throw"])}function k(a){var b=a.constructor;return b?"GeneratorFunction"===b.name||"GeneratorFunction"===b.displayName?!0:j(b.prototype):!1}function l(a){return Object==a.constructor}function m(a,b,c,d){var e=new y;return d.push(n(e,b,c)),a.apply(b,d),e.asObservable()}function n(a,b,c){return function(){for(var d=arguments.length,e=new Array(d),f=0;d>f;f++)e[f]=arguments[f];if(E(c)){if(e=I(c).apply(b,e),e===H)return a.onError(e.e);a.onNext(e)}else e.length<=1?a.onNext(e[0]):a.onNext(e);a.onCompleted()}}function o(a,b,c,d){var e=new y;return d.push(p(e,b,c)),a.apply(b,d),e.asObservable()}function p(a,b,c){return function(){var d=arguments[0];if(d)return a.onError(d);for(var e=arguments.length,f=[],g=1;e>g;g++)f[g-1]=arguments[g];if(E(c)){var f=I(c).apply(b,f);if(f===H)return a.onError(f.e);a.onNext(f)}else f.length<=1?a.onNext(f[0]):a.onNext(f);a.onCompleted()}}function q(b){return a.StaticNodeList?b instanceof a.StaticNodeList||b instanceof a.NodeList:"[object NodeList]"===Object.prototype.toString.call(b)}function r(a,b,c){this._e=a,this._n=b,this._fn=c,this._e.addEventListener(this._n,this._fn,!1),this.isDisposed=!1}function s(a,b,c){var d=new z,e=Object.prototype.toString.call(a);if(q(a)||"[object HTMLCollection]"===e)for(var f=0,g=a.length;g>f;f++)d.add(s(a.item(f),b,c));else a&&d.add(new r(a,b,c));return d}var t=c.Observable,u=t.fromPromise,v=t.throwError,w=c.AnonymousObservable,x=c.ObservableBase,y=c.AsyncSubject,z=(c.Disposable.create,c.CompositeDisposable),A=(c.Scheduler.immediate,c.Scheduler["default"]),B=c.internals.inherits,C=c.Scheduler.isScheduler,D=c.helpers.isPromise,E=c.helpers.isFunction,F=c.helpers.isIterable,G=c.helpers.isArrayLike,H={e:{}},I=c.internals.tryCatch=function(a){if(!E(a))throw new TypeError("fn must be a function");return e(a)};t.wrap=function(a){function b(){return t.spawn.call(this,a.apply(this,arguments))}return b.__generatorFunction__=a,b};var J=t.spawn=function(){for(var a=arguments[0],b=this,c=[],d=1,e=arguments.length;e>d;d++)c.push(arguments[d]);return new w(function(d){function e(b){var c=I(a.next).call(a,b);return c===H?d.onError(c.e):void h(c)}function g(b){var c=I(a.next).call(a,b);return c===H?d.onError(c.e):void h(c)}function h(a){if(a.done)return d.onNext(a.value),void d.onCompleted();var c=f.call(b,a.value),h=null,j=!1;t.isObservable(c)?i.add(c.subscribe(function(a){j=!0,h=a},g,function(){j&&e(h)})):g(new TypeError("type not supported"))}var i=new z;return E(a)&&(a=a.apply(b,c)),a&&E(a.next)?(e(),i):(d.onNext(a),d.onCompleted())})};t.start=function(a,b,c){return K(a,b,c)()};var K=t.toAsync=function(a,b,c){return C(c)||(c=A),function(){var d=arguments,e=new y;return c.schedule(null,function(){var c;try{c=a.apply(b,d)}catch(f){return void e.onError(f)}e.onNext(c),e.onCompleted()}),e.asObservable()}};t.fromCallback=function(a,b,c){return function(){"undefined"==typeof b&&(b=this);for(var d=arguments.length,e=new Array(d),f=0;d>f;f++)e[f]=arguments[f];return m(a,b,c,e)}},t.fromNodeCallback=function(a,b,c){return function(){"undefined"==typeof b&&(b=this);for(var d=arguments.length,e=new Array(d),f=0;d>f;f++)e[f]=arguments[f];return o(a,b,c,e)}},r.prototype.dispose=function(){this.isDisposed||(this._e.removeEventListener(this._n,this._fn,!1),this.isDisposed=!0)},c.config.useNativeEvents=!1;var L=function(a){function b(b,c,d){this._el=b,this._n=c,this._fn=d,a.call(this)}function c(a,b){return function(){var c=arguments[0];return E(b)&&(c=I(b).apply(null,arguments),c===H)?a.onError(c.e):void a.onNext(c)}}return B(b,a),b.prototype.subscribeCore=function(a){return s(this._el,this._n,c(a,this._fn))},b}(x);t.fromEvent=function(a,b,d){return a.addListener?N(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 L(a,b,d).publish().refCount():N(function(c){a.on(b,c)},function(c){a.off(b,c)},d)};var M=function(a){function b(b,c,d){this._add=b,this._del=c,this._fn=d,a.call(this)}function c(a,b){return function(){var c=arguments[0];return E(b)&&(c=I(b).apply(null,arguments),c===H)?a.onError(c.e):void a.onNext(c)}}function d(a,b,c){this._del=a,this._fn=b,this._ret=c,this.isDisposed=!1}return B(b,a),b.prototype.subscribeCore=function(a){var b=c(a,this._fn),e=this._add(b);return new d(this._del,b,e)},d.prototype.dispose=function(){this.isDisposed||(E(this._del)&&this._del(this._fn,this._ret),this.isDisposed=!0)},b}(x),N=t.fromEventPattern=function(a,b,c){return new M(a,b,c).publish().refCount()};return t.startAsync=function(a){var b=I(a)();return b===H?v(b.e):u(b)},c});
  3. //# sourceMappingURL=rx.async.compat.map