Socket
Socket
Sign inDemoInstall

rxjs

Package Overview
Dependencies
1
Maintainers
2
Versions
165
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.0.0-beta.6 to 5.0.0-beta.7

add/observable/generate.d.ts

4

Observable.js
"use strict";
var root_1 = require('./util/root');
var observable_1 = require('./symbol/observable');
var toSubscriber_1 = require('./util/toSubscriber');
var $$observable = require('symbol-observable');
/**

@@ -116,3 +116,3 @@ * A representation of any set of values over any amount of time. This the most basic building block

*/
Observable.prototype[observable_1.$$observable] = function () {
Observable.prototype[$$observable] = function () {
return this;

@@ -119,0 +119,0 @@ };

@@ -27,11 +27,33 @@ "use strict";

/**
* Converts a callback function to an observable sequence.
* @param {function} callbackFunc Function with a callback as the last
* parameter.
* @param {function} selector A selector which takes the arguments from the
* callback to produce a single item to yield on next.
* @param {Scheduler} [scheduler] The scheduler on which to schedule
* the callbacks.
* @return {function(...params: *): Observable<T>} a function which returns the
* Observable that corresponds to the callback.
* 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, but 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 where the
* results will be delivered to.
*
* @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));
*
* @see {@link bindNodeCallback}
* @see {@link from}
* @see {@link fromPromise}
*
* @param {function} func Function with a callback as the last parameter.
* @param {function} selector A function which takes the arguments from the
* callback and maps those 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 callback would deliver.
* @static true

@@ -41,3 +63,3 @@ * @name bindCallback

*/
BoundCallbackObservable.create = function (callbackFunc, selector, scheduler) {
BoundCallbackObservable.create = function (func, selector, scheduler) {
if (selector === void 0) { selector = undefined; }

@@ -49,3 +71,3 @@ return function () {

}
return new BoundCallbackObservable(callbackFunc, selector, args, scheduler);
return new BoundCallbackObservable(func, selector, args, scheduler);
};

@@ -52,0 +74,0 @@ };

@@ -27,7 +27,36 @@ "use strict";

/**
* Converts a node callback to an Observable.
* @param callbackFunc
* @param selector
* @param scheduler
* @return {function(...params: *): Observable<T>}
* 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, while remaining
* arguments are the callback result. 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 where the results will be delivered to.
*
* @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));
*
* @see {@link bindCallback}
* @see {@link from}
* @see {@link fromPromise}
*
* @param {function} func Function with a callback as the last parameter.
* @param {function} selector A function which takes the arguments from the
* callback and maps those 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

@@ -37,3 +66,3 @@ * @name bindNodeCallback

*/
BoundNodeCallbackObservable.create = function (callbackFunc, selector, scheduler) {
BoundNodeCallbackObservable.create = function (func, selector, scheduler) {
if (selector === void 0) { selector = undefined; }

@@ -45,3 +74,3 @@ return function () {

}
return new BoundNodeCallbackObservable(callbackFunc, selector, args, scheduler);
return new BoundNodeCallbackObservable(func, selector, args, scheduler);
};

@@ -48,0 +77,0 @@ };

@@ -22,6 +22,32 @@ import { Observable } from '../Observable';

/**
* @param sourceObj
* @param eventName
* @param selector
* @return {FromEventObservable}
* 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
* EventEmitter events or others.</span>
*
* <img src="./img/fromEvent.png" width="100%">
*
* Creates an Observable by attaching an event listener to an "event target",
* which may be an object with `addEventListener` and `removeEventListener`,
* a Node.js EventEmitter, a jQuery style EventEmitter, a NodeList from the
* DOM, or an HTMLCollection from the DOM. The event handler is attached when
* the output Observable is subscribed, and removed when the Subscription is
* unsubscribed.
*
* @example <caption>Emits clicks happening on the DOM document</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* clicks.subscribe(x => console.log(x));
*
* @see {@link from}
* @see {@link fromEventPattern}
*
* @param {EventTargetLike} target The DOMElement, event target, Node.js
* EventEmitter, NodeList or HTMLCollection to attach the event handler to.
* @param {string} eventName The event name of interest, being emitted by the
* `target`.
* @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

@@ -31,3 +57,3 @@ * @name fromEvent

*/
static create<T>(sourceObj: EventTargetLike, eventName: string, selector?: (...args: Array<any>) => T): Observable<T>;
static create<T>(target: EventTargetLike, eventName: string, selector?: (...args: Array<any>) => T): Observable<T>;
constructor(sourceObj: EventTargetLike, eventName: string, selector?: (...args: Array<any>) => T);

@@ -34,0 +60,0 @@ private static setupSubscription<T>(sourceObj, eventName, handler, subscriber);

@@ -40,6 +40,32 @@ "use strict";

/**
* @param sourceObj
* @param eventName
* @param selector
* @return {FromEventObservable}
* 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
* EventEmitter events or others.</span>
*
* <img src="./img/fromEvent.png" width="100%">
*
* Creates an Observable by attaching an event listener to an "event target",
* which may be an object with `addEventListener` and `removeEventListener`,
* a Node.js EventEmitter, a jQuery style EventEmitter, a NodeList from the
* DOM, or an HTMLCollection from the DOM. The event handler is attached when
* the output Observable is subscribed, and removed when the Subscription is
* unsubscribed.
*
* @example <caption>Emits clicks happening on the DOM document</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* clicks.subscribe(x => console.log(x));
*
* @see {@link from}
* @see {@link fromEventPattern}
*
* @param {EventTargetLike} target The DOMElement, event target, Node.js
* EventEmitter, NodeList or HTMLCollection to attach the event handler to.
* @param {string} eventName The event name of interest, being emitted by the
* `target`.
* @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

@@ -49,4 +75,4 @@ * @name fromEvent

*/
FromEventObservable.create = function (sourceObj, eventName, selector) {
return new FromEventObservable(sourceObj, eventName, selector);
FromEventObservable.create = function (target, eventName, selector) {
return new FromEventObservable(target, eventName, selector);
};

@@ -53,0 +79,0 @@ FromEventObservable.setupSubscription = function (sourceObj, eventName, handler, subscriber) {

@@ -13,6 +13,44 @@ import { Observable } from '../Observable';

/**
* @param addHandler
* @param removeHandler
* @param selector
* @return {FromEventPatternObservable}
* 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): void} removeHandler A function that
* takes a `handler` function as argument and removes it in case it was
* previously attached using `addHandler`.
* @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

@@ -19,0 +57,0 @@ * @name fromEventPattern

@@ -25,6 +25,44 @@ "use strict";

/**
* @param addHandler
* @param removeHandler
* @param selector
* @return {FromEventPatternObservable}
* 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): void} removeHandler A function that
* takes a `handler` function as argument and removes it in case it was
* previously attached using `addHandler`.
* @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

@@ -31,0 +69,0 @@ * @name fromEventPattern

@@ -13,12 +13,2 @@ import { Scheduler } from '../Scheduler';

constructor(ish: ObservableInput<T>, scheduler: Scheduler);
/**
* @param ish
* @param mapFnOrScheduler
* @param thisArg
* @param lastScheduler
* @return {any}
* @static true
* @name from
* @owner Observable
*/
static create<T>(ish: ObservableInput<T>, scheduler?: Scheduler): Observable<T>;

@@ -25,0 +15,0 @@ static create<T, R>(ish: ArrayLike<T>, mapFn: (x: any, y: number) => R, thisArg?: any, scheduler?: Scheduler): Observable<R>;

@@ -15,6 +15,6 @@ "use strict";

var ArrayLikeObservable_1 = require('./ArrayLikeObservable');
var observable_1 = require('../symbol/observable');
var iterator_1 = require('../symbol/iterator');
var Observable_1 = require('../Observable');
var observeOn_1 = require('../operator/observeOn');
var $$observable = require('symbol-observable');
var isArrayLike = (function (x) { return x && typeof x.length === 'number'; });

@@ -33,2 +33,57 @@ /**

}
/**
* 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));
*
* @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));
*
* @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 {function(x: any, i: number): T} [mapFn] A "map" function to call
* when converting array-like objects, where `x` is a value from the
* array-like and `i` is the index of that value in the sequence.
* @param {any} [thisArg] The context object to use when calling the `mapFn`,
* if provided.
* @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
*/
FromObservable.create = function (ish, mapFnOrScheduler, thisArg, lastScheduler) {

@@ -45,3 +100,3 @@ var scheduler = null;

if (ish != null) {
if (typeof ish[observable_1.$$observable] === 'function') {
if (typeof ish[$$observable] === 'function') {
if (ish instanceof Observable_1.Observable && !scheduler) {

@@ -71,6 +126,6 @@ return ish;

if (scheduler == null) {
return ish[observable_1.$$observable]().subscribe(subscriber);
return ish[$$observable]().subscribe(subscriber);
}
else {
return ish[observable_1.$$observable]().subscribe(new observeOn_1.ObserveOnSubscriber(subscriber, scheduler, 0));
return ish[$$observable]().subscribe(new observeOn_1.ObserveOnSubscriber(subscriber, scheduler, 0));
}

@@ -77,0 +132,0 @@ };

@@ -15,5 +15,23 @@ import { Scheduler } from '../Scheduler';

/**
* @param promise
* @param scheduler
* @return {PromiseObservable}
* 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 {Promise<T>} promise The promise to be converted.
* @param {Scheduler} [scheduler] An optional Scheduler to use for scheduling
* the delivery of the resolved value (or the rejection).
* @return {Observable<T>} An Observable which wraps the Promise.
* @static true

@@ -20,0 +38,0 @@ * @name fromPromise

@@ -23,5 +23,23 @@ "use strict";

/**
* @param promise
* @param scheduler
* @return {PromiseObservable}
* 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 {Promise<T>} promise The promise to be converted.
* @param {Scheduler} [scheduler] An optional Scheduler to use for scheduling
* the delivery of the resolved value (or the rejection).
* @return {Observable<T>} An Observable which wraps the Promise.
* @static true

@@ -28,0 +46,0 @@ * @name fromPromise

import { Observable, SubscribableOrPromise } from '../Observable';
/**
* @param durationSelector
* @return {Observable<R>|WebSocketSubject<T>|Observable<T>}
* Ignores source values for a duration determined by another Observable, then
* emits the most recent value from the source Observable, then repeats this
* process.
*
* <span class="informal">It's like {@link auditTime}, but the silencing
* duration is determined by a second Observable.</span>
*
* <img src="./img/audit.png" width="100%">
*
* `audit` is similar to `throttle`, but emits the last value from the silenced
* time window, instead of the first value. `audit` emits the most recent value
* from the source Observable on the output Observable as soon as its internal
* timer becomes disabled, and ignores source values while the timer is enabled.
* Initially, the timer is disabled. As soon as the first source value arrives,
* the timer is enabled by calling the `durationSelector` function with the
* source value, which returns the "duration" Observable. When the duration
* Observable emits a value or completes, the timer is disabled, then the most
* recent source value is emitted on the output Observable, and this process
* repeats for the next source value.
*
* @example <caption>Emit clicks at a rate of at most one click per second</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.audit(ev => Rx.Observable.interval(1000));
* result.subscribe(x => console.log(x));
*
* @see {@link auditTime}
* @see {@link debounce}
* @see {@link delayWhen}
* @see {@link sample}
* @see {@link throttle}
*
* @param {function(value: T): Observable|Promise} durationSelector A function
* that receives a value from the source Observable, for computing the silencing
* duration, returned as an Observable or a Promise.
* @return {Observable<T>} An Observable that performs rate-limiting of
* emissions from the source Observable.
* @method audit

@@ -6,0 +40,0 @@ * @owner Observable

@@ -12,4 +12,38 @@ "use strict";

/**
* @param durationSelector
* @return {Observable<R>|WebSocketSubject<T>|Observable<T>}
* Ignores source values for a duration determined by another Observable, then
* emits the most recent value from the source Observable, then repeats this
* process.
*
* <span class="informal">It's like {@link auditTime}, but the silencing
* duration is determined by a second Observable.</span>
*
* <img src="./img/audit.png" width="100%">
*
* `audit` is similar to `throttle`, but emits the last value from the silenced
* time window, instead of the first value. `audit` emits the most recent value
* from the source Observable on the output Observable as soon as its internal
* timer becomes disabled, and ignores source values while the timer is enabled.
* Initially, the timer is disabled. As soon as the first source value arrives,
* the timer is enabled by calling the `durationSelector` function with the
* source value, which returns the "duration" Observable. When the duration
* Observable emits a value or completes, the timer is disabled, then the most
* recent source value is emitted on the output Observable, and this process
* repeats for the next source value.
*
* @example <caption>Emit clicks at a rate of at most one click per second</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.audit(ev => Rx.Observable.interval(1000));
* result.subscribe(x => console.log(x));
*
* @see {@link auditTime}
* @see {@link debounce}
* @see {@link delayWhen}
* @see {@link sample}
* @see {@link throttle}
*
* @param {function(value: T): Observable|Promise} durationSelector A function
* that receives a value from the source Observable, for computing the silencing
* duration, returned as an Observable or a Promise.
* @return {Observable<T>} An Observable that performs rate-limiting of
* emissions from the source Observable.
* @method audit

@@ -16,0 +50,0 @@ * @owner Observable

import { Scheduler } from '../Scheduler';
import { Observable } from '../Observable';
/**
* @param delay
* @param scheduler
* @return {Observable<R>|WebSocketSubject<T>|Observable<T>}
* Ignores source values for `duration` milliseconds, then emits the most recent
* value from the source Observable, then repeats this process.
*
* <span class="informal">When it sees a source values, it ignores that plus
* the next ones for `duration` milliseconds, and then it emits the most recent
* value from the source.</span>
*
* <img src="./img/auditTime.png" width="100%">
*
* `auditTime` is similar to `throttleTime`, but emits the last value from the
* silenced time window, instead of the first value. `auditTime` emits the most
* recent value from the source Observable on the output Observable as soon as
* its internal timer becomes disabled, and ignores source values while the
* timer is enabled. Initially, the timer is disabled. As soon as the first
* source value arrives, the timer is enabled. After `duration` milliseconds (or
* the time unit determined internally by the optional `scheduler`) has passed,
* the timer is disabled, then the most recent source value is emitted on the
* output Observable, and this process repeats for the next source value.
* Optionally takes a {@link Scheduler} for managing timers.
*
* @example <caption>Emit clicks at a rate of at most one click per second</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.auditTime(1000);
* result.subscribe(x => console.log(x));
*
* @see {@link audit}
* @see {@link debounceTime}
* @see {@link delay}
* @see {@link sampleTime}
* @see {@link throttleTime}
*
* @param {number} duration Time to wait before emitting the most recent source
* value, measured in milliseconds or the time unit determined internally
* by the optional `scheduler`.
* @param {Scheduler} [scheduler=async] The {@link Scheduler} to use for
* managing the timers that handle the rate-limiting behavior.
* @return {Observable<T>} An Observable that performs rate-limiting of
* emissions from the source Observable.
* @method auditTime
* @owner Observable
*/
export declare function auditTime<T>(delay: number, scheduler?: Scheduler): Observable<T>;
export declare function auditTime<T>(duration: number, scheduler?: Scheduler): Observable<T>;
export interface AuditTimeSignature<T> {
(delay: number, scheduler?: Scheduler): Observable<T>;
(duration: number, scheduler?: Scheduler): Observable<T>;
}

@@ -10,20 +10,55 @@ "use strict";

/**
* @param delay
* @param scheduler
* @return {Observable<R>|WebSocketSubject<T>|Observable<T>}
* Ignores source values for `duration` milliseconds, then emits the most recent
* value from the source Observable, then repeats this process.
*
* <span class="informal">When it sees a source values, it ignores that plus
* the next ones for `duration` milliseconds, and then it emits the most recent
* value from the source.</span>
*
* <img src="./img/auditTime.png" width="100%">
*
* `auditTime` is similar to `throttleTime`, but emits the last value from the
* silenced time window, instead of the first value. `auditTime` emits the most
* recent value from the source Observable on the output Observable as soon as
* its internal timer becomes disabled, and ignores source values while the
* timer is enabled. Initially, the timer is disabled. As soon as the first
* source value arrives, the timer is enabled. After `duration` milliseconds (or
* the time unit determined internally by the optional `scheduler`) has passed,
* the timer is disabled, then the most recent source value is emitted on the
* output Observable, and this process repeats for the next source value.
* Optionally takes a {@link Scheduler} for managing timers.
*
* @example <caption>Emit clicks at a rate of at most one click per second</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.auditTime(1000);
* result.subscribe(x => console.log(x));
*
* @see {@link audit}
* @see {@link debounceTime}
* @see {@link delay}
* @see {@link sampleTime}
* @see {@link throttleTime}
*
* @param {number} duration Time to wait before emitting the most recent source
* value, measured in milliseconds or the time unit determined internally
* by the optional `scheduler`.
* @param {Scheduler} [scheduler=async] The {@link Scheduler} to use for
* managing the timers that handle the rate-limiting behavior.
* @return {Observable<T>} An Observable that performs rate-limiting of
* emissions from the source Observable.
* @method auditTime
* @owner Observable
*/
function auditTime(delay, scheduler) {
function auditTime(duration, scheduler) {
if (scheduler === void 0) { scheduler = async_1.async; }
return this.lift(new AuditTimeOperator(delay, scheduler));
return this.lift(new AuditTimeOperator(duration, scheduler));
}
exports.auditTime = auditTime;
var AuditTimeOperator = (function () {
function AuditTimeOperator(delay, scheduler) {
this.delay = delay;
function AuditTimeOperator(duration, scheduler) {
this.duration = duration;
this.scheduler = scheduler;
}
AuditTimeOperator.prototype.call = function (subscriber, source) {
return source._subscribe(new AuditTimeSubscriber(subscriber, this.delay, this.scheduler));
return source._subscribe(new AuditTimeSubscriber(subscriber, this.duration, this.scheduler));
};

@@ -39,5 +74,5 @@ return AuditTimeOperator;

__extends(AuditTimeSubscriber, _super);
function AuditTimeSubscriber(destination, delay, scheduler) {
function AuditTimeSubscriber(destination, duration, scheduler) {
_super.call(this, destination);
this.delay = delay;
this.duration = duration;
this.scheduler = scheduler;

@@ -50,3 +85,3 @@ this.hasValue = false;

if (!this.throttled) {
this.add(this.throttled = this.scheduler.schedule(dispatchNext, this.delay, this));
this.add(this.throttled = this.scheduler.schedule(dispatchNext, this.duration, this));
}

@@ -53,0 +88,0 @@ };

@@ -31,2 +31,3 @@ import { Observable } from '../Observable';

* @see {@link bufferWhen}
* @see {@link pairwise}
* @see {@link windowCount}

@@ -33,0 +34,0 @@ *

@@ -37,2 +37,3 @@ "use strict";

* @see {@link bufferWhen}
* @see {@link pairwise}
* @see {@link windowCount}

@@ -39,0 +40,0 @@ *

@@ -70,10 +70,40 @@ "use strict";

/**
* Combines the values from observables passed as arguments. This is done by subscribing
* to each observable, in order, and collecting an array of each of the most recent values any time any of the observables
* emits, then either taking that array and passing it as arguments to an option `project` function and emitting the return
* value of that, or just emitting the array of recent values directly if there is no `project` function.
* @param {...Observable} observables the observables to combine
* @param {function} [project] an optional function to project the values from the combined recent values into a new value for emission.
* @return {Observable} an observable of other projected values from the most recent values from each observable, or an array of each of
* the most recent values from each observable.
* 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
* collecting an array of each of the most recent values any time any of the
* input Observables emits, then either taking that array and passing it as
* arguments to an optional `project` function and emitting the return value of
* that, or just emitting the array of recent values directly if there is no
* `project` function.
*
* @example <caption>Dynamically calculate the Body-Mass Index from an Observable of weight and one for height</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));
*
* @see {@link combineAll}
* @see {@link merge}
* @see {@link withLatestFrom}
*
* @param {Observable} observable1 An input Observable to combine with the
* source Observable.
* @param {Observable} observable2 An input Observable to combine with the
* source Observable. More than one input Observables may be given as 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 Scheduler 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

@@ -80,0 +110,0 @@ * @name combineLatest

import { Observable, SubscribableOrPromise } from '../Observable';
/**
* Returns the source Observable delayed by the computed debounce duration,
* with the duration lengthened if a new source item arrives before the delay
* duration ends.
* In practice, for each item emitted on the source, this operator holds the
* latest item, waits for a silence as long as the `durationSelector` specifies,
* and only then emits the latest source item on the result Observable.
* @param {function} durationSelector function for computing the timeout duration for each item.
* @return {Observable} an Observable the same as source Observable, but drops items.
* Emits a value from the source Observable only after a particular time span
* determined by another Observable has passed without another source emission.
*
* <span class="informal">It's like {@link debounceTime}, but the time span of
* emission silence is determined by a second Observable.</span>
*
* <img src="./img/debounce.png" width="100%">
*
* `debounce` delays values emitted by the source Observable, but drops previous
* pending delayed emissions if a new value arrives on the source Observable.
* This operator keeps track of the most recent value from the source
* Observable, and spawns a duration Observable by calling the
* `durationSelector` function. The value is emitted only when the duration
* Observable emits a value or completes, and if no other value was emitted on
* the source Observable since the duration Observable was spawned. If a new
* value appears before the duration Observable emits, the previous value will
* be dropped and will not be emitted on the output Observable.
*
* Like {@link debounceTime}, this is a rate-limiting operator, and also a
* delay-like operator since output emissions do not necessarily occur at the
* same time as they did on the source Observable.
*
* @example <caption>Emit the most recent click after a burst of clicks</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.debounce(() => Rx.Observable.interval(1000));
* result.subscribe(x => console.log(x));
*
* @see {@link audit}
* @see {@link debounceTime}
* @see {@link delayWhen}
* @see {@link throttle}
*
* @param {function(value: T): Observable|Promise} durationSelector A function
* that receives a value from the source Observable, for computing the timeout
* duration for each source value, returned as an Observable or a Promise.
* @return {Observable} An Observable that delays the emissions of the source
* Observable by the specified duration Observable returned by
* `durationSelector`, and may drop some values if they occur too frequently.
* @method debounce

@@ -12,0 +42,0 @@ * @owner Observable

@@ -10,10 +10,40 @@ "use strict";

/**
* Returns the source Observable delayed by the computed debounce duration,
* with the duration lengthened if a new source item arrives before the delay
* duration ends.
* In practice, for each item emitted on the source, this operator holds the
* latest item, waits for a silence as long as the `durationSelector` specifies,
* and only then emits the latest source item on the result Observable.
* @param {function} durationSelector function for computing the timeout duration for each item.
* @return {Observable} an Observable the same as source Observable, but drops items.
* Emits a value from the source Observable only after a particular time span
* determined by another Observable has passed without another source emission.
*
* <span class="informal">It's like {@link debounceTime}, but the time span of
* emission silence is determined by a second Observable.</span>
*
* <img src="./img/debounce.png" width="100%">
*
* `debounce` delays values emitted by the source Observable, but drops previous
* pending delayed emissions if a new value arrives on the source Observable.
* This operator keeps track of the most recent value from the source
* Observable, and spawns a duration Observable by calling the
* `durationSelector` function. The value is emitted only when the duration
* Observable emits a value or completes, and if no other value was emitted on
* the source Observable since the duration Observable was spawned. If a new
* value appears before the duration Observable emits, the previous value will
* be dropped and will not be emitted on the output Observable.
*
* Like {@link debounceTime}, this is a rate-limiting operator, and also a
* delay-like operator since output emissions do not necessarily occur at the
* same time as they did on the source Observable.
*
* @example <caption>Emit the most recent click after a burst of clicks</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.debounce(() => Rx.Observable.interval(1000));
* result.subscribe(x => console.log(x));
*
* @see {@link audit}
* @see {@link debounceTime}
* @see {@link delayWhen}
* @see {@link throttle}
*
* @param {function(value: T): Observable|Promise} durationSelector A function
* that receives a value from the source Observable, for computing the timeout
* duration for each source value, returned as an Observable or a Promise.
* @return {Observable} An Observable that delays the emissions of the source
* Observable by the specified duration Observable returned by
* `durationSelector`, and may drop some values if they occur too frequently.
* @method debounce

@@ -20,0 +50,0 @@ * @owner Observable

import { Observable } from '../Observable';
import { Scheduler } from '../Scheduler';
/**
* Returns the source Observable delayed by the computed debounce duration,
* with the duration lengthened if a new source item arrives before the delay
* duration ends.
* In practice, for each item emitted on the source, this operator holds the
* latest item, waits for a silence for the `dueTime` length, and only then
* emits the latest source item on the result Observable.
* Optionally takes a scheduler for manging timers.
* @param {number} dueTime the timeout value for the window of time required to not drop the item.
* @param {Scheduler} [scheduler] the Scheduler to use for managing the timers that handle the timeout for each item.
* @return {Observable} an Observable the same as source Observable, but drops items.
* Emits a value from the source Observable only after a particular time span
* has passed without another source emission.
*
* <span class="informal">It's like {@link delay}, but passes only the most
* recent value from each burst of emissions.</span>
*
* <img src="./img/debounceTime.png" width="100%">
*
* `debounceTime` delays values emitted by the source Observable, but drops
* previous pending delayed emissions if a new value arrives on the source
* Observable. This operator keeps track of the most recent value from the
* source Observable, and emits that only when `dueTime` enough time has passed
* without any other value appearing on the source Observable. If a new value
* appears before `dueTime` silence occurs, the previous value will be dropped
* and will not be emitted on the output Observable.
*
* This is a rate-limiting operator, because it is impossible for more than one
* value to be emitted in any time window of duration `dueTime`, but it is also
* a delay-like operator since output emissions do not occur at the same time as
* they did on the source Observable. Optionally takes a {@link Scheduler} for
* managing timers.
*
* @example <caption>Emit the most recent click after a burst of clicks</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.debounceTime(1000);
* result.subscribe(x => console.log(x));
*
* @see {@link auditTime}
* @see {@link debounce}
* @see {@link delay}
* @see {@link sampleTime}
* @see {@link throttleTime}
*
* @param {number} dueTime The timeout duration in milliseconds (or the time
* unit determined internally by the optional `scheduler`) for the window of
* time required to wait for emission silence before emitting the most recent
* source value.
* @param {Scheduler} [scheduler=async] The {@link Scheduler} to use for
* managing the timers that handle the timeout for each value.
* @return {Observable} An Observable that delays the emissions of the source
* Observable by the specified `dueTime`, and may drop some values if they occur
* too frequently.
* @method debounceTime

@@ -15,0 +47,0 @@ * @owner Observable

@@ -10,12 +10,44 @@ "use strict";

/**
* Returns the source Observable delayed by the computed debounce duration,
* with the duration lengthened if a new source item arrives before the delay
* duration ends.
* In practice, for each item emitted on the source, this operator holds the
* latest item, waits for a silence for the `dueTime` length, and only then
* emits the latest source item on the result Observable.
* Optionally takes a scheduler for manging timers.
* @param {number} dueTime the timeout value for the window of time required to not drop the item.
* @param {Scheduler} [scheduler] the Scheduler to use for managing the timers that handle the timeout for each item.
* @return {Observable} an Observable the same as source Observable, but drops items.
* Emits a value from the source Observable only after a particular time span
* has passed without another source emission.
*
* <span class="informal">It's like {@link delay}, but passes only the most
* recent value from each burst of emissions.</span>
*
* <img src="./img/debounceTime.png" width="100%">
*
* `debounceTime` delays values emitted by the source Observable, but drops
* previous pending delayed emissions if a new value arrives on the source
* Observable. This operator keeps track of the most recent value from the
* source Observable, and emits that only when `dueTime` enough time has passed
* without any other value appearing on the source Observable. If a new value
* appears before `dueTime` silence occurs, the previous value will be dropped
* and will not be emitted on the output Observable.
*
* This is a rate-limiting operator, because it is impossible for more than one
* value to be emitted in any time window of duration `dueTime`, but it is also
* a delay-like operator since output emissions do not occur at the same time as
* they did on the source Observable. Optionally takes a {@link Scheduler} for
* managing timers.
*
* @example <caption>Emit the most recent click after a burst of clicks</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.debounceTime(1000);
* result.subscribe(x => console.log(x));
*
* @see {@link auditTime}
* @see {@link debounce}
* @see {@link delay}
* @see {@link sampleTime}
* @see {@link throttleTime}
*
* @param {number} dueTime The timeout duration in milliseconds (or the time
* unit determined internally by the optional `scheduler`) for the window of
* time required to wait for emission silence before emitting the most recent
* source value.
* @param {Scheduler} [scheduler=async] The {@link Scheduler} to use for
* managing the timers that handle the timeout for each value.
* @return {Observable} An Observable that delays the emissions of the source
* Observable by the specified `dueTime`, and may drop some values if they occur
* too frequently.
* @method debounceTime

@@ -22,0 +54,0 @@ * @owner Observable

import { Observable } from '../Observable';
/**
* Returns an Observable that emits the elements of the source or a specified default value if empty.
* @param {any} defaultValue the default value used if source is empty; defaults to null.
* @return {Observable} an Observable of the items emitted by the where empty values are replaced by the specified default value or null.
* Emits a given value if the source Observable completes without emitting any
* `next` value, otherwise mirrors the source Observable.
*
* <span class="informal">If the source Observable turns out to be empty, then
* this operator will emit a default value.</span>
*
* <img src="./img/defaultIfEmpty.png" width="100%">
*
* `defaultIfEmpty` emits the values emitted by the source Observable or a
* specified default value if the source Observable is empty (completes without
* having emitted any `next` value).
*
* @example <caption>If no clicks happen in 5 seconds, then emit "no clicks"</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var clicksBeforeFive = clicks.takeUntil(Rx.Observable.interval(5000));
* var result = clicksBeforeFive.defaultIfEmpty('no clicks');
* result.subscribe(x => console.log(x));
*
* @see {@link empty}
* @see {@link last}
*
* @param {any} [defaultValue=null] The default value used if the source
* Observable is empty.
* @return {Observable} An Observable that emits either the specified
* `defaultValue` if the source Observable emits no items, or the values emitted
* by the source Observable.
* @method defaultIfEmpty

@@ -7,0 +30,0 @@ * @owner Observable

@@ -9,5 +9,28 @@ "use strict";

/**
* Returns an Observable that emits the elements of the source or a specified default value if empty.
* @param {any} defaultValue the default value used if source is empty; defaults to null.
* @return {Observable} an Observable of the items emitted by the where empty values are replaced by the specified default value or null.
* Emits a given value if the source Observable completes without emitting any
* `next` value, otherwise mirrors the source Observable.
*
* <span class="informal">If the source Observable turns out to be empty, then
* this operator will emit a default value.</span>
*
* <img src="./img/defaultIfEmpty.png" width="100%">
*
* `defaultIfEmpty` emits the values emitted by the source Observable or a
* specified default value if the source Observable is empty (completes without
* having emitted any `next` value).
*
* @example <caption>If no clicks happen in 5 seconds, then emit "no clicks"</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var clicksBeforeFive = clicks.takeUntil(Rx.Observable.interval(5000));
* var result = clicksBeforeFive.defaultIfEmpty('no clicks');
* result.subscribe(x => console.log(x));
*
* @see {@link empty}
* @see {@link last}
*
* @param {any} [defaultValue=null] The default value used if the source
* Observable is empty.
* @return {Observable} An Observable that emits either the specified
* `defaultValue` if the source Observable emits no items, or the values emitted
* by the source Observable.
* @method defaultIfEmpty

@@ -14,0 +37,0 @@ * @owner Observable

import { Observable } from '../Observable';
/**
* Returns an Observable that delays the emission of items from the source Observable
* by a subscription delay and a delay selector function for each element.
* @param {Function} selector function to retrieve a sequence indicating the delay for each given element.
* @param {Observable} sequence indicating the delay for the subscription to the source.
* @return {Observable} an Observable that delays the emissions of the source Observable by the specified timeout or Date.
* Delays the emission of items from the source Observable by a given time span
* determined by the emissions of another Observable.
*
* <span class="informal">It's like {@link delay}, but the time span of the
* delay duration is determined by a second Observable.</span>
*
* <img src="./img/delayWhen.png" width="100%">
*
* `delayWhen` time shifts each emitted value from the source Observable by a
* time span determined by another Observable. When the source emits a value,
* the `delayDurationSelector` function is called with the source value as
* argument, and should return an Observable, called the "duration" Observable.
* The source value is emitted on the output Observable only when the duration
* Observable emits a value or completes.
*
* Optionally, `delayWhen` takes a second argument, `subscriptionDelay`, which
* is an Observable. When `subscriptionDelay` emits its first value or
* completes, the source Observable is subscribed to and starts behaving like
* described in the previous paragraph. If `subscriptionDelay` is not provided,
* `delayWhen` will subscribe to the source Observable as soon as the output
* Observable is subscribed.
*
* @example <caption>Delay each click by a random amount of time, between 0 and 5 seconds</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var delayedClicks = clicks.delayWhen(event =>
* Rx.Observable.interval(Math.random() * 5000)
* );
* delayedClicks.subscribe(x => console.log(x));
*
* @see {@link debounce}
* @see {@link delay}
*
* @param {function(value: T): Observable} delayDurationSelector A function that
* returns an Observable for each value emitted by the source Observable, which
* is then used to delay the emission of that item on the output Observable
* until the Observable returned from this function emits a value.
* @param {Observable} subscriptionDelay An Observable that triggers the
* subscription to the source Observable once it emits any value.
* @return {Observable} An Observable that delays the emissions of the source
* Observable by an amount of time specified by the Observable returned by
* `delayDurationSelector`.
* @method delayWhen

@@ -9,0 +45,0 @@ * @owner Observable

@@ -12,7 +12,43 @@ "use strict";

/**
* Returns an Observable that delays the emission of items from the source Observable
* by a subscription delay and a delay selector function for each element.
* @param {Function} selector function to retrieve a sequence indicating the delay for each given element.
* @param {Observable} sequence indicating the delay for the subscription to the source.
* @return {Observable} an Observable that delays the emissions of the source Observable by the specified timeout or Date.
* Delays the emission of items from the source Observable by a given time span
* determined by the emissions of another Observable.
*
* <span class="informal">It's like {@link delay}, but the time span of the
* delay duration is determined by a second Observable.</span>
*
* <img src="./img/delayWhen.png" width="100%">
*
* `delayWhen` time shifts each emitted value from the source Observable by a
* time span determined by another Observable. When the source emits a value,
* the `delayDurationSelector` function is called with the source value as
* argument, and should return an Observable, called the "duration" Observable.
* The source value is emitted on the output Observable only when the duration
* Observable emits a value or completes.
*
* Optionally, `delayWhen` takes a second argument, `subscriptionDelay`, which
* is an Observable. When `subscriptionDelay` emits its first value or
* completes, the source Observable is subscribed to and starts behaving like
* described in the previous paragraph. If `subscriptionDelay` is not provided,
* `delayWhen` will subscribe to the source Observable as soon as the output
* Observable is subscribed.
*
* @example <caption>Delay each click by a random amount of time, between 0 and 5 seconds</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var delayedClicks = clicks.delayWhen(event =>
* Rx.Observable.interval(Math.random() * 5000)
* );
* delayedClicks.subscribe(x => console.log(x));
*
* @see {@link debounce}
* @see {@link delay}
*
* @param {function(value: T): Observable} delayDurationSelector A function that
* returns an Observable for each value emitted by the source Observable, which
* is then used to delay the emission of that item on the output Observable
* until the Observable returned from this function emits a value.
* @param {Observable} subscriptionDelay An Observable that triggers the
* subscription to the source Observable once it emits any value.
* @return {Observable} An Observable that delays the emissions of the source
* Observable by an amount of time specified by the Observable returned by
* `delayDurationSelector`.
* @method delayWhen

@@ -19,0 +55,0 @@ * @owner Observable

import { Observable } from '../Observable';
/**
* Returns an Observable that emits the item at the specified index in the source Observable.
* If default is given, missing indices will output this value on next; otherwise, outputs error.
* Emits the single value at the specified `index` in a sequence of emissions
* from the source Observable.
*
* <span class="informal">Emits only the i-th value, then completes.</span>
*
* <img src="./img/elementAt.png" width="100%">
*
* `elementAt` returns an Observable that emits the item at the specified
* `index` in the source Observable, or a default value if that `index` is out
* of range and the `default` argument is provided. If the `default` argument is
* not given and the `index` is out of range, the output Observable will emit an
* `ArgumentOutOfRangeError` error.
*
* @example <caption>Emit only the third click event</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.elementAt(2);
* result.subscribe(x => console.log(x));
*
* @see {@link first}
* @see {@link last}
* @see {@link skip}
* @see {@link single}
* @see {@link take}
*
* @throws {ArgumentOutOfRangeError} When using `elementAt(i)`, it delivers an
* ArgumentOutOrRangeError to the Observer's `error` callback if `i < 0` or the
* Observable has completed before emitting the i-th `next` notification.
* @param {number} index the index of the value to be retrieved.
* @param {any} [defaultValue] the default value returned for missing indices.
* @return {Observable} an Observable that emits a single item, if it is found. Otherwise, will emit the default value if given.
*
* @param {number} index Is the number `i` for the i-th source emission that has
* happened since the subscription, starting from the number `0`.
* @param {T} [defaultValue] The default value returned for missing indices.
* @return {Observable} An Observable that emits a single item, if it is found.
* Otherwise, will emit the default value if given. If not, then emits an error.
* @method elementAt

@@ -12,0 +37,0 @@ * @owner Observable

@@ -10,10 +10,35 @@ "use strict";

/**
* Returns an Observable that emits the item at the specified index in the source Observable.
* If default is given, missing indices will output this value on next; otherwise, outputs error.
* Emits the single value at the specified `index` in a sequence of emissions
* from the source Observable.
*
* <span class="informal">Emits only the i-th value, then completes.</span>
*
* <img src="./img/elementAt.png" width="100%">
*
* `elementAt` returns an Observable that emits the item at the specified
* `index` in the source Observable, or a default value if that `index` is out
* of range and the `default` argument is provided. If the `default` argument is
* not given and the `index` is out of range, the output Observable will emit an
* `ArgumentOutOfRangeError` error.
*
* @example <caption>Emit only the third click event</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.elementAt(2);
* result.subscribe(x => console.log(x));
*
* @see {@link first}
* @see {@link last}
* @see {@link skip}
* @see {@link single}
* @see {@link take}
*
* @throws {ArgumentOutOfRangeError} When using `elementAt(i)`, it delivers an
* ArgumentOutOrRangeError to the Observer's `error` callback if `i < 0` or the
* Observable has completed before emitting the i-th `next` notification.
* @param {number} index the index of the value to be retrieved.
* @param {any} [defaultValue] the default value returned for missing indices.
* @return {Observable} an Observable that emits a single item, if it is found. Otherwise, will emit the default value if given.
*
* @param {number} index Is the number `i` for the i-th source emission that has
* happened since the subscription, starting from the number `0`.
* @param {T} [defaultValue] The default value returned for missing indices.
* @return {Observable} An Observable that emits a single item, if it is found.
* Otherwise, will emit the default value if given. If not, then emits an error.
* @method elementAt

@@ -20,0 +45,0 @@ * @owner Observable

@@ -17,4 +17,3 @@ "use strict";

function every(predicate, thisArg) {
var source = this;
return source.lift(new EveryOperator(predicate, thisArg, source));
return this.lift(new EveryOperator(predicate, thisArg, this));
}

@@ -21,0 +20,0 @@ exports.every = every;

import { Observable } from '../Observable';
/**
* Returns a new observable that triggers on the second and following inputs.
* An input that triggers an event will return an pair of [(N - 1)th, Nth].
* The (N-1)th is stored in the internal state until Nth input occurs.
* Groups pairs of consecutive emissions together and emits them as an array of
* two values.
*
* <span class="informal">Puts the current value and previous value together as
* an array, and emits that.</span>
*
* <img src="./img/pairwise.png" width="100%">
*
* @return {Observable<R>} an observable of pairs of values.
* The Nth emission from the source Observable will cause the output Observable
* to emit an array [(N-1)th, Nth] of the previous and the current value, as a
* pair. For this reason, `pairwise` emits on the second and subsequent
* emissions from the source Observable, but not on the first emission, because
* there is no previous value in that case.
*
* @example <caption>On every click (starting from the second), emit the relative distance to the previous click</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var pairs = clicks.pairwise();
* var distance = pairs.map(pair => {
* var x0 = pair[0].clientX;
* var y0 = pair[0].clientY;
* var x1 = pair[1].clientX;
* var y1 = pair[1].clientY;
* return Math.sqrt(Math.pow(x0 - x1, 2) + Math.pow(y0 - y1, 2));
* });
* distance.subscribe(x => console.log(x));
*
* @see {@link buffer}
* @see {@link bufferCount}
*
* @return {Observable<[T, T]>} An Observable of pairs of consecutive values
* from the source Observable.
* @method pairwise

@@ -11,0 +35,0 @@ * @owner Observable

@@ -9,9 +9,33 @@ "use strict";

/**
* Returns a new observable that triggers on the second and following inputs.
* An input that triggers an event will return an pair of [(N - 1)th, Nth].
* The (N-1)th is stored in the internal state until Nth input occurs.
* Groups pairs of consecutive emissions together and emits them as an array of
* two values.
*
* <span class="informal">Puts the current value and previous value together as
* an array, and emits that.</span>
*
* <img src="./img/pairwise.png" width="100%">
*
* @return {Observable<R>} an observable of pairs of values.
* The Nth emission from the source Observable will cause the output Observable
* to emit an array [(N-1)th, Nth] of the previous and the current value, as a
* pair. For this reason, `pairwise` emits on the second and subsequent
* emissions from the source Observable, but not on the first emission, because
* there is no previous value in that case.
*
* @example <caption>On every click (starting from the second), emit the relative distance to the previous click</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var pairs = clicks.pairwise();
* var distance = pairs.map(pair => {
* var x0 = pair[0].clientX;
* var y0 = pair[0].clientY;
* var x1 = pair[1].clientX;
* var y1 = pair[1].clientY;
* return Math.sqrt(Math.pow(x0 - x1, 2) + Math.pow(y0 - y1, 2));
* });
* distance.subscribe(x => console.log(x));
*
* @see {@link buffer}
* @see {@link bufferCount}
*
* @return {Observable<[T, T]>} An Observable of pairs of consecutive values
* from the source Observable.
* @method pairwise

@@ -18,0 +42,0 @@ * @owner Observable

import { Observable } from '../Observable';
/**
* @param predicate
* @param thisArg
* @return {Observable<T>[]}
* Splits the source Observable into two, one with values that satisfy a
* predicate, and another with values that don't satisfy the predicate.
*
* <span class="informal">It's like {@link filter}, but returns two Observables:
* one like the output of {@link filter}, and the other with values that did not
* pass the condition.</span>
*
* <img src="./img/partition.png" width="100%">
*
* `partition` outputs an array with two Observables that partition the values
* from the source Observable through the given `predicate` function. The first
* Observable in that array emits source values for which the predicate argument
* returns true. The second Observable emits source values for which the
* predicate returns false. The first behaves like {@link filter} and the second
* behaves like {@link filter} with the predicate negated.
*
* @example <caption>Partition click events into those on DIV elements and those elsewhere</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var parts = clicks.partition(ev => ev.target.tagName === 'DIV');
* var clicksOnDivs = parts[0];
* var clicksElsewhere = parts[1];
* clicksOnDivs.subscribe(x => console.log('DIV clicked: ', x));
* clicksElsewhere.subscribe(x => console.log('Other clicked: ', x));
*
* @see {@link filter}
*
* @param {function(value: T, index: number): boolean} predicate A function that
* evaluates each value emitted by the source Observable. If it returns `true`,
* the value is emitted on the first Observable in the returned array, if
* `false` the value is emitted on the second Observable in the array. The
* `index` parameter is the number `i` for the i-th source emission that has
* happened since the subscription, starting from the number `0`.
* @param {any} [thisArg] An optional argument to determine the value of `this`
* in the `predicate` function.
* @return {[Observable<T>, Observable<T>]} An array with two Observables: one
* with values that passed the predicate, and another with values that did not
* pass the predicate.
* @method partition

@@ -7,0 +41,0 @@ * @owner Observable

@@ -5,5 +5,39 @@ "use strict";

/**
* @param predicate
* @param thisArg
* @return {Observable<T>[]}
* Splits the source Observable into two, one with values that satisfy a
* predicate, and another with values that don't satisfy the predicate.
*
* <span class="informal">It's like {@link filter}, but returns two Observables:
* one like the output of {@link filter}, and the other with values that did not
* pass the condition.</span>
*
* <img src="./img/partition.png" width="100%">
*
* `partition` outputs an array with two Observables that partition the values
* from the source Observable through the given `predicate` function. The first
* Observable in that array emits source values for which the predicate argument
* returns true. The second Observable emits source values for which the
* predicate returns false. The first behaves like {@link filter} and the second
* behaves like {@link filter} with the predicate negated.
*
* @example <caption>Partition click events into those on DIV elements and those elsewhere</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var parts = clicks.partition(ev => ev.target.tagName === 'DIV');
* var clicksOnDivs = parts[0];
* var clicksElsewhere = parts[1];
* clicksOnDivs.subscribe(x => console.log('DIV clicked: ', x));
* clicksElsewhere.subscribe(x => console.log('Other clicked: ', x));
*
* @see {@link filter}
*
* @param {function(value: T, index: number): boolean} predicate A function that
* evaluates each value emitted by the source Observable. If it returns `true`,
* the value is emitted on the first Observable in the returned array, if
* `false` the value is emitted on the second Observable in the array. The
* `index` parameter is the number `i` for the i-th source emission that has
* happened since the subscription, starting from the number `0`.
* @param {any} [thisArg] An optional argument to determine the value of `this`
* in the `predicate` function.
* @return {[Observable<T>, Observable<T>]} An array with two Observables: one
* with values that passed the predicate, and another with values that did not
* pass the predicate.
* @method partition

@@ -10,0 +44,0 @@ * @owner Observable

@@ -86,4 +86,6 @@ "use strict";

var subscription = subscribeToResult_1.subscribeToResult(this, observable, observable, i);
this.subscriptions.push(subscription);
this.add(subscription);
if (this.subscriptions) {
this.subscriptions.push(subscription);
this.add(subscription);
}
}

@@ -90,0 +92,0 @@ this.observables = null;

import { Observable } from '../Observable';
/**
* Returns an Observable that, when the specified sampler Observable emits an item or completes, it then emits the most
* recently emitted item (if any) emitted by the source Observable since the previous emission from the sampler
* Observable.
* Emits the most recently emitted value from the source Observable whenever
* another Observable, the `notifier`, emits.
*
* <span class="informal">It's like {@link sampleTime}, but samples whenever
* the `notifier` Observable emits something.</span>
*
* <img src="./img/sample.png" width="100%">
*
* @param {Observable} sampler - the Observable to use for sampling the source Observable.
* @return {Observable<T>} an Observable that emits the results of sampling the items emitted by this Observable
* whenever the sampler Observable emits an item or completes.
* Whenever the `notifier` Observable emits a value or completes, `sample`
* looks at the source Observable and emits whichever value it has most recently
* emitted since the previous sampling, unless the source has not emitted
* anything since the previous sampling. The `notifier` is subscribed to as soon
* as the output Observable is subscribed.
*
* @example <caption>On every click, sample the most recent "seconds" timer</caption>
* var seconds = Rx.Observable.interval(1000);
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = seconds.sample(clicks);
* result.subscribe(x => console.log(x));
*
* @see {@link audit}
* @see {@link debounce}
* @see {@link sampleTime}
* @see {@link throttle}
*
* @param {Observable<any>} notifier The Observable to use for sampling the
* source Observable.
* @return {Observable<T>} An Observable that emits the results of sampling the
* values emitted by the source Observable whenever the notifier Observable
* emits value or completes.
* @method sample

@@ -13,0 +34,0 @@ * @owner Observable

@@ -10,11 +10,32 @@ "use strict";

/**
* Returns an Observable that, when the specified sampler Observable emits an item or completes, it then emits the most
* recently emitted item (if any) emitted by the source Observable since the previous emission from the sampler
* Observable.
* Emits the most recently emitted value from the source Observable whenever
* another Observable, the `notifier`, emits.
*
* <span class="informal">It's like {@link sampleTime}, but samples whenever
* the `notifier` Observable emits something.</span>
*
* <img src="./img/sample.png" width="100%">
*
* @param {Observable} sampler - the Observable to use for sampling the source Observable.
* @return {Observable<T>} an Observable that emits the results of sampling the items emitted by this Observable
* whenever the sampler Observable emits an item or completes.
* Whenever the `notifier` Observable emits a value or completes, `sample`
* looks at the source Observable and emits whichever value it has most recently
* emitted since the previous sampling, unless the source has not emitted
* anything since the previous sampling. The `notifier` is subscribed to as soon
* as the output Observable is subscribed.
*
* @example <caption>On every click, sample the most recent "seconds" timer</caption>
* var seconds = Rx.Observable.interval(1000);
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = seconds.sample(clicks);
* result.subscribe(x => console.log(x));
*
* @see {@link audit}
* @see {@link debounce}
* @see {@link sampleTime}
* @see {@link throttle}
*
* @param {Observable<any>} notifier The Observable to use for sampling the
* source Observable.
* @return {Observable<T>} An Observable that emits the results of sampling the
* values emitted by the source Observable whenever the notifier Observable
* emits value or completes.
* @method sample

@@ -21,0 +42,0 @@ * @owner Observable

import { Observable } from '../Observable';
import { Scheduler } from '../Scheduler';
/**
* @param delay
* @param scheduler
* @return {Observable<R>|WebSocketSubject<T>|Observable<T>}
* Emits the most recently emitted value from the source Observable within
* periodic time intervals.
*
* <span class="informal">Samples the source Observable at periodic time
* intervals, emitting what it samples.</span>
*
* <img src="./img/sampleTime.png" width="100%">
*
* `sampleTime` periodically looks at the source Observable and emits whichever
* value it has most recently emitted since the previous sampling, unless the
* source has not emitted anything since the previous sampling. The sampling
* happens periodically in time every `period` milliseconds (or the time unit
* defined by the optional `scheduler` argument). The sampling starts as soon as
* the output Observable is subscribed.
*
* @example <caption>Every second, emit the most recent click at most once</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.sampleTime(1000);
* result.subscribe(x => console.log(x));
*
* @see {@link auditTime}
* @see {@link debounceTime}
* @see {@link delay}
* @see {@link sample}
* @see {@link throttleTime}
*
* @param {number} period The sampling period expressed in milliseconds or the
* time unit determined internally by the optional `scheduler`.
* @param {Scheduler} [scheduler=async] The {@link Scheduler} to use for
* managing the timers that handle the sampling.
* @return {Observable<T>} An Observable that emits the results of sampling the
* values emitted by the source Observable at the specified time interval.
* @method sampleTime
* @owner Observable
*/
export declare function sampleTime<T>(delay: number, scheduler?: Scheduler): Observable<T>;
export declare function sampleTime<T>(period: number, scheduler?: Scheduler): Observable<T>;
export interface SampleTimeSignature<T> {
(delay: number, scheduler?: Scheduler): Observable<T>;
(period: number, scheduler?: Scheduler): Observable<T>;
}

@@ -10,20 +10,49 @@ "use strict";

/**
* @param delay
* @param scheduler
* @return {Observable<R>|WebSocketSubject<T>|Observable<T>}
* Emits the most recently emitted value from the source Observable within
* periodic time intervals.
*
* <span class="informal">Samples the source Observable at periodic time
* intervals, emitting what it samples.</span>
*
* <img src="./img/sampleTime.png" width="100%">
*
* `sampleTime` periodically looks at the source Observable and emits whichever
* value it has most recently emitted since the previous sampling, unless the
* source has not emitted anything since the previous sampling. The sampling
* happens periodically in time every `period` milliseconds (or the time unit
* defined by the optional `scheduler` argument). The sampling starts as soon as
* the output Observable is subscribed.
*
* @example <caption>Every second, emit the most recent click at most once</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.sampleTime(1000);
* result.subscribe(x => console.log(x));
*
* @see {@link auditTime}
* @see {@link debounceTime}
* @see {@link delay}
* @see {@link sample}
* @see {@link throttleTime}
*
* @param {number} period The sampling period expressed in milliseconds or the
* time unit determined internally by the optional `scheduler`.
* @param {Scheduler} [scheduler=async] The {@link Scheduler} to use for
* managing the timers that handle the sampling.
* @return {Observable<T>} An Observable that emits the results of sampling the
* values emitted by the source Observable at the specified time interval.
* @method sampleTime
* @owner Observable
*/
function sampleTime(delay, scheduler) {
function sampleTime(period, scheduler) {
if (scheduler === void 0) { scheduler = async_1.async; }
return this.lift(new SampleTimeOperator(delay, scheduler));
return this.lift(new SampleTimeOperator(period, scheduler));
}
exports.sampleTime = sampleTime;
var SampleTimeOperator = (function () {
function SampleTimeOperator(delay, scheduler) {
this.delay = delay;
function SampleTimeOperator(period, scheduler) {
this.period = period;
this.scheduler = scheduler;
}
SampleTimeOperator.prototype.call = function (subscriber, source) {
return source._subscribe(new SampleTimeSubscriber(subscriber, this.delay, this.scheduler));
return source._subscribe(new SampleTimeSubscriber(subscriber, this.period, this.scheduler));
};

@@ -39,8 +68,8 @@ return SampleTimeOperator;

__extends(SampleTimeSubscriber, _super);
function SampleTimeSubscriber(destination, delay, scheduler) {
function SampleTimeSubscriber(destination, period, scheduler) {
_super.call(this, destination);
this.delay = delay;
this.period = period;
this.scheduler = scheduler;
this.hasValue = false;
this.add(scheduler.schedule(dispatchNotification, delay, { subscriber: this, delay: delay }));
this.add(scheduler.schedule(dispatchNotification, period, { subscriber: this, period: period }));
}

@@ -60,6 +89,6 @@ SampleTimeSubscriber.prototype._next = function (value) {

function dispatchNotification(state) {
var subscriber = state.subscriber, delay = state.delay;
var subscriber = state.subscriber, period = state.period;
subscriber.notifyNext();
this.schedule(state, delay);
this.schedule(state, period);
}
//# sourceMappingURL=sampleTime.js.map

@@ -32,4 +32,4 @@ import { Observable } from '../Observable';

*
* @param {function(acc: R, value: T): R} accumulator The accumulator function
* called on each source value.
* @param {function(acc: R, value: T, index: number): R} accumulator
* The accumulator function called on each source value.
* @param {T|R} [seed] The initial accumulation value.

@@ -40,5 +40,5 @@ * @return {Observable<R>} An observable of the accumulated values.

*/
export declare function scan<T, R>(accumulator: (acc: R, value: T) => R, seed?: T | R): Observable<R>;
export declare function scan<T, R>(accumulator: (acc: R, value: T, index: number) => R, seed?: T | R): Observable<R>;
export interface ScanSignature<T> {
<R>(accumulator: (acc: R, value: T) => R, seed?: T | R): Observable<R>;
<R>(accumulator: (acc: R, value: T, index: number) => R, seed?: T | R): Observable<R>;
}

@@ -38,4 +38,4 @@ "use strict";

*
* @param {function(acc: R, value: T): R} accumulator The accumulator function
* called on each source value.
* @param {function(acc: R, value: T, index: number): R} accumulator
* The accumulator function called on each source value.
* @param {T|R} [seed] The initial accumulation value.

@@ -70,5 +70,5 @@ * @return {Observable<R>} An observable of the accumulated values.

this.accumulator = accumulator;
this.index = 0;
this.accumulatorSet = false;
this.seed = seed;
this.accumulator = accumulator;
this.accumulatorSet = typeof seed !== 'undefined';

@@ -97,5 +97,6 @@ }

ScanSubscriber.prototype._tryNext = function (value) {
var index = this.index++;
var result;
try {
result = this.accumulator(this.seed, value);
result = this.accumulator(this.seed, value, index);
}

@@ -102,0 +103,0 @@ catch (err) {

import { Observable } from '../Observable';
/**
* Emits only the first `count` values emitted by the source Observable.
*
* <span class="informal">Takes the first `count` values from the source, then
* completes.</span>
*
* <img src="./img/take.png" width="100%">
*
* `take` returns an Observable that emits only the first `count` values emitted
* by the source Observable. If the source emits fewer than `count` values then
* all of its values are emitted. After that, it completes, regardless if the
* source completes.
*
* @example <caption>Take the first 5 seconds of an infinite 1-second interval Observable</caption>
* var interval = Rx.Observable.interval(1000);
* var five = interval.take(5);
* five.subscribe(x => console.log(x));
*
* @see {@link takeLast}
* @see {@link takeUntil}
* @see {@link takeWhile}
* @see {@link skip}
*
* @throws {ArgumentOutOfRangeError} When using `take(i)`, it delivers an
* ArgumentOutOrRangeError to the Observer's `error` callback if `i < 0`.
* @param total
* @return {any}
*
* @param {number} count The maximum number of `next` values to emit.
* @return {Observable<T>} An Observable that emits only the first `count`
* values emitted by the source Observable, or all of the values from the source
* if the source emits fewer than `count` values.
* @method take
* @owner Observable
*/
export declare function take<T>(total: number): Observable<T>;
export declare function take<T>(count: number): Observable<T>;
export interface TakeSignature<T> {
(total: number): Observable<T>;
(count: number): Observable<T>;
}

@@ -11,15 +11,40 @@ "use strict";

/**
* Emits only the first `count` values emitted by the source Observable.
*
* <span class="informal">Takes the first `count` values from the source, then
* completes.</span>
*
* <img src="./img/take.png" width="100%">
*
* `take` returns an Observable that emits only the first `count` values emitted
* by the source Observable. If the source emits fewer than `count` values then
* all of its values are emitted. After that, it completes, regardless if the
* source completes.
*
* @example <caption>Take the first 5 seconds of an infinite 1-second interval Observable</caption>
* var interval = Rx.Observable.interval(1000);
* var five = interval.take(5);
* five.subscribe(x => console.log(x));
*
* @see {@link takeLast}
* @see {@link takeUntil}
* @see {@link takeWhile}
* @see {@link skip}
*
* @throws {ArgumentOutOfRangeError} When using `take(i)`, it delivers an
* ArgumentOutOrRangeError to the Observer's `error` callback if `i < 0`.
* @param total
* @return {any}
*
* @param {number} count The maximum number of `next` values to emit.
* @return {Observable<T>} An Observable that emits only the first `count`
* values emitted by the source Observable, or all of the values from the source
* if the source emits fewer than `count` values.
* @method take
* @owner Observable
*/
function take(total) {
if (total === 0) {
function take(count) {
if (count === 0) {
return new EmptyObservable_1.EmptyObservable();
}
else {
return this.lift(new TakeOperator(total));
return this.lift(new TakeOperator(count));
}

@@ -26,0 +51,0 @@ }

import { Observable } from '../Observable';
/**
* Emits only the last `count` values emitted by the source Observable.
*
* <span class="informal">Remembers the latest `count` values, then emits those
* only when the source completes.</span>
*
* <img src="./img/takeLast.png" width="100%">
*
* `takeLast` returns an Observable that emits at most the last `count` values
* emitted by the source Observable. If the source emits fewer than `count`
* values then all of its values are emitted. This operator must wait until the
* `complete` notification emission from the source in order to emit the `next`
* values on the output Observable, because otherwise it is impossible to know
* whether or not more values will be emitted on the source. For this reason,
* all values are emitted synchronously, followed by the complete notification.
*
* @example <caption>Take the last 3 values of an Observable with many values</caption>
* var many = Rx.Observable.range(1, 100);
* var lastThree = many.takeLast(3);
* lastThree.subscribe(x => console.log(x));
*
* @see {@link take}
* @see {@link takeUntil}
* @see {@link takeWhile}
* @see {@link skip}
*
* @throws {ArgumentOutOfRangeError} When using `takeLast(i)`, it delivers an
* ArgumentOutOrRangeError to the Observer's `error` callback if `i < 0`.
* @param total
* @return {any}
*
* @param {number} count The maximum number of values to emit from the end of
* the sequence of values emitted by the source Observable.
* @return {Observable<T>} An Observable that emits at most the last count
* values emitted by the source Observable.
* @method takeLast
* @owner Observable
*/
export declare function takeLast<T>(total: number): Observable<T>;
export declare function takeLast<T>(count: number): Observable<T>;
export interface TakeLastSignature<T> {
(total: number): Observable<T>;
(count: number): Observable<T>;
}

@@ -11,15 +11,43 @@ "use strict";

/**
* Emits only the last `count` values emitted by the source Observable.
*
* <span class="informal">Remembers the latest `count` values, then emits those
* only when the source completes.</span>
*
* <img src="./img/takeLast.png" width="100%">
*
* `takeLast` returns an Observable that emits at most the last `count` values
* emitted by the source Observable. If the source emits fewer than `count`
* values then all of its values are emitted. This operator must wait until the
* `complete` notification emission from the source in order to emit the `next`
* values on the output Observable, because otherwise it is impossible to know
* whether or not more values will be emitted on the source. For this reason,
* all values are emitted synchronously, followed by the complete notification.
*
* @example <caption>Take the last 3 values of an Observable with many values</caption>
* var many = Rx.Observable.range(1, 100);
* var lastThree = many.takeLast(3);
* lastThree.subscribe(x => console.log(x));
*
* @see {@link take}
* @see {@link takeUntil}
* @see {@link takeWhile}
* @see {@link skip}
*
* @throws {ArgumentOutOfRangeError} When using `takeLast(i)`, it delivers an
* ArgumentOutOrRangeError to the Observer's `error` callback if `i < 0`.
* @param total
* @return {any}
*
* @param {number} count The maximum number of values to emit from the end of
* the sequence of values emitted by the source Observable.
* @return {Observable<T>} An Observable that emits at most the last count
* values emitted by the source Observable.
* @method takeLast
* @owner Observable
*/
function takeLast(total) {
if (total === 0) {
function takeLast(count) {
if (count === 0) {
return new EmptyObservable_1.EmptyObservable();
}
else {
return this.lift(new TakeLastOperator(total));
return this.lift(new TakeLastOperator(count));
}

@@ -26,0 +54,0 @@ }

import { Observable } from '../Observable';
/**
* @param notifier
* @return {Observable<R>|WebSocketSubject<T>|Observable<T>}
* Emits the values emitted by the source Observable until a `notifier`
* Observable emits a value.
*
* <span class="informal">Lets values pass until a second Observable,
* `notifier`, emits something. Then, it completes.</span>
*
* <img src="./img/takeUntil.png" width="100%">
*
* `takeUntil` subscribes and begins mirroring the source Observable. It also
* monitors a second Observable, `notifier` that you provide. If the `notifier`
* emits a value or a complete notification, the output Observable stops
* mirroring the source Observable and completes.
*
* @example <caption>Tick every second until the first click happens</caption>
* var interval = Rx.Observable.interval(1000);
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = interval.takeUntil(clicks);
* result.subscribe(x => console.log(x));
*
* @see {@link take}
* @see {@link takeLast}
* @see {@link takeWhile}
* @see {@link skip}
*
* @param {Observable} notifier The Observable whose first emitted value will
* cause the output Observable of `takeUntil` to stop emitting values from the
* source Observable.
* @return {Observable<T>} An Observable that emits the values from the source
* Observable until such time as `notifier` emits its first value.
* @method takeUntil

@@ -6,0 +33,0 @@ * @owner Observable

@@ -10,4 +10,31 @@ "use strict";

/**
* @param notifier
* @return {Observable<R>|WebSocketSubject<T>|Observable<T>}
* Emits the values emitted by the source Observable until a `notifier`
* Observable emits a value.
*
* <span class="informal">Lets values pass until a second Observable,
* `notifier`, emits something. Then, it completes.</span>
*
* <img src="./img/takeUntil.png" width="100%">
*
* `takeUntil` subscribes and begins mirroring the source Observable. It also
* monitors a second Observable, `notifier` that you provide. If the `notifier`
* emits a value or a complete notification, the output Observable stops
* mirroring the source Observable and completes.
*
* @example <caption>Tick every second until the first click happens</caption>
* var interval = Rx.Observable.interval(1000);
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = interval.takeUntil(clicks);
* result.subscribe(x => console.log(x));
*
* @see {@link take}
* @see {@link takeLast}
* @see {@link takeWhile}
* @see {@link skip}
*
* @param {Observable} notifier The Observable whose first emitted value will
* cause the output Observable of `takeUntil` to stop emitting values from the
* source Observable.
* @return {Observable<T>} An Observable that emits the values from the source
* Observable until such time as `notifier` emits its first value.
* @method takeUntil

@@ -14,0 +41,0 @@ * @owner Observable

import { Observable } from '../Observable';
/**
* @param predicate
* @return {Observable<R>|WebSocketSubject<T>|Observable<T>}
* Emits values emitted by the source Observable so long as each value satisfies
* the given `predicate`, and then completes as soon as this `predicate` is not
* satisfied.
*
* <span class="informal">Takes values from the source only while they pass the
* condition given. When the first value does not satisfy, it completes.</span>
*
* <img src="./img/takeWhile.png" width="100%">
*
* `takeWhile` subscribes and begins mirroring the source Observable. Each value
* emitted on the source is given to the `predicate` function which returns a
* boolean, representing a condition to be satisfied by the source values. The
* output Observable emits the source values until such time as the `predicate`
* returns false, at which point `takeWhile` stops mirroring the source
* Observable and completes the output Observable.
*
* @example <caption>Emit click events only while the clientX property is greater than 200</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.takeWhile(ev => ev.clientX > 200);
* result.subscribe(x => console.log(x));
*
* @see {@link take}
* @see {@link takeLast}
* @see {@link takeUntil}
* @see {@link skip}
*
* @param {function(value: T, index: number): boolean} predicate A function that
* evaluates a value emitted by the source Observable and returns a boolean.
* Also takes the (zero-based) index as the second argument.
* @return {Observable<T>} An Observable that emits the values from the source
* Observable so long as each value satisfies the condition defined by the
* `predicate`, then completes.
* @method takeWhile

@@ -6,0 +36,0 @@ * @owner Observable

@@ -9,4 +9,34 @@ "use strict";

/**
* @param predicate
* @return {Observable<R>|WebSocketSubject<T>|Observable<T>}
* Emits values emitted by the source Observable so long as each value satisfies
* the given `predicate`, and then completes as soon as this `predicate` is not
* satisfied.
*
* <span class="informal">Takes values from the source only while they pass the
* condition given. When the first value does not satisfy, it completes.</span>
*
* <img src="./img/takeWhile.png" width="100%">
*
* `takeWhile` subscribes and begins mirroring the source Observable. Each value
* emitted on the source is given to the `predicate` function which returns a
* boolean, representing a condition to be satisfied by the source values. The
* output Observable emits the source values until such time as the `predicate`
* returns false, at which point `takeWhile` stops mirroring the source
* Observable and completes the output Observable.
*
* @example <caption>Emit click events only while the clientX property is greater than 200</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.takeWhile(ev => ev.clientX > 200);
* result.subscribe(x => console.log(x));
*
* @see {@link take}
* @see {@link takeLast}
* @see {@link takeUntil}
* @see {@link skip}
*
* @param {function(value: T, index: number): boolean} predicate A function that
* evaluates a value emitted by the source Observable and returns a boolean.
* Also takes the (zero-based) index as the second argument.
* @return {Observable<T>} An Observable that emits the values from the source
* Observable so long as each value satisfies the condition defined by the
* `predicate`, then completes.
* @method takeWhile

@@ -13,0 +43,0 @@ * @owner Observable

import { Observable, SubscribableOrPromise } from '../Observable';
/**
* @param durationSelector
* @return {Observable<R>|WebSocketSubject<T>|Observable<T>}
* Emits a value from the source Observable, then ignores subsequent source
* values for a duration determined by another Observable, then repeats this
* process.
*
* <span class="informal">It's like {@link throttleTime}, but the silencing
* duration is determined by a second Observable.</span>
*
* <img src="./img/throttle.png" width="100%">
*
* `throttle` emits the source Observable values on the output Observable
* when its internal timer is disabled, and ignores source values when the timer
* is enabled. Initially, the timer is disabled. As soon as the first source
* value arrives, it is forwarded to the output Observable, and then the timer
* is enabled by calling the `durationSelector` function with the source value,
* which returns the "duration" Observable. When the duration Observable emits a
* value or completes, the timer is disabled, and this process repeats for the
* next source value.
*
* @example <caption>Emit clicks at a rate of at most one click per second</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.throttle(ev => Rx.Observable.interval(1000));
* result.subscribe(x => console.log(x));
*
* @see {@link audit}
* @see {@link debounce}
* @see {@link delayWhen}
* @see {@link sample}
* @see {@link throttleTime}
*
* @param {function(value: T): Observable|Promise} durationSelector A function
* that receives a value from the source Observable, for computing the silencing
* duration for each source value, returned as an Observable or a Promise.
* @return {Observable<T>} An Observable that performs the throttle operation to
* limit the rate of emissions from the source.
* @method throttle

@@ -6,0 +38,0 @@ * @owner Observable

@@ -10,4 +10,36 @@ "use strict";

/**
* @param durationSelector
* @return {Observable<R>|WebSocketSubject<T>|Observable<T>}
* Emits a value from the source Observable, then ignores subsequent source
* values for a duration determined by another Observable, then repeats this
* process.
*
* <span class="informal">It's like {@link throttleTime}, but the silencing
* duration is determined by a second Observable.</span>
*
* <img src="./img/throttle.png" width="100%">
*
* `throttle` emits the source Observable values on the output Observable
* when its internal timer is disabled, and ignores source values when the timer
* is enabled. Initially, the timer is disabled. As soon as the first source
* value arrives, it is forwarded to the output Observable, and then the timer
* is enabled by calling the `durationSelector` function with the source value,
* which returns the "duration" Observable. When the duration Observable emits a
* value or completes, the timer is disabled, and this process repeats for the
* next source value.
*
* @example <caption>Emit clicks at a rate of at most one click per second</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.throttle(ev => Rx.Observable.interval(1000));
* result.subscribe(x => console.log(x));
*
* @see {@link audit}
* @see {@link debounce}
* @see {@link delayWhen}
* @see {@link sample}
* @see {@link throttleTime}
*
* @param {function(value: T): Observable|Promise} durationSelector A function
* that receives a value from the source Observable, for computing the silencing
* duration for each source value, returned as an Observable or a Promise.
* @return {Observable<T>} An Observable that performs the throttle operation to
* limit the rate of emissions from the source.
* @method throttle

@@ -14,0 +46,0 @@ * @owner Observable

import { Scheduler } from '../Scheduler';
import { Observable } from '../Observable';
/**
* @param delay
* @param scheduler
* @return {Observable<R>|WebSocketSubject<T>|Observable<T>}
* Emits a value from the source Observable, then ignores subsequent source
* values for `duration` milliseconds, then repeats this process.
*
* <span class="informal">Lets a value pass, then ignores source values for the
* next `duration` milliseconds.</span>
*
* <img src="./img/throttleTime.png" width="100%">
*
* `throttleTime` emits the source Observable values on the output Observable
* when its internal timer is disabled, and ignores source values when the timer
* is enabled. Initially, the timer is disabled. As soon as the first source
* value arrives, it is forwarded to the output Observable, and then the timer
* is enabled. After `duration` milliseconds (or the time unit determined
* internally by the optional `scheduler`) has passed, the timer is disabled,
* and this process repeats for the next source value. Optionally takes a
* {@link Scheduler} for managing timers.
*
* @example <caption>Emit clicks at a rate of at most one click per second</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.throttleTime(1000);
* result.subscribe(x => console.log(x));
*
* @see {@link auditTime}
* @see {@link debounceTime}
* @see {@link delay}
* @see {@link sampleTime}
* @see {@link throttle}
*
* @param {number} duration Time to wait before emitting another value after
* emitting the last value, measured in milliseconds or the time unit determined
* internally by the optional `scheduler`.
* @param {Scheduler} [scheduler=async] The {@link Scheduler} to use for
* managing the timers that handle the sampling.
* @return {Observable<T>} An Observable that performs the throttle operation to
* limit the rate of emissions from the source.
* @method throttleTime
* @owner Observable
*/
export declare function throttleTime<T>(delay: number, scheduler?: Scheduler): Observable<T>;
export declare function throttleTime<T>(duration: number, scheduler?: Scheduler): Observable<T>;
export interface ThrottleTimeSignature<T> {
(dueTime: number, scheduler?: Scheduler): Observable<T>;
(duration: number, scheduler?: Scheduler): Observable<T>;
}

@@ -10,20 +10,52 @@ "use strict";

/**
* @param delay
* @param scheduler
* @return {Observable<R>|WebSocketSubject<T>|Observable<T>}
* Emits a value from the source Observable, then ignores subsequent source
* values for `duration` milliseconds, then repeats this process.
*
* <span class="informal">Lets a value pass, then ignores source values for the
* next `duration` milliseconds.</span>
*
* <img src="./img/throttleTime.png" width="100%">
*
* `throttleTime` emits the source Observable values on the output Observable
* when its internal timer is disabled, and ignores source values when the timer
* is enabled. Initially, the timer is disabled. As soon as the first source
* value arrives, it is forwarded to the output Observable, and then the timer
* is enabled. After `duration` milliseconds (or the time unit determined
* internally by the optional `scheduler`) has passed, the timer is disabled,
* and this process repeats for the next source value. Optionally takes a
* {@link Scheduler} for managing timers.
*
* @example <caption>Emit clicks at a rate of at most one click per second</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.throttleTime(1000);
* result.subscribe(x => console.log(x));
*
* @see {@link auditTime}
* @see {@link debounceTime}
* @see {@link delay}
* @see {@link sampleTime}
* @see {@link throttle}
*
* @param {number} duration Time to wait before emitting another value after
* emitting the last value, measured in milliseconds or the time unit determined
* internally by the optional `scheduler`.
* @param {Scheduler} [scheduler=async] The {@link Scheduler} to use for
* managing the timers that handle the sampling.
* @return {Observable<T>} An Observable that performs the throttle operation to
* limit the rate of emissions from the source.
* @method throttleTime
* @owner Observable
*/
function throttleTime(delay, scheduler) {
function throttleTime(duration, scheduler) {
if (scheduler === void 0) { scheduler = async_1.async; }
return this.lift(new ThrottleTimeOperator(delay, scheduler));
return this.lift(new ThrottleTimeOperator(duration, scheduler));
}
exports.throttleTime = throttleTime;
var ThrottleTimeOperator = (function () {
function ThrottleTimeOperator(delay, scheduler) {
this.delay = delay;
function ThrottleTimeOperator(duration, scheduler) {
this.duration = duration;
this.scheduler = scheduler;
}
ThrottleTimeOperator.prototype.call = function (subscriber, source) {
return source._subscribe(new ThrottleTimeSubscriber(subscriber, this.delay, this.scheduler));
return source._subscribe(new ThrottleTimeSubscriber(subscriber, this.duration, this.scheduler));
};

@@ -39,5 +71,5 @@ return ThrottleTimeOperator;

__extends(ThrottleTimeSubscriber, _super);
function ThrottleTimeSubscriber(destination, delay, scheduler) {
function ThrottleTimeSubscriber(destination, duration, scheduler) {
_super.call(this, destination);
this.delay = delay;
this.duration = duration;
this.scheduler = scheduler;

@@ -47,3 +79,3 @@ }

if (!this.throttled) {
this.add(this.throttled = this.scheduler.schedule(dispatchNext, this.delay, { subscriber: this }));
this.add(this.throttled = this.scheduler.schedule(dispatchNext, this.duration, { subscriber: this }));
this.destination.next(value);

@@ -50,0 +82,0 @@ }

{
"dependencies": {
"symbol-observable": "^0.2.4"
},
"name": "rxjs",
"homepage": "https://github.com/ReactiveX/RxJS",
"scripts-info": {
"info": "List available script",
"build_all": "Build all packages(ES6, CJS, AMD, Global) and generate packages",
"build_amd": "Build AMD package with clean up existing build, copy source into dist",
"build_cjs": "Build CJS package with clean up existing build, copy source into dist",
"build_es6": "Build ES6 package with clean up existing build, copy source into dist",
"build_closure_core": "Minify Global core build using closure compiler",
"build_closure_kitchensink": "Minify Global kitchenSink build using closure compiler",
"build_global": "Build Global package, then minify core & kitchensink build",
"build_perf": "Build CJS & Global build, run macro performance test",
"build_test": "Build CJS package & test spec, execute mocha test runner",
"build_cover": "Run lint to current code, build CJS & test spec, execute test coverage",
"build_docs": "Build ES6 & global package, create documentation using it",
"build_spec": "Build test specs",
"check_circular_dependencies": "Check codebase has circular dependencies",
"clean_spec": "Clean up existing test spec build output",
"clean_dist_amd": "Clean up existing AMD package output",
"clean_dist_cjs": "Clean up existing CJS package output",
"clean_dist_es6": "Clean up existing ES6 package output",
"commit": "Run git commit wizard",
"compile_dist_amd": "Compile codebase into AMD module",
"compile_dist_cjs": "Compile codebase into CJS module",
"compile_dist_es6": "Compile codebase into ES6",
"cover": "Execute test coverage",
"lint_perf": "Run lint against performance test suite",
"lint_spec": "Run lint against test spec",
"lint_src": "Run lint against source",
"lint": "Run lint against everything",
"perf": "Run macro performance benchmark",
"perf_micro": "Run micro performance benchmark",
"test_mocha": "Execute mocha test runner against existing test spec build",
"test_browser": "Execute mocha test runner on browser against existing test spec build",
"test": "Clean up existing test spec build, build test spec and execute mocha test runner",
"tests2png": "Generate marble diagram image from test spec",
"watch": "Watch codebase, trigger compile when source code changes"
},
"config": {
"commitizen": {
"path": "node_modules/cz-conventional-changelog"
},
"ghooks": {
"commit-msg": "node ./node_modules/validate-commit-msg/index.js"
}
},
"description": "Reactive Extensions for modern JavaScript",
"repository": {
"type": "git",
"url": "git@github.com:ReactiveX/RxJS.git"
},
"typings": "Rx.d.ts",
"engines": {
"npm": ">=2.0.0"
},
"bugs": {
"url": "https://github.com/ReactiveX/RxJS/issues"
},
"license": "Apache-2.0",
"version": "5.0.0-beta.7",
"contributors": [

@@ -32,7 +90,2 @@ {

],
"version": "5.0.0-beta.6",
"repository": {
"type": "git",
"url": "git@github.com:ReactiveX/RxJS.git"
},
"keywords": [

@@ -50,54 +103,3 @@ "Rx",

],
"config": {
"commitizen": {
"path": "node_modules/cz-conventional-changelog"
},
"ghooks": {
"commit-msg": "node ./node_modules/validate-commit-msg/index.js"
}
},
"engines": {
"npm": ">=2.0.0"
},
"description": "Reactive Extensions for modern JavaScript",
"scripts-info": {
"info": "List available script",
"build_all": "Build all packages(ES6, CJS, AMD, Global) and generate packages",
"build_amd": "Build AMD package with clean up existing build, copy source into dist",
"build_cjs": "Build CJS package with clean up existing build, copy source into dist",
"build_es6": "Build ES6 package with clean up existing build, copy source into dist",
"build_closure_core": "Minify Global core build using closure compiler",
"build_closure_kitchensink": "Minify Global kitchenSink build using closure compiler",
"build_global": "Build Global package, then minify core & kitchensink build",
"build_perf": "Build CJS & Global build, run macro performance test",
"build_test": "Build CJS package & test spec, execute mocha test runner",
"build_cover": "Run lint to current code, build CJS & test spec, execute test coverage",
"build_docs": "Build ES6 & global package, create documentation using it",
"build_spec": "Build test specs",
"check_circular_dependencies": "Check codebase has circular dependencies",
"clean_spec": "Clean up existing test spec build output",
"clean_dist_amd": "Clean up existing AMD package output",
"clean_dist_cjs": "Clean up existing CJS package output",
"clean_dist_es6": "Clean up existing ES6 package output",
"commit": "Run git commit wizard",
"compile_dist_amd": "Compile codebase into AMD module",
"compile_dist_cjs": "Compile codebase into CJS module",
"compile_dist_es6": "Compile codebase into ES6",
"cover": "Execute test coverage",
"lint_perf": "Run lint against performance test suite",
"lint_spec": "Run lint against test spec",
"lint_src": "Run lint against source",
"lint": "Run lint against everything",
"perf": "Run macro performance benchmark",
"perf_micro": "Run micro performance benchmark",
"test_mocha": "Execute mocha test runner against existing test spec build",
"test_browser": "Execute mocha test runner on browser against existing test spec build",
"test": "Clean up existing test spec build, build test spec and execute mocha test runner",
"tests2png": "Generate marble diagram image from test spec",
"watch": "Watch codebase, trigger compile when source code changes"
},
"main": "Rx.js",
"name": "rxjs",
"homepage": "https://github.com/ReactiveX/RxJS",
"typings": "Rx.d.ts",
"author": "Ben Lesh <blesh@netflix.com>",

@@ -146,3 +148,3 @@ "devDependencies": {

"tslint": "^3.5.0",
"typescript": "^1.8.7",
"typescript": "^1.8.10",
"typings": "^0.7.8",

@@ -154,3 +156,4 @@ "validate-commit-msg": "^2.3.1",

"xmlhttprequest": "1.8.0"
}
},
"license": "Apache-2.0"
}

@@ -14,2 +14,3 @@ export { Subject } from './Subject';

import './add/observable/fromPromise';
import './add/observable/generate';
import './add/observable/interval';

@@ -16,0 +17,0 @@ import './add/observable/merge';

@@ -24,2 +24,3 @@ "use strict";

require('./add/observable/fromPromise');
require('./add/observable/generate');
require('./add/observable/interval');

@@ -148,4 +149,4 @@ require('./add/observable/merge');

var rxSubscriber_1 = require('./symbol/rxSubscriber');
var observable_1 = require('./symbol/observable');
var iterator_1 = require('./symbol/iterator');
var observable = require('symbol-observable');
/* tslint:enable:no-unused-variable */

@@ -184,3 +185,3 @@ /**

rxSubscriber: rxSubscriber_1.$$rxSubscriber,
observable: observable_1.$$observable,
observable: observable,
iterator: iterator_1.$$iterator

@@ -187,0 +188,0 @@ };

@@ -6,3 +6,2 @@ import {PartialObserver} from './Observer';

import {root} from './util/root';
import {$$observable} from './symbol/observable';
import {toSubscriber} from './util/toSubscriber';

@@ -13,2 +12,4 @@

import * as $$observable from 'symbol-observable';
export interface Subscribable<T> {

@@ -15,0 +16,0 @@ subscribe(observerOrNext?: PartialObserver<T> | ((value: T) => void),

@@ -37,11 +37,33 @@ import {Observable} from '../Observable';

/**
* Converts a callback function to an observable sequence.
* @param {function} callbackFunc Function with a callback as the last
* parameter.
* @param {function} selector A selector which takes the arguments from the
* callback to produce a single item to yield on next.
* @param {Scheduler} [scheduler] The scheduler on which to schedule
* the callbacks.
* @return {function(...params: *): Observable<T>} a function which returns the
* Observable that corresponds to the callback.
* 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, but 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 where the
* results will be delivered to.
*
* @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));
*
* @see {@link bindNodeCallback}
* @see {@link from}
* @see {@link fromPromise}
*
* @param {function} func Function with a callback as the last parameter.
* @param {function} selector A function which takes the arguments from the
* callback and maps those 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 callback would deliver.
* @static true

@@ -51,7 +73,7 @@ * @name bindCallback

*/
static create<T>(callbackFunc: Function,
static create<T>(func: Function,
selector: Function | void = undefined,
scheduler?: Scheduler): (...args: any[]) => Observable<T> {
return (...args: any[]): Observable<T> => {
return new BoundCallbackObservable<T>(callbackFunc, <any>selector, args, scheduler);
return new BoundCallbackObservable<T>(func, <any>selector, args, scheduler);
};

@@ -58,0 +80,0 @@ }

@@ -30,7 +30,36 @@ import {Observable} from '../Observable';

/**
* Converts a node callback to an Observable.
* @param callbackFunc
* @param selector
* @param scheduler
* @return {function(...params: *): Observable<T>}
* 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, while remaining
* arguments are the callback result. 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 where the results will be delivered to.
*
* @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));
*
* @see {@link bindCallback}
* @see {@link from}
* @see {@link fromPromise}
*
* @param {function} func Function with a callback as the last parameter.
* @param {function} selector A function which takes the arguments from the
* callback and maps those 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

@@ -40,7 +69,7 @@ * @name bindNodeCallback

*/
static create<T>(callbackFunc: Function,
static create<T>(func: Function,
selector: Function | void = undefined,
scheduler?: Scheduler): Function {
scheduler?: Scheduler): (...args: any[]) => Observable<T> {
return (...args: any[]): Observable<T> => {
return new BoundNodeCallbackObservable<T>(callbackFunc, <any>selector, args, scheduler);
return new BoundNodeCallbackObservable<T>(func, <any>selector, args, scheduler);
};

@@ -47,0 +76,0 @@ }

@@ -45,6 +45,32 @@ import {Observable} from '../Observable';

/**
* @param sourceObj
* @param eventName
* @param selector
* @return {FromEventObservable}
* 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
* EventEmitter events or others.</span>
*
* <img src="./img/fromEvent.png" width="100%">
*
* Creates an Observable by attaching an event listener to an "event target",
* which may be an object with `addEventListener` and `removeEventListener`,
* a Node.js EventEmitter, a jQuery style EventEmitter, a NodeList from the
* DOM, or an HTMLCollection from the DOM. The event handler is attached when
* the output Observable is subscribed, and removed when the Subscription is
* unsubscribed.
*
* @example <caption>Emits clicks happening on the DOM document</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* clicks.subscribe(x => console.log(x));
*
* @see {@link from}
* @see {@link fromEventPattern}
*
* @param {EventTargetLike} target The DOMElement, event target, Node.js
* EventEmitter, NodeList or HTMLCollection to attach the event handler to.
* @param {string} eventName The event name of interest, being emitted by the
* `target`.
* @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

@@ -54,11 +80,18 @@ * @name fromEvent

*/
static create<T>(sourceObj: EventTargetLike, eventName: string, selector?: (...args: Array<any>) => T): Observable<T> {
return new FromEventObservable(sourceObj, eventName, selector);
static create<T>(target: EventTargetLike,
eventName: string,
selector?: (...args: Array<any>) => T): Observable<T> {
return new FromEventObservable(target, eventName, selector);
}
constructor(private sourceObj: EventTargetLike, private eventName: string, private selector?: (...args: Array<any>) => T) {
constructor(private sourceObj: EventTargetLike,
private eventName: string,
private selector?: (...args: Array<any>) => T) {
super();
}
private static setupSubscription<T>(sourceObj: EventTargetLike, eventName: string, handler: Function, subscriber: Subscriber<T>) {
private static setupSubscription<T>(sourceObj: EventTargetLike,
eventName: string,
handler: Function,
subscriber: Subscriber<T>) {
let unsubscribe: () => void;

@@ -65,0 +98,0 @@ if (isNodeList(sourceObj) || isHTMLCollection(sourceObj)) {

@@ -15,6 +15,44 @@ import {Observable} from '../Observable';

/**
* @param addHandler
* @param removeHandler
* @param selector
* @return {FromEventPatternObservable}
* 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): void} removeHandler A function that
* takes a `handler` function as argument and removes it in case it was
* previously attached using `addHandler`.
* @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

@@ -21,0 +59,0 @@ * @name fromEventPattern

@@ -11,3 +11,2 @@ import {isArray} from '../util/isArray';

import {Scheduler} from '../Scheduler';
import {$$observable} from '../symbol/observable';
import {$$iterator} from '../symbol/iterator';

@@ -18,2 +17,4 @@ import {Observable, ObservableInput} from '../Observable';

import * as $$observable from 'symbol-observable';
const isArrayLike = (<T>(x: any): x is ArrayLike<T> => x && typeof x.length === 'number');

@@ -31,8 +32,56 @@

static create<T>(ish: ObservableInput<T>, scheduler?: Scheduler): Observable<T>;
static create<T, R>(ish: ArrayLike<T>, mapFn: (x: any, y: number) => R, thisArg?: any, scheduler?: Scheduler): Observable<R>;
/**
* @param ish
* @param mapFnOrScheduler
* @param thisArg
* @param lastScheduler
* @return {any}
* 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));
*
* @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));
*
* @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 {function(x: any, i: number): T} [mapFn] A "map" function to call
* when converting array-like objects, where `x` is a value from the
* array-like and `i` is the index of that value in the sequence.
* @param {any} [thisArg] The context object to use when calling the `mapFn`,
* if provided.
* @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

@@ -42,4 +91,2 @@ * @name from

*/
static create<T>(ish: ObservableInput<T>, scheduler?: Scheduler): Observable<T>;
static create<T, R>(ish: ArrayLike<T>, mapFn: (x: any, y: number) => R, thisArg?: any, scheduler?: Scheduler): Observable<R>;
static create<T>(ish: ObservableInput<T>,

@@ -46,0 +93,0 @@ mapFnOrScheduler?: Scheduler | ((x: any, y: number) => T),

@@ -17,5 +17,23 @@ import {root} from '../util/root';

/**
* @param promise
* @param scheduler
* @return {PromiseObservable}
* 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 {Promise<T>} promise The promise to be converted.
* @param {Scheduler} [scheduler] An optional Scheduler to use for scheduling
* the delivery of the resolved value (or the rejection).
* @return {Observable<T>} An Observable which wraps the Promise.
* @static true

@@ -22,0 +40,0 @@ * @name fromPromise

@@ -12,4 +12,38 @@ import {Operator} from '../Operator';

/**
* @param durationSelector
* @return {Observable<R>|WebSocketSubject<T>|Observable<T>}
* Ignores source values for a duration determined by another Observable, then
* emits the most recent value from the source Observable, then repeats this
* process.
*
* <span class="informal">It's like {@link auditTime}, but the silencing
* duration is determined by a second Observable.</span>
*
* <img src="./img/audit.png" width="100%">
*
* `audit` is similar to `throttle`, but emits the last value from the silenced
* time window, instead of the first value. `audit` emits the most recent value
* from the source Observable on the output Observable as soon as its internal
* timer becomes disabled, and ignores source values while the timer is enabled.
* Initially, the timer is disabled. As soon as the first source value arrives,
* the timer is enabled by calling the `durationSelector` function with the
* source value, which returns the "duration" Observable. When the duration
* Observable emits a value or completes, the timer is disabled, then the most
* recent source value is emitted on the output Observable, and this process
* repeats for the next source value.
*
* @example <caption>Emit clicks at a rate of at most one click per second</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.audit(ev => Rx.Observable.interval(1000));
* result.subscribe(x => console.log(x));
*
* @see {@link auditTime}
* @see {@link debounce}
* @see {@link delayWhen}
* @see {@link sample}
* @see {@link throttle}
*
* @param {function(value: T): Observable|Promise} durationSelector A function
* that receives a value from the source Observable, for computing the silencing
* duration, returned as an Observable or a Promise.
* @return {Observable<T>} An Observable that performs rate-limiting of
* emissions from the source Observable.
* @method audit

@@ -16,0 +50,0 @@ * @owner Observable

@@ -9,22 +9,58 @@ import {async} from '../scheduler/async';

/**
* @param delay
* @param scheduler
* @return {Observable<R>|WebSocketSubject<T>|Observable<T>}
* Ignores source values for `duration` milliseconds, then emits the most recent
* value from the source Observable, then repeats this process.
*
* <span class="informal">When it sees a source values, it ignores that plus
* the next ones for `duration` milliseconds, and then it emits the most recent
* value from the source.</span>
*
* <img src="./img/auditTime.png" width="100%">
*
* `auditTime` is similar to `throttleTime`, but emits the last value from the
* silenced time window, instead of the first value. `auditTime` emits the most
* recent value from the source Observable on the output Observable as soon as
* its internal timer becomes disabled, and ignores source values while the
* timer is enabled. Initially, the timer is disabled. As soon as the first
* source value arrives, the timer is enabled. After `duration` milliseconds (or
* the time unit determined internally by the optional `scheduler`) has passed,
* the timer is disabled, then the most recent source value is emitted on the
* output Observable, and this process repeats for the next source value.
* Optionally takes a {@link Scheduler} for managing timers.
*
* @example <caption>Emit clicks at a rate of at most one click per second</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.auditTime(1000);
* result.subscribe(x => console.log(x));
*
* @see {@link audit}
* @see {@link debounceTime}
* @see {@link delay}
* @see {@link sampleTime}
* @see {@link throttleTime}
*
* @param {number} duration Time to wait before emitting the most recent source
* value, measured in milliseconds or the time unit determined internally
* by the optional `scheduler`.
* @param {Scheduler} [scheduler=async] The {@link Scheduler} to use for
* managing the timers that handle the rate-limiting behavior.
* @return {Observable<T>} An Observable that performs rate-limiting of
* emissions from the source Observable.
* @method auditTime
* @owner Observable
*/
export function auditTime<T>(delay: number, scheduler: Scheduler = async): Observable<T> {
return this.lift(new AuditTimeOperator(delay, scheduler));
export function auditTime<T>(duration: number, scheduler: Scheduler = async): Observable<T> {
return this.lift(new AuditTimeOperator(duration, scheduler));
}
export interface AuditTimeSignature<T> {
(delay: number, scheduler?: Scheduler): Observable<T>;
(duration: number, scheduler?: Scheduler): Observable<T>;
}
class AuditTimeOperator<T> implements Operator<T, T> {
constructor(private delay: number, private scheduler: Scheduler) {
constructor(private duration: number,
private scheduler: Scheduler) {
}
call(subscriber: Subscriber<T>, source: any): any {
return source._subscribe(new AuditTimeSubscriber(subscriber, this.delay, this.scheduler));
return source._subscribe(new AuditTimeSubscriber(subscriber, this.duration, this.scheduler));
}

@@ -45,3 +81,3 @@ }

constructor(destination: Subscriber<T>,
private delay: number,
private duration: number,
private scheduler: Scheduler) {

@@ -55,3 +91,3 @@ super(destination);

if (!this.throttled) {
this.add(this.throttled = this.scheduler.schedule(dispatchNext, this.delay, this));
this.add(this.throttled = this.scheduler.schedule(dispatchNext, this.duration, this));
}

@@ -58,0 +94,0 @@ }

@@ -34,2 +34,3 @@ import {Operator} from '../Operator';

* @see {@link bufferWhen}
* @see {@link pairwise}
* @see {@link windowCount}

@@ -36,0 +37,0 @@ *

@@ -109,10 +109,40 @@ import {Observable, ObservableInput} from '../Observable';

/**
* Combines the values from observables passed as arguments. This is done by subscribing
* to each observable, in order, and collecting an array of each of the most recent values any time any of the observables
* emits, then either taking that array and passing it as arguments to an option `project` function and emitting the return
* value of that, or just emitting the array of recent values directly if there is no `project` function.
* @param {...Observable} observables the observables to combine
* @param {function} [project] an optional function to project the values from the combined recent values into a new value for emission.
* @return {Observable} an observable of other projected values from the most recent values from each observable, or an array of each of
* the most recent values from each observable.
* 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
* collecting an array of each of the most recent values any time any of the
* input Observables emits, then either taking that array and passing it as
* arguments to an optional `project` function and emitting the return value of
* that, or just emitting the array of recent values directly if there is no
* `project` function.
*
* @example <caption>Dynamically calculate the Body-Mass Index from an Observable of weight and one for height</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));
*
* @see {@link combineAll}
* @see {@link merge}
* @see {@link withLatestFrom}
*
* @param {Observable} observable1 An input Observable to combine with the
* source Observable.
* @param {Observable} observable2 An input Observable to combine with the
* source Observable. More than one input Observables may be given as 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 Scheduler 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

@@ -119,0 +149,0 @@ * @name combineLatest

@@ -11,10 +11,40 @@ import {Operator} from '../Operator';

/**
* Returns the source Observable delayed by the computed debounce duration,
* with the duration lengthened if a new source item arrives before the delay
* duration ends.
* In practice, for each item emitted on the source, this operator holds the
* latest item, waits for a silence as long as the `durationSelector` specifies,
* and only then emits the latest source item on the result Observable.
* @param {function} durationSelector function for computing the timeout duration for each item.
* @return {Observable} an Observable the same as source Observable, but drops items.
* Emits a value from the source Observable only after a particular time span
* determined by another Observable has passed without another source emission.
*
* <span class="informal">It's like {@link debounceTime}, but the time span of
* emission silence is determined by a second Observable.</span>
*
* <img src="./img/debounce.png" width="100%">
*
* `debounce` delays values emitted by the source Observable, but drops previous
* pending delayed emissions if a new value arrives on the source Observable.
* This operator keeps track of the most recent value from the source
* Observable, and spawns a duration Observable by calling the
* `durationSelector` function. The value is emitted only when the duration
* Observable emits a value or completes, and if no other value was emitted on
* the source Observable since the duration Observable was spawned. If a new
* value appears before the duration Observable emits, the previous value will
* be dropped and will not be emitted on the output Observable.
*
* Like {@link debounceTime}, this is a rate-limiting operator, and also a
* delay-like operator since output emissions do not necessarily occur at the
* same time as they did on the source Observable.
*
* @example <caption>Emit the most recent click after a burst of clicks</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.debounce(() => Rx.Observable.interval(1000));
* result.subscribe(x => console.log(x));
*
* @see {@link audit}
* @see {@link debounceTime}
* @see {@link delayWhen}
* @see {@link throttle}
*
* @param {function(value: T): Observable|Promise} durationSelector A function
* that receives a value from the source Observable, for computing the timeout
* duration for each source value, returned as an Observable or a Promise.
* @return {Observable} An Observable that delays the emissions of the source
* Observable by the specified duration Observable returned by
* `durationSelector`, and may drop some values if they occur too frequently.
* @method debounce

@@ -21,0 +51,0 @@ * @owner Observable

@@ -9,12 +9,44 @@ import {Operator} from '../Operator';

/**
* Returns the source Observable delayed by the computed debounce duration,
* with the duration lengthened if a new source item arrives before the delay
* duration ends.
* In practice, for each item emitted on the source, this operator holds the
* latest item, waits for a silence for the `dueTime` length, and only then
* emits the latest source item on the result Observable.
* Optionally takes a scheduler for manging timers.
* @param {number} dueTime the timeout value for the window of time required to not drop the item.
* @param {Scheduler} [scheduler] the Scheduler to use for managing the timers that handle the timeout for each item.
* @return {Observable} an Observable the same as source Observable, but drops items.
* Emits a value from the source Observable only after a particular time span
* has passed without another source emission.
*
* <span class="informal">It's like {@link delay}, but passes only the most
* recent value from each burst of emissions.</span>
*
* <img src="./img/debounceTime.png" width="100%">
*
* `debounceTime` delays values emitted by the source Observable, but drops
* previous pending delayed emissions if a new value arrives on the source
* Observable. This operator keeps track of the most recent value from the
* source Observable, and emits that only when `dueTime` enough time has passed
* without any other value appearing on the source Observable. If a new value
* appears before `dueTime` silence occurs, the previous value will be dropped
* and will not be emitted on the output Observable.
*
* This is a rate-limiting operator, because it is impossible for more than one
* value to be emitted in any time window of duration `dueTime`, but it is also
* a delay-like operator since output emissions do not occur at the same time as
* they did on the source Observable. Optionally takes a {@link Scheduler} for
* managing timers.
*
* @example <caption>Emit the most recent click after a burst of clicks</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.debounceTime(1000);
* result.subscribe(x => console.log(x));
*
* @see {@link auditTime}
* @see {@link debounce}
* @see {@link delay}
* @see {@link sampleTime}
* @see {@link throttleTime}
*
* @param {number} dueTime The timeout duration in milliseconds (or the time
* unit determined internally by the optional `scheduler`) for the window of
* time required to wait for emission silence before emitting the most recent
* source value.
* @param {Scheduler} [scheduler=async] The {@link Scheduler} to use for
* managing the timers that handle the timeout for each value.
* @return {Observable} An Observable that delays the emissions of the source
* Observable by the specified `dueTime`, and may drop some values if they occur
* too frequently.
* @method debounceTime

@@ -21,0 +53,0 @@ * @owner Observable

@@ -6,5 +6,28 @@ import {Operator} from '../Operator';

/**
* Returns an Observable that emits the elements of the source or a specified default value if empty.
* @param {any} defaultValue the default value used if source is empty; defaults to null.
* @return {Observable} an Observable of the items emitted by the where empty values are replaced by the specified default value or null.
* Emits a given value if the source Observable completes without emitting any
* `next` value, otherwise mirrors the source Observable.
*
* <span class="informal">If the source Observable turns out to be empty, then
* this operator will emit a default value.</span>
*
* <img src="./img/defaultIfEmpty.png" width="100%">
*
* `defaultIfEmpty` emits the values emitted by the source Observable or a
* specified default value if the source Observable is empty (completes without
* having emitted any `next` value).
*
* @example <caption>If no clicks happen in 5 seconds, then emit "no clicks"</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var clicksBeforeFive = clicks.takeUntil(Rx.Observable.interval(5000));
* var result = clicksBeforeFive.defaultIfEmpty('no clicks');
* result.subscribe(x => console.log(x));
*
* @see {@link empty}
* @see {@link last}
*
* @param {any} [defaultValue=null] The default value used if the source
* Observable is empty.
* @return {Observable} An Observable that emits either the specified
* `defaultValue` if the source Observable emits no items, or the values emitted
* by the source Observable.
* @method defaultIfEmpty

@@ -11,0 +34,0 @@ * @owner Observable

@@ -11,7 +11,43 @@ import {Operator} from '../Operator';

/**
* Returns an Observable that delays the emission of items from the source Observable
* by a subscription delay and a delay selector function for each element.
* @param {Function} selector function to retrieve a sequence indicating the delay for each given element.
* @param {Observable} sequence indicating the delay for the subscription to the source.
* @return {Observable} an Observable that delays the emissions of the source Observable by the specified timeout or Date.
* Delays the emission of items from the source Observable by a given time span
* determined by the emissions of another Observable.
*
* <span class="informal">It's like {@link delay}, but the time span of the
* delay duration is determined by a second Observable.</span>
*
* <img src="./img/delayWhen.png" width="100%">
*
* `delayWhen` time shifts each emitted value from the source Observable by a
* time span determined by another Observable. When the source emits a value,
* the `delayDurationSelector` function is called with the source value as
* argument, and should return an Observable, called the "duration" Observable.
* The source value is emitted on the output Observable only when the duration
* Observable emits a value or completes.
*
* Optionally, `delayWhen` takes a second argument, `subscriptionDelay`, which
* is an Observable. When `subscriptionDelay` emits its first value or
* completes, the source Observable is subscribed to and starts behaving like
* described in the previous paragraph. If `subscriptionDelay` is not provided,
* `delayWhen` will subscribe to the source Observable as soon as the output
* Observable is subscribed.
*
* @example <caption>Delay each click by a random amount of time, between 0 and 5 seconds</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var delayedClicks = clicks.delayWhen(event =>
* Rx.Observable.interval(Math.random() * 5000)
* );
* delayedClicks.subscribe(x => console.log(x));
*
* @see {@link debounce}
* @see {@link delay}
*
* @param {function(value: T): Observable} delayDurationSelector A function that
* returns an Observable for each value emitted by the source Observable, which
* is then used to delay the emission of that item on the output Observable
* until the Observable returned from this function emits a value.
* @param {Observable} subscriptionDelay An Observable that triggers the
* subscription to the source Observable once it emits any value.
* @return {Observable} An Observable that delays the emissions of the source
* Observable by an amount of time specified by the Observable returned by
* `delayDurationSelector`.
* @method delayWhen

@@ -18,0 +54,0 @@ * @owner Observable

@@ -7,10 +7,35 @@ import {Operator} from '../Operator';

/**
* Returns an Observable that emits the item at the specified index in the source Observable.
* If default is given, missing indices will output this value on next; otherwise, outputs error.
* Emits the single value at the specified `index` in a sequence of emissions
* from the source Observable.
*
* <span class="informal">Emits only the i-th value, then completes.</span>
*
* <img src="./img/elementAt.png" width="100%">
*
* `elementAt` returns an Observable that emits the item at the specified
* `index` in the source Observable, or a default value if that `index` is out
* of range and the `default` argument is provided. If the `default` argument is
* not given and the `index` is out of range, the output Observable will emit an
* `ArgumentOutOfRangeError` error.
*
* @example <caption>Emit only the third click event</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.elementAt(2);
* result.subscribe(x => console.log(x));
*
* @see {@link first}
* @see {@link last}
* @see {@link skip}
* @see {@link single}
* @see {@link take}
*
* @throws {ArgumentOutOfRangeError} When using `elementAt(i)`, it delivers an
* ArgumentOutOrRangeError to the Observer's `error` callback if `i < 0` or the
* Observable has completed before emitting the i-th `next` notification.
* @param {number} index the index of the value to be retrieved.
* @param {any} [defaultValue] the default value returned for missing indices.
* @return {Observable} an Observable that emits a single item, if it is found. Otherwise, will emit the default value if given.
*
* @param {number} index Is the number `i` for the i-th source emission that has
* happened since the subscription, starting from the number `0`.
* @param {T} [defaultValue] The default value returned for missing indices.
* @return {Observable} An Observable that emits a single item, if it is found.
* Otherwise, will emit the default value if given. If not, then emits an error.
* @method elementAt

@@ -17,0 +42,0 @@ * @owner Observable

@@ -16,4 +16,3 @@ import {Operator} from '../Operator';

thisArg?: any): Observable<boolean> {
const source = this;
return source.lift(new EveryOperator(predicate, thisArg, source));
return this.lift(new EveryOperator(predicate, thisArg, this));
}

@@ -20,0 +19,0 @@

@@ -6,9 +6,33 @@ import {Operator} from '../Operator';

/**
* Returns a new observable that triggers on the second and following inputs.
* An input that triggers an event will return an pair of [(N - 1)th, Nth].
* The (N-1)th is stored in the internal state until Nth input occurs.
* Groups pairs of consecutive emissions together and emits them as an array of
* two values.
*
* <span class="informal">Puts the current value and previous value together as
* an array, and emits that.</span>
*
* <img src="./img/pairwise.png" width="100%">
*
* @return {Observable<R>} an observable of pairs of values.
* The Nth emission from the source Observable will cause the output Observable
* to emit an array [(N-1)th, Nth] of the previous and the current value, as a
* pair. For this reason, `pairwise` emits on the second and subsequent
* emissions from the source Observable, but not on the first emission, because
* there is no previous value in that case.
*
* @example <caption>On every click (starting from the second), emit the relative distance to the previous click</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var pairs = clicks.pairwise();
* var distance = pairs.map(pair => {
* var x0 = pair[0].clientX;
* var y0 = pair[0].clientY;
* var x1 = pair[1].clientX;
* var y1 = pair[1].clientY;
* return Math.sqrt(Math.pow(x0 - x1, 2) + Math.pow(y0 - y1, 2));
* });
* distance.subscribe(x => console.log(x));
*
* @see {@link buffer}
* @see {@link bufferCount}
*
* @return {Observable<[T, T]>} An Observable of pairs of consecutive values
* from the source Observable.
* @method pairwise

@@ -15,0 +39,0 @@ * @owner Observable

@@ -6,5 +6,39 @@ import {not} from '../util/not';

/**
* @param predicate
* @param thisArg
* @return {Observable<T>[]}
* Splits the source Observable into two, one with values that satisfy a
* predicate, and another with values that don't satisfy the predicate.
*
* <span class="informal">It's like {@link filter}, but returns two Observables:
* one like the output of {@link filter}, and the other with values that did not
* pass the condition.</span>
*
* <img src="./img/partition.png" width="100%">
*
* `partition` outputs an array with two Observables that partition the values
* from the source Observable through the given `predicate` function. The first
* Observable in that array emits source values for which the predicate argument
* returns true. The second Observable emits source values for which the
* predicate returns false. The first behaves like {@link filter} and the second
* behaves like {@link filter} with the predicate negated.
*
* @example <caption>Partition click events into those on DIV elements and those elsewhere</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var parts = clicks.partition(ev => ev.target.tagName === 'DIV');
* var clicksOnDivs = parts[0];
* var clicksElsewhere = parts[1];
* clicksOnDivs.subscribe(x => console.log('DIV clicked: ', x));
* clicksElsewhere.subscribe(x => console.log('Other clicked: ', x));
*
* @see {@link filter}
*
* @param {function(value: T, index: number): boolean} predicate A function that
* evaluates each value emitted by the source Observable. If it returns `true`,
* the value is emitted on the first Observable in the returned array, if
* `false` the value is emitted on the second Observable in the array. The
* `index` parameter is the number `i` for the i-th source emission that has
* happened since the subscription, starting from the number `0`.
* @param {any} [thisArg] An optional argument to determine the value of `this`
* in the `predicate` function.
* @return {[Observable<T>, Observable<T>]} An array with two Observables: one
* with values that passed the predicate, and another with values that did not
* pass the predicate.
* @method partition

@@ -11,0 +45,0 @@ * @owner Observable

@@ -85,2 +85,3 @@ import {Observable} from '../Observable';

const len = observables.length;
if (len === 0) {

@@ -93,4 +94,6 @@ this.destination.complete();

this.subscriptions.push(subscription);
this.add(subscription);
if (this.subscriptions) {
this.subscriptions.push(subscription);
this.add(subscription);
}
}

@@ -97,0 +100,0 @@ this.observables = null;

@@ -10,11 +10,32 @@ import {Operator} from '../Operator';

/**
* Returns an Observable that, when the specified sampler Observable emits an item or completes, it then emits the most
* recently emitted item (if any) emitted by the source Observable since the previous emission from the sampler
* Observable.
* Emits the most recently emitted value from the source Observable whenever
* another Observable, the `notifier`, emits.
*
* <span class="informal">It's like {@link sampleTime}, but samples whenever
* the `notifier` Observable emits something.</span>
*
* <img src="./img/sample.png" width="100%">
*
* @param {Observable} sampler - the Observable to use for sampling the source Observable.
* @return {Observable<T>} an Observable that emits the results of sampling the items emitted by this Observable
* whenever the sampler Observable emits an item or completes.
* Whenever the `notifier` Observable emits a value or completes, `sample`
* looks at the source Observable and emits whichever value it has most recently
* emitted since the previous sampling, unless the source has not emitted
* anything since the previous sampling. The `notifier` is subscribed to as soon
* as the output Observable is subscribed.
*
* @example <caption>On every click, sample the most recent "seconds" timer</caption>
* var seconds = Rx.Observable.interval(1000);
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = seconds.sample(clicks);
* result.subscribe(x => console.log(x));
*
* @see {@link audit}
* @see {@link debounce}
* @see {@link sampleTime}
* @see {@link throttle}
*
* @param {Observable<any>} notifier The Observable to use for sampling the
* source Observable.
* @return {Observable<T>} An Observable that emits the results of sampling the
* values emitted by the source Observable whenever the notifier Observable
* emits value or completes.
* @method sample

@@ -21,0 +42,0 @@ * @owner Observable

@@ -8,22 +8,52 @@ import {Observable} from '../Observable';

/**
* @param delay
* @param scheduler
* @return {Observable<R>|WebSocketSubject<T>|Observable<T>}
* Emits the most recently emitted value from the source Observable within
* periodic time intervals.
*
* <span class="informal">Samples the source Observable at periodic time
* intervals, emitting what it samples.</span>
*
* <img src="./img/sampleTime.png" width="100%">
*
* `sampleTime` periodically looks at the source Observable and emits whichever
* value it has most recently emitted since the previous sampling, unless the
* source has not emitted anything since the previous sampling. The sampling
* happens periodically in time every `period` milliseconds (or the time unit
* defined by the optional `scheduler` argument). The sampling starts as soon as
* the output Observable is subscribed.
*
* @example <caption>Every second, emit the most recent click at most once</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.sampleTime(1000);
* result.subscribe(x => console.log(x));
*
* @see {@link auditTime}
* @see {@link debounceTime}
* @see {@link delay}
* @see {@link sample}
* @see {@link throttleTime}
*
* @param {number} period The sampling period expressed in milliseconds or the
* time unit determined internally by the optional `scheduler`.
* @param {Scheduler} [scheduler=async] The {@link Scheduler} to use for
* managing the timers that handle the sampling.
* @return {Observable<T>} An Observable that emits the results of sampling the
* values emitted by the source Observable at the specified time interval.
* @method sampleTime
* @owner Observable
*/
export function sampleTime<T>(delay: number, scheduler: Scheduler = async): Observable<T> {
return this.lift(new SampleTimeOperator(delay, scheduler));
export function sampleTime<T>(period: number, scheduler: Scheduler = async): Observable<T> {
return this.lift(new SampleTimeOperator(period, scheduler));
}
export interface SampleTimeSignature<T> {
(delay: number, scheduler?: Scheduler): Observable<T>;
(period: number, scheduler?: Scheduler): Observable<T>;
}
class SampleTimeOperator<T> implements Operator<T, T> {
constructor(private delay: number, private scheduler: Scheduler) {
constructor(private period: number,
private scheduler: Scheduler) {
}
call(subscriber: Subscriber<T>, source: any): any {
return source._subscribe(new SampleTimeSubscriber(subscriber, this.delay, this.scheduler));
return source._subscribe(new SampleTimeSubscriber(subscriber, this.period, this.scheduler));
}

@@ -41,5 +71,7 @@ }

constructor(destination: Subscriber<T>, private delay: number, private scheduler: Scheduler) {
constructor(destination: Subscriber<T>,
private period: number,
private scheduler: Scheduler) {
super(destination);
this.add(scheduler.schedule(dispatchNotification, delay, { subscriber: this, delay }));
this.add(scheduler.schedule(dispatchNotification, period, { subscriber: this, period }));
}

@@ -61,5 +93,5 @@

function dispatchNotification<T>(state: any) {
let { subscriber, delay } = state;
let { subscriber, period } = state;
subscriber.notifyNext();
(<any>this).schedule(state, delay);
(<any>this).schedule(state, period);
}

@@ -35,4 +35,4 @@ import {Operator} from '../Operator';

*
* @param {function(acc: R, value: T): R} accumulator The accumulator function
* called on each source value.
* @param {function(acc: R, value: T, index: number): R} accumulator
* The accumulator function called on each source value.
* @param {T|R} [seed] The initial accumulation value.

@@ -43,3 +43,3 @@ * @return {Observable<R>} An observable of the accumulated values.

*/
export function scan<T, R>(accumulator: (acc: R, value: T) => R, seed?: T | R): Observable<R> {
export function scan<T, R>(accumulator: (acc: R, value: T, index: number) => R, seed?: T | R): Observable<R> {
return this.lift(new ScanOperator(accumulator, seed));

@@ -49,7 +49,7 @@ }

export interface ScanSignature<T> {
<R>(accumulator: (acc: R, value: T) => R, seed?: T | R): Observable<R>;
<R>(accumulator: (acc: R, value: T, index: number) => R, seed?: T | R): Observable<R>;
}
class ScanOperator<T, R> implements Operator<T, R> {
constructor(private accumulator: (acc: R, value: T) => R, private seed?: T | R) {
constructor(private accumulator: (acc: R, value: T, index: number) => R, private seed?: T | R) {
}

@@ -68,2 +68,4 @@

class ScanSubscriber<T, R> extends Subscriber<T> {
private index: number = 0;
private accumulatorSet: boolean = false;
private _seed: T | R;

@@ -80,8 +82,5 @@

private accumulatorSet: boolean = false;
constructor(destination: Subscriber<R>, private accumulator: (acc: R, value: T) => R, seed?: T|R) {
constructor(destination: Subscriber<R>, private accumulator: (acc: R, value: T, index: number) => R, seed?: T|R) {
super(destination);
this.seed = seed;
this.accumulator = accumulator;
this.accumulatorSet = typeof seed !== 'undefined';

@@ -100,5 +99,6 @@ }

private _tryNext(value: T): void {
const index = this.index++;
let result: any;
try {
result = this.accumulator(<R>this.seed, value);
result = this.accumulator(<R>this.seed, value, index);
} catch (err) {

@@ -105,0 +105,0 @@ this.destination.error(err);

@@ -8,14 +8,39 @@ import {Operator} from '../Operator';

/**
* Emits only the first `count` values emitted by the source Observable.
*
* <span class="informal">Takes the first `count` values from the source, then
* completes.</span>
*
* <img src="./img/take.png" width="100%">
*
* `take` returns an Observable that emits only the first `count` values emitted
* by the source Observable. If the source emits fewer than `count` values then
* all of its values are emitted. After that, it completes, regardless if the
* source completes.
*
* @example <caption>Take the first 5 seconds of an infinite 1-second interval Observable</caption>
* var interval = Rx.Observable.interval(1000);
* var five = interval.take(5);
* five.subscribe(x => console.log(x));
*
* @see {@link takeLast}
* @see {@link takeUntil}
* @see {@link takeWhile}
* @see {@link skip}
*
* @throws {ArgumentOutOfRangeError} When using `take(i)`, it delivers an
* ArgumentOutOrRangeError to the Observer's `error` callback if `i < 0`.
* @param total
* @return {any}
*
* @param {number} count The maximum number of `next` values to emit.
* @return {Observable<T>} An Observable that emits only the first `count`
* values emitted by the source Observable, or all of the values from the source
* if the source emits fewer than `count` values.
* @method take
* @owner Observable
*/
export function take<T>(total: number): Observable<T> {
if (total === 0) {
export function take<T>(count: number): Observable<T> {
if (count === 0) {
return new EmptyObservable<T>();
} else {
return this.lift(new TakeOperator(total));
return this.lift(new TakeOperator(count));
}

@@ -25,3 +50,3 @@ }

export interface TakeSignature<T> {
(total: number): Observable<T>;
(count: number): Observable<T>;
}

@@ -28,0 +53,0 @@

@@ -8,14 +8,42 @@ import {Operator} from '../Operator';

/**
* Emits only the last `count` values emitted by the source Observable.
*
* <span class="informal">Remembers the latest `count` values, then emits those
* only when the source completes.</span>
*
* <img src="./img/takeLast.png" width="100%">
*
* `takeLast` returns an Observable that emits at most the last `count` values
* emitted by the source Observable. If the source emits fewer than `count`
* values then all of its values are emitted. This operator must wait until the
* `complete` notification emission from the source in order to emit the `next`
* values on the output Observable, because otherwise it is impossible to know
* whether or not more values will be emitted on the source. For this reason,
* all values are emitted synchronously, followed by the complete notification.
*
* @example <caption>Take the last 3 values of an Observable with many values</caption>
* var many = Rx.Observable.range(1, 100);
* var lastThree = many.takeLast(3);
* lastThree.subscribe(x => console.log(x));
*
* @see {@link take}
* @see {@link takeUntil}
* @see {@link takeWhile}
* @see {@link skip}
*
* @throws {ArgumentOutOfRangeError} When using `takeLast(i)`, it delivers an
* ArgumentOutOrRangeError to the Observer's `error` callback if `i < 0`.
* @param total
* @return {any}
*
* @param {number} count The maximum number of values to emit from the end of
* the sequence of values emitted by the source Observable.
* @return {Observable<T>} An Observable that emits at most the last count
* values emitted by the source Observable.
* @method takeLast
* @owner Observable
*/
export function takeLast<T>(total: number): Observable<T> {
if (total === 0) {
export function takeLast<T>(count: number): Observable<T> {
if (count === 0) {
return new EmptyObservable<T>();
} else {
return this.lift(new TakeLastOperator(total));
return this.lift(new TakeLastOperator(count));
}

@@ -25,3 +53,3 @@ }

export interface TakeLastSignature<T> {
(total: number): Observable<T>;
(count: number): Observable<T>;
}

@@ -28,0 +56,0 @@

@@ -10,4 +10,31 @@ import {Operator} from '../Operator';

/**
* @param notifier
* @return {Observable<R>|WebSocketSubject<T>|Observable<T>}
* Emits the values emitted by the source Observable until a `notifier`
* Observable emits a value.
*
* <span class="informal">Lets values pass until a second Observable,
* `notifier`, emits something. Then, it completes.</span>
*
* <img src="./img/takeUntil.png" width="100%">
*
* `takeUntil` subscribes and begins mirroring the source Observable. It also
* monitors a second Observable, `notifier` that you provide. If the `notifier`
* emits a value or a complete notification, the output Observable stops
* mirroring the source Observable and completes.
*
* @example <caption>Tick every second until the first click happens</caption>
* var interval = Rx.Observable.interval(1000);
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = interval.takeUntil(clicks);
* result.subscribe(x => console.log(x));
*
* @see {@link take}
* @see {@link takeLast}
* @see {@link takeWhile}
* @see {@link skip}
*
* @param {Observable} notifier The Observable whose first emitted value will
* cause the output Observable of `takeUntil` to stop emitting values from the
* source Observable.
* @return {Observable<T>} An Observable that emits the values from the source
* Observable until such time as `notifier` emits its first value.
* @method takeUntil

@@ -14,0 +41,0 @@ * @owner Observable

@@ -6,4 +6,34 @@ import {Operator} from '../Operator';

/**
* @param predicate
* @return {Observable<R>|WebSocketSubject<T>|Observable<T>}
* Emits values emitted by the source Observable so long as each value satisfies
* the given `predicate`, and then completes as soon as this `predicate` is not
* satisfied.
*
* <span class="informal">Takes values from the source only while they pass the
* condition given. When the first value does not satisfy, it completes.</span>
*
* <img src="./img/takeWhile.png" width="100%">
*
* `takeWhile` subscribes and begins mirroring the source Observable. Each value
* emitted on the source is given to the `predicate` function which returns a
* boolean, representing a condition to be satisfied by the source values. The
* output Observable emits the source values until such time as the `predicate`
* returns false, at which point `takeWhile` stops mirroring the source
* Observable and completes the output Observable.
*
* @example <caption>Emit click events only while the clientX property is greater than 200</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.takeWhile(ev => ev.clientX > 200);
* result.subscribe(x => console.log(x));
*
* @see {@link take}
* @see {@link takeLast}
* @see {@link takeUntil}
* @see {@link skip}
*
* @param {function(value: T, index: number): boolean} predicate A function that
* evaluates a value emitted by the source Observable and returns a boolean.
* Also takes the (zero-based) index as the second argument.
* @return {Observable<T>} An Observable that emits the values from the source
* Observable so long as each value satisfies the condition defined by the
* `predicate`, then completes.
* @method takeWhile

@@ -10,0 +40,0 @@ * @owner Observable

@@ -11,4 +11,36 @@ import {Operator} from '../Operator';

/**
* @param durationSelector
* @return {Observable<R>|WebSocketSubject<T>|Observable<T>}
* Emits a value from the source Observable, then ignores subsequent source
* values for a duration determined by another Observable, then repeats this
* process.
*
* <span class="informal">It's like {@link throttleTime}, but the silencing
* duration is determined by a second Observable.</span>
*
* <img src="./img/throttle.png" width="100%">
*
* `throttle` emits the source Observable values on the output Observable
* when its internal timer is disabled, and ignores source values when the timer
* is enabled. Initially, the timer is disabled. As soon as the first source
* value arrives, it is forwarded to the output Observable, and then the timer
* is enabled by calling the `durationSelector` function with the source value,
* which returns the "duration" Observable. When the duration Observable emits a
* value or completes, the timer is disabled, and this process repeats for the
* next source value.
*
* @example <caption>Emit clicks at a rate of at most one click per second</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.throttle(ev => Rx.Observable.interval(1000));
* result.subscribe(x => console.log(x));
*
* @see {@link audit}
* @see {@link debounce}
* @see {@link delayWhen}
* @see {@link sample}
* @see {@link throttleTime}
*
* @param {function(value: T): Observable|Promise} durationSelector A function
* that receives a value from the source Observable, for computing the silencing
* duration for each source value, returned as an Observable or a Promise.
* @return {Observable<T>} An Observable that performs the throttle operation to
* limit the rate of emissions from the source.
* @method throttle

@@ -15,0 +47,0 @@ * @owner Observable

@@ -9,22 +9,55 @@ import {Operator} from '../Operator';

/**
* @param delay
* @param scheduler
* @return {Observable<R>|WebSocketSubject<T>|Observable<T>}
* Emits a value from the source Observable, then ignores subsequent source
* values for `duration` milliseconds, then repeats this process.
*
* <span class="informal">Lets a value pass, then ignores source values for the
* next `duration` milliseconds.</span>
*
* <img src="./img/throttleTime.png" width="100%">
*
* `throttleTime` emits the source Observable values on the output Observable
* when its internal timer is disabled, and ignores source values when the timer
* is enabled. Initially, the timer is disabled. As soon as the first source
* value arrives, it is forwarded to the output Observable, and then the timer
* is enabled. After `duration` milliseconds (or the time unit determined
* internally by the optional `scheduler`) has passed, the timer is disabled,
* and this process repeats for the next source value. Optionally takes a
* {@link Scheduler} for managing timers.
*
* @example <caption>Emit clicks at a rate of at most one click per second</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.throttleTime(1000);
* result.subscribe(x => console.log(x));
*
* @see {@link auditTime}
* @see {@link debounceTime}
* @see {@link delay}
* @see {@link sampleTime}
* @see {@link throttle}
*
* @param {number} duration Time to wait before emitting another value after
* emitting the last value, measured in milliseconds or the time unit determined
* internally by the optional `scheduler`.
* @param {Scheduler} [scheduler=async] The {@link Scheduler} to use for
* managing the timers that handle the sampling.
* @return {Observable<T>} An Observable that performs the throttle operation to
* limit the rate of emissions from the source.
* @method throttleTime
* @owner Observable
*/
export function throttleTime<T>(delay: number, scheduler: Scheduler = async): Observable<T> {
return this.lift(new ThrottleTimeOperator(delay, scheduler));
export function throttleTime<T>(duration: number, scheduler: Scheduler = async): Observable<T> {
return this.lift(new ThrottleTimeOperator(duration, scheduler));
}
export interface ThrottleTimeSignature<T> {
(dueTime: number, scheduler?: Scheduler): Observable<T>;
(duration: number, scheduler?: Scheduler): Observable<T>;
}
class ThrottleTimeOperator<T> implements Operator<T, T> {
constructor(private delay: number, private scheduler: Scheduler) {
constructor(private duration: number,
private scheduler: Scheduler) {
}
call(subscriber: Subscriber<T>, source: any): any {
return source._subscribe(new ThrottleTimeSubscriber(subscriber, this.delay, this.scheduler));
return source._subscribe(new ThrottleTimeSubscriber(subscriber, this.duration, this.scheduler));
}

@@ -42,3 +75,3 @@ }

constructor(destination: Subscriber<T>,
private delay: number,
private duration: number,
private scheduler: Scheduler) {

@@ -50,3 +83,3 @@ super(destination);

if (!this.throttled) {
this.add(this.throttled = this.scheduler.schedule(dispatchNext, this.delay, { subscriber: this }));
this.add(this.throttled = this.scheduler.schedule(dispatchNext, this.duration, { subscriber: this }));
this.destination.next(value);

@@ -53,0 +86,0 @@ }

@@ -22,2 +22,3 @@ /* tslint:disable:no-unused-variable */

import './add/observable/fromPromise';
import './add/observable/generate';
import './add/observable/interval';

@@ -141,4 +142,5 @@ import './add/observable/merge';

import {$$rxSubscriber as rxSubscriber} from './symbol/rxSubscriber';
import {$$observable as observable} from './symbol/observable';
import {$$iterator as iterator} from './symbol/iterator';
import * as observable from 'symbol-observable';
/* tslint:enable:no-unused-variable */

@@ -145,0 +147,0 @@

@@ -7,3 +7,2 @@ import {root} from './root';

import {$$iterator} from '../symbol/iterator';
import {$$observable} from '../symbol/observable';
import {Subscription} from '../Subscription';

@@ -13,2 +12,4 @@ import {InnerSubscriber} from '../InnerSubscriber';

import * as $$observable from 'symbol-observable';
export function subscribeToResult<T, R>(outerSubscriber: OuterSubscriber<T, R>,

@@ -15,0 +16,0 @@ result: any,

@@ -7,4 +7,4 @@ "use strict";

var iterator_1 = require('../symbol/iterator');
var observable_1 = require('../symbol/observable');
var InnerSubscriber_1 = require('../InnerSubscriber');
var $$observable = require('symbol-observable');
function subscribeToResult(outerSubscriber, result, outerValue, outerIndex) {

@@ -58,4 +58,4 @@ var destination = new InnerSubscriber_1.InnerSubscriber(outerSubscriber, outerValue, outerIndex);

}
else if (typeof result[observable_1.$$observable] === 'function') {
var obs = result[observable_1.$$observable]();
else if (typeof result[$$observable] === 'function') {
var obs = result[$$observable]();
if (typeof obs.subscribe !== 'function') {

@@ -62,0 +62,0 @@ destination.error('invalid observable');

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc