This commit is contained in:
tatianamac
2019-11-26 14:50:43 -08:00
parent 8a55660ed0
commit 6d5445ecc5
13894 changed files with 2233957 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
import { Observable } from '../Observable';
import { ScalarObservable } from './ScalarObservable';
import { EmptyObservable } from './EmptyObservable';
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
export class ArrayLikeObservable extends Observable {
constructor(arrayLike, scheduler) {
super();
this.arrayLike = arrayLike;
this.scheduler = scheduler;
if (!scheduler && arrayLike.length === 1) {
this._isScalar = true;
this.value = arrayLike[0];
}
}
static create(arrayLike, scheduler) {
const length = arrayLike.length;
if (length === 0) {
return new EmptyObservable();
}
else if (length === 1) {
return new ScalarObservable(arrayLike[0], scheduler);
}
else {
return new ArrayLikeObservable(arrayLike, scheduler);
}
}
static dispatch(state) {
const { arrayLike, index, length, subscriber } = state;
if (subscriber.closed) {
return;
}
if (index >= length) {
subscriber.complete();
return;
}
subscriber.next(arrayLike[index]);
state.index = index + 1;
this.schedule(state);
}
/** @deprecated internal use only */ _subscribe(subscriber) {
let index = 0;
const { arrayLike, scheduler } = this;
const length = arrayLike.length;
if (scheduler) {
return scheduler.schedule(ArrayLikeObservable.dispatch, 0, {
arrayLike, index, length, subscriber
});
}
else {
for (let i = 0; i < length && !subscriber.closed; i++) {
subscriber.next(arrayLike[i]);
}
subscriber.complete();
}
}
}
//# sourceMappingURL=ArrayLikeObservable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ArrayLikeObservable.js","sourceRoot":"","sources":["../../src/observable/ArrayLikeObservable.ts"],"names":[],"mappings":"OACO,EAAE,UAAU,EAAE,MAAM,eAAe;OACnC,EAAE,gBAAgB,EAAE,MAAM,oBAAoB;OAC9C,EAAE,eAAe,EAAE,MAAM,mBAAmB;AAInD;;;;GAIG;AACH,yCAA4C,UAAU;IAmCpD,YAAoB,SAAuB,EAAU,SAAsB;QACzE,OAAO,CAAC;QADU,cAAS,GAAT,SAAS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KAAK,CAAC,CAAC;IAC/B,CAAC;IAaD,oCAAoC,CAAC,UAAU,CAAC,UAAyB;QACvE,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;QACtC,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;QAEhC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;YACd,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,mBAAmB,CAAC,QAAQ,EAAE,CAAC,EAAE;gBACzD,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU;aACrC,CAAC,CAAC;QACL,CAAC;QAAC,IAAI,CAAC,CAAC;YACN,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACtD,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;YAChC,CAAC;YACD,UAAU,CAAC,QAAQ,EAAE,CAAC;QACxB,CAAC;IACH,CAAC;AACH,CAAC;AAAA"}

View File

@@ -0,0 +1,109 @@
import { Observable } from '../Observable';
import { ScalarObservable } from './ScalarObservable';
import { EmptyObservable } from './EmptyObservable';
import { isScheduler } from '../util/isScheduler';
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
export class ArrayObservable extends Observable {
constructor(array, scheduler) {
super();
this.array = array;
this.scheduler = scheduler;
if (!scheduler && array.length === 1) {
this._isScalar = true;
this.value = array[0];
}
}
static create(array, scheduler) {
return new ArrayObservable(array, scheduler);
}
/**
* Creates an Observable that emits some values you specify as arguments,
* immediately one after the other, and then emits a complete notification.
*
* <span class="informal">Emits the arguments you provide, then completes.
* </span>
*
* <img src="./img/of.png" width="100%">
*
* This static operator is useful for creating a simple Observable that only
* emits the arguments given, and the complete notification thereafter. It can
* be used for composing with other Observables, such as with {@link concat}.
* By default, it uses a `null` IScheduler, which means the `next`
* notifications are sent synchronously, although with a different IScheduler
* it is possible to determine when those notifications will be delivered.
*
* @example <caption>Emit 10, 20, 30, then 'a', 'b', 'c', then start ticking every second.</caption>
* var numbers = Rx.Observable.of(10, 20, 30);
* var letters = Rx.Observable.of('a', 'b', 'c');
* var interval = Rx.Observable.interval(1000);
* var result = numbers.concat(letters).concat(interval);
* result.subscribe(x => console.log(x));
*
* @see {@link create}
* @see {@link empty}
* @see {@link never}
* @see {@link throw}
*
* @param {...T} values Arguments that represent `next` values to be emitted.
* @param {Scheduler} [scheduler] A {@link IScheduler} to use for scheduling
* the emissions of the `next` notifications.
* @return {Observable<T>} An Observable that emits each given input value.
* @static true
* @name of
* @owner Observable
*/
static of(...array) {
let scheduler = array[array.length - 1];
if (isScheduler(scheduler)) {
array.pop();
}
else {
scheduler = null;
}
const len = array.length;
if (len > 1) {
return new ArrayObservable(array, scheduler);
}
else if (len === 1) {
return new ScalarObservable(array[0], scheduler);
}
else {
return new EmptyObservable(scheduler);
}
}
static dispatch(state) {
const { array, index, count, subscriber } = state;
if (index >= count) {
subscriber.complete();
return;
}
subscriber.next(array[index]);
if (subscriber.closed) {
return;
}
state.index = index + 1;
this.schedule(state);
}
/** @deprecated internal use only */ _subscribe(subscriber) {
let index = 0;
const array = this.array;
const count = array.length;
const scheduler = this.scheduler;
if (scheduler) {
return scheduler.schedule(ArrayObservable.dispatch, 0, {
array, index, count, subscriber
});
}
else {
for (let i = 0; i < count && !subscriber.closed; i++) {
subscriber.next(array[i]);
}
subscriber.complete();
}
}
}
//# sourceMappingURL=ArrayObservable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ArrayObservable.js","sourceRoot":"","sources":["../../src/observable/ArrayObservable.ts"],"names":[],"mappings":"OACO,EAAE,UAAU,EAAE,MAAM,eAAe;OACnC,EAAE,gBAAgB,EAAE,MAAM,oBAAoB;OAC9C,EAAE,eAAe,EAAE,MAAM,mBAA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,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YAC5B,CAAC;YACD,UAAU,CAAC,QAAQ,EAAE,CAAC;QACxB,CAAC;IACH,CAAC;AACH,CAAC;AAAA"}

View File

@@ -0,0 +1,242 @@
import { Observable } from '../Observable';
import { tryCatch } from '../util/tryCatch';
import { errorObject } from '../util/errorObject';
import { AsyncSubject } from '../AsyncSubject';
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
export class BoundCallbackObservable extends Observable {
constructor(callbackFunc, selector, args, context, scheduler) {
super();
this.callbackFunc = callbackFunc;
this.selector = selector;
this.args = args;
this.context = context;
this.scheduler = scheduler;
}
/* tslint:enable:max-line-length */
/**
* Converts a callback API to a function that returns an Observable.
*
* <span class="informal">Give it a function `f` of type `f(x, callback)` and
* it will return a function `g` that when called as `g(x)` will output an
* Observable.</span>
*
* `bindCallback` is not an operator because its input and output are not
* Observables. The input is a function `func` with some parameters, the
* last parameter must be a callback function that `func` calls when it is
* done.
*
* The output of `bindCallback` is a function that takes the same parameters
* as `func`, except the last one (the callback). When the output function
* is called with arguments it will return an Observable. If function `func`
* calls its callback with one argument the Observable will emit that value.
* If on the other hand the callback is called with multiple values the resulting
* Observable will emit an array with said values as arguments.
*
* It is very important to remember that input function `func` is not called
* when the output function is, but rather when the Observable returned by the output
* function is subscribed. This means if `func` makes an AJAX request, that request
* will be made every time someone subscribes to the resulting Observable, but not before.
*
* Optionally, a selector function can be passed to `bindObservable`. The selector function
* takes the same arguments as the callback and returns the value that will be emitted by the Observable.
* Even though by default multiple arguments passed to callback appear in the stream as an array
* the selector function will be called with arguments directly, just as the callback would.
* This means you can imagine the default selector (when one is not provided explicitly)
* as a function that aggregates all its arguments into an array, or simply returns first argument
* if there is only one.
*
* The last optional parameter - {@link Scheduler} - can be used to control when the call
* to `func` happens after someone subscribes to Observable, as well as when results
* passed to callback will be emitted. By default, the subscription to an Observable calls `func`
* synchronously, but using `Scheduler.async` as the last parameter will defer the call to `func`,
* just like wrapping the call in `setTimeout` with a timeout of `0` would. If you use the async Scheduler
* and call `subscribe` on the output Observable all function calls that are currently executing
* will end before `func` is invoked.
*
* By default results passed to the callback are emitted immediately after `func` invokes the callback.
* In particular, if the callback is called synchronously the subscription of the resulting Observable
* will call the `next` function synchronously as well. If you want to defer that call,
* you may use `Scheduler.async` just as before. This means that by using `Scheduler.async` you can
* ensure that `func` always calls its callback asynchronously, thus avoiding terrifying Zalgo.
*
* Note that the Observable created by the output function will always emit a single value
* and then complete immediately. If `func` calls the callback multiple times, values from subsequent
* calls will not appear in the stream. If you need to listen for multiple calls,
* you probably want to use {@link fromEvent} or {@link fromEventPattern} instead.
*
* If `func` depends on some context (`this` property) and is not already bound the context of `func`
* will be the context that the output function has at call time. In particular, if `func`
* is called as a method of some objec and if `func` is not already bound, in order to preserve the context
* it is recommended that the context of the output function is set to that object as well.
*
* If the input function calls its callback in the "node style" (i.e. first argument to callback is
* optional error parameter signaling whether the call failed or not), {@link bindNodeCallback}
* provides convenient error handling and probably is a better choice.
* `bindCallback` will treat such functions the same as any other and error parameters
* (whether passed or not) will always be interpreted as regular callback argument.
*
*
* @example <caption>Convert jQuery's getJSON to an Observable API</caption>
* // Suppose we have jQuery.getJSON('/my/url', callback)
* var getJSONAsObservable = Rx.Observable.bindCallback(jQuery.getJSON);
* var result = getJSONAsObservable('/my/url');
* result.subscribe(x => console.log(x), e => console.error(e));
*
*
* @example <caption>Receive an array of arguments passed to a callback</caption>
* someFunction((a, b, c) => {
* console.log(a); // 5
* console.log(b); // 'some string'
* console.log(c); // {someProperty: 'someValue'}
* });
*
* const boundSomeFunction = Rx.Observable.bindCallback(someFunction);
* boundSomeFunction().subscribe(values => {
* console.log(values) // [5, 'some string', {someProperty: 'someValue'}]
* });
*
*
* @example <caption>Use bindCallback with a selector function</caption>
* someFunction((a, b, c) => {
* console.log(a); // 'a'
* console.log(b); // 'b'
* console.log(c); // 'c'
* });
*
* const boundSomeFunction = Rx.Observable.bindCallback(someFunction, (a, b, c) => a + b + c);
* boundSomeFunction().subscribe(value => {
* console.log(value) // 'abc'
* });
*
*
* @example <caption>Compare behaviour with and without async Scheduler</caption>
* function iCallMyCallbackSynchronously(cb) {
* cb();
* }
*
* const boundSyncFn = Rx.Observable.bindCallback(iCallMyCallbackSynchronously);
* const boundAsyncFn = Rx.Observable.bindCallback(iCallMyCallbackSynchronously, null, Rx.Scheduler.async);
*
* boundSyncFn().subscribe(() => console.log('I was sync!'));
* boundAsyncFn().subscribe(() => console.log('I was async!'));
* console.log('This happened...');
*
* // Logs:
* // I was sync!
* // This happened...
* // I was async!
*
*
* @example <caption>Use bindCallback on an object method</caption>
* const boundMethod = Rx.Observable.bindCallback(someObject.methodWithCallback);
* boundMethod.call(someObject) // make sure methodWithCallback has access to someObject
* .subscribe(subscriber);
*
*
* @see {@link bindNodeCallback}
* @see {@link from}
* @see {@link fromPromise}
*
* @param {function} func A function with a callback as the last parameter.
* @param {function} [selector] A function which takes the arguments from the
* callback and maps them to a value that is emitted on the output Observable.
* @param {Scheduler} [scheduler] The scheduler on which to schedule the
* callbacks.
* @return {function(...params: *): Observable} A function which returns the
* Observable that delivers the same values the callback would deliver.
* @static true
* @name bindCallback
* @owner Observable
*/
static create(func, selector = undefined, scheduler) {
return function (...args) {
return new BoundCallbackObservable(func, selector, args, this, scheduler);
};
}
/** @deprecated internal use only */ _subscribe(subscriber) {
const callbackFunc = this.callbackFunc;
const args = this.args;
const scheduler = this.scheduler;
let subject = this.subject;
if (!scheduler) {
if (!subject) {
subject = this.subject = new AsyncSubject();
const handler = function handlerFn(...innerArgs) {
const source = handlerFn.source;
const { selector, subject } = source;
if (selector) {
const result = tryCatch(selector).apply(this, innerArgs);
if (result === errorObject) {
subject.error(errorObject.e);
}
else {
subject.next(result);
subject.complete();
}
}
else {
subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs);
subject.complete();
}
};
// use named function instance to avoid closure.
handler.source = this;
const result = tryCatch(callbackFunc).apply(this.context, args.concat(handler));
if (result === errorObject) {
subject.error(errorObject.e);
}
}
return subject.subscribe(subscriber);
}
else {
return scheduler.schedule(BoundCallbackObservable.dispatch, 0, { source: this, subscriber, context: this.context });
}
}
static dispatch(state) {
const self = this;
const { source, subscriber, context } = state;
const { callbackFunc, args, scheduler } = source;
let subject = source.subject;
if (!subject) {
subject = source.subject = new AsyncSubject();
const handler = function handlerFn(...innerArgs) {
const source = handlerFn.source;
const { selector, subject } = source;
if (selector) {
const result = tryCatch(selector).apply(this, innerArgs);
if (result === errorObject) {
self.add(scheduler.schedule(dispatchError, 0, { err: errorObject.e, subject }));
}
else {
self.add(scheduler.schedule(dispatchNext, 0, { value: result, subject }));
}
}
else {
const value = innerArgs.length <= 1 ? innerArgs[0] : innerArgs;
self.add(scheduler.schedule(dispatchNext, 0, { value, subject }));
}
};
// use named function to pass values in without closure
handler.source = source;
const result = tryCatch(callbackFunc).apply(context, args.concat(handler));
if (result === errorObject) {
subject.error(errorObject.e);
}
}
self.add(subject.subscribe(subscriber));
}
}
function dispatchNext(arg) {
const { value, subject } = arg;
subject.next(value);
subject.complete();
}
function dispatchError(arg) {
const { err, subject } = arg;
subject.error(err);
}
//# sourceMappingURL=BoundCallbackObservable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"BoundCallbackObservable.js","sourceRoot":"","sources":["../../src/observable/BoundCallbackObservable.ts"],"names":[],"mappings":"OAAO,EAAE,UAAU,EAAE,MAAM,eAAe;OAInC,EAAE,QAAQ,EAAE,MAAM,kBAAkB;OACpC,EAAE,WAAW,EAAE,MAAM,qBAAqB;OAC1C,EAAE,YAAY,EAAE,MAAM,iBAAiB;AAE9C;;;;GAIG;AACH,6CAAgD,UAAU;IAsKxD,YAAoB,YAAsB,EACtB,QAAkB,EAClB,IAAW,EACX,OAAY,EACZ,SAAqB;QACvC,OAAO,CAAC;QALU,iBAAY,GAAZ,YAAY,CAAU;QACtB,aAAQ,GAAR,QAAQ,CAAU;QAClB,SAAI,GAAJ,IAAI,CA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,EAAE,CAAC,CAAC,CAAC;gBACpE,CAAC;YACH,CAAC,CAAC;YACF,uDAAuD;YACjD,OAAQ,CAAC,MAAM,GAAG,MAAM,CAAC;YAE/B,MAAM,MAAM,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;YAC3E,EAAE,CAAC,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC;gBAC3B,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC;AAMD,sBAAyB,GAAuB;IAC9C,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC;IAC/B,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACpB,OAAO,CAAC,QAAQ,EAAE,CAAC;AACrB,CAAC;AAMD,uBAA0B,GAAwB;IAChD,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC;IAC7B,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACrB,CAAC"}

View File

@@ -0,0 +1,241 @@
import { Observable } from '../Observable';
import { tryCatch } from '../util/tryCatch';
import { errorObject } from '../util/errorObject';
import { AsyncSubject } from '../AsyncSubject';
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
export class BoundNodeCallbackObservable extends Observable {
constructor(callbackFunc, selector, args, context, scheduler) {
super();
this.callbackFunc = callbackFunc;
this.selector = selector;
this.args = args;
this.context = context;
this.scheduler = scheduler;
}
/* tslint:enable:max-line-length */
/**
* Converts a Node.js-style callback API to a function that returns an
* Observable.
*
* <span class="informal">It's just like {@link bindCallback}, but the
* callback is expected to be of type `callback(error, result)`.</span>
*
* `bindNodeCallback` is not an operator because its input and output are not
* Observables. The input is a function `func` with some parameters, but the
* last parameter must be a callback function that `func` calls when it is
* done. The callback function is expected to follow Node.js conventions,
* where the first argument to the callback is an error object, signaling
* whether call was successful. If that object is passed to callback, it means
* something went wrong.
*
* The output of `bindNodeCallback` is a function that takes the same
* parameters as `func`, except the last one (the callback). When the output
* function is called with arguments, it will return an Observable.
* If `func` calls its callback with error parameter present, Observable will
* error with that value as well. If error parameter is not passed, Observable will emit
* second parameter. If there are more parameters (third and so on),
* Observable will emit an array with all arguments, except first error argument.
*
* Optionally `bindNodeCallback` accepts selector function, which allows you to
* make resulting Observable emit value computed by selector, instead of regular
* callback arguments. It works similarly to {@link bindCallback} selector, but
* Node.js-style error argument will never be passed to that function.
*
* Note that `func` will not be called at the same time output function is,
* but rather whenever resulting Observable is subscribed. By default call to
* `func` will happen synchronously after subscription, but that can be changed
* with proper {@link Scheduler} provided as optional third parameter. Scheduler
* can also control when values from callback will be emitted by Observable.
* To find out more, check out documentation for {@link bindCallback}, where
* Scheduler works exactly the same.
*
* As in {@link bindCallback}, context (`this` property) of input function will be set to context
* of returned function, when it is called.
*
* After Observable emits value, it will complete immediately. This means
* even if `func` calls callback again, values from second and consecutive
* calls will never appear on the stream. If you need to handle functions
* that call callbacks multiple times, check out {@link fromEvent} or
* {@link fromEventPattern} instead.
*
* Note that `bindNodeCallback` can be used in non-Node.js environments as well.
* "Node.js-style" callbacks are just a convention, so if you write for
* browsers or any other environment and API you use implements that callback style,
* `bindNodeCallback` can be safely used on that API functions as well.
*
* Remember that Error object passed to callback does not have to be an instance
* of JavaScript built-in `Error` object. In fact, it does not even have to an object.
* Error parameter of callback function is interpreted as "present", when value
* of that parameter is truthy. It could be, for example, non-zero number, non-empty
* string or boolean `true`. In all of these cases resulting Observable would error
* with that value. This means usually regular style callbacks will fail very often when
* `bindNodeCallback` is used. If your Observable errors much more often then you
* would expect, check if callback really is called in Node.js-style and, if not,
* switch to {@link bindCallback} instead.
*
* Note that even if error parameter is technically present in callback, but its value
* is falsy, it still won't appear in array emitted by Observable or in selector function.
*
*
* @example <caption>Read a file from the filesystem and get the data as an Observable</caption>
* import * as fs from 'fs';
* var readFileAsObservable = Rx.Observable.bindNodeCallback(fs.readFile);
* var result = readFileAsObservable('./roadNames.txt', 'utf8');
* result.subscribe(x => console.log(x), e => console.error(e));
*
*
* @example <caption>Use on function calling callback with multiple arguments</caption>
* someFunction((err, a, b) => {
* console.log(err); // null
* console.log(a); // 5
* console.log(b); // "some string"
* });
* var boundSomeFunction = Rx.Observable.bindNodeCallback(someFunction);
* boundSomeFunction()
* .subscribe(value => {
* console.log(value); // [5, "some string"]
* });
*
*
* @example <caption>Use with selector function</caption>
* someFunction((err, a, b) => {
* console.log(err); // undefined
* console.log(a); // "abc"
* console.log(b); // "DEF"
* });
* var boundSomeFunction = Rx.Observable.bindNodeCallback(someFunction, (a, b) => a + b);
* boundSomeFunction()
* .subscribe(value => {
* console.log(value); // "abcDEF"
* });
*
*
* @example <caption>Use on function calling callback in regular style</caption>
* someFunction(a => {
* console.log(a); // 5
* });
* var boundSomeFunction = Rx.Observable.bindNodeCallback(someFunction);
* boundSomeFunction()
* .subscribe(
* value => {} // never gets called
* err => console.log(err) // 5
*);
*
*
* @see {@link bindCallback}
* @see {@link from}
* @see {@link fromPromise}
*
* @param {function} func Function with a Node.js-style callback as the last parameter.
* @param {function} [selector] A function which takes the arguments from the
* callback and maps those to a value to emit on the output Observable.
* @param {Scheduler} [scheduler] The scheduler on which to schedule the
* callbacks.
* @return {function(...params: *): Observable} A function which returns the
* Observable that delivers the same values the Node.js callback would
* deliver.
* @static true
* @name bindNodeCallback
* @owner Observable
*/
static create(func, selector = undefined, scheduler) {
return function (...args) {
return new BoundNodeCallbackObservable(func, selector, args, this, scheduler);
};
}
/** @deprecated internal use only */ _subscribe(subscriber) {
const callbackFunc = this.callbackFunc;
const args = this.args;
const scheduler = this.scheduler;
let subject = this.subject;
if (!scheduler) {
if (!subject) {
subject = this.subject = new AsyncSubject();
const handler = function handlerFn(...innerArgs) {
const source = handlerFn.source;
const { selector, subject } = source;
const err = innerArgs.shift();
if (err) {
subject.error(err);
}
else if (selector) {
const result = tryCatch(selector).apply(this, innerArgs);
if (result === errorObject) {
subject.error(errorObject.e);
}
else {
subject.next(result);
subject.complete();
}
}
else {
subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs);
subject.complete();
}
};
// use named function instance to avoid closure.
handler.source = this;
const result = tryCatch(callbackFunc).apply(this.context, args.concat(handler));
if (result === errorObject) {
subject.error(errorObject.e);
}
}
return subject.subscribe(subscriber);
}
else {
return scheduler.schedule(dispatch, 0, { source: this, subscriber, context: this.context });
}
}
}
function dispatch(state) {
const self = this;
const { source, subscriber, context } = state;
// XXX: cast to `any` to access to the private field in `source`.
const { callbackFunc, args, scheduler } = source;
let subject = source.subject;
if (!subject) {
subject = source.subject = new AsyncSubject();
const handler = function handlerFn(...innerArgs) {
const source = handlerFn.source;
const { selector, subject } = source;
const err = innerArgs.shift();
if (err) {
self.add(scheduler.schedule(dispatchError, 0, { err, subject }));
}
else if (selector) {
const result = tryCatch(selector).apply(this, innerArgs);
if (result === errorObject) {
self.add(scheduler.schedule(dispatchError, 0, { err: errorObject.e, subject }));
}
else {
self.add(scheduler.schedule(dispatchNext, 0, { value: result, subject }));
}
}
else {
const value = innerArgs.length <= 1 ? innerArgs[0] : innerArgs;
self.add(scheduler.schedule(dispatchNext, 0, { value, subject }));
}
};
// use named function to pass values in without closure
handler.source = source;
const result = tryCatch(callbackFunc).apply(context, args.concat(handler));
if (result === errorObject) {
self.add(scheduler.schedule(dispatchError, 0, { err: errorObject.e, subject }));
}
}
self.add(subject.subscribe(subscriber));
}
function dispatchNext(arg) {
const { value, subject } = arg;
subject.next(value);
subject.complete();
}
function dispatchError(arg) {
const { err, subject } = arg;
subject.error(err);
}
//# sourceMappingURL=BoundNodeCallbackObservable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"BoundNodeCallbackObservable.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AE,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;QAClF,CAAC;IACH,CAAC;IAED,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;AAC1C,CAAC;AAMD,sBAAyB,GAAuB;IAC9C,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC;IAC/B,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACpB,OAAO,CAAC,QAAQ,EAAE,CAAC;AACrB,CAAC;AAMD,uBAA0B,GAAwB;IAChD,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC;IAC7B,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACrB,CAAC"}

View File

@@ -0,0 +1,157 @@
import { SubjectSubscriber } from '../Subject';
import { Observable } from '../Observable';
import { Subscriber } from '../Subscriber';
import { Subscription } from '../Subscription';
import { refCount as higherOrderRefCount } from '../operators/refCount';
/**
* @class ConnectableObservable<T>
*/
export class ConnectableObservable extends Observable {
constructor(/** @deprecated internal use only */ source,
/** @deprecated internal use only */ subjectFactory) {
super();
this.source = source;
this.subjectFactory = subjectFactory;
/** @deprecated internal use only */ this._refCount = 0;
this._isComplete = false;
}
/** @deprecated internal use only */ _subscribe(subscriber) {
return this.getSubject().subscribe(subscriber);
}
/** @deprecated internal use only */ getSubject() {
const subject = this._subject;
if (!subject || subject.isStopped) {
this._subject = this.subjectFactory();
}
return this._subject;
}
connect() {
let connection = this._connection;
if (!connection) {
this._isComplete = false;
connection = this._connection = new Subscription();
connection.add(this.source
.subscribe(new ConnectableSubscriber(this.getSubject(), this)));
if (connection.closed) {
this._connection = null;
connection = Subscription.EMPTY;
}
else {
this._connection = connection;
}
}
return connection;
}
refCount() {
return higherOrderRefCount()(this);
}
}
const connectableProto = ConnectableObservable.prototype;
export const connectableObservableDescriptor = {
operator: { value: null },
_refCount: { value: 0, writable: true },
_subject: { value: null, writable: true },
_connection: { value: null, writable: true },
_subscribe: { value: connectableProto._subscribe },
_isComplete: { value: connectableProto._isComplete, writable: true },
getSubject: { value: connectableProto.getSubject },
connect: { value: connectableProto.connect },
refCount: { value: connectableProto.refCount }
};
class ConnectableSubscriber extends SubjectSubscriber {
constructor(destination, connectable) {
super(destination);
this.connectable = connectable;
}
_error(err) {
this._unsubscribe();
super._error(err);
}
_complete() {
this.connectable._isComplete = true;
this._unsubscribe();
super._complete();
}
/** @deprecated internal use only */ _unsubscribe() {
const connectable = this.connectable;
if (connectable) {
this.connectable = null;
const connection = connectable._connection;
connectable._refCount = 0;
connectable._subject = null;
connectable._connection = null;
if (connection) {
connection.unsubscribe();
}
}
}
}
class RefCountOperator {
constructor(connectable) {
this.connectable = connectable;
}
call(subscriber, source) {
const { connectable } = this;
connectable._refCount++;
const refCounter = new RefCountSubscriber(subscriber, connectable);
const subscription = source.subscribe(refCounter);
if (!refCounter.closed) {
refCounter.connection = connectable.connect();
}
return subscription;
}
}
class RefCountSubscriber extends Subscriber {
constructor(destination, connectable) {
super(destination);
this.connectable = connectable;
}
/** @deprecated internal use only */ _unsubscribe() {
const { connectable } = this;
if (!connectable) {
this.connection = null;
return;
}
this.connectable = null;
const refCount = connectable._refCount;
if (refCount <= 0) {
this.connection = null;
return;
}
connectable._refCount = refCount - 1;
if (refCount > 1) {
this.connection = null;
return;
}
///
// Compare the local RefCountSubscriber's connection Subscription to the
// connection Subscription on the shared ConnectableObservable. In cases
// where the ConnectableObservable source synchronously emits values, and
// the RefCountSubscriber's downstream Observers synchronously unsubscribe,
// execution continues to here before the RefCountOperator has a chance to
// supply the RefCountSubscriber with the shared connection Subscription.
// For example:
// ```
// Observable.range(0, 10)
// .publish()
// .refCount()
// .take(5)
// .subscribe();
// ```
// In order to account for this case, RefCountSubscriber should only dispose
// the ConnectableObservable's shared connection Subscription if the
// connection Subscription exists, *and* either:
// a. RefCountSubscriber doesn't have a reference to the shared connection
// Subscription yet, or,
// b. RefCountSubscriber's connection Subscription reference is identical
// to the shared connection Subscription
///
const { connection } = this;
const sharedConnection = connectable._connection;
this.connection = null;
if (sharedConnection && (!connection || sharedConnection === connection)) {
sharedConnection.unsubscribe();
}
}
}
//# sourceMappingURL=ConnectableObservable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ConnectableObservable.js","sourceRoot":"","sources":["../../src/observable/ConnectableObservable.ts"],"names":[],"mappings":"OAAO,EAAW,iBAAiB,EAAE,MAAM,YAAY;OAEhD,EAAE,UAAU,EAAE,MAAM,eAAe;OACnC,EAAE,UAAU,EAAE,MAAM,eAAe;OACnC,EAAE,YAAY,EAAiB,MAAM,iBAAiB;OACtD,EAAE,QAAQ,IAAI,mBAAmB,EAAE,MAAM,uBAAuB;AAEvE;;GAEG;AACH,2CAA8C,UAAU;IAOtD,YAAY,oCAAoC,CAAQ,MAAqB;QACjE,oCAAoC,CAAQ,cAAgC;QACtF,OAAO,CAAC;QAF8C,WAAM,GAAN,MAAM,CAAe;QACrB,mBAAc,GAAd,cAAc,CAAkB;QALxF,oCAAoC,CAAQ,cAAS,GAAW,CAAC,CAAC;QAElE,gBAAW,GAAG,KAAK,CAAC;IAKpB,CAAC;IAED,oCAAoC,CAAC,UAAU,CAAC,UAAyB;QACvE,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACjD,CAAC;IAED,oCAAoC,CAAQ,UAAU;QACpD,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;YAClC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QACxC,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,OAAO;QACL,IAAI,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC;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,gBAAgB;QAChB,aAAa;QACb,kBAAkB;QAClB,MAAM;QACN,4EAA4E;QAC5E,oEAAoE;QACpE,gDAAgD;QAChD,4EAA4E;QAC5E,6BAA6B;QAC7B,2EAA2E;QAC3E,6CAA6C;QAC7C,GAAG;QACH,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;QAC5B,MAAM,gBAAgB,GAAU,WAAY,CAAC,WAAW,CAAC;QACzD,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QAEvB,EAAE,CAAC,CAAC,gBAAgB,IAAI,CAAC,CAAC,UAAU,IAAI,gBAAgB,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC;YACzE,gBAAgB,CAAC,WAAW,EAAE,CAAC;QACjC,CAAC;IACH,CAAC;AACH,CAAC;AAAA"}

View File

@@ -0,0 +1,88 @@
import { Observable } from '../Observable';
import { subscribeToResult } from '../util/subscribeToResult';
import { OuterSubscriber } from '../OuterSubscriber';
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
export class DeferObservable extends Observable {
constructor(observableFactory) {
super();
this.observableFactory = observableFactory;
}
/**
* Creates an Observable that, on subscribe, calls an Observable factory to
* make an Observable for each new Observer.
*
* <span class="informal">Creates the Observable lazily, that is, only when it
* is subscribed.
* </span>
*
* <img src="./img/defer.png" width="100%">
*
* `defer` allows you to create the Observable only when the Observer
* subscribes, and create a fresh Observable for each Observer. It waits until
* an Observer subscribes to it, and then it generates an Observable,
* typically with an Observable factory function. It does this afresh for each
* subscriber, so although each subscriber may think it is subscribing to the
* same Observable, in fact each subscriber gets its own individual
* Observable.
*
* @example <caption>Subscribe to either an Observable of clicks or an Observable of interval, at random</caption>
* var clicksOrInterval = Rx.Observable.defer(function () {
* if (Math.random() > 0.5) {
* return Rx.Observable.fromEvent(document, 'click');
* } else {
* return Rx.Observable.interval(1000);
* }
* });
* clicksOrInterval.subscribe(x => console.log(x));
*
* // Results in the following behavior:
* // If the result of Math.random() is greater than 0.5 it will listen
* // for clicks anywhere on the "document"; when document is clicked it
* // will log a MouseEvent object to the console. If the result is less
* // than 0.5 it will emit ascending numbers, one every second(1000ms).
*
* @see {@link create}
*
* @param {function(): SubscribableOrPromise} observableFactory The Observable
* factory function to invoke for each Observer that subscribes to the output
* Observable. May also return a Promise, which will be converted on the fly
* to an Observable.
* @return {Observable} An Observable whose Observers' subscriptions trigger
* an invocation of the given Observable factory function.
* @static true
* @name defer
* @owner Observable
*/
static create(observableFactory) {
return new DeferObservable(observableFactory);
}
/** @deprecated internal use only */ _subscribe(subscriber) {
return new DeferSubscriber(subscriber, this.observableFactory);
}
}
class DeferSubscriber extends OuterSubscriber {
constructor(destination, factory) {
super(destination);
this.factory = factory;
this.tryDefer();
}
tryDefer() {
try {
this._callFactory();
}
catch (err) {
this._error(err);
}
}
_callFactory() {
const result = this.factory();
if (result) {
this.add(subscribeToResult(this, result));
}
}
}
//# sourceMappingURL=DeferObservable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DeferObservable.js","sourceRoot":"","sources":["../../src/observable/DeferObservable.ts"],"names":[],"mappings":"OAAO,EAAE,UAAU,EAAyB,MAAM,eAAe;OAI1D,EAAE,iBAAiB,EAAE,MAAM,2BAA2B;OACtD,EAAE,eAAe,EAAE,MAAM,oBAAoB;AACpD;;;;GAIG;AACH,qCAAwC,UAAU;IAoDhD,YAAoB,iBAAwD;QAC1E,OAAO,CAAC;QADU,sBAAiB,GAAjB,iBAAiB,CAAuC;IAE5E,CAAC;IApDD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6CG;IACH,OAAO,MAAM,CAAI,iBAAwD;QACvE,MAAM,CAAC,IAAI,eAAe,CAAC,iBAAiB,CAAC,CAAC;IAChD,CAAC;IAMD,oCAAoC,CAAC,UAAU,CAAC,UAAyB;QACvE,MAAM,CAAC,IAAI,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACjE,CAAC;AACH,CAAC;AAED,8BAAiC,eAAe;IAC9C,YAAY,WAA0B,EAClB,OAA8C;QAChE,MAAM,WAAW,CAAC,CAAC;QADD,YAAO,GAAP,OAAO,CAAuC;QAEhE,IAAI,CAAC,QAAQ,EAAE,CAAC;IAClB,CAAC;IAEO,QAAQ;QACd,IAAI,CAAC;YACH,IAAI,CAAC,YAAY,EAAE,CAAC;QACtB,CAAE;QAAA,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC;IAEO,YAAY;QAClB,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC9B,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;YACX,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;AACH,CAAC;AAAA"}

View File

@@ -0,0 +1,72 @@
import { Observable } from '../Observable';
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
export class EmptyObservable extends Observable {
constructor(scheduler) {
super();
this.scheduler = scheduler;
}
/**
* Creates an Observable that emits no items to the Observer and immediately
* emits a complete notification.
*
* <span class="informal">Just emits 'complete', and nothing else.
* </span>
*
* <img src="./img/empty.png" width="100%">
*
* This static operator is useful for creating a simple Observable that only
* emits the complete notification. It can be used for composing with other
* Observables, such as in a {@link mergeMap}.
*
* @example <caption>Emit the number 7, then complete.</caption>
* var result = Rx.Observable.empty().startWith(7);
* result.subscribe(x => console.log(x));
*
* @example <caption>Map and flatten only odd numbers to the sequence 'a', 'b', 'c'</caption>
* var interval = Rx.Observable.interval(1000);
* var result = interval.mergeMap(x =>
* x % 2 === 1 ? Rx.Observable.of('a', 'b', 'c') : Rx.Observable.empty()
* );
* result.subscribe(x => console.log(x));
*
* // Results in the following to the console:
* // x is equal to the count on the interval eg(0,1,2,3,...)
* // x will occur every 1000ms
* // if x % 2 is equal to 1 print abc
* // if x % 2 is not equal to 1 nothing will be output
*
* @see {@link create}
* @see {@link never}
* @see {@link of}
* @see {@link throw}
*
* @param {Scheduler} [scheduler] A {@link IScheduler} to use for scheduling
* the emission of the complete notification.
* @return {Observable} An "empty" Observable: emits only the complete
* notification.
* @static true
* @name empty
* @owner Observable
*/
static create(scheduler) {
return new EmptyObservable(scheduler);
}
static dispatch(arg) {
const { subscriber } = arg;
subscriber.complete();
}
/** @deprecated internal use only */ _subscribe(subscriber) {
const scheduler = this.scheduler;
if (scheduler) {
return scheduler.schedule(EmptyObservable.dispatch, 0, { subscriber });
}
else {
subscriber.complete();
}
}
}
//# sourceMappingURL=EmptyObservable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"EmptyObservable.js","sourceRoot":"","sources":["../../src/observable/EmptyObservable.ts"],"names":[],"mappings":"OAEO,EAAE,UAAU,EAAE,MAAM,eAAe;AAO1C;;;;GAIG;AACH,qCAAwC,UAAU;IAsDhD,YAAoB,SAAsB;QACxC,OAAO,CAAC;QADU,cAAS,GAAT,SAAS,CAAa;IAE1C,CAAC;IAtDD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA0CG;IACH,OAAO,MAAM,CAAI,SAAsB;QACrC,MAAM,CAAC,IAAI,eAAe,CAAI,SAAS,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO,QAAQ,CAAI,GAAmB;QACpC,MAAM,EAAE,UAAU,EAAE,GAAG,GAAG,CAAC;QAC3B,UAAU,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;IAMD,oCAAoC,CAAC,UAAU,CAAC,UAAyB;QAEvE,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAEjC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;YACd,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;QACzE,CAAC;QAAC,IAAI,CAAC,CAAC;YACN,UAAU,CAAC,QAAQ,EAAE,CAAC;QACxB,CAAC;IACH,CAAC;AACH,CAAC;AAAA"}

View File

@@ -0,0 +1,74 @@
import { Observable } from '../Observable';
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
export class ErrorObservable extends Observable {
constructor(error, scheduler) {
super();
this.error = error;
this.scheduler = scheduler;
}
/**
* Creates an Observable that emits no items to the Observer and immediately
* emits an error notification.
*
* <span class="informal">Just emits 'error', and nothing else.
* </span>
*
* <img src="./img/throw.png" width="100%">
*
* This static operator is useful for creating a simple Observable that only
* emits the error notification. It can be used for composing with other
* Observables, such as in a {@link mergeMap}.
*
* @example <caption>Emit the number 7, then emit an error.</caption>
* var result = Rx.Observable.throw(new Error('oops!')).startWith(7);
* result.subscribe(x => console.log(x), e => console.error(e));
*
* @example <caption>Map and flatten numbers to the sequence 'a', 'b', 'c', but throw an error for 13</caption>
* var interval = Rx.Observable.interval(1000);
* var result = interval.mergeMap(x =>
* x === 13 ?
* Rx.Observable.throw('Thirteens are bad') :
* Rx.Observable.of('a', 'b', 'c')
* );
* result.subscribe(x => console.log(x), e => console.error(e));
*
* @see {@link create}
* @see {@link empty}
* @see {@link never}
* @see {@link of}
*
* @param {any} error The particular Error to pass to the error notification.
* @param {Scheduler} [scheduler] A {@link IScheduler} to use for scheduling
* the emission of the error notification.
* @return {Observable} An error Observable: emits only the error notification
* using the given error argument.
* @static true
* @name throw
* @owner Observable
*/
static create(error, scheduler) {
return new ErrorObservable(error, scheduler);
}
static dispatch(arg) {
const { error, subscriber } = arg;
subscriber.error(error);
}
/** @deprecated internal use only */ _subscribe(subscriber) {
const error = this.error;
const scheduler = this.scheduler;
subscriber.syncErrorThrowable = true;
if (scheduler) {
return scheduler.schedule(ErrorObservable.dispatch, 0, {
error, subscriber
});
}
else {
subscriber.error(error);
}
}
}
//# sourceMappingURL=ErrorObservable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ErrorObservable.js","sourceRoot":"","sources":["../../src/observable/ErrorObservable.ts"],"names":[],"mappings":"OACO,EAAE,UAAU,EAAE,MAAM,eAAe;AAS1C;;;;GAIG;AACH,qCAAqC,UAAU;IAmD7C,YAAmB,KAAU,EAAU,SAAsB;QAC3D,OAAO,CAAC;QADS,UAAK,GAAL,KAAK,CAAK;QAAU,cAAS,GAAT,SAAS,CAAa;IAE7D,CAAC;IAnDD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuCG;IACH,OAAO,MAAM,CAAC,KAAU,EAAE,SAAsB;QAC9C,MAAM,CAAC,IAAI,eAAe,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,QAAQ,CAAC,GAAgB;QAC9B,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,GAAG,CAAC;QAClC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IAMD,oCAAoC,CAAC,UAAU,CAAC,UAA2B;QACzE,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAEjC,UAAU,CAAC,kBAAkB,GAAG,IAAI,CAAC;QAErC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;YACd,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC,EAAE;gBACrD,KAAK,EAAE,UAAU;aAClB,CAAC,CAAC;QACL,CAAC;QAAC,IAAI,CAAC,CAAC;YACN,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;AACH,CAAC;AAAA"}

View File

@@ -0,0 +1,187 @@
import { Observable } from '../Observable';
import { EmptyObservable } from './EmptyObservable';
import { isArray } from '../util/isArray';
import { subscribeToResult } from '../util/subscribeToResult';
import { OuterSubscriber } from '../OuterSubscriber';
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
export class ForkJoinObservable extends Observable {
constructor(sources, resultSelector) {
super();
this.sources = sources;
this.resultSelector = resultSelector;
}
/* tslint:enable:max-line-length */
/**
* Joins last values emitted by passed Observables.
*
* <span class="informal">Wait for Observables to complete and then combine last values they emitted.</span>
*
* <img src="./img/forkJoin.png" width="100%">
*
* `forkJoin` is an operator that takes any number of Observables which can be passed either as an array
* or directly as arguments. If no input Observables are provided, resulting stream will complete
* immediately.
*
* `forkJoin` will wait for all passed Observables to complete and then it will emit an array with last
* values from corresponding Observables. So if you pass `n` Observables to the operator, resulting
* array will have `n` values, where first value is the last thing emitted by the first Observable,
* second value is the last thing emitted by the second Observable and so on. That means `forkJoin` will
* not emit more than once and it will complete after that. If you need to emit combined values not only
* at the end of lifecycle of passed Observables, but also throughout it, try out {@link combineLatest}
* or {@link zip} instead.
*
* In order for resulting array to have the same length as the number of input Observables, whenever any of
* that Observables completes without emitting any value, `forkJoin` will complete at that moment as well
* and it will not emit anything either, even if it already has some last values from other Observables.
* Conversely, if there is an Observable that never completes, `forkJoin` will never complete as well,
* unless at any point some other Observable completes without emitting value, which brings us back to
* the previous case. Overall, in order for `forkJoin` to emit a value, all Observables passed as arguments
* have to emit something at least once and complete.
*
* If any input Observable errors at some point, `forkJoin` will error as well and all other Observables
* will be immediately unsubscribed.
*
* Optionally `forkJoin` accepts project function, that will be called with values which normally
* would land in emitted array. Whatever is returned by project function, will appear in output
* Observable instead. This means that default project can be thought of as a function that takes
* all its arguments and puts them into an array. Note that project function will be called only
* when output Observable is supposed to emit a result.
*
* @example <caption>Use forkJoin with operator emitting immediately</caption>
* const observable = Rx.Observable.forkJoin(
* Rx.Observable.of(1, 2, 3, 4),
* Rx.Observable.of(5, 6, 7, 8)
* );
* observable.subscribe(
* value => console.log(value),
* err => {},
* () => console.log('This is how it ends!')
* );
*
* // Logs:
* // [4, 8]
* // "This is how it ends!"
*
*
* @example <caption>Use forkJoin with operator emitting after some time</caption>
* const observable = Rx.Observable.forkJoin(
* Rx.Observable.interval(1000).take(3), // emit 0, 1, 2 every second and complete
* Rx.Observable.interval(500).take(4) // emit 0, 1, 2, 3 every half a second and complete
* );
* observable.subscribe(
* value => console.log(value),
* err => {},
* () => console.log('This is how it ends!')
* );
*
* // Logs:
* // [2, 3] after 3 seconds
* // "This is how it ends!" immediately after
*
*
* @example <caption>Use forkJoin with project function</caption>
* const observable = Rx.Observable.forkJoin(
* Rx.Observable.interval(1000).take(3), // emit 0, 1, 2 every second and complete
* Rx.Observable.interval(500).take(4), // emit 0, 1, 2, 3 every half a second and complete
* (n, m) => n + m
* );
* observable.subscribe(
* value => console.log(value),
* err => {},
* () => console.log('This is how it ends!')
* );
*
* // Logs:
* // 5 after 3 seconds
* // "This is how it ends!" immediately after
*
* @see {@link combineLatest}
* @see {@link zip}
*
* @param {...SubscribableOrPromise} sources Any number of Observables provided either as an array or as an arguments
* passed directly to the operator.
* @param {function} [project] Function that takes values emitted by input Observables and returns value
* that will appear in resulting Observable instead of default array.
* @return {Observable} Observable emitting either an array of last values emitted by passed Observables
* or value from project function.
* @static true
* @name forkJoin
* @owner Observable
*/
static create(...sources) {
if (sources === null || arguments.length === 0) {
return new EmptyObservable();
}
let resultSelector = null;
if (typeof sources[sources.length - 1] === 'function') {
resultSelector = sources.pop();
}
// if the first and only other argument besides the resultSelector is an array
// assume it's been called with `forkJoin([obs1, obs2, obs3], resultSelector)`
if (sources.length === 1 && isArray(sources[0])) {
sources = sources[0];
}
if (sources.length === 0) {
return new EmptyObservable();
}
return new ForkJoinObservable(sources, resultSelector);
}
/** @deprecated internal use only */ _subscribe(subscriber) {
return new ForkJoinSubscriber(subscriber, this.sources, this.resultSelector);
}
}
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
class ForkJoinSubscriber extends OuterSubscriber {
constructor(destination, sources, resultSelector) {
super(destination);
this.sources = sources;
this.resultSelector = resultSelector;
this.completed = 0;
this.haveValues = 0;
const len = sources.length;
this.total = len;
this.values = new Array(len);
for (let i = 0; i < len; i++) {
const source = sources[i];
const innerSubscription = subscribeToResult(this, source, null, i);
if (innerSubscription) {
innerSubscription.outerIndex = i;
this.add(innerSubscription);
}
}
}
notifyNext(outerValue, innerValue, outerIndex, innerIndex, innerSub) {
this.values[outerIndex] = innerValue;
if (!innerSub._hasValue) {
innerSub._hasValue = true;
this.haveValues++;
}
}
notifyComplete(innerSub) {
const destination = this.destination;
const { haveValues, resultSelector, values } = this;
const len = values.length;
if (!innerSub._hasValue) {
destination.complete();
return;
}
this.completed++;
if (this.completed !== len) {
return;
}
if (haveValues === len) {
const value = resultSelector ? resultSelector.apply(this, values) : values;
destination.next(value);
}
destination.complete();
}
}
//# sourceMappingURL=ForkJoinObservable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ForkJoinObservable.js","sourceRoot":"","sources":["../../src/observable/ForkJoinObservable.ts"],"names":[],"mappings":"OAAO,EAAE,UAAU,EAAyB,MAAM,eAAe;OAG1D,EAAE,eAAe,EAAE,MAAM,mBAAmB;OAC5C,EAAE,OAAO,EAAE,MAAM,iBAAiB;OAElC,EAAE,iBAAiB,EAAE,MAAM,2BAA2B;OACtD,EAAE,eAAe,EAAE,MAAM,oBAAoB;AAGpD;;;;GAIG;AACH,wCAA2C,UAAU;IACnD,YAAoB,OAA0C,EAC1C,cAA6C;QAC/D,OAAO,CAAC;QAFU,YAAO,GAAP,OAAO,CAAmC;QAC1C,mBAAc,GAAd,cAAc,CAA+B;IAEjE,CAAC;IAoBD,mCAAmC;IAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgGG;IACH,OAAO,MAAM,CAAI,GAAG,OAE6C;QAC/D,EAAE,CAAC,CAAC,OAAO,KAAK,IAAI,IAAI,SAAS,CAAC,MAAM,KAA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,CAAC;QACT,CAAC;QAED,EAAE,CAAC,CAAC,UAAU,KAAK,GAAG,CAAC,CAAC,CAAC;YACvB,MAAM,KAAK,GAAG,cAAc,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC;YAC3E,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1B,CAAC;QAED,WAAW,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC;AACH,CAAC;AAAA"}

View File

@@ -0,0 +1,203 @@
import { Observable } from '../Observable';
import { tryCatch } from '../util/tryCatch';
import { isFunction } from '../util/isFunction';
import { errorObject } from '../util/errorObject';
import { Subscription } from '../Subscription';
const toString = Object.prototype.toString;
function isNodeStyleEventEmitter(sourceObj) {
return !!sourceObj && typeof sourceObj.addListener === 'function' && typeof sourceObj.removeListener === 'function';
}
function isJQueryStyleEventEmitter(sourceObj) {
return !!sourceObj && typeof sourceObj.on === 'function' && typeof sourceObj.off === 'function';
}
function isNodeList(sourceObj) {
return !!sourceObj && toString.call(sourceObj) === '[object NodeList]';
}
function isHTMLCollection(sourceObj) {
return !!sourceObj && toString.call(sourceObj) === '[object HTMLCollection]';
}
function isEventTarget(sourceObj) {
return !!sourceObj && typeof sourceObj.addEventListener === 'function' && typeof sourceObj.removeEventListener === 'function';
}
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
export class FromEventObservable extends Observable {
constructor(sourceObj, eventName, selector, options) {
super();
this.sourceObj = sourceObj;
this.eventName = eventName;
this.selector = selector;
this.options = options;
}
/* tslint:enable:max-line-length */
/**
* Creates an Observable that emits events of a specific type coming from the
* given event target.
*
* <span class="informal">Creates an Observable from DOM events, or Node.js
* EventEmitter events or others.</span>
*
* <img src="./img/fromEvent.png" width="100%">
*
* `fromEvent` accepts as a first argument event target, which is an object with methods
* for registering event handler functions. As a second argument it takes string that indicates
* type of event we want to listen for. `fromEvent` supports selected types of event targets,
* which are described in detail below. If your event target does not match any of the ones listed,
* you should use {@link fromEventPattern}, which can be used on arbitrary APIs.
* When it comes to APIs supported by `fromEvent`, their methods for adding and removing event
* handler functions have different names, but they all accept a string describing event type
* and function itself, which will be called whenever said event happens.
*
* Every time resulting Observable is subscribed, event handler function will be registered
* to event target on given event type. When that event fires, value
* passed as a first argument to registered function will be emitted by output Observable.
* When Observable is unsubscribed, function will be unregistered from event target.
*
* Note that if event target calls registered function with more than one argument, second
* and following arguments will not appear in resulting stream. In order to get access to them,
* you can pass to `fromEvent` optional project function, which will be called with all arguments
* passed to event handler. Output Observable will then emit value returned by project function,
* instead of the usual value.
*
* Remember that event targets listed below are checked via duck typing. It means that
* no matter what kind of object you have and no matter what environment you work in,
* you can safely use `fromEvent` on that object if it exposes described methods (provided
* of course they behave as was described above). So for example if Node.js library exposes
* event target which has the same method names as DOM EventTarget, `fromEvent` is still
* a good choice.
*
* If the API you use is more callback then event handler oriented (subscribed
* callback function fires only once and thus there is no need to manually
* unregister it), you should use {@link bindCallback} or {@link bindNodeCallback}
* instead.
*
* `fromEvent` supports following types of event targets:
*
* **DOM EventTarget**
*
* This is an object with `addEventListener` and `removeEventListener` methods.
*
* In the browser, `addEventListener` accepts - apart from event type string and event
* handler function arguments - optional third parameter, which is either an object or boolean,
* both used for additional configuration how and when passed function will be called. When
* `fromEvent` is used with event target of that type, you can provide this values
* as third parameter as well.
*
* **Node.js EventEmitter**
*
* An object with `addListener` and `removeListener` methods.
*
* **JQuery-style event target**
*
* An object with `on` and `off` methods
*
* **DOM NodeList**
*
* List of DOM Nodes, returned for example by `document.querySelectorAll` or `Node.childNodes`.
*
* Although this collection is not event target in itself, `fromEvent` will iterate over all Nodes
* it contains and install event handler function in every of them. When returned Observable
* is unsubscribed, function will be removed from all Nodes.
*
* **DOM HtmlCollection**
*
* Just as in case of NodeList it is a collection of DOM nodes. Here as well event handler function is
* installed and removed in each of elements.
*
*
* @example <caption>Emits clicks happening on the DOM document</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* clicks.subscribe(x => console.log(x));
*
* // Results in:
* // MouseEvent object logged to console every time a click
* // occurs on the document.
*
*
* @example <caption>Use addEventListener with capture option</caption>
* var clicksInDocument = Rx.Observable.fromEvent(document, 'click', true); // note optional configuration parameter
* // which will be passed to addEventListener
* var clicksInDiv = Rx.Observable.fromEvent(someDivInDocument, 'click');
*
* clicksInDocument.subscribe(() => console.log('document'));
* clicksInDiv.subscribe(() => console.log('div'));
*
* // By default events bubble UP in DOM tree, so normally
* // when we would click on div in document
* // "div" would be logged first and then "document".
* // Since we specified optional `capture` option, document
* // will catch event when it goes DOWN DOM tree, so console
* // will log "document" and then "div".
*
* @see {@link bindCallback}
* @see {@link bindNodeCallback}
* @see {@link fromEventPattern}
*
* @param {EventTargetLike} target The DOM EventTarget, Node.js
* EventEmitter, JQuery-like event target, NodeList or HTMLCollection to attach the event handler to.
* @param {string} eventName The event name of interest, being emitted by the
* `target`.
* @param {EventListenerOptions} [options] Options to pass through to addEventListener
* @param {SelectorMethodSignature<T>} [selector] An optional function to
* post-process results. It takes the arguments from the event handler and
* should return a single value.
* @return {Observable<T>}
* @static true
* @name fromEvent
* @owner Observable
*/
static create(target, eventName, options, selector) {
if (isFunction(options)) {
selector = options;
options = undefined;
}
return new FromEventObservable(target, eventName, selector, options);
}
static setupSubscription(sourceObj, eventName, handler, subscriber, options) {
let unsubscribe;
if (isNodeList(sourceObj) || isHTMLCollection(sourceObj)) {
for (let i = 0, len = sourceObj.length; i < len; i++) {
FromEventObservable.setupSubscription(sourceObj[i], eventName, handler, subscriber, options);
}
}
else if (isEventTarget(sourceObj)) {
const source = sourceObj;
sourceObj.addEventListener(eventName, handler, options);
unsubscribe = () => source.removeEventListener(eventName, handler, options);
}
else if (isJQueryStyleEventEmitter(sourceObj)) {
const source = sourceObj;
sourceObj.on(eventName, handler);
unsubscribe = () => source.off(eventName, handler);
}
else if (isNodeStyleEventEmitter(sourceObj)) {
const source = sourceObj;
sourceObj.addListener(eventName, handler);
unsubscribe = () => source.removeListener(eventName, handler);
}
else {
throw new TypeError('Invalid event target');
}
subscriber.add(new Subscription(unsubscribe));
}
/** @deprecated internal use only */ _subscribe(subscriber) {
const sourceObj = this.sourceObj;
const eventName = this.eventName;
const options = this.options;
const selector = this.selector;
let handler = selector ? (...args) => {
let result = tryCatch(selector)(...args);
if (result === errorObject) {
subscriber.error(errorObject.e);
}
else {
subscriber.next(result);
}
} : (e) => subscriber.next(e);
FromEventObservable.setupSubscription(sourceObj, eventName, handler, subscriber, options);
}
}
//# sourceMappingURL=FromEventObservable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"FromEventObservable.js","sourceRoot":"","sources":["../../src/observable/FromEventObservable.ts"],"names":[],"mappings":"OAAO,EAAE,UAAU,EAAE,MAAM,eAAe;OACnC,EAAE,QAAQ,EAAE,MAAM,kBAAkB;OACpC,EAAE,UAAU,EAAE,MAAM,oBAAoB;OACxC,EAAE,WAAW,EAAE,MAAM,qBAAqB;OAC1C,EAAE,YAAY,EAAE,MAAM,iBAAiB;AAG9C,MAAM,QAAQ,GAAa,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;AASrD,iCAAiC,SAAc;IAC7C,MAAM,CAAC,CAAC,CAAC,SAAS,IAAI,OAAO,SAAS,CAAC,WAAW,KAAK,UAAU,IAAI,OAAO,SAAS,CAAC,cAAc,KAAK,UAAU,CAAC;AACtH,CAAC;AAMD,mCAAmC,SAAc;IAC/C,MAAM,CAAC,CAAC,CAAC,SAAS,IAAI,OAAO,SAAS,CAAC,EAAE,KAAK,UAAU,IAAI,OAAO,SAAS,CAAC,GAAG,KAAK,UAAU,CAAC;AAClG,CAAC;AAED,oBAAoB,SAAc;IAChC,MAAM,CAAC,CAAC,CAAC,SAAS,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,mBAAmB,CAAC;AACzE,CAAC;AAED,0BAA0B,SAAc;IACtC,MAAM,CAAC,CAAC,CAAC,SAAS,IAAI,QAAQ,CAAC,I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,oCAAoC,CAAC,UAAU,CAAC,UAAyB;QACvE,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QACjC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QACjC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/B,IAAI,OAAO,GAAG,QAAQ,GAAG,CAAC,GAAG,IAAW;YACtC,IAAI,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;YACzC,EAAE,CAAC,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC;gBAC3B,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAClC,CAAC;YAAC,IAAI,CAAC,CAAC;gBACN,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC,GAAG,CAAC,CAAM,KAAK,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAEnC,mBAAmB,CAAC,iBAAiB,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IAC5F,CAAC;AACH,CAAC;AAAA"}

View File

@@ -0,0 +1,99 @@
import { isFunction } from '../util/isFunction';
import { Observable } from '../Observable';
import { Subscription } from '../Subscription';
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
export class FromEventPatternObservable extends Observable {
constructor(addHandler, removeHandler, selector) {
super();
this.addHandler = addHandler;
this.removeHandler = removeHandler;
this.selector = selector;
}
/**
* Creates an Observable from an API based on addHandler/removeHandler
* functions.
*
* <span class="informal">Converts any addHandler/removeHandler API to an
* Observable.</span>
*
* <img src="./img/fromEventPattern.png" width="100%">
*
* Creates an Observable by using the `addHandler` and `removeHandler`
* functions to add and remove the handlers, with an optional selector
* function to project the event arguments to a result. The `addHandler` is
* called when the output Observable is subscribed, and `removeHandler` is
* called when the Subscription is unsubscribed.
*
* @example <caption>Emits clicks happening on the DOM document</caption>
* function addClickHandler(handler) {
* document.addEventListener('click', handler);
* }
*
* function removeClickHandler(handler) {
* document.removeEventListener('click', handler);
* }
*
* var clicks = Rx.Observable.fromEventPattern(
* addClickHandler,
* removeClickHandler
* );
* clicks.subscribe(x => console.log(x));
*
* @see {@link from}
* @see {@link fromEvent}
*
* @param {function(handler: Function): any} addHandler A function that takes
* a `handler` function as argument and attaches it somehow to the actual
* source of events.
* @param {function(handler: Function, signal?: any): void} [removeHandler] An optional function that
* takes a `handler` function as argument and removes it in case it was
* previously attached using `addHandler`. if addHandler returns signal to teardown when remove,
* removeHandler function will forward it.
* @param {function(...args: any): T} [selector] An optional function to
* post-process results. It takes the arguments from the event handler and
* should return a single value.
* @return {Observable<T>}
* @static true
* @name fromEventPattern
* @owner Observable
*/
static create(addHandler, removeHandler, selector) {
return new FromEventPatternObservable(addHandler, removeHandler, selector);
}
/** @deprecated internal use only */ _subscribe(subscriber) {
const removeHandler = this.removeHandler;
const handler = !!this.selector ? (...args) => {
this._callSelector(subscriber, args);
} : function (e) { subscriber.next(e); };
const retValue = this._callAddHandler(handler, subscriber);
if (!isFunction(removeHandler)) {
return;
}
subscriber.add(new Subscription(() => {
//TODO: determine whether or not to forward to error handler
removeHandler(handler, retValue);
}));
}
_callSelector(subscriber, args) {
try {
const result = this.selector(...args);
subscriber.next(result);
}
catch (e) {
subscriber.error(e);
}
}
_callAddHandler(handler, errorSubscriber) {
try {
return this.addHandler(handler) || null;
}
catch (e) {
errorSubscriber.error(e);
}
}
}
//# sourceMappingURL=FromEventPatternObservable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"FromEventPatternObservable.js","sourceRoot":"","sources":["../../src/observable/FromEventPatternObservable.ts"],"names":[],"mappings":"OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB;OACxC,EAAE,UAAU,EAAE,MAAM,eAAe;OACnC,EAAE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,GAAG,IAAI,CAAC,CAAC;YACzC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1B,CACA;QAAA,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACT,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;IAEO,eAAe,CAAC,OAAyB,EAAE,eAA8B;QAC/E,IAAI,CAAC;YACH,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC;QAC1C,CACA;QAAA,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACT,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;AACH,CAAC;AAAA"}

113
node_modules/rxjs/_esm2015/observable/FromObservable.js generated vendored Normal file
View File

@@ -0,0 +1,113 @@
import { isArray } from '../util/isArray';
import { isArrayLike } from '../util/isArrayLike';
import { isPromise } from '../util/isPromise';
import { PromiseObservable } from './PromiseObservable';
import { IteratorObservable } from './IteratorObservable';
import { ArrayObservable } from './ArrayObservable';
import { ArrayLikeObservable } from './ArrayLikeObservable';
import { iterator as Symbol_iterator } from '../symbol/iterator';
import { Observable } from '../Observable';
import { ObserveOnSubscriber } from '../operators/observeOn';
import { observable as Symbol_observable } from '../symbol/observable';
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
export class FromObservable extends Observable {
constructor(ish, scheduler) {
super(null);
this.ish = ish;
this.scheduler = scheduler;
}
/**
* Creates an Observable from an Array, an array-like object, a Promise, an
* iterable object, or an Observable-like object.
*
* <span class="informal">Converts almost anything to an Observable.</span>
*
* <img src="./img/from.png" width="100%">
*
* Convert various other objects and data types into Observables. `from`
* converts a Promise or an array-like or an
* [iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#iterable)
* object into an Observable that emits the items in that promise or array or
* iterable. A String, in this context, is treated as an array of characters.
* Observable-like objects (contains a function named with the ES2015 Symbol
* for Observable) can also be converted through this operator.
*
* @example <caption>Converts an array to an Observable</caption>
* var array = [10, 20, 30];
* var result = Rx.Observable.from(array);
* result.subscribe(x => console.log(x));
*
* // Results in the following:
* // 10 20 30
*
* @example <caption>Convert an infinite iterable (from a generator) to an Observable</caption>
* function* generateDoubles(seed) {
* var i = seed;
* while (true) {
* yield i;
* i = 2 * i; // double it
* }
* }
*
* var iterator = generateDoubles(3);
* var result = Rx.Observable.from(iterator).take(10);
* result.subscribe(x => console.log(x));
*
* // Results in the following:
* // 3 6 12 24 48 96 192 384 768 1536
*
* @see {@link create}
* @see {@link fromEvent}
* @see {@link fromEventPattern}
* @see {@link fromPromise}
*
* @param {ObservableInput<T>} ish A subscribable object, a Promise, an
* Observable-like, an Array, an iterable or an array-like object to be
* converted.
* @param {Scheduler} [scheduler] The scheduler on which to schedule the
* emissions of values.
* @return {Observable<T>} The Observable whose values are originally from the
* input object that was converted.
* @static true
* @name from
* @owner Observable
*/
static create(ish, scheduler) {
if (ish != null) {
if (typeof ish[Symbol_observable] === 'function') {
if (ish instanceof Observable && !scheduler) {
return ish;
}
return new FromObservable(ish, scheduler);
}
else if (isArray(ish)) {
return new ArrayObservable(ish, scheduler);
}
else if (isPromise(ish)) {
return new PromiseObservable(ish, scheduler);
}
else if (typeof ish[Symbol_iterator] === 'function' || typeof ish === 'string') {
return new IteratorObservable(ish, scheduler);
}
else if (isArrayLike(ish)) {
return new ArrayLikeObservable(ish, scheduler);
}
}
throw new TypeError((ish !== null && typeof ish || ish) + ' is not observable');
}
/** @deprecated internal use only */ _subscribe(subscriber) {
const ish = this.ish;
const scheduler = this.scheduler;
if (scheduler == null) {
return ish[Symbol_observable]().subscribe(subscriber);
}
else {
return ish[Symbol_observable]().subscribe(new ObserveOnSubscriber(subscriber, scheduler, 0));
}
}
}
//# sourceMappingURL=FromObservable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"FromObservable.js","sourceRoot":"","sources":["../../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"}

View File

@@ -0,0 +1,126 @@
import { Observable } from '../Observable';
import { isScheduler } from '../util/isScheduler';
const selfSelector = (value) => value;
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
export class GenerateObservable extends Observable {
constructor(initialState, condition, iterate, resultSelector, scheduler) {
super();
this.initialState = initialState;
this.condition = condition;
this.iterate = iterate;
this.resultSelector = resultSelector;
this.scheduler = scheduler;
}
static create(initialStateOrOptions, condition, iterate, resultSelectorOrObservable, scheduler) {
if (arguments.length == 1) {
return new GenerateObservable(initialStateOrOptions.initialState, initialStateOrOptions.condition, initialStateOrOptions.iterate, initialStateOrOptions.resultSelector || selfSelector, initialStateOrOptions.scheduler);
}
if (resultSelectorOrObservable === undefined || isScheduler(resultSelectorOrObservable)) {
return new GenerateObservable(initialStateOrOptions, condition, iterate, selfSelector, resultSelectorOrObservable);
}
return new GenerateObservable(initialStateOrOptions, condition, iterate, resultSelectorOrObservable, scheduler);
}
/** @deprecated internal use only */ _subscribe(subscriber) {
let state = this.initialState;
if (this.scheduler) {
return this.scheduler.schedule(GenerateObservable.dispatch, 0, {
subscriber,
iterate: this.iterate,
condition: this.condition,
resultSelector: this.resultSelector,
state });
}
const { condition, resultSelector, iterate } = this;
do {
if (condition) {
let conditionResult;
try {
conditionResult = condition(state);
}
catch (err) {
subscriber.error(err);
return;
}
if (!conditionResult) {
subscriber.complete();
break;
}
}
let value;
try {
value = resultSelector(state);
}
catch (err) {
subscriber.error(err);
return;
}
subscriber.next(value);
if (subscriber.closed) {
break;
}
try {
state = iterate(state);
}
catch (err) {
subscriber.error(err);
return;
}
} while (true);
}
static dispatch(state) {
const { subscriber, condition } = state;
if (subscriber.closed) {
return;
}
if (state.needIterate) {
try {
state.state = state.iterate(state.state);
}
catch (err) {
subscriber.error(err);
return;
}
}
else {
state.needIterate = true;
}
if (condition) {
let conditionResult;
try {
conditionResult = condition(state.state);
}
catch (err) {
subscriber.error(err);
return;
}
if (!conditionResult) {
subscriber.complete();
return;
}
if (subscriber.closed) {
return;
}
}
let value;
try {
value = state.resultSelector(state.state);
}
catch (err) {
subscriber.error(err);
return;
}
if (subscriber.closed) {
return;
}
subscriber.next(value);
if (subscriber.closed) {
return;
}
return this.schedule(state);
}
}
//# sourceMappingURL=GenerateObservable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"GenerateObservable.js","sourceRoot":"","sources":["../../src/observable/GenerateObservable.ts"],"names":[],"mappings":"OAEO,EAAE,UAAU,EAAE,MAAM,eAAe;OAGnC,EAAE,WAAW,EAAE,MAAM,qBAAqB;AAEjD,MAAM,YAAY,GAAG,CAAI,KAAQ,KAAK,KAAK,CAAC;AA4C5C;;;;GAIG;AACH,wCAA8C,UAAU;IACtD,YAAoB,YAAe,EACf,SAA2B,EAC3B,OAAuB,EACvB,cAAgC,EAChC,SAAsB;QACtC,OAAO,CAAC;QALQ,iBAAY,GAAZ,YAAY,CAAG;QACf,cAAS,GAAT,SAAS,CAAkB;QAC3B,YAAO,GAAP,OAAO,CAAgB;QACvB,mBAAc,GAAd,cAAc,CAAkB;QAChC,cAAS,GAAT,SAAS,CAAa;IAE1C,CAAC;IA4GD,OAAO,MAAM,CAAO,qBAAgD,EAChD,SAA4B,EAC5B,OAAwB,EACxB,0BAA4D,EAC5D,SAAsB;QACxC,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;YAC1B,MAAM,CAAC,IAAI,kBAAkB,CACH,qBAAsB,CAAC,YAAY,EACnC,qBAAsB,CAAC,SAAS,EAChC,qBAAsB,CAAC,OAAO,EAC9B,qBAAsB,CAAC,cAAc,IAAI,YAAgC,EACzE,qBAAsB,CAAC,SAAS,CAAC,CAAC;QAC9D,CAAC;QAED,EAAE,CAAC,CAAC,0BAA0B,KAAK,SAAS,IAAI,WAAW,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC;YACxF,MAAM,CAAC,IAAI,kBAAkB,CACxB,qBAAqB,EACxB,SAAS,E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,GAAG,CAAC,CAAC,CAAC;gBACb,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACtB,MAAM,CAAC;YACT,CAAC;YACD,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC;gBACrB,UAAU,CAAC,QAAQ,EAAE,CAAC;gBACtB,MAAM,CAAC;YACT,CAAC;YACD,EAAE,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;gBACtB,MAAM,CAAC;YACT,CAAC;QACH,CAAC;QACD,IAAI,KAAQ,CAAC;QACb,IAAI,CAAC;YACH,KAAK,GAAG,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC5C,CAAE;QAAA,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACb,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACtB,MAAM,CAAC;QACT,CAAC;QACD,EAAE,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;YACtB,MAAM,CAAC;QACT,CAAC;QACD,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvB,EAAE,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;YACtB,MAAM,CAAC;QACT,CAAC;QACD,MAAM,CAAqC,IAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACnE,CAAC;AACH,CAAC;AAAA"}

50
node_modules/rxjs/_esm2015/observable/IfObservable.js generated vendored Normal file
View File

@@ -0,0 +1,50 @@
import { Observable } from '../Observable';
import { subscribeToResult } from '../util/subscribeToResult';
import { OuterSubscriber } from '../OuterSubscriber';
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
export class IfObservable extends Observable {
constructor(condition, thenSource, elseSource) {
super();
this.condition = condition;
this.thenSource = thenSource;
this.elseSource = elseSource;
}
static create(condition, thenSource, elseSource) {
return new IfObservable(condition, thenSource, elseSource);
}
/** @deprecated internal use only */ _subscribe(subscriber) {
const { condition, thenSource, elseSource } = this;
return new IfSubscriber(subscriber, condition, thenSource, elseSource);
}
}
class IfSubscriber extends OuterSubscriber {
constructor(destination, condition, thenSource, elseSource) {
super(destination);
this.condition = condition;
this.thenSource = thenSource;
this.elseSource = elseSource;
this.tryIf();
}
tryIf() {
const { condition, thenSource, elseSource } = this;
let result;
try {
result = condition();
const source = result ? thenSource : elseSource;
if (source) {
this.add(subscribeToResult(this, source));
}
else {
this._complete();
}
}
catch (err) {
this._error(err);
}
}
}
//# sourceMappingURL=IfObservable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"IfObservable.js","sourceRoot":"","sources":["../../src/observable/IfObservable.ts"],"names":[],"mappings":"OAAO,EAAE,UAAU,EAAyB,MAAM,eAAe;OAI1D,EAAE,iBAAiB,EAAE,MAAM,2BAA2B;OACtD,EAAE,eAAe,EAAE,MAAM,oBAAoB;AACpD;;;;GAIG;AACH,kCAAwC,UAAU;IAQhD,YAAoB,SAA+B,EAC/B,UAA4C,EAC5C,UAA4C;QAC9D,OAAO,CAAC;QAHU,cAAS,GAAT,SAAS,CAAsB;QAC/B,eAAU,GAAV,UAAU,CAAkC;QAC5C,eAAU,GAAV,UAAU,CAAkC;IAEhE,CAAC;IAVD,OAAO,MAAM,CAAO,SAA+B,EAC/B,UAA4C,EAC5C,UAA4C;QAC9D,MAAM,CAAC,IAAI,YAAY,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IAC7D,CAAC;IAQD,oCAAoC,CAAC,UAAU,CAAC,UAA2B;QACzE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;QAEnD,MAAM,CAAC,IAAI,YAAY,CAAC,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IACzE,CAAC;AACH,CAAC;AAED,2BAAiC,eAAe;IAC9C,YAAY,WAA0B,EAClB,SAA+B,EAC/B,UAA4C,EAC5C,UAA4C;QAC9D,MAAM,WAAW,CAAC,CAAC;QAHD,cAAS,GAAT,SAAS,CAAsB;QAC/B,eAAU,GAAV,UAAU,CAAkC;QAC5C,eAAU,GAAV,UAAU,CAAkC;QAE9D,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IAEO,KAAK;QACX,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;QAEnD,IAAI,MAAe,CAAC;QACpB,IAAI,CAAC;YACH,MAAM,GAAY,SAAS,EAAE,CAAC;YAC9B,MAAM,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,CAAC;YAEhD,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;gBACX,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;YAC5C,CAAC;YAAC,IAAI,CAAC,CAAC;gBACN,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,CAAC;QACH,CAAE;QAAA,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC;AACH,CAAC;AAAA"}

View File

@@ -0,0 +1,75 @@
import { isNumeric } from '../util/isNumeric';
import { Observable } from '../Observable';
import { async } from '../scheduler/async';
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
export class IntervalObservable extends Observable {
constructor(period = 0, scheduler = async) {
super();
this.period = period;
this.scheduler = scheduler;
if (!isNumeric(period) || period < 0) {
this.period = 0;
}
if (!scheduler || typeof scheduler.schedule !== 'function') {
this.scheduler = async;
}
}
/**
* Creates an Observable that emits sequential numbers every specified
* interval of time, on a specified IScheduler.
*
* <span class="informal">Emits incremental numbers periodically in time.
* </span>
*
* <img src="./img/interval.png" width="100%">
*
* `interval` returns an Observable that emits an infinite sequence of
* ascending integers, with a constant interval of time of your choosing
* between those emissions. The first emission is not sent immediately, but
* only after the first period has passed. By default, this operator uses the
* `async` IScheduler to provide a notion of time, but you may pass any
* IScheduler to it.
*
* @example <caption>Emits ascending numbers, one every second (1000ms)</caption>
* var numbers = Rx.Observable.interval(1000);
* numbers.subscribe(x => console.log(x));
*
* @see {@link timer}
* @see {@link delay}
*
* @param {number} [period=0] The interval size in milliseconds (by default)
* or the time unit determined by the scheduler's clock.
* @param {Scheduler} [scheduler=async] The IScheduler to use for scheduling
* the emission of values, and providing a notion of "time".
* @return {Observable} An Observable that emits a sequential number each time
* interval.
* @static true
* @name interval
* @owner Observable
*/
static create(period = 0, scheduler = async) {
return new IntervalObservable(period, scheduler);
}
static dispatch(state) {
const { index, subscriber, period } = state;
subscriber.next(index);
if (subscriber.closed) {
return;
}
state.index += 1;
this.schedule(state, period);
}
/** @deprecated internal use only */ _subscribe(subscriber) {
const index = 0;
const period = this.period;
const scheduler = this.scheduler;
subscriber.add(scheduler.schedule(IntervalObservable.dispatch, period, {
index, subscriber, period
}));
}
}
//# sourceMappingURL=IntervalObservable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"IntervalObservable.js","sourceRoot":"","sources":["../../src/observable/IntervalObservable.ts"],"names":[],"mappings":"OACO,EAAE,SAAS,EAAE,MAAM,mBAAmB;OAEtC,EAAE,UAAU,EAAE,MAAM,eAAe;OACnC,EAAE,KAAK,EAAE,MAAM,oBAAoB;AAE1C;;;;GAIG;AACH,wCAAwC,UAAU;IAqDhD,YAAoB,MAAM,GAAW,CAAC,EAClB,SAAS,GAAe,KAAK;QAC/C,OAAO,CAAC;QAFU,WAAM,GAAN,MAAM,CAAY;QAClB,cAAS,GAAT,SAAS,CAAoB;QAE/C,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;YACrC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAClB,CAAC;QACD,EAAE,CAAC,CAAC,CAAC,SAAS,IAAI,OAAO,SAAS,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC;YAC3D,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACzB,CAAC;IACH,CAAC;IA7DD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,OAAO,MAAM,CAAC,MAAM,GAAW,CAAC,EAClB,SAAS,GAAe,KAAK;QACzC,MAAM,CAAC,IAAI,kBAAkB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,QAAQ,CAAC,KAAU;QACxB,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;QAE5C,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEvB,EAAE,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;YACtB,MAAM,CAAC;QACT,CAAC;QAED,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC;QAEV,IAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACvC,CAAC;IAaD,oCAAoC,CAAC,UAAU,CAAC,UAA8B;QAC5E,MAAM,KAAK,GAAG,CAAC,CAAC;QAChB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAEjC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE;YACrE,KAAK,EAAE,UAAU,EAAE,MAAM;SAC1B,CAAC,CAAC,CAAC;IACN,CAAC;AACH,CAAC;AAAA"}

View File

@@ -0,0 +1,148 @@
import { root } from '../util/root';
import { Observable } from '../Observable';
import { iterator as Symbol_iterator } from '../symbol/iterator';
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
export class IteratorObservable extends Observable {
constructor(iterator, scheduler) {
super();
this.scheduler = scheduler;
if (iterator == null) {
throw new Error('iterator cannot be null.');
}
this.iterator = getIterator(iterator);
}
static create(iterator, scheduler) {
return new IteratorObservable(iterator, scheduler);
}
static dispatch(state) {
const { index, hasError, iterator, subscriber } = state;
if (hasError) {
subscriber.error(state.error);
return;
}
let result = iterator.next();
if (result.done) {
subscriber.complete();
return;
}
subscriber.next(result.value);
state.index = index + 1;
if (subscriber.closed) {
if (typeof iterator.return === 'function') {
iterator.return();
}
return;
}
this.schedule(state);
}
/** @deprecated internal use only */ _subscribe(subscriber) {
let index = 0;
const { iterator, scheduler } = this;
if (scheduler) {
return scheduler.schedule(IteratorObservable.dispatch, 0, {
index, iterator, subscriber
});
}
else {
do {
let result = iterator.next();
if (result.done) {
subscriber.complete();
break;
}
else {
subscriber.next(result.value);
}
if (subscriber.closed) {
if (typeof iterator.return === 'function') {
iterator.return();
}
break;
}
} while (true);
}
}
}
class StringIterator {
constructor(str, idx = 0, len = str.length) {
this.str = str;
this.idx = idx;
this.len = len;
}
[Symbol_iterator]() { return (this); }
next() {
return this.idx < this.len ? {
done: false,
value: this.str.charAt(this.idx++)
} : {
done: true,
value: undefined
};
}
}
class ArrayIterator {
constructor(arr, idx = 0, len = toLength(arr)) {
this.arr = arr;
this.idx = idx;
this.len = len;
}
[Symbol_iterator]() { return this; }
next() {
return this.idx < this.len ? {
done: false,
value: this.arr[this.idx++]
} : {
done: true,
value: undefined
};
}
}
function getIterator(obj) {
const i = obj[Symbol_iterator];
if (!i && typeof obj === 'string') {
return new StringIterator(obj);
}
if (!i && obj.length !== undefined) {
return new ArrayIterator(obj);
}
if (!i) {
throw new TypeError('object is not iterable');
}
return obj[Symbol_iterator]();
}
const maxSafeInteger = Math.pow(2, 53) - 1;
function toLength(o) {
let len = +o.length;
if (isNaN(len)) {
return 0;
}
if (len === 0 || !numberIsFinite(len)) {
return len;
}
len = sign(len) * Math.floor(Math.abs(len));
if (len <= 0) {
return 0;
}
if (len > maxSafeInteger) {
return maxSafeInteger;
}
return len;
}
function numberIsFinite(value) {
return typeof value === 'number' && root.isFinite(value);
}
function sign(value) {
let valueAsNumber = +value;
if (valueAsNumber === 0) {
return valueAsNumber;
}
if (isNaN(valueAsNumber)) {
return valueAsNumber;
}
return valueAsNumber < 0 ? -1 : 1;
}
//# sourceMappingURL=IteratorObservable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"IteratorObservable.js","sourceRoot":"","sources":["../../src/observable/IteratorObservable.ts"],"names":[],"mappings":"OAAO,EAAE,IAAI,EAAE,MAAM,cAAc;OAE5B,EAAE,UAAU,EAAE,MAAM,eAAe;OACnC,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,oBAAoB;AAIhE;;;;GAIG;AACH,wCAA2C,UAAU;IAmCnD,YAAY,QAAa,EAAU,SAAsB;QACvD,OAAO,CAAC;QADyB,cAAS,GAAT,SAAS,CAAa;QAGvD,EAAE,CAAC,CAAC,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC9C,CAAC;QAED,IAAI,CAAC,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;IAxCD,OAAO,MAAM,CAAI,QAAa,EAAE,SAAsB;QACpD,MAAM,CAAC,IAAI,kBAAkB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,QAAQ,CAAC,KAAU;QAExB,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;QAExD,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;YACb,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAC9B,MAAM,CAAC;QACT,CAAC;QAED,IAAI,MAAM,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC7B,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CA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GAAG,GAAG,cAAc,CAAC,CAAC,CAAC;QACvB,MAAM,CAAC,cAAc,CAAC;IAC1B,CAAC;IACD,MAAM,CAAC,GAAG,CAAC;AACb,CAAC;AAED,wBAAwB,KAAU;IAChC,MAAM,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC3D,CAAC;AAED,cAAc,KAAU;IACtB,IAAI,aAAa,GAAG,CAAC,KAAK,CAAC;IAC3B,EAAE,CAAC,CAAC,aAAa,KAAK,CAAC,CAAC,CAAC,CAAC;QACxB,MAAM,CAAC,aAAa,CAAC;IACvB,CAAC;IACD,EAAE,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QACzB,MAAM,CAAC,aAAa,CAAC;IACvB,CAAC;IACD,MAAM,CAAC,aAAa,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;AACpC,CAAC"}

View File

@@ -0,0 +1,50 @@
import { Observable } from '../Observable';
import { noop } from '../util/noop';
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
export class NeverObservable extends Observable {
constructor() {
super();
}
/**
* Creates an Observable that emits no items to the Observer.
*
* <span class="informal">An Observable that never emits anything.</span>
*
* <img src="./img/never.png" width="100%">
*
* This static operator is useful for creating a simple Observable that emits
* neither values nor errors nor the completion notification. It can be used
* for testing purposes or for composing with other Observables. Please note
* that by never emitting a complete notification, this Observable keeps the
* subscription from being disposed automatically. Subscriptions need to be
* manually disposed.
*
* @example <caption>Emit the number 7, then never emit anything else (not even complete).</caption>
* function info() {
* console.log('Will not be called');
* }
* var result = Rx.Observable.never().startWith(7);
* result.subscribe(x => console.log(x), info, info);
*
* @see {@link create}
* @see {@link empty}
* @see {@link of}
* @see {@link throw}
*
* @return {Observable} A "never" Observable: never emits anything.
* @static true
* @name never
* @owner Observable
*/
static create() {
return new NeverObservable();
}
/** @deprecated internal use only */ _subscribe(subscriber) {
noop();
}
}
//# sourceMappingURL=NeverObservable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"NeverObservable.js","sourceRoot":"","sources":["../../src/observable/NeverObservable.ts"],"names":[],"mappings":"OAAO,EAAE,UAAU,EAAE,MAAM,eAAe;OAEnC,EAAE,IAAI,EAAE,MAAM,cAAc;AAEnC;;;;GAIG;AACH,qCAAwC,UAAU;IAoChD;QACE,OAAO,CAAC;IACV,CAAC;IArCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,OAAO,MAAM;QACX,MAAM,CAAC,IAAI,eAAe,EAAK,CAAC;IAClC,CAAC;IAMD,oCAAoC,CAAC,UAAU,CAAC,UAAyB;QACvE,IAAI,EAAE,CAAC;IACT,CAAC;AACH,CAAC;AAAA"}

View File

@@ -0,0 +1,76 @@
import { Observable } from '../Observable';
function dispatch(state) {
const { obj, keys, length, index, subscriber } = state;
if (index === length) {
subscriber.complete();
return;
}
const key = keys[index];
subscriber.next([key, obj[key]]);
state.index = index + 1;
this.schedule(state);
}
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
export class PairsObservable extends Observable {
constructor(obj, scheduler) {
super();
this.obj = obj;
this.scheduler = scheduler;
this.keys = Object.keys(obj);
}
/**
* Convert an object into an observable sequence of [key, value] pairs
* using an optional IScheduler to enumerate the object.
*
* @example <caption>Converts a javascript object to an Observable</caption>
* var obj = {
* foo: 42,
* bar: 56,
* baz: 78
* };
*
* var source = Rx.Observable.pairs(obj);
*
* var subscription = source.subscribe(
* function (x) {
* console.log('Next: %s', x);
* },
* function (err) {
* console.log('Error: %s', err);
* },
* function () {
* console.log('Completed');
* });
*
* @param {Object} obj The object to inspect and turn into an
* Observable sequence.
* @param {Scheduler} [scheduler] An optional IScheduler to run the
* enumeration of the input sequence on.
* @returns {(Observable<Array<string | T>>)} An observable sequence of
* [key, value] pairs from the object.
*/
static create(obj, scheduler) {
return new PairsObservable(obj, scheduler);
}
/** @deprecated internal use only */ _subscribe(subscriber) {
const { keys, scheduler } = this;
const length = keys.length;
if (scheduler) {
return scheduler.schedule(dispatch, 0, {
obj: this.obj, keys, length, index: 0, subscriber
});
}
else {
for (let idx = 0; idx < length; idx++) {
const key = keys[idx];
subscriber.next([key, this.obj[key]]);
}
subscriber.complete();
}
}
}
//# sourceMappingURL=PairsObservable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PairsObservable.js","sourceRoot":"","sources":["../../src/observable/PairsObservable.ts"],"names":[],"mappings":"OAEO,EAAE,UAAU,EAAE,MAAM,eAAe;AAY1C,kBAAoD,KAAsB;IACxE,MAAM,EAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAC,GAAG,KAAK,CAAC;IAErD,EAAE,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC;QACrB,UAAU,CAAC,QAAQ,EAAE,CAAC;QACtB,MAAM,CAAC;IACT,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IACxB,UAAU,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAEjC,KAAK,CAAC,KAAK,GAAG,KAAK,GAAG,CAAC,CAAC;IAExB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED;;;;GAIG;AACH,qCAAwC,UAAU;IAsChD,YAAoB,GAAW,EAAU,SAAsB;QAC7D,OAAO,CAAC;QADU,QAAG,GAAH,GAAG,CAAQ;QAAU,cAAS,GAAT,SAAS,CAAa;QAE7D,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;IAtCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,OAAO,MAAM,CAAI,GAAW,EAAE,SAAsB;QAClD,MAAM,CAAC,IAAI,eAAe,CAAI,GAAG,EAAE,SAAS,CAAC,CAAC;IAChD,CAAC;IAOD,oCAAoC,CAAC,UAAU,CAAC,UAAyC;QACvF,MAAM,EAAC,IAAI,EAAE,SAAS,EAAC,GAAG,IAAI,CAAC;QAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAE3B,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;YACd,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,EAAE;gBACrC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU;aAClD,CAAC,CAAC;QACL,CAAC;QAAC,IAAI,CAAC,CAAC;YACN,GAAG,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC;gBACtC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;gBACtB,UAAU,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACxC,CAAC;YACD,UAAU,CAAC,QAAQ,EAAE,CAAC;QACxB,CAAC;IACH,CAAC;AACH,CAAC;AAAA"}

View File

@@ -0,0 +1,111 @@
import { root } from '../util/root';
import { Observable } from '../Observable';
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
export class PromiseObservable extends Observable {
constructor(promise, scheduler) {
super();
this.promise = promise;
this.scheduler = scheduler;
}
/**
* Converts a Promise to an Observable.
*
* <span class="informal">Returns an Observable that just emits the Promise's
* resolved value, then completes.</span>
*
* Converts an ES2015 Promise or a Promises/A+ spec compliant Promise to an
* Observable. If the Promise resolves with a value, the output Observable
* emits that resolved value as a `next`, and then completes. If the Promise
* is rejected, then the output Observable emits the corresponding Error.
*
* @example <caption>Convert the Promise returned by Fetch to an Observable</caption>
* var result = Rx.Observable.fromPromise(fetch('http://myserver.com/'));
* result.subscribe(x => console.log(x), e => console.error(e));
*
* @see {@link bindCallback}
* @see {@link from}
*
* @param {PromiseLike<T>} promise The promise to be converted.
* @param {Scheduler} [scheduler] An optional IScheduler to use for scheduling
* the delivery of the resolved value (or the rejection).
* @return {Observable<T>} An Observable which wraps the Promise.
* @static true
* @name fromPromise
* @owner Observable
*/
static create(promise, scheduler) {
return new PromiseObservable(promise, scheduler);
}
/** @deprecated internal use only */ _subscribe(subscriber) {
const promise = this.promise;
const scheduler = this.scheduler;
if (scheduler == null) {
if (this._isScalar) {
if (!subscriber.closed) {
subscriber.next(this.value);
subscriber.complete();
}
}
else {
promise.then((value) => {
this.value = value;
this._isScalar = true;
if (!subscriber.closed) {
subscriber.next(value);
subscriber.complete();
}
}, (err) => {
if (!subscriber.closed) {
subscriber.error(err);
}
})
.then(null, err => {
// escape the promise trap, throw unhandled errors
root.setTimeout(() => { throw err; });
});
}
}
else {
if (this._isScalar) {
if (!subscriber.closed) {
return scheduler.schedule(dispatchNext, 0, { value: this.value, subscriber });
}
}
else {
promise.then((value) => {
this.value = value;
this._isScalar = true;
if (!subscriber.closed) {
subscriber.add(scheduler.schedule(dispatchNext, 0, { value, subscriber }));
}
}, (err) => {
if (!subscriber.closed) {
subscriber.add(scheduler.schedule(dispatchError, 0, { err, subscriber }));
}
})
.then(null, (err) => {
// escape the promise trap, throw unhandled errors
root.setTimeout(() => { throw err; });
});
}
}
}
}
function dispatchNext(arg) {
const { value, subscriber } = arg;
if (!subscriber.closed) {
subscriber.next(value);
subscriber.complete();
}
}
function dispatchError(arg) {
const { err, subscriber } = arg;
if (!subscriber.closed) {
subscriber.error(err);
}
}
//# sourceMappingURL=PromiseObservable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PromiseObservable.js","sourceRoot":"","sources":["../../src/observable/PromiseObservable.ts"],"names":[],"mappings":"OAAO,EAAE,IAAI,EAAE,MAAM,cAAc;OAE5B,EAAE,UAAU,EAAE,MA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AC,UAAU,CAAC,QAAQ,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;gBACxC,CAAC,CAAC,CAAC;YACP,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAMD,sBAAyB,GAAuB;IAC9C,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,GAAG,CAAC;IAClC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;QACvB,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvB,UAAU,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;AACH,CAAC;AAMD,uBAA0B,GAAwB;IAChD,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,GAAG,CAAC;IAChC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;QACvB,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;AACH,CAAC"}

View File

@@ -0,0 +1,85 @@
import { Observable } from '../Observable';
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
export class RangeObservable extends Observable {
constructor(start, count, scheduler) {
super();
this.start = start;
this._count = count;
this.scheduler = scheduler;
}
/**
* Creates an Observable that emits a sequence of numbers within a specified
* range.
*
* <span class="informal">Emits a sequence of numbers in a range.</span>
*
* <img src="./img/range.png" width="100%">
*
* `range` operator emits a range of sequential integers, in order, where you
* select the `start` of the range and its `length`. By default, uses no
* IScheduler and just delivers the notifications synchronously, but may use
* an optional IScheduler to regulate those deliveries.
*
* @example <caption>Emits the numbers 1 to 10</caption>
* var numbers = Rx.Observable.range(1, 10);
* numbers.subscribe(x => console.log(x));
*
* @see {@link timer}
* @see {@link interval}
*
* @param {number} [start=0] The value of the first integer in the sequence.
* @param {number} [count=0] The number of sequential integers to generate.
* @param {Scheduler} [scheduler] A {@link IScheduler} to use for scheduling
* the emissions of the notifications.
* @return {Observable} An Observable of numbers that emits a finite range of
* sequential integers.
* @static true
* @name range
* @owner Observable
*/
static create(start = 0, count = 0, scheduler) {
return new RangeObservable(start, count, scheduler);
}
static dispatch(state) {
const { start, index, count, subscriber } = state;
if (index >= count) {
subscriber.complete();
return;
}
subscriber.next(start);
if (subscriber.closed) {
return;
}
state.index = index + 1;
state.start = start + 1;
this.schedule(state);
}
/** @deprecated internal use only */ _subscribe(subscriber) {
let index = 0;
let start = this.start;
const count = this._count;
const scheduler = this.scheduler;
if (scheduler) {
return scheduler.schedule(RangeObservable.dispatch, 0, {
index, count, start, subscriber
});
}
else {
do {
if (index++ >= count) {
subscriber.complete();
break;
}
subscriber.next(start++);
if (subscriber.closed) {
break;
}
} while (true);
}
}
}
//# sourceMappingURL=RangeObservable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"RangeObservable.js","sourceRoot":"","sources":["../../src/observable/RangeObservable.ts"],"names":[],"mappings":"OACO,EAAE,UAAU,EAAE,MAAM,eAAe;AAI1C;;;;GAIG;AACH,qCAAqC,UAAU;IA+D7C,YAAY,KAAa,EACb,KAAa,EACb,SAAsB;QAChC,OAAO,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IApED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,OAAO,MAAM,CAAC,KAAK,GAAW,CAAC,EACjB,KAAK,GAAW,CAAC,EACjB,SAAsB;QAClC,MAAM,CAAC,IAAI,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,QAAQ,CAAC,KAAU;QAExB,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;QAElD,EAAE,CAAC,CAAC,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC;YACnB,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/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
export class ScalarObservable extends Observable {
constructor(value, scheduler) {
super();
this.value = value;
this.scheduler = scheduler;
this._isScalar = true;
if (scheduler) {
this._isScalar = false;
}
}
static create(value, scheduler) {
return new ScalarObservable(value, scheduler);
}
static dispatch(state) {
const { done, value, subscriber } = state;
if (done) {
subscriber.complete();
return;
}
subscriber.next(value);
if (subscriber.closed) {
return;
}
state.done = true;
this.schedule(state);
}
/** @deprecated internal use only */ _subscribe(subscriber) {
const value = this.value;
const scheduler = this.scheduler;
if (scheduler) {
return scheduler.schedule(ScalarObservable.dispatch, 0, {
done: false, value, subscriber
});
}
else {
subscriber.next(value);
if (!subscriber.closed) {
subscriber.complete();
}
}
}
}
//# sourceMappingURL=ScalarObservable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ScalarObservable.js","sourceRoot":"","sources":["../../src/observable/ScalarObservable.ts"],"names":[],"mappings":"OACO,EAAE,UAAU,EAAE,MAAM,eAAe;AAI1C;;;;GAIG;AACH,sCAAyC,UAAU;IAwBjD,YAAmB,KAAQ,EAAU,SAAsB;QACzD,OAAO,CAAC;QADS,UAAK,GAAL,KAAK,CAAG;QAAU,cAAS,GAAT,SAAS,CAAa;QAF3D,cAAS,GAAY,IAAI,CAAC;QAIxB,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;YACd,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACzB,CAAC;IACH,CAAC;IA5BD,OAAO,MAAM,CAAI,KAAQ,EAAE,SAAsB;QAC/C,MAAM,CAAC,IAAI,gBAAgB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,QAAQ,CAAC,KAAU;QACxB,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;QAE1C,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;YACT,UAAU,CAAC,QAAQ,EAAE,CAAC;YACtB,MAAM,CAAC;QACT,CAAC;QAED,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvB,EAAE,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;YACtB,MAAM,CAAC;QACT,CAAC;QAED,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;QACX,IAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAWD,oCAAoC,CAAC,UAAU,CAAC,UAAyB;QACvE,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAEjC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;YACd,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC,EAAE;gBACtD,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU;aAC/B,CAAC,CAAC;QACL,CAAC;QAAC,IAAI,CAAC,CAAC;YACN,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACvB,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;gBACvB,UAAU,CAAC,QAAQ,EAAE,CAAC;YACxB,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAAA"}

View File

@@ -0,0 +1,38 @@
import { Observable } from '../Observable';
import { asap } from '../scheduler/asap';
import { isNumeric } from '../util/isNumeric';
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
export class SubscribeOnObservable extends Observable {
constructor(source, delayTime = 0, scheduler = asap) {
super();
this.source = source;
this.delayTime = delayTime;
this.scheduler = scheduler;
if (!isNumeric(delayTime) || delayTime < 0) {
this.delayTime = 0;
}
if (!scheduler || typeof scheduler.schedule !== 'function') {
this.scheduler = asap;
}
}
static create(source, delay = 0, scheduler = asap) {
return new SubscribeOnObservable(source, delay, scheduler);
}
static dispatch(arg) {
const { source, subscriber } = arg;
return this.add(source.subscribe(subscriber));
}
/** @deprecated internal use only */ _subscribe(subscriber) {
const delay = this.delayTime;
const source = this.source;
const scheduler = this.scheduler;
return scheduler.schedule(SubscribeOnObservable.dispatch, delay, {
source, subscriber
});
}
}
//# sourceMappingURL=SubscribeOnObservable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"SubscribeOnObservable.js","sourceRoot":"","sources":["../../src/observable/SubscribeOnObservable.ts"],"names":[],"mappings":"OAIO,EAAE,UAAU,EAAE,MAAM,eAAe;OACnC,EAAE,IAAI,EAAE,MAAM,mBAAmB;OACjC,EAAE,SAAS,EAAE,MAAM,mBAAmB;AAO7C;;;;GAIG;AACH,2CAA8C,UAAU;IAUtD,YAAmB,MAAqB,EACpB,SAAS,GAAW,CAAC,EACrB,SAAS,GAAe,IAAI;QAC9C,OAAO,CAAC;QAHS,WAAM,GAAN,MAAM,CAAe;QACpB,cAAS,GAAT,SAAS,CAAY;QACrB,cAAS,GAAT,SAAS,CAAmB;QAE9C,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC;YAC3C,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;QACrB,CAAC;QACD,EAAE,CAAC,CAAC,CAAC,SAAS,IAAI,OAAO,SAAS,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC;YAC3D,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACxB,CAAC;IACH,CAAC;IAnBD,OAAO,MAAM,CAAI,MAAqB,EAAE,KAAK,GAAW,CAAC,EAAE,SAAS,GAAe,IAAI;QACrF,MAAM,CAAC,IAAI,qBAAqB,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,QAAQ,CAAqB,GAAmB;QACrD,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,GAAG,CAAC;QACnC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;IAChD,CAAC;IAcD,oCAAoC,CAAC,UAAU,CAAC,UAAyB;QACvE,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC;QAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAEjC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,qBAAqB,CAAC,QAAQ,EAAE,KAAK,EAAE;YAC/D,MAAM,EAAE,UAAU;SACnB,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAAA"}

View File

@@ -0,0 +1,96 @@
import { isNumeric } from '../util/isNumeric';
import { Observable } from '../Observable';
import { async } from '../scheduler/async';
import { isScheduler } from '../util/isScheduler';
import { isDate } from '../util/isDate';
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
export class TimerObservable extends Observable {
constructor(dueTime = 0, period, scheduler) {
super();
this.period = -1;
this.dueTime = 0;
if (isNumeric(period)) {
this.period = Number(period) < 1 && 1 || Number(period);
}
else if (isScheduler(period)) {
scheduler = period;
}
if (!isScheduler(scheduler)) {
scheduler = async;
}
this.scheduler = scheduler;
this.dueTime = isDate(dueTime) ?
(+dueTime - this.scheduler.now()) :
dueTime;
}
/**
* Creates an Observable that starts emitting after an `initialDelay` and
* emits ever increasing numbers after each `period` of time thereafter.
*
* <span class="informal">Its like {@link interval}, but you can specify when
* should the emissions start.</span>
*
* <img src="./img/timer.png" width="100%">
*
* `timer` returns an Observable that emits an infinite sequence of ascending
* integers, with a constant interval of time, `period` of your choosing
* between those emissions. The first emission happens after the specified
* `initialDelay`. The initial delay may be a {@link Date}. By default, this
* operator uses the `async` IScheduler to provide a notion of time, but you
* may pass any IScheduler to it. If `period` is not specified, the output
* Observable emits only one value, `0`. Otherwise, it emits an infinite
* sequence.
*
* @example <caption>Emits ascending numbers, one every second (1000ms), starting after 3 seconds</caption>
* var numbers = Rx.Observable.timer(3000, 1000);
* numbers.subscribe(x => console.log(x));
*
* @example <caption>Emits one number after five seconds</caption>
* var numbers = Rx.Observable.timer(5000);
* numbers.subscribe(x => console.log(x));
*
* @see {@link interval}
* @see {@link delay}
*
* @param {number|Date} initialDelay The initial delay time to wait before
* emitting the first value of `0`.
* @param {number} [period] The period of time between emissions of the
* subsequent numbers.
* @param {Scheduler} [scheduler=async] The IScheduler to use for scheduling
* the emission of values, and providing a notion of "time".
* @return {Observable} An Observable that emits a `0` after the
* `initialDelay` and ever increasing numbers after each `period` of time
* thereafter.
* @static true
* @name timer
* @owner Observable
*/
static create(initialDelay = 0, period, scheduler) {
return new TimerObservable(initialDelay, period, scheduler);
}
static dispatch(state) {
const { index, period, subscriber } = state;
const action = this;
subscriber.next(index);
if (subscriber.closed) {
return;
}
else if (period === -1) {
return subscriber.complete();
}
state.index = index + 1;
action.schedule(state, period);
}
/** @deprecated internal use only */ _subscribe(subscriber) {
const index = 0;
const { period, dueTime, scheduler } = this;
return scheduler.schedule(TimerObservable.dispatch, dueTime, {
index, period, subscriber
});
}
}
//# sourceMappingURL=TimerObservable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"TimerObservable.js","sourceRoot":"","sources":["../../src/observable/TimerObservable.ts"],"names":[],"mappings":"OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB;OAEtC,EAAE,UAAU,EAAE,MAAM,eAAe;OACnC,EAAE,KAAK,EAAE,MAAM,oBAAoB;OACnC,EAAE,WAAW,EAAE,MAAM,qBAAqB;OAC1C,EAAE,MAAM,EAAE,MAAM,gBAAgB;AAIvC;;;;GAIG;AACH,qCAAqC,UAAU;IAuE7C,YAAY,OAAO,GAAkB,CAAC,EAC1B,MAA4B,EAC5B,SAAsB;QAChC,OAAO,CAAC;QAPF,WAAM,GAAW,CAAC,CAAC,CAAC;QACpB,YAAO,GAAW,CAAC,CAAC;QA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UAAU,CAAC,QAAQ,EAAE,CAAC;QAC/B,CAAC;QAED,KAAK,CAAC,KAAK,GAAG,KAAK,GAAG,CAAC,CAAC;QACxB,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACjC,CAAC;IA2BD,oCAAoC,CAAC,UAAU,CAAC,UAA8B;QAC5E,MAAM,KAAK,GAAG,CAAC,CAAC;QAChB,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;QAE5C,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,eAAe,CAAC,QAAQ,EAAE,OAAO,EAAE;YAC3D,KAAK,EAAE,MAAM,EAAE,UAAU;SAC1B,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAAA"}

View File

@@ -0,0 +1,50 @@
import { Observable } from '../Observable';
import { subscribeToResult } from '../util/subscribeToResult';
import { OuterSubscriber } from '../OuterSubscriber';
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
export class UsingObservable extends Observable {
constructor(resourceFactory, observableFactory) {
super();
this.resourceFactory = resourceFactory;
this.observableFactory = observableFactory;
}
static create(resourceFactory, observableFactory) {
return new UsingObservable(resourceFactory, observableFactory);
}
/** @deprecated internal use only */ _subscribe(subscriber) {
const { resourceFactory, observableFactory } = this;
let resource;
try {
resource = resourceFactory();
return new UsingSubscriber(subscriber, resource, observableFactory);
}
catch (err) {
subscriber.error(err);
}
}
}
class UsingSubscriber extends OuterSubscriber {
constructor(destination, resource, observableFactory) {
super(destination);
this.resource = resource;
this.observableFactory = observableFactory;
destination.add(resource);
this.tryUse();
}
tryUse() {
try {
const source = this.observableFactory.call(this, this.resource);
if (source) {
this.add(subscribeToResult(this, source));
}
}
catch (err) {
this._error(err);
}
}
}
//# sourceMappingURL=UsingObservable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"UsingObservable.js","sourceRoot":"","sources":["../../src/observable/UsingObservable.ts"],"names":[],"m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;YAChE,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;gBACX,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;YAC5C,CAAC;QACH,CAAE;QAAA,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC;AACH,CAAC;AAAA"}

View File

@@ -0,0 +1,3 @@
import { BoundCallbackObservable } from './BoundCallbackObservable';
export const bindCallback = BoundCallbackObservable.create;
//# sourceMappingURL=bindCallback.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"bindCallback.js","sourceRoot":"","sources":["../../src/observable/bindCallback.ts"],"names":[],"mappings":"OAAO,EAAG,uBAAuB,EAAG,MAAM,2BAA2B;AAErE,OAAO,MAAM,YAAY,GAAG,uBAAuB,CAAC,MAAM,CAAC"}

View File

@@ -0,0 +1,3 @@
import { BoundNodeCallbackObservable } from './BoundNodeCallbackObservable';
export const bindNodeCallback = BoundNodeCallbackObservable.create;
//# sourceMappingURL=bindNodeCallback.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"bindNodeCallback.js","sourceRoot":"","sources":["../../src/observable/bindNodeCallback.ts"],"names":[],"mappings":"OAAO,EAAG,2BAA2B,EAAG,MAAM,+BAA+B;AAE7E,OAAO,MAAM,gBAAgB,GAAG,2BAA2B,CAAC,MAAM,CAAC"}

130
node_modules/rxjs/_esm2015/observable/combineLatest.js generated vendored Normal file
View File

@@ -0,0 +1,130 @@
import { isScheduler } from '../util/isScheduler';
import { isArray } from '../util/isArray';
import { ArrayObservable } from './ArrayObservable';
import { CombineLatestOperator } from '../operators/combineLatest';
/* tslint:enable:max-line-length */
/**
* Combines multiple Observables to create an Observable whose values are
* calculated from the latest values of each of its input Observables.
*
* <span class="informal">Whenever any input Observable emits a value, it
* computes a formula using the latest values from all the inputs, then emits
* the output of that formula.</span>
*
* <img src="./img/combineLatest.png" width="100%">
*
* `combineLatest` combines the values from all the Observables passed as
* arguments. This is done by subscribing to each Observable in order and,
* whenever any Observable emits, collecting an array of the most recent
* values from each Observable. So if you pass `n` Observables to operator,
* returned Observable will always emit an array of `n` values, in order
* corresponding to order of passed Observables (value from the first Observable
* on the first place and so on).
*
* Static version of `combineLatest` accepts either an array of Observables
* or each Observable can be put directly as an argument. Note that array of
* Observables is good choice, if you don't know beforehand how many Observables
* you will combine. Passing empty array will result in Observable that
* completes immediately.
*
* To ensure output array has always the same length, `combineLatest` will
* actually wait for all input Observables to emit at least once,
* before it starts emitting results. This means if some Observable emits
* values before other Observables started emitting, all that values but last
* will be lost. On the other hand, is some Observable does not emit value but
* completes, resulting Observable will complete at the same moment without
* emitting anything, since it will be now impossible to include value from
* completed Observable in resulting array. Also, if some input Observable does
* not emit any value and never completes, `combineLatest` will also never emit
* and never complete, since, again, it will wait for all streams to emit some
* value.
*
* If at least one Observable was passed to `combineLatest` and all passed Observables
* emitted something, resulting Observable will complete when all combined
* streams complete. So even if some Observable completes, result of
* `combineLatest` will still emit values when other Observables do. In case
* of completed Observable, its value from now on will always be the last
* emitted value. On the other hand, if any Observable errors, `combineLatest`
* will error immediately as well, and all other Observables will be unsubscribed.
*
* `combineLatest` accepts as optional parameter `project` function, which takes
* as arguments all values that would normally be emitted by resulting Observable.
* `project` can return any kind of value, which will be then emitted by Observable
* instead of default array. Note that `project` does not take as argument that array
* of values, but values themselves. That means default `project` can be imagined
* as function that takes all its arguments and puts them into an array.
*
*
* @example <caption>Combine two timer Observables</caption>
* const firstTimer = Rx.Observable.timer(0, 1000); // emit 0, 1, 2... after every second, starting from now
* const secondTimer = Rx.Observable.timer(500, 1000); // emit 0, 1, 2... after every second, starting 0,5s from now
* const combinedTimers = Rx.Observable.combineLatest(firstTimer, secondTimer);
* combinedTimers.subscribe(value => console.log(value));
* // Logs
* // [0, 0] after 0.5s
* // [1, 0] after 1s
* // [1, 1] after 1.5s
* // [2, 1] after 2s
*
*
* @example <caption>Combine an array of Observables</caption>
* const observables = [1, 5, 10].map(
* n => Rx.Observable.of(n).delay(n * 1000).startWith(0) // emit 0 and then emit n after n seconds
* );
* const combined = Rx.Observable.combineLatest(observables);
* combined.subscribe(value => console.log(value));
* // Logs
* // [0, 0, 0] immediately
* // [1, 0, 0] after 1s
* // [1, 5, 0] after 5s
* // [1, 5, 10] after 10s
*
*
* @example <caption>Use project function to dynamically calculate the Body-Mass Index</caption>
* var weight = Rx.Observable.of(70, 72, 76, 79, 75);
* var height = Rx.Observable.of(1.76, 1.77, 1.78);
* var bmi = Rx.Observable.combineLatest(weight, height, (w, h) => w / (h * h));
* bmi.subscribe(x => console.log('BMI is ' + x));
*
* // With output to console:
* // BMI is 24.212293388429753
* // BMI is 23.93948099205209
* // BMI is 23.671253629592222
*
*
* @see {@link combineAll}
* @see {@link merge}
* @see {@link withLatestFrom}
*
* @param {ObservableInput} observable1 An input Observable to combine with other Observables.
* @param {ObservableInput} observable2 An input Observable to combine with other Observables.
* More than one input Observables may be given as arguments
* or an array of Observables may be given as the first argument.
* @param {function} [project] An optional function to project the values from
* the combined latest values into a new value on the output Observable.
* @param {Scheduler} [scheduler=null] The IScheduler to use for subscribing to
* each input Observable.
* @return {Observable} An Observable of projected values from the most recent
* values from each input Observable, or an array of the most recent values from
* each input Observable.
* @static true
* @name combineLatest
* @owner Observable
*/
export function combineLatest(...observables) {
let project = null;
let scheduler = null;
if (isScheduler(observables[observables.length - 1])) {
scheduler = observables.pop();
}
if (typeof observables[observables.length - 1] === 'function') {
project = observables.pop();
}
// if the first and only other argument besides the resultSelector is an array
// assume it's been called with `combineLatest([obs1, obs2, obs3], project)`
if (observables.length === 1 && isArray(observables[0])) {
observables = observables[0];
}
return new ArrayObservable(observables, scheduler).lift(new CombineLatestOperator(project));
}
//# sourceMappingURL=combineLatest.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"combineLatest.js","sourceRoot":"","sources":["../../src/observable/combineLatest.ts"],"names":[],"mappings":"OAEO,EAAG,WAAW,EAAG,MAAM,qBAAqB;OAC5C,EAAG,OAAO,EAAG,MAAM,iBAAiB;OACpC,EAAG,eAAe,EAAG,MAAM,mBAAmB;OAC9C,EAAG,qBAAqB,EAAG,MAAM,4BAA4B;AAuBpE,mCAAmC;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2GG;AACH,8BAAoC,GAAG,WAGwB;IAC7D,IAAI,OAAO,GAAkC,IAAI,CAAC;IAClD,IAAI,SAAS,GAAe,IAAI,CAAC;IAEjC,EAAE,CAAC,CAAC,WAAW,CAAC,WAAW,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACrD,SAAS,GAAe,WAAW,CAAC,GAAG,EAAE,CAAC;IAC5C,CAAC;IAED,EAAE,CAAC,CAAC,OAAO,WAAW,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC;QAC9D,OAAO,GAAiC,WAAW,CAAC,GAAG,EAAE,CAAC;IAC5D,CAAC;IAED,8EAA8E;IAC9E,4EAA4E;IAC5E,EAAE,CAAC,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACxD,WAAW,GAA2B,WAAW,CAAC,CAAC,CAAC,CAAC;IACvD,CAAC;IAED,MAAM,CAAC,IAAI,eAAe,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,qBAAqB,CAAO,OAAO,CAAC,CAAC,CAAC;AACpG,CAAC"}

105
node_modules/rxjs/_esm2015/observable/concat.js generated vendored Normal file
View File

@@ -0,0 +1,105 @@
import { isScheduler } from '../util/isScheduler';
import { of } from './of';
import { from } from './from';
import { concatAll } from '../operators/concatAll';
/* tslint:enable:max-line-length */
/**
* Creates an output Observable which sequentially emits all values from given
* Observable and then moves on to the next.
*
* <span class="informal">Concatenates multiple Observables together by
* sequentially emitting their values, one Observable after the other.</span>
*
* <img src="./img/concat.png" width="100%">
*
* `concat` joins multiple Observables together, by subscribing to them one at a time and
* merging their results into the output Observable. You can pass either an array of
* Observables, or put them directly as arguments. Passing an empty array will result
* in Observable that completes immediately.
*
* `concat` will subscribe to first input Observable and emit all its values, without
* changing or affecting them in any way. When that Observable completes, it will
* subscribe to then next Observable passed and, again, emit its values. This will be
* repeated, until the operator runs out of Observables. When last input Observable completes,
* `concat` will complete as well. At any given moment only one Observable passed to operator
* emits values. If you would like to emit values from passed Observables concurrently, check out
* {@link merge} instead, especially with optional `concurrent` parameter. As a matter of fact,
* `concat` is an equivalent of `merge` operator with `concurrent` parameter set to `1`.
*
* Note that if some input Observable never completes, `concat` will also never complete
* and Observables following the one that did not complete will never be subscribed. On the other
* hand, if some Observable simply completes immediately after it is subscribed, it will be
* invisible for `concat`, which will just move on to the next Observable.
*
* If any Observable in chain errors, instead of passing control to the next Observable,
* `concat` will error immediately as well. Observables that would be subscribed after
* the one that emitted error, never will.
*
* If you pass to `concat` the same Observable many times, its stream of values
* will be "replayed" on every subscription, which means you can repeat given Observable
* as many times as you like. If passing the same Observable to `concat` 1000 times becomes tedious,
* you can always use {@link repeat}.
*
* @example <caption>Concatenate a timer counting from 0 to 3 with a synchronous sequence from 1 to 10</caption>
* var timer = Rx.Observable.interval(1000).take(4);
* var sequence = Rx.Observable.range(1, 10);
* var result = Rx.Observable.concat(timer, sequence);
* result.subscribe(x => console.log(x));
*
* // results in:
* // 0 -1000ms-> 1 -1000ms-> 2 -1000ms-> 3 -immediate-> 1 ... 10
*
*
* @example <caption>Concatenate an array of 3 Observables</caption>
* var timer1 = Rx.Observable.interval(1000).take(10);
* var timer2 = Rx.Observable.interval(2000).take(6);
* var timer3 = Rx.Observable.interval(500).take(10);
* var result = Rx.Observable.concat([timer1, timer2, timer3]); // note that array is passed
* result.subscribe(x => console.log(x));
*
* // results in the following:
* // (Prints to console sequentially)
* // -1000ms-> 0 -1000ms-> 1 -1000ms-> ... 9
* // -2000ms-> 0 -2000ms-> 1 -2000ms-> ... 5
* // -500ms-> 0 -500ms-> 1 -500ms-> ... 9
*
*
* @example <caption>Concatenate the same Observable to repeat it</caption>
* const timer = Rx.Observable.interval(1000).take(2);
*
* Rx.Observable.concat(timer, timer) // concating the same Observable!
* .subscribe(
* value => console.log(value),
* err => {},
* () => console.log('...and it is done!')
* );
*
* // Logs:
* // 0 after 1s
* // 1 after 2s
* // 0 after 3s
* // 1 after 4s
* // "...and it is done!" also after 4s
*
* @see {@link concatAll}
* @see {@link concatMap}
* @see {@link concatMapTo}
*
* @param {ObservableInput} input1 An input Observable to concatenate with others.
* @param {ObservableInput} input2 An input Observable to concatenate with others.
* More than one input Observables may be given as argument.
* @param {Scheduler} [scheduler=null] An optional IScheduler to schedule each
* Observable subscription on.
* @return {Observable} All values of each passed Observable merged into a
* single Observable, in order, in serial fashion.
* @static true
* @name concat
* @owner Observable
*/
export function concat(...observables) {
if (observables.length === 1 || (observables.length === 2 && isScheduler(observables[1]))) {
return from(observables[0]);
}
return concatAll()(of(...observables));
}
//# sourceMappingURL=concat.js.map

1
node_modules/rxjs/_esm2015/observable/concat.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"concat.js","sourceRoot":"","sources":["../../src/observable/concat.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE,MAAM,qBAAqB;OAC1C,EAAE,EAAE,EAAE,MAAM,MAAM;OAClB,EAAE,IAAI,EAAE,MAAM,QAAQ;OACtB,EAAE,SAAS,EAAE,MAAM,wBAAwB;AAWlD,mCAAmC;AACnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4FG;AACH,uBAA6B,GAAG,WAAqD;IACnF,EAAE,CAAC,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,IAAI,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1F,MAAM,CAAC,IAAI,CAAM,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC;IACD,MAAM,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,CAAkB,CAAC;AAC1D,CAAC"}

3
node_modules/rxjs/_esm2015/observable/defer.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import { DeferObservable } from './DeferObservable';
export const defer = DeferObservable.create;
//# sourceMappingURL=defer.js.map

1
node_modules/rxjs/_esm2015/observable/defer.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"defer.js","sourceRoot":"","sources":["../../src/observable/defer.ts"],"names":[],"mappings":"OAAO,EAAG,eAAe,EAAG,MAAM,mBAAmB;AAErD,OAAO,MAAM,KAAK,GAAG,eAAe,CAAC,MAAM,CAAC"}

View File

@@ -0,0 +1,399 @@
import { root } from '../../util/root';
import { tryCatch } from '../../util/tryCatch';
import { errorObject } from '../../util/errorObject';
import { Observable } from '../../Observable';
import { Subscriber } from '../../Subscriber';
import { map } from '../../operators/map';
function getCORSRequest() {
if (root.XMLHttpRequest) {
return new root.XMLHttpRequest();
}
else if (!!root.XDomainRequest) {
return new root.XDomainRequest();
}
else {
throw new Error('CORS is not supported by your browser');
}
}
function getXMLHttpRequest() {
if (root.XMLHttpRequest) {
return new root.XMLHttpRequest();
}
else {
let progId;
try {
const progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];
for (let i = 0; i < 3; i++) {
try {
progId = progIds[i];
if (new root.ActiveXObject(progId)) {
break;
}
}
catch (e) {
}
}
return new root.ActiveXObject(progId);
}
catch (e) {
throw new Error('XMLHttpRequest is not supported by your browser');
}
}
}
export function ajaxGet(url, headers = null) {
return new AjaxObservable({ method: 'GET', url, headers });
}
;
export function ajaxPost(url, body, headers) {
return new AjaxObservable({ method: 'POST', url, body, headers });
}
;
export function ajaxDelete(url, headers) {
return new AjaxObservable({ method: 'DELETE', url, headers });
}
;
export function ajaxPut(url, body, headers) {
return new AjaxObservable({ method: 'PUT', url, body, headers });
}
;
export function ajaxPatch(url, body, headers) {
return new AjaxObservable({ method: 'PATCH', url, body, headers });
}
;
const mapResponse = map((x, index) => x.response);
export function ajaxGetJSON(url, headers) {
return mapResponse(new AjaxObservable({
method: 'GET',
url,
responseType: 'json',
headers
}));
}
;
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
export class AjaxObservable extends Observable {
constructor(urlOrRequest) {
super();
const request = {
async: true,
createXHR: function () {
return this.crossDomain ? getCORSRequest.call(this) : getXMLHttpRequest();
},
crossDomain: false,
withCredentials: false,
headers: {},
method: 'GET',
responseType: 'json',
timeout: 0
};
if (typeof urlOrRequest === 'string') {
request.url = urlOrRequest;
}
else {
for (const prop in urlOrRequest) {
if (urlOrRequest.hasOwnProperty(prop)) {
request[prop] = urlOrRequest[prop];
}
}
}
this.request = request;
}
/** @deprecated internal use only */ _subscribe(subscriber) {
return new AjaxSubscriber(subscriber, this.request);
}
}
/**
* Creates an observable for an Ajax request with either a request object with
* url, headers, etc or a string for a URL.
*
* @example
* source = Rx.Observable.ajax('/products');
* source = Rx.Observable.ajax({ url: 'products', method: 'GET' });
*
* @param {string|Object} request Can be one of the following:
* A string of the URL to make the Ajax call.
* An object with the following properties
* - url: URL of the request
* - body: The body of the request
* - method: Method of the request, such as GET, POST, PUT, PATCH, DELETE
* - async: Whether the request is async
* - headers: Optional headers
* - crossDomain: true if a cross domain request, else false
* - createXHR: a function to override if you need to use an alternate
* XMLHttpRequest implementation.
* - resultSelector: a function to use to alter the output value type of
* the Observable. Gets {@link AjaxResponse} as an argument.
* @return {Observable} An observable sequence containing the XMLHttpRequest.
* @static true
* @name ajax
* @owner Observable
*/
AjaxObservable.create = (() => {
const create = (urlOrRequest) => {
return new AjaxObservable(urlOrRequest);
};
create.get = ajaxGet;
create.post = ajaxPost;
create.delete = ajaxDelete;
create.put = ajaxPut;
create.patch = ajaxPatch;
create.getJSON = ajaxGetJSON;
return create;
})();
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
export class AjaxSubscriber extends Subscriber {
constructor(destination, request) {
super(destination);
this.request = request;
this.done = false;
const headers = request.headers = request.headers || {};
// force CORS if requested
if (!request.crossDomain && !headers['X-Requested-With']) {
headers['X-Requested-With'] = 'XMLHttpRequest';
}
// ensure content type is set
if (!('Content-Type' in headers) && !(root.FormData && request.body instanceof root.FormData) && typeof request.body !== 'undefined') {
headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
}
// properly serialize body
request.body = this.serializeBody(request.body, request.headers['Content-Type']);
this.send();
}
next(e) {
this.done = true;
const { xhr, request, destination } = this;
const response = new AjaxResponse(e, xhr, request);
destination.next(response);
}
send() {
const { request, request: { user, method, url, async, password, headers, body } } = this;
const createXHR = request.createXHR;
const xhr = tryCatch(createXHR).call(request);
if (xhr === errorObject) {
this.error(errorObject.e);
}
else {
this.xhr = xhr;
// set up the events before open XHR
// https://developer.mozilla.org/en/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest
// You need to add the event listeners before calling open() on the request.
// Otherwise the progress events will not fire.
this.setupEvents(xhr, request);
// open XHR
let result;
if (user) {
result = tryCatch(xhr.open).call(xhr, method, url, async, user, password);
}
else {
result = tryCatch(xhr.open).call(xhr, method, url, async);
}
if (result === errorObject) {
this.error(errorObject.e);
return null;
}
// timeout, responseType and withCredentials can be set once the XHR is open
if (async) {
xhr.timeout = request.timeout;
xhr.responseType = request.responseType;
}
if ('withCredentials' in xhr) {
xhr.withCredentials = !!request.withCredentials;
}
// set headers
this.setHeaders(xhr, headers);
// finally send the request
result = body ? tryCatch(xhr.send).call(xhr, body) : tryCatch(xhr.send).call(xhr);
if (result === errorObject) {
this.error(errorObject.e);
return null;
}
}
return xhr;
}
serializeBody(body, contentType) {
if (!body || typeof body === 'string') {
return body;
}
else if (root.FormData && body instanceof root.FormData) {
return body;
}
if (contentType) {
const splitIndex = contentType.indexOf(';');
if (splitIndex !== -1) {
contentType = contentType.substring(0, splitIndex);
}
}
switch (contentType) {
case 'application/x-www-form-urlencoded':
return Object.keys(body).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(body[key])}`).join('&');
case 'application/json':
return JSON.stringify(body);
default:
return body;
}
}
setHeaders(xhr, headers) {
for (let key in headers) {
if (headers.hasOwnProperty(key)) {
xhr.setRequestHeader(key, headers[key]);
}
}
}
setupEvents(xhr, request) {
const progressSubscriber = request.progressSubscriber;
function xhrTimeout(e) {
const { subscriber, progressSubscriber, request } = xhrTimeout;
if (progressSubscriber) {
progressSubscriber.error(e);
}
subscriber.error(new AjaxTimeoutError(this, request)); //TODO: Make betterer.
}
;
xhr.ontimeout = xhrTimeout;
xhrTimeout.request = request;
xhrTimeout.subscriber = this;
xhrTimeout.progressSubscriber = progressSubscriber;
if (xhr.upload && 'withCredentials' in xhr) {
if (progressSubscriber) {
let xhrProgress;
xhrProgress = function (e) {
const { progressSubscriber } = xhrProgress;
progressSubscriber.next(e);
};
if (root.XDomainRequest) {
xhr.onprogress = xhrProgress;
}
else {
xhr.upload.onprogress = xhrProgress;
}
xhrProgress.progressSubscriber = progressSubscriber;
}
let xhrError;
xhrError = function (e) {
const { progressSubscriber, subscriber, request } = xhrError;
if (progressSubscriber) {
progressSubscriber.error(e);
}
subscriber.error(new AjaxError('ajax error', this, request));
};
xhr.onerror = xhrError;
xhrError.request = request;
xhrError.subscriber = this;
xhrError.progressSubscriber = progressSubscriber;
}
function xhrReadyStateChange(e) {
const { subscriber, progressSubscriber, request } = xhrReadyStateChange;
if (this.readyState === 4) {
// normalize IE9 bug (http://bugs.jquery.com/ticket/1450)
let status = this.status === 1223 ? 204 : this.status;
let response = (this.responseType === 'text' ? (this.response || this.responseText) : this.response);
// fix status code when it is 0 (0 status is undocumented).
// Occurs when accessing file resources or on Android 4.1 stock browser
// while retrieving files from application cache.
if (status === 0) {
status = response ? 200 : 0;
}
if (200 <= status && status < 300) {
if (progressSubscriber) {
progressSubscriber.complete();
}
subscriber.next(e);
subscriber.complete();
}
else {
if (progressSubscriber) {
progressSubscriber.error(e);
}
subscriber.error(new AjaxError('ajax error ' + status, this, request));
}
}
}
;
xhr.onreadystatechange = xhrReadyStateChange;
xhrReadyStateChange.subscriber = this;
xhrReadyStateChange.progressSubscriber = progressSubscriber;
xhrReadyStateChange.request = request;
}
unsubscribe() {
const { done, xhr } = this;
if (!done && xhr && xhr.readyState !== 4 && typeof xhr.abort === 'function') {
xhr.abort();
}
super.unsubscribe();
}
}
/**
* A normalized AJAX response.
*
* @see {@link ajax}
*
* @class AjaxResponse
*/
export class AjaxResponse {
constructor(originalEvent, xhr, request) {
this.originalEvent = originalEvent;
this.xhr = xhr;
this.request = request;
this.status = xhr.status;
this.responseType = xhr.responseType || request.responseType;
this.response = parseXhrResponse(this.responseType, xhr);
}
}
/**
* A normalized AJAX error.
*
* @see {@link ajax}
*
* @class AjaxError
*/
export class AjaxError extends Error {
constructor(message, xhr, request) {
super(message);
this.message = message;
this.xhr = xhr;
this.request = request;
this.status = xhr.status;
this.responseType = xhr.responseType || request.responseType;
this.response = parseXhrResponse(this.responseType, xhr);
}
}
function parseXhrResponse(responseType, xhr) {
switch (responseType) {
case 'json':
if ('response' in xhr) {
//IE does not support json as responseType, parse it internally
return xhr.responseType ? xhr.response : JSON.parse(xhr.response || xhr.responseText || 'null');
}
else {
// HACK(benlesh): TypeScript shennanigans
// tslint:disable-next-line:no-any latest TS seems to think xhr is "never" here.
return JSON.parse(xhr.responseText || 'null');
}
case 'xml':
return xhr.responseXML;
case 'text':
default:
// HACK(benlesh): TypeScript shennanigans
// tslint:disable-next-line:no-any latest TS seems to think xhr is "never" here.
return ('response' in xhr) ? xhr.response : xhr.responseText;
}
}
/**
* @see {@link ajax}
*
* @class AjaxTimeoutError
*/
export class AjaxTimeoutError extends AjaxError {
constructor(xhr, request) {
super('ajax timeout', xhr, request);
}
}
//# sourceMappingURL=AjaxObservable.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,239 @@
import { Subject, AnonymousSubject } from '../../Subject';
import { Subscriber } from '../../Subscriber';
import { Observable } from '../../Observable';
import { Subscription } from '../../Subscription';
import { root } from '../../util/root';
import { ReplaySubject } from '../../ReplaySubject';
import { tryCatch } from '../../util/tryCatch';
import { errorObject } from '../../util/errorObject';
import { assign } from '../../util/assign';
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
export class WebSocketSubject extends AnonymousSubject {
constructor(urlConfigOrSource, destination) {
if (urlConfigOrSource instanceof Observable) {
super(destination, urlConfigOrSource);
}
else {
super();
this.WebSocketCtor = root.WebSocket;
this._output = new Subject();
if (typeof urlConfigOrSource === 'string') {
this.url = urlConfigOrSource;
}
else {
// WARNING: config object could override important members here.
assign(this, urlConfigOrSource);
}
if (!this.WebSocketCtor) {
throw new Error('no WebSocket constructor can be found');
}
this.destination = new ReplaySubject();
}
}
resultSelector(e) {
return JSON.parse(e.data);
}
/**
* Wrapper around the w3c-compatible WebSocket object provided by the browser.
*
* @example <caption>Wraps browser WebSocket</caption>
*
* let socket$ = Observable.webSocket('ws://localhost:8081');
*
* socket$.subscribe(
* (msg) => console.log('message received: ' + msg),
* (err) => console.log(err),
* () => console.log('complete')
* );
*
* socket$.next(JSON.stringify({ op: 'hello' }));
*
* @example <caption>Wraps WebSocket from nodejs-websocket (using node.js)</caption>
*
* import { w3cwebsocket } from 'websocket';
*
* let socket$ = Observable.webSocket({
* url: 'ws://localhost:8081',
* WebSocketCtor: w3cwebsocket
* });
*
* socket$.subscribe(
* (msg) => console.log('message received: ' + msg),
* (err) => console.log(err),
* () => console.log('complete')
* );
*
* socket$.next(JSON.stringify({ op: 'hello' }));
*
* @param {string | WebSocketSubjectConfig} urlConfigOrSource the source of the websocket as an url or a structure defining the websocket object
* @return {WebSocketSubject}
* @static true
* @name webSocket
* @owner Observable
*/
static create(urlConfigOrSource) {
return new WebSocketSubject(urlConfigOrSource);
}
lift(operator) {
const sock = new WebSocketSubject(this, this.destination);
sock.operator = operator;
return sock;
}
_resetState() {
this.socket = null;
if (!this.source) {
this.destination = new ReplaySubject();
}
this._output = new Subject();
}
// TODO: factor this out to be a proper Operator/Subscriber implementation and eliminate closures
multiplex(subMsg, unsubMsg, messageFilter) {
const self = this;
return new Observable((observer) => {
const result = tryCatch(subMsg)();
if (result === errorObject) {
observer.error(errorObject.e);
}
else {
self.next(result);
}
let subscription = self.subscribe(x => {
const result = tryCatch(messageFilter)(x);
if (result === errorObject) {
observer.error(errorObject.e);
}
else if (result) {
observer.next(x);
}
}, err => observer.error(err), () => observer.complete());
return () => {
const result = tryCatch(unsubMsg)();
if (result === errorObject) {
observer.error(errorObject.e);
}
else {
self.next(result);
}
subscription.unsubscribe();
};
});
}
_connectSocket() {
const { WebSocketCtor } = this;
const observer = this._output;
let socket = null;
try {
socket = this.protocol ?
new WebSocketCtor(this.url, this.protocol) :
new WebSocketCtor(this.url);
this.socket = socket;
if (this.binaryType) {
this.socket.binaryType = this.binaryType;
}
}
catch (e) {
observer.error(e);
return;
}
const subscription = new Subscription(() => {
this.socket = null;
if (socket && socket.readyState === 1) {
socket.close();
}
});
socket.onopen = (e) => {
const openObserver = this.openObserver;
if (openObserver) {
openObserver.next(e);
}
const queue = this.destination;
this.destination = Subscriber.create((x) => socket.readyState === 1 && socket.send(x), (e) => {
const closingObserver = this.closingObserver;
if (closingObserver) {
closingObserver.next(undefined);
}
if (e && e.code) {
socket.close(e.code, e.reason);
}
else {
observer.error(new TypeError('WebSocketSubject.error must be called with an object with an error code, ' +
'and an optional reason: { code: number, reason: string }'));
}
this._resetState();
}, () => {
const closingObserver = this.closingObserver;
if (closingObserver) {
closingObserver.next(undefined);
}
socket.close();
this._resetState();
});
if (queue && queue instanceof ReplaySubject) {
subscription.add(queue.subscribe(this.destination));
}
};
socket.onerror = (e) => {
this._resetState();
observer.error(e);
};
socket.onclose = (e) => {
this._resetState();
const closeObserver = this.closeObserver;
if (closeObserver) {
closeObserver.next(e);
}
if (e.wasClean) {
observer.complete();
}
else {
observer.error(e);
}
};
socket.onmessage = (e) => {
const result = tryCatch(this.resultSelector)(e);
if (result === errorObject) {
observer.error(errorObject.e);
}
else {
observer.next(result);
}
};
}
/** @deprecated internal use only */ _subscribe(subscriber) {
const { source } = this;
if (source) {
return source.subscribe(subscriber);
}
if (!this.socket) {
this._connectSocket();
}
let subscription = new Subscription();
subscription.add(this._output.subscribe(subscriber));
subscription.add(() => {
const { socket } = this;
if (this._output.observers.length === 0) {
if (socket && socket.readyState === 1) {
socket.close();
}
this._resetState();
}
});
return subscription;
}
unsubscribe() {
const { source, socket } = this;
if (socket && socket.readyState === 1) {
socket.close();
this._resetState();
}
super.unsubscribe();
if (!source) {
this.destination = new ReplaySubject();
}
}
}
//# sourceMappingURL=WebSocketSubject.js.map

File diff suppressed because one or more lines are too long

3
node_modules/rxjs/_esm2015/observable/dom/ajax.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import { AjaxObservable } from './AjaxObservable';
export const ajax = AjaxObservable.create;
//# sourceMappingURL=ajax.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ajax.js","sourceRoot":"","sources":["../../../src/observable/dom/ajax.ts"],"names":[],"mappings":"OAAO,EAAG,cAAc,EAAuB,MAAM,kBAAkB;AAEvE,OAAO,MAAM,IAAI,GAAuB,cAAc,CAAC,MAAM,CAAC"}

View File

@@ -0,0 +1,3 @@
import { WebSocketSubject } from './WebSocketSubject';
export const webSocket = WebSocketSubject.create;
//# sourceMappingURL=webSocket.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"webSocket.js","sourceRoot":"","sources":["../../../src/observable/dom/webSocket.ts"],"names":[],"mappings":"OAAO,EAAG,gBAAgB,EAAG,MAAM,oBAAoB;AAEvD,OAAO,MAAM,SAAS,GAAG,gBAAgB,CAAC,MAAM,CAAC"}

3
node_modules/rxjs/_esm2015/observable/empty.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import { EmptyObservable } from './EmptyObservable';
export const empty = EmptyObservable.create;
//# sourceMappingURL=empty.js.map

1
node_modules/rxjs/_esm2015/observable/empty.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"empty.js","sourceRoot":"","sources":["../../src/observable/empty.ts"],"names":[],"mappings":"OAAO,EAAG,eAAe,EAAG,MAAM,mBAAmB;AAErD,OAAO,MAAM,KAAK,GAAG,eAAe,CAAC,MAAM,CAAC"}

3
node_modules/rxjs/_esm2015/observable/forkJoin.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import { ForkJoinObservable } from './ForkJoinObservable';
export const forkJoin = ForkJoinObservable.create;
//# sourceMappingURL=forkJoin.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"forkJoin.js","sourceRoot":"","sources":["../../src/observable/forkJoin.ts"],"names":[],"mappings":"OAAO,EAAG,kBAAkB,EAAG,MAAM,sBAAsB;AAE3D,OAAO,MAAM,QAAQ,GAAG,kBAAkB,CAAC,MAAM,CAAC"}

3
node_modules/rxjs/_esm2015/observable/from.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import { FromObservable } from './FromObservable';
export const from = FromObservable.create;
//# sourceMappingURL=from.js.map

1
node_modules/rxjs/_esm2015/observable/from.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"from.js","sourceRoot":"","sources":["../../src/observable/from.ts"],"names":[],"mappings":"OAAO,EAAG,cAAc,EAAG,MAAM,kBAAkB;AAEnD,OAAO,MAAM,IAAI,GAAG,cAAc,CAAC,MAAM,CAAC"}

3
node_modules/rxjs/_esm2015/observable/fromEvent.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import { FromEventObservable } from './FromEventObservable';
export const fromEvent = FromEventObservable.create;
//# sourceMappingURL=fromEvent.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"fromEvent.js","sourceRoot":"","sources":["../../src/observable/fromEvent.ts"],"names":[],"mappings":"OAAO,EAAG,mBAAmB,EAAG,MAAM,uBAAuB;AAE7D,OAAO,MAAM,SAAS,GAAG,mBAAmB,CAAC,MAAM,CAAC"}

View File

@@ -0,0 +1,3 @@
import { FromEventPatternObservable } from './FromEventPatternObservable';
export const fromEventPattern = FromEventPatternObservable.create;
//# sourceMappingURL=fromEventPattern.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"fromEventPattern.js","sourceRoot":"","sources":["../../src/observable/fromEventPattern.ts"],"names":[],"mappings":"OAAO,EAAG,0BAA0B,EAAG,MAAM,8BAA8B;AAE3E,OAAO,MAAM,gBAAgB,GAAG,0BAA0B,CAAC,MAAM,CAAC"}

3
node_modules/rxjs/_esm2015/observable/fromPromise.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import { PromiseObservable } from './PromiseObservable';
export const fromPromise = PromiseObservable.create;
//# sourceMappingURL=fromPromise.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"fromPromise.js","sourceRoot":"","sources":["../../src/observable/fromPromise.ts"],"names":[],"mappings":"OAAO,EAAG,iBAAiB,EAAG,MAAM,qBAAqB;AAEzD,OAAO,MAAM,WAAW,GAAG,iBAAiB,CAAC,MAAM,CAAC"}

3
node_modules/rxjs/_esm2015/observable/generate.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import { GenerateObservable } from './GenerateObservable';
export const generate = GenerateObservable.create;
//# sourceMappingURL=generate.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../src/observable/generate.ts"],"names":[],"mappings":"OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB;AAEzD,OAAO,MAAM,QAAQ,GAAG,kBAAkB,CAAC,MAAM,CAAC"}

3
node_modules/rxjs/_esm2015/observable/if.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import { IfObservable } from './IfObservable';
export const _if = IfObservable.create;
//# sourceMappingURL=if.js.map

1
node_modules/rxjs/_esm2015/observable/if.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"if.js","sourceRoot":"","sources":["../../src/observable/if.ts"],"names":[],"mappings":"OAAO,EAAG,YAAY,EAAG,MAAM,gBAAgB;AAE/C,OAAO,MAAM,GAAG,GAAG,YAAY,CAAC,MAAM,CAAC"}

3
node_modules/rxjs/_esm2015/observable/interval.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import { IntervalObservable } from './IntervalObservable';
export const interval = IntervalObservable.create;
//# sourceMappingURL=interval.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"interval.js","sourceRoot":"","sources":["../../src/observable/interval.ts"],"names":[],"mappings":"OAAO,EAAG,kBAAkB,EAAG,MAAM,sBAAsB;AAE3D,OAAO,MAAM,QAAQ,GAAG,kBAAkB,CAAC,MAAM,CAAC"}

84
node_modules/rxjs/_esm2015/observable/merge.js generated vendored Normal file
View File

@@ -0,0 +1,84 @@
import { Observable } from '../Observable';
import { ArrayObservable } from './ArrayObservable';
import { isScheduler } from '../util/isScheduler';
import { mergeAll } from '../operators/mergeAll';
/* tslint:enable:max-line-length */
/**
* Creates an output Observable which concurrently emits all values from every
* given input Observable.
*
* <span class="informal">Flattens multiple Observables together by blending
* their values into one Observable.</span>
*
* <img src="./img/merge.png" width="100%">
*
* `merge` subscribes to each given input Observable (as arguments), and simply
* forwards (without doing any transformation) all the values from all the input
* Observables to the output Observable. The output Observable only completes
* once all input Observables have completed. Any error delivered by an input
* Observable will be immediately emitted on the output Observable.
*
* @example <caption>Merge together two Observables: 1s interval and clicks</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var timer = Rx.Observable.interval(1000);
* var clicksOrTimer = Rx.Observable.merge(clicks, timer);
* clicksOrTimer.subscribe(x => console.log(x));
*
* // Results in the following:
* // timer will emit ascending values, one every second(1000ms) to console
* // clicks logs MouseEvents to console everytime the "document" is clicked
* // Since the two streams are merged you see these happening
* // as they occur.
*
* @example <caption>Merge together 3 Observables, but only 2 run concurrently</caption>
* var timer1 = Rx.Observable.interval(1000).take(10);
* var timer2 = Rx.Observable.interval(2000).take(6);
* var timer3 = Rx.Observable.interval(500).take(10);
* var concurrent = 2; // the argument
* var merged = Rx.Observable.merge(timer1, timer2, timer3, concurrent);
* merged.subscribe(x => console.log(x));
*
* // Results in the following:
* // - First timer1 and timer2 will run concurrently
* // - timer1 will emit a value every 1000ms for 10 iterations
* // - timer2 will emit a value every 2000ms for 6 iterations
* // - after timer1 hits it's max iteration, timer2 will
* // continue, and timer3 will start to run concurrently with timer2
* // - when timer2 hits it's max iteration it terminates, and
* // timer3 will continue to emit a value every 500ms until it is complete
*
* @see {@link mergeAll}
* @see {@link mergeMap}
* @see {@link mergeMapTo}
* @see {@link mergeScan}
*
* @param {...ObservableInput} observables Input Observables to merge together.
* @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input
* Observables being subscribed to concurrently.
* @param {Scheduler} [scheduler=null] The IScheduler to use for managing
* concurrency of input Observables.
* @return {Observable} an Observable that emits items that are the result of
* every input Observable.
* @static true
* @name merge
* @owner Observable
*/
export function merge(...observables) {
let concurrent = Number.POSITIVE_INFINITY;
let scheduler = null;
let last = observables[observables.length - 1];
if (isScheduler(last)) {
scheduler = observables.pop();
if (observables.length > 1 && typeof observables[observables.length - 1] === 'number') {
concurrent = observables.pop();
}
}
else if (typeof last === 'number') {
concurrent = observables.pop();
}
if (scheduler === null && observables.length === 1 && observables[0] instanceof Observable) {
return observables[0];
}
return mergeAll(concurrent)(new ArrayObservable(observables, scheduler));
}
//# sourceMappingURL=merge.js.map

1
node_modules/rxjs/_esm2015/observable/merge.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../src/observable/merge.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AAkB,CAAC;AACjG,CAAC"}

3
node_modules/rxjs/_esm2015/observable/never.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import { NeverObservable } from './NeverObservable';
export const never = NeverObservable.create;
//# sourceMappingURL=never.js.map

1
node_modules/rxjs/_esm2015/observable/never.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"never.js","sourceRoot":"","sources":["../../src/observable/never.ts"],"names":[],"mappings":"OAAO,EAAG,eAAe,EAAG,MAAM,mBAAmB;AAErD,OAAO,MAAM,KAAK,GAAG,eAAe,CAAC,MAAM,CAAC"}

3
node_modules/rxjs/_esm2015/observable/of.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import { ArrayObservable } from './ArrayObservable';
export const of = ArrayObservable.of;
//# sourceMappingURL=of.js.map

1
node_modules/rxjs/_esm2015/observable/of.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"of.js","sourceRoot":"","sources":["../../src/observable/of.ts"],"names":[],"mappings":"OAAO,EAAG,eAAe,EAAG,MAAM,mBAAmB;AAErD,OAAO,MAAM,EAAE,GAAG,eAAe,CAAC,EAAE,CAAC"}

View File

@@ -0,0 +1,3 @@
import { onErrorResumeNextStatic } from '../operators/onErrorResumeNext';
export const onErrorResumeNext = onErrorResumeNextStatic;
//# sourceMappingURL=onErrorResumeNext.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"onErrorResumeNext.js","sourceRoot":"","sources":["../../src/observable/onErrorResumeNext.ts"],"names":[],"mappings":"OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC;AAExE,OAAO,MAAM,iBAAiB,GAAG,uBAAuB,CAAC"}

3
node_modules/rxjs/_esm2015/observable/pairs.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import { PairsObservable } from './PairsObservable';
export const pairs = PairsObservable.create;
//# sourceMappingURL=pairs.js.map

1
node_modules/rxjs/_esm2015/observable/pairs.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"pairs.js","sourceRoot":"","sources":["../../src/observable/pairs.ts"],"names":[],"mappings":"OAAO,EAAG,eAAe,EAAG,MAAM,mBAAmB;AAErD,OAAO,MAAM,KAAK,GAAG,eAAe,CAAC,MAAM,CAAC"}

71
node_modules/rxjs/_esm2015/observable/race.js generated vendored Normal file
View File

@@ -0,0 +1,71 @@
import { isArray } from '../util/isArray';
import { ArrayObservable } from '../observable/ArrayObservable';
import { OuterSubscriber } from '../OuterSubscriber';
import { subscribeToResult } from '../util/subscribeToResult';
export function race(...observables) {
// if the only argument is an array, it was most likely called with
// `race([obs1, obs2, ...])`
if (observables.length === 1) {
if (isArray(observables[0])) {
observables = observables[0];
}
else {
return observables[0];
}
}
return new ArrayObservable(observables).lift(new RaceOperator());
}
export class RaceOperator {
call(subscriber, source) {
return source.subscribe(new RaceSubscriber(subscriber));
}
}
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
export class RaceSubscriber extends OuterSubscriber {
constructor(destination) {
super(destination);
this.hasFirst = false;
this.observables = [];
this.subscriptions = [];
}
_next(observable) {
this.observables.push(observable);
}
_complete() {
const observables = this.observables;
const len = observables.length;
if (len === 0) {
this.destination.complete();
}
else {
for (let i = 0; i < len && !this.hasFirst; i++) {
let observable = observables[i];
let subscription = subscribeToResult(this, observable, observable, i);
if (this.subscriptions) {
this.subscriptions.push(subscription);
}
this.add(subscription);
}
this.observables = null;
}
}
notifyNext(outerValue, innerValue, outerIndex, innerIndex, innerSub) {
if (!this.hasFirst) {
this.hasFirst = true;
for (let i = 0; i < this.subscriptions.length; i++) {
if (i !== outerIndex) {
let subscription = this.subscriptions[i];
subscription.unsubscribe();
this.remove(subscription);
}
}
this.subscriptions = null;
}
this.destination.next(innerValue);
}
}
//# sourceMappingURL=race.js.map

1
node_modules/rxjs/_esm2015/observable/race.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"race.js","sourceRoot":"","sources":["../../src/observable/race.ts"],"names":[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,GAAG,IAAI,CAAC;QAC5B,CAAC;QAED,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACpC,CAAC;AACH,CAAC;AAAA"}

3
node_modules/rxjs/_esm2015/observable/range.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import { RangeObservable } from './RangeObservable';
export const range = RangeObservable.create;
//# sourceMappingURL=range.js.map

1
node_modules/rxjs/_esm2015/observable/range.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"range.js","sourceRoot":"","sources":["../../src/observable/range.ts"],"names":[],"mappings":"OAAO,EAAG,eAAe,EAAG,MAAM,mBAAmB;AAErD,OAAO,MAAM,KAAK,GAAG,eAAe,CAAC,MAAM,CAAC"}

3
node_modules/rxjs/_esm2015/observable/throw.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import { ErrorObservable } from './ErrorObservable';
export const _throw = ErrorObservable.create;
//# sourceMappingURL=throw.js.map

1
node_modules/rxjs/_esm2015/observable/throw.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"throw.js","sourceRoot":"","sources":["../../src/observable/throw.ts"],"names":[],"mappings":"OAAO,EAAG,eAAe,EAAG,MAAM,mBAAmB;AAErD,OAAO,MAAM,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC"}

Some files were not shown because too many files have changed in this diff Show More