Template Upload
This commit is contained in:
778
node_modules/rx/dist/rx.aggregates.js
generated
vendored
Normal file
778
node_modules/rx/dist/rx.aggregates.js
generated
vendored
Normal file
@ -0,0 +1,778 @@
|
||||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
;(function (factory) {
|
||||
var objectTypes = {
|
||||
'boolean': false,
|
||||
'function': true,
|
||||
'object': true,
|
||||
'number': false,
|
||||
'string': false,
|
||||
'undefined': false
|
||||
};
|
||||
|
||||
var root = (objectTypes[typeof window] && window) || this,
|
||||
freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports,
|
||||
freeModule = objectTypes[typeof module] && module && !module.nodeType && module,
|
||||
moduleExports = freeModule && freeModule.exports === freeExports && freeExports,
|
||||
freeGlobal = objectTypes[typeof global] && global;
|
||||
|
||||
if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) {
|
||||
root = freeGlobal;
|
||||
}
|
||||
|
||||
// Because of build optimizers
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['rx'], function (Rx, exports) {
|
||||
return factory(root, exports, Rx);
|
||||
});
|
||||
} else if (typeof module === 'object' && module && module.exports === freeExports) {
|
||||
module.exports = factory(root, module.exports, require('./rx'));
|
||||
} else {
|
||||
root.Rx = factory(root, {}, root.Rx);
|
||||
}
|
||||
}.call(this, function (root, exp, Rx, undefined) {
|
||||
|
||||
// References
|
||||
var Observable = Rx.Observable,
|
||||
observableProto = Observable.prototype,
|
||||
CompositeDisposable = Rx.CompositeDisposable,
|
||||
AnonymousObservable = Rx.AnonymousObservable,
|
||||
disposableEmpty = Rx.Disposable.empty,
|
||||
isEqual = Rx.internals.isEqual,
|
||||
helpers = Rx.helpers,
|
||||
not = helpers.not,
|
||||
defaultComparer = helpers.defaultComparer,
|
||||
identity = helpers.identity,
|
||||
defaultSubComparer = helpers.defaultSubComparer,
|
||||
isFunction = helpers.isFunction,
|
||||
isPromise = helpers.isPromise,
|
||||
isArrayLike = helpers.isArrayLike,
|
||||
isIterable = helpers.isIterable,
|
||||
observableFromPromise = Observable.fromPromise,
|
||||
observableFrom = Observable.from,
|
||||
bindCallback = Rx.internals.bindCallback;
|
||||
|
||||
// Defaults
|
||||
var argumentOutOfRange = 'Argument out of range',
|
||||
sequenceContainsNoElements = "Sequence contains no elements.";
|
||||
|
||||
function extremaBy(source, keySelector, comparer) {
|
||||
return new AnonymousObservable(function (o) {
|
||||
var hasValue = false, lastKey = null, list = [];
|
||||
return source.subscribe(function (x) {
|
||||
var comparison, key;
|
||||
try {
|
||||
key = keySelector(x);
|
||||
} catch (ex) {
|
||||
o.onError(ex);
|
||||
return;
|
||||
}
|
||||
comparison = 0;
|
||||
if (!hasValue) {
|
||||
hasValue = true;
|
||||
lastKey = key;
|
||||
} else {
|
||||
try {
|
||||
comparison = comparer(key, lastKey);
|
||||
} catch (ex1) {
|
||||
o.onError(ex1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (comparison > 0) {
|
||||
lastKey = key;
|
||||
list = [];
|
||||
}
|
||||
if (comparison >= 0) { list.push(x); }
|
||||
}, function (e) { o.onError(e); }, function () {
|
||||
o.onNext(list);
|
||||
o.onCompleted();
|
||||
});
|
||||
}, source);
|
||||
}
|
||||
|
||||
function firstOnly(x) {
|
||||
if (x.length === 0) { throw new Error(sequenceContainsNoElements); }
|
||||
return x[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specified seed value is used as the initial accumulator value.
|
||||
* For aggregation behavior with incremental intermediate results, see Observable.scan.
|
||||
* @deprecated Use #reduce instead
|
||||
* @param {Mixed} [seed] The initial accumulator value.
|
||||
* @param {Function} accumulator An accumulator function to be invoked on each element.
|
||||
* @returns {Observable} An observable sequence containing a single element with the final accumulator value.
|
||||
*/
|
||||
observableProto.aggregate = function () {
|
||||
//deprecate('aggregate', 'reduce');
|
||||
var hasSeed = false, accumulator, seed, source = this;
|
||||
if (arguments.length === 2) {
|
||||
hasSeed = true;
|
||||
seed = arguments[0];
|
||||
accumulator = arguments[1];
|
||||
} else {
|
||||
accumulator = arguments[0];
|
||||
}
|
||||
return new AnonymousObservable(function (o) {
|
||||
var hasAccumulation, accumulation, hasValue;
|
||||
return source.subscribe (
|
||||
function (x) {
|
||||
!hasValue && (hasValue = true);
|
||||
try {
|
||||
if (hasAccumulation) {
|
||||
accumulation = accumulator(accumulation, x);
|
||||
} else {
|
||||
accumulation = hasSeed ? accumulator(seed, x) : x;
|
||||
hasAccumulation = true;
|
||||
}
|
||||
} catch (e) {
|
||||
o.onError(e);
|
||||
return;
|
||||
}
|
||||
},
|
||||
function (e) { o.onError(e); },
|
||||
function () {
|
||||
hasValue && o.onNext(accumulation);
|
||||
!hasValue && hasSeed && o.onNext(seed);
|
||||
!hasValue && !hasSeed && o.onError(new Error(sequenceContainsNoElements));
|
||||
o.onCompleted();
|
||||
}
|
||||
);
|
||||
}, source);
|
||||
};
|
||||
|
||||
/**
|
||||
* Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specified seed value is used as the initial accumulator value.
|
||||
* For aggregation behavior with incremental intermediate results, see Observable.scan.
|
||||
* @param {Function} accumulator An accumulator function to be invoked on each element.
|
||||
* @param {Any} [seed] The initial accumulator value.
|
||||
* @returns {Observable} An observable sequence containing a single element with the final accumulator value.
|
||||
*/
|
||||
observableProto.reduce = function (accumulator) {
|
||||
var hasSeed = false, seed, source = this;
|
||||
if (arguments.length === 2) {
|
||||
hasSeed = true;
|
||||
seed = arguments[1];
|
||||
}
|
||||
return new AnonymousObservable(function (o) {
|
||||
var hasAccumulation, accumulation, hasValue;
|
||||
return source.subscribe (
|
||||
function (x) {
|
||||
!hasValue && (hasValue = true);
|
||||
try {
|
||||
if (hasAccumulation) {
|
||||
accumulation = accumulator(accumulation, x);
|
||||
} else {
|
||||
accumulation = hasSeed ? accumulator(seed, x) : x;
|
||||
hasAccumulation = true;
|
||||
}
|
||||
} catch (e) {
|
||||
o.onError(e);
|
||||
return;
|
||||
}
|
||||
},
|
||||
function (e) { o.onError(e); },
|
||||
function () {
|
||||
hasValue && o.onNext(accumulation);
|
||||
!hasValue && hasSeed && o.onNext(seed);
|
||||
!hasValue && !hasSeed && o.onError(new Error(sequenceContainsNoElements));
|
||||
o.onCompleted();
|
||||
}
|
||||
);
|
||||
}, source);
|
||||
};
|
||||
|
||||
/**
|
||||
* Determines whether any element of an observable sequence satisfies a condition if present, else if any items are in the sequence.
|
||||
* @param {Function} [predicate] A function to test each element for a condition.
|
||||
* @returns {Observable} An observable sequence containing a single element determining whether any elements in the source sequence pass the test in the specified predicate if given, else if any items are in the sequence.
|
||||
*/
|
||||
observableProto.some = function (predicate, thisArg) {
|
||||
var source = this;
|
||||
return predicate ?
|
||||
source.filter(predicate, thisArg).some() :
|
||||
new AnonymousObservable(function (observer) {
|
||||
return source.subscribe(function () {
|
||||
observer.onNext(true);
|
||||
observer.onCompleted();
|
||||
}, function (e) { observer.onError(e); }, function () {
|
||||
observer.onNext(false);
|
||||
observer.onCompleted();
|
||||
});
|
||||
}, source);
|
||||
};
|
||||
|
||||
/** @deprecated use #some instead */
|
||||
observableProto.any = function () {
|
||||
//deprecate('any', 'some');
|
||||
return this.some.apply(this, arguments);
|
||||
};
|
||||
|
||||
/**
|
||||
* Determines whether an observable sequence is empty.
|
||||
* @returns {Observable} An observable sequence containing a single element determining whether the source sequence is empty.
|
||||
*/
|
||||
observableProto.isEmpty = function () {
|
||||
return this.any().map(not);
|
||||
};
|
||||
|
||||
/**
|
||||
* Determines whether all elements of an observable sequence satisfy a condition.
|
||||
* @param {Function} [predicate] A function to test each element for a condition.
|
||||
* @param {Any} [thisArg] Object to use as this when executing callback.
|
||||
* @returns {Observable} An observable sequence containing a single element determining whether all elements in the source sequence pass the test in the specified predicate.
|
||||
*/
|
||||
observableProto.every = function (predicate, thisArg) {
|
||||
return this.filter(function (v) { return !predicate(v); }, thisArg).some().map(not);
|
||||
};
|
||||
|
||||
/** @deprecated use #every instead */
|
||||
observableProto.all = function () {
|
||||
//deprecate('all', 'every');
|
||||
return this.every.apply(this, arguments);
|
||||
};
|
||||
|
||||
/**
|
||||
* Determines whether an observable sequence contains a specified element with an optional equality comparer.
|
||||
* @param searchElement The value to locate in the source sequence.
|
||||
* @param {Number} [fromIndex] An equality comparer to compare elements.
|
||||
* @returns {Observable} An observable sequence containing a single element determining whether the source sequence contains an element that has the specified value from the given index.
|
||||
*/
|
||||
observableProto.contains = function (searchElement, fromIndex) {
|
||||
var source = this;
|
||||
function comparer(a, b) {
|
||||
return (a === 0 && b === 0) || (a === b || (isNaN(a) && isNaN(b)));
|
||||
}
|
||||
return new AnonymousObservable(function (o) {
|
||||
var i = 0, n = +fromIndex || 0;
|
||||
Math.abs(n) === Infinity && (n = 0);
|
||||
if (n < 0) {
|
||||
o.onNext(false);
|
||||
o.onCompleted();
|
||||
return disposableEmpty;
|
||||
}
|
||||
return source.subscribe(
|
||||
function (x) {
|
||||
if (i++ >= n && comparer(x, searchElement)) {
|
||||
o.onNext(true);
|
||||
o.onCompleted();
|
||||
}
|
||||
},
|
||||
function (e) { o.onError(e); },
|
||||
function () {
|
||||
o.onNext(false);
|
||||
o.onCompleted();
|
||||
});
|
||||
}, this);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an observable sequence containing a value that represents how many elements in the specified observable sequence satisfy a condition if provided, else the count of items.
|
||||
* @example
|
||||
* res = source.count();
|
||||
* res = source.count(function (x) { return x > 3; });
|
||||
* @param {Function} [predicate]A function to test each element for a condition.
|
||||
* @param {Any} [thisArg] Object to use as this when executing callback.
|
||||
* @returns {Observable} An observable sequence containing a single element with a number that represents how many elements in the input sequence satisfy the condition in the predicate function if provided, else the count of items in the sequence.
|
||||
*/
|
||||
observableProto.count = function (predicate, thisArg) {
|
||||
return predicate ?
|
||||
this.filter(predicate, thisArg).count() :
|
||||
this.reduce(function (count) { return count + 1; }, 0);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the first index at which a given element can be found in the observable sequence, or -1 if it is not present.
|
||||
* @param {Any} searchElement Element to locate in the array.
|
||||
* @param {Number} [fromIndex] The index to start the search. If not specified, defaults to 0.
|
||||
* @returns {Observable} And observable sequence containing the first index at which a given element can be found in the observable sequence, or -1 if it is not present.
|
||||
*/
|
||||
observableProto.indexOf = function(searchElement, fromIndex) {
|
||||
var source = this;
|
||||
return new AnonymousObservable(function (o) {
|
||||
var i = 0, n = +fromIndex || 0;
|
||||
Math.abs(n) === Infinity && (n = 0);
|
||||
if (n < 0) {
|
||||
o.onNext(-1);
|
||||
o.onCompleted();
|
||||
return disposableEmpty;
|
||||
}
|
||||
return source.subscribe(
|
||||
function (x) {
|
||||
if (i >= n && x === searchElement) {
|
||||
o.onNext(i);
|
||||
o.onCompleted();
|
||||
}
|
||||
i++;
|
||||
},
|
||||
function (e) { o.onError(e); },
|
||||
function () {
|
||||
o.onNext(-1);
|
||||
o.onCompleted();
|
||||
});
|
||||
}, source);
|
||||
};
|
||||
|
||||
/**
|
||||
* Computes the sum of a sequence of values that are obtained by invoking an optional transform function on each element of the input sequence, else if not specified computes the sum on each item in the sequence.
|
||||
* @param {Function} [selector] A transform function to apply to each element.
|
||||
* @param {Any} [thisArg] Object to use as this when executing callback.
|
||||
* @returns {Observable} An observable sequence containing a single element with the sum of the values in the source sequence.
|
||||
*/
|
||||
observableProto.sum = function (keySelector, thisArg) {
|
||||
return keySelector && isFunction(keySelector) ?
|
||||
this.map(keySelector, thisArg).sum() :
|
||||
this.reduce(function (prev, curr) { return prev + curr; }, 0);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the elements in an observable sequence with the minimum key value according to the specified comparer.
|
||||
* @example
|
||||
* var res = source.minBy(function (x) { return x.value; });
|
||||
* var res = source.minBy(function (x) { return x.value; }, function (x, y) { return x - y; });
|
||||
* @param {Function} keySelector Key selector function.
|
||||
* @param {Function} [comparer] Comparer used to compare key values.
|
||||
* @returns {Observable} An observable sequence containing a list of zero or more elements that have a minimum key value.
|
||||
*/
|
||||
observableProto.minBy = function (keySelector, comparer) {
|
||||
comparer || (comparer = defaultSubComparer);
|
||||
return extremaBy(this, keySelector, function (x, y) { return comparer(x, y) * -1; });
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the minimum element in an observable sequence according to the optional comparer else a default greater than less than check.
|
||||
* @example
|
||||
* var res = source.min();
|
||||
* var res = source.min(function (x, y) { return x.value - y.value; });
|
||||
* @param {Function} [comparer] Comparer used to compare elements.
|
||||
* @returns {Observable} An observable sequence containing a single element with the minimum element in the source sequence.
|
||||
*/
|
||||
observableProto.min = function (comparer) {
|
||||
return this.minBy(identity, comparer).map(function (x) { return firstOnly(x); });
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the elements in an observable sequence with the maximum key value according to the specified comparer.
|
||||
* @example
|
||||
* var res = source.maxBy(function (x) { return x.value; });
|
||||
* var res = source.maxBy(function (x) { return x.value; }, function (x, y) { return x - y;; });
|
||||
* @param {Function} keySelector Key selector function.
|
||||
* @param {Function} [comparer] Comparer used to compare key values.
|
||||
* @returns {Observable} An observable sequence containing a list of zero or more elements that have a maximum key value.
|
||||
*/
|
||||
observableProto.maxBy = function (keySelector, comparer) {
|
||||
comparer || (comparer = defaultSubComparer);
|
||||
return extremaBy(this, keySelector, comparer);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the maximum value in an observable sequence according to the specified comparer.
|
||||
* @example
|
||||
* var res = source.max();
|
||||
* var res = source.max(function (x, y) { return x.value - y.value; });
|
||||
* @param {Function} [comparer] Comparer used to compare elements.
|
||||
* @returns {Observable} An observable sequence containing a single element with the maximum element in the source sequence.
|
||||
*/
|
||||
observableProto.max = function (comparer) {
|
||||
return this.maxBy(identity, comparer).map(function (x) { return firstOnly(x); });
|
||||
};
|
||||
|
||||
/**
|
||||
* Computes the average of an observable sequence of values that are in the sequence or obtained by invoking a transform function on each element of the input sequence if present.
|
||||
* @param {Function} [selector] A transform function to apply to each element.
|
||||
* @param {Any} [thisArg] Object to use as this when executing callback.
|
||||
* @returns {Observable} An observable sequence containing a single element with the average of the sequence of values.
|
||||
*/
|
||||
observableProto.average = function (keySelector, thisArg) {
|
||||
return keySelector && isFunction(keySelector) ?
|
||||
this.map(keySelector, thisArg).average() :
|
||||
this.reduce(function (prev, cur) {
|
||||
return {
|
||||
sum: prev.sum + cur,
|
||||
count: prev.count + 1
|
||||
};
|
||||
}, {sum: 0, count: 0 }).map(function (s) {
|
||||
if (s.count === 0) { throw new Error(sequenceContainsNoElements); }
|
||||
return s.sum / s.count;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Determines whether two sequences are equal by comparing the elements pairwise using a specified equality comparer.
|
||||
*
|
||||
* @example
|
||||
* var res = res = source.sequenceEqual([1,2,3]);
|
||||
* var res = res = source.sequenceEqual([{ value: 42 }], function (x, y) { return x.value === y.value; });
|
||||
* 3 - res = source.sequenceEqual(Rx.Observable.returnValue(42));
|
||||
* 4 - res = source.sequenceEqual(Rx.Observable.returnValue({ value: 42 }), function (x, y) { return x.value === y.value; });
|
||||
* @param {Observable} second Second observable sequence or array to compare.
|
||||
* @param {Function} [comparer] Comparer used to compare elements of both sequences.
|
||||
* @returns {Observable} An observable sequence that contains a single element which indicates whether both sequences are of equal length and their corresponding elements are equal according to the specified equality comparer.
|
||||
*/
|
||||
observableProto.sequenceEqual = function (second, comparer) {
|
||||
var first = this;
|
||||
comparer || (comparer = defaultComparer);
|
||||
return new AnonymousObservable(function (o) {
|
||||
var donel = false, doner = false, ql = [], qr = [];
|
||||
var subscription1 = first.subscribe(function (x) {
|
||||
var equal, v;
|
||||
if (qr.length > 0) {
|
||||
v = qr.shift();
|
||||
try {
|
||||
equal = comparer(v, x);
|
||||
} catch (e) {
|
||||
o.onError(e);
|
||||
return;
|
||||
}
|
||||
if (!equal) {
|
||||
o.onNext(false);
|
||||
o.onCompleted();
|
||||
}
|
||||
} else if (doner) {
|
||||
o.onNext(false);
|
||||
o.onCompleted();
|
||||
} else {
|
||||
ql.push(x);
|
||||
}
|
||||
}, function(e) { o.onError(e); }, function () {
|
||||
donel = true;
|
||||
if (ql.length === 0) {
|
||||
if (qr.length > 0) {
|
||||
o.onNext(false);
|
||||
o.onCompleted();
|
||||
} else if (doner) {
|
||||
o.onNext(true);
|
||||
o.onCompleted();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
(isArrayLike(second) || isIterable(second)) && (second = observableFrom(second));
|
||||
isPromise(second) && (second = observableFromPromise(second));
|
||||
var subscription2 = second.subscribe(function (x) {
|
||||
var equal;
|
||||
if (ql.length > 0) {
|
||||
var v = ql.shift();
|
||||
try {
|
||||
equal = comparer(v, x);
|
||||
} catch (exception) {
|
||||
o.onError(exception);
|
||||
return;
|
||||
}
|
||||
if (!equal) {
|
||||
o.onNext(false);
|
||||
o.onCompleted();
|
||||
}
|
||||
} else if (donel) {
|
||||
o.onNext(false);
|
||||
o.onCompleted();
|
||||
} else {
|
||||
qr.push(x);
|
||||
}
|
||||
}, function(e) { o.onError(e); }, function () {
|
||||
doner = true;
|
||||
if (qr.length === 0) {
|
||||
if (ql.length > 0) {
|
||||
o.onNext(false);
|
||||
o.onCompleted();
|
||||
} else if (donel) {
|
||||
o.onNext(true);
|
||||
o.onCompleted();
|
||||
}
|
||||
}
|
||||
});
|
||||
return new CompositeDisposable(subscription1, subscription2);
|
||||
}, first);
|
||||
};
|
||||
|
||||
function elementAtOrDefault(source, index, hasDefault, defaultValue) {
|
||||
if (index < 0) { throw new Error(argumentOutOfRange); }
|
||||
return new AnonymousObservable(function (o) {
|
||||
var i = index;
|
||||
return source.subscribe(function (x) {
|
||||
if (i-- === 0) {
|
||||
o.onNext(x);
|
||||
o.onCompleted();
|
||||
}
|
||||
}, function (e) { o.onError(e); }, function () {
|
||||
if (!hasDefault) {
|
||||
o.onError(new Error(argumentOutOfRange));
|
||||
} else {
|
||||
o.onNext(defaultValue);
|
||||
o.onCompleted();
|
||||
}
|
||||
});
|
||||
}, source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the element at a specified index in a sequence.
|
||||
* @example
|
||||
* var res = source.elementAt(5);
|
||||
* @param {Number} index The zero-based index of the element to retrieve.
|
||||
* @returns {Observable} An observable sequence that produces the element at the specified position in the source sequence.
|
||||
*/
|
||||
observableProto.elementAt = function (index) {
|
||||
return elementAtOrDefault(this, index, false);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the element at a specified index in a sequence or a default value if the index is out of range.
|
||||
* @example
|
||||
* var res = source.elementAtOrDefault(5);
|
||||
* var res = source.elementAtOrDefault(5, 0);
|
||||
* @param {Number} index The zero-based index of the element to retrieve.
|
||||
* @param [defaultValue] The default value if the index is outside the bounds of the source sequence.
|
||||
* @returns {Observable} An observable sequence that produces the element at the specified position in the source sequence, or a default value if the index is outside the bounds of the source sequence.
|
||||
*/
|
||||
observableProto.elementAtOrDefault = function (index, defaultValue) {
|
||||
return elementAtOrDefault(this, index, true, defaultValue);
|
||||
};
|
||||
|
||||
function singleOrDefaultAsync(source, hasDefault, defaultValue) {
|
||||
return new AnonymousObservable(function (o) {
|
||||
var value = defaultValue, seenValue = false;
|
||||
return source.subscribe(function (x) {
|
||||
if (seenValue) {
|
||||
o.onError(new Error('Sequence contains more than one element'));
|
||||
} else {
|
||||
value = x;
|
||||
seenValue = true;
|
||||
}
|
||||
}, function (e) { o.onError(e); }, function () {
|
||||
if (!seenValue && !hasDefault) {
|
||||
o.onError(new Error(sequenceContainsNoElements));
|
||||
} else {
|
||||
o.onNext(value);
|
||||
o.onCompleted();
|
||||
}
|
||||
});
|
||||
}, source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the only element of an observable sequence that satisfies the condition in the optional predicate, and reports an exception if there is not exactly one element in the observable sequence.
|
||||
* @param {Function} [predicate] A predicate function to evaluate for elements in the source sequence.
|
||||
* @param {Any} [thisArg] Object to use as `this` when executing the predicate.
|
||||
* @returns {Observable} Sequence containing the single element in the observable sequence that satisfies the condition in the predicate.
|
||||
*/
|
||||
observableProto.single = function (predicate, thisArg) {
|
||||
return predicate && isFunction(predicate) ?
|
||||
this.where(predicate, thisArg).single() :
|
||||
singleOrDefaultAsync(this, false);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the only element of an observable sequence that matches the predicate, or a default value if no such element exists; this method reports an exception if there is more than one element in the observable sequence.
|
||||
* @example
|
||||
* var res = res = source.singleOrDefault();
|
||||
* var res = res = source.singleOrDefault(function (x) { return x === 42; });
|
||||
* res = source.singleOrDefault(function (x) { return x === 42; }, 0);
|
||||
* res = source.singleOrDefault(null, 0);
|
||||
* @memberOf Observable#
|
||||
* @param {Function} predicate A predicate function to evaluate for elements in the source sequence.
|
||||
* @param [defaultValue] The default value if the index is outside the bounds of the source sequence.
|
||||
* @param {Any} [thisArg] Object to use as `this` when executing the predicate.
|
||||
* @returns {Observable} Sequence containing the single element in the observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.
|
||||
*/
|
||||
observableProto.singleOrDefault = function (predicate, defaultValue, thisArg) {
|
||||
return predicate && isFunction(predicate) ?
|
||||
this.filter(predicate, thisArg).singleOrDefault(null, defaultValue) :
|
||||
singleOrDefaultAsync(this, true, defaultValue);
|
||||
};
|
||||
|
||||
function firstOrDefaultAsync(source, hasDefault, defaultValue) {
|
||||
return new AnonymousObservable(function (o) {
|
||||
return source.subscribe(function (x) {
|
||||
o.onNext(x);
|
||||
o.onCompleted();
|
||||
}, function (e) { o.onError(e); }, function () {
|
||||
if (!hasDefault) {
|
||||
o.onError(new Error(sequenceContainsNoElements));
|
||||
} else {
|
||||
o.onNext(defaultValue);
|
||||
o.onCompleted();
|
||||
}
|
||||
});
|
||||
}, source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first element of an observable sequence that satisfies the condition in the predicate if present else the first item in the sequence.
|
||||
* @example
|
||||
* var res = res = source.first();
|
||||
* var res = res = source.first(function (x) { return x > 3; });
|
||||
* @param {Function} [predicate] A predicate function to evaluate for elements in the source sequence.
|
||||
* @param {Any} [thisArg] Object to use as `this` when executing the predicate.
|
||||
* @returns {Observable} Sequence containing the first element in the observable sequence that satisfies the condition in the predicate if provided, else the first item in the sequence.
|
||||
*/
|
||||
observableProto.first = function (predicate, thisArg) {
|
||||
return predicate ?
|
||||
this.where(predicate, thisArg).first() :
|
||||
firstOrDefaultAsync(this, false);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the first element of an observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.
|
||||
* @param {Function} [predicate] A predicate function to evaluate for elements in the source sequence.
|
||||
* @param {Any} [defaultValue] The default value if no such element exists. If not specified, defaults to null.
|
||||
* @param {Any} [thisArg] Object to use as `this` when executing the predicate.
|
||||
* @returns {Observable} Sequence containing the first element in the observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.
|
||||
*/
|
||||
observableProto.firstOrDefault = function (predicate, defaultValue, thisArg) {
|
||||
return predicate ?
|
||||
this.where(predicate).firstOrDefault(null, defaultValue) :
|
||||
firstOrDefaultAsync(this, true, defaultValue);
|
||||
};
|
||||
|
||||
function lastOrDefaultAsync(source, hasDefault, defaultValue) {
|
||||
return new AnonymousObservable(function (o) {
|
||||
var value = defaultValue, seenValue = false;
|
||||
return source.subscribe(function (x) {
|
||||
value = x;
|
||||
seenValue = true;
|
||||
}, function (e) { o.onError(e); }, function () {
|
||||
if (!seenValue && !hasDefault) {
|
||||
o.onError(new Error(sequenceContainsNoElements));
|
||||
} else {
|
||||
o.onNext(value);
|
||||
o.onCompleted();
|
||||
}
|
||||
});
|
||||
}, source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last element of an observable sequence that satisfies the condition in the predicate if specified, else the last element.
|
||||
* @param {Function} [predicate] A predicate function to evaluate for elements in the source sequence.
|
||||
* @param {Any} [thisArg] Object to use as `this` when executing the predicate.
|
||||
* @returns {Observable} Sequence containing the last element in the observable sequence that satisfies the condition in the predicate.
|
||||
*/
|
||||
observableProto.last = function (predicate, thisArg) {
|
||||
return predicate ?
|
||||
this.where(predicate, thisArg).last() :
|
||||
lastOrDefaultAsync(this, false);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the last element of an observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.
|
||||
* @param {Function} [predicate] A predicate function to evaluate for elements in the source sequence.
|
||||
* @param [defaultValue] The default value if no such element exists. If not specified, defaults to null.
|
||||
* @param {Any} [thisArg] Object to use as `this` when executing the predicate.
|
||||
* @returns {Observable} Sequence containing the last element in the observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.
|
||||
*/
|
||||
observableProto.lastOrDefault = function (predicate, defaultValue, thisArg) {
|
||||
return predicate ?
|
||||
this.where(predicate, thisArg).lastOrDefault(null, defaultValue) :
|
||||
lastOrDefaultAsync(this, true, defaultValue);
|
||||
};
|
||||
|
||||
function findValue (source, predicate, thisArg, yieldIndex) {
|
||||
var callback = bindCallback(predicate, thisArg, 3);
|
||||
return new AnonymousObservable(function (o) {
|
||||
var i = 0;
|
||||
return source.subscribe(function (x) {
|
||||
var shouldRun;
|
||||
try {
|
||||
shouldRun = callback(x, i, source);
|
||||
} catch (e) {
|
||||
o.onError(e);
|
||||
return;
|
||||
}
|
||||
if (shouldRun) {
|
||||
o.onNext(yieldIndex ? i : x);
|
||||
o.onCompleted();
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}, function (e) { o.onError(e); }, function () {
|
||||
o.onNext(yieldIndex ? -1 : undefined);
|
||||
o.onCompleted();
|
||||
});
|
||||
}, source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire Observable sequence.
|
||||
* @param {Function} predicate The predicate that defines the conditions of the element to search for.
|
||||
* @param {Any} [thisArg] Object to use as `this` when executing the predicate.
|
||||
* @returns {Observable} An Observable sequence with the first element that matches the conditions defined by the specified predicate, if found; otherwise, undefined.
|
||||
*/
|
||||
observableProto.find = function (predicate, thisArg) {
|
||||
return findValue(this, predicate, thisArg, false);
|
||||
};
|
||||
|
||||
/**
|
||||
* Searches for an element that matches the conditions defined by the specified predicate, and returns
|
||||
* an Observable sequence with the zero-based index of the first occurrence within the entire Observable sequence.
|
||||
* @param {Function} predicate The predicate that defines the conditions of the element to search for.
|
||||
* @param {Any} [thisArg] Object to use as `this` when executing the predicate.
|
||||
* @returns {Observable} An Observable sequence with the zero-based index of the first occurrence of an element that matches the conditions defined by match, if found; otherwise, –1.
|
||||
*/
|
||||
observableProto.findIndex = function (predicate, thisArg) {
|
||||
return findValue(this, predicate, thisArg, true);
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts the observable sequence to a Set if it exists.
|
||||
* @returns {Observable} An observable sequence with a single value of a Set containing the values from the observable sequence.
|
||||
*/
|
||||
observableProto.toSet = function () {
|
||||
if (typeof root.Set === 'undefined') { throw new TypeError(); }
|
||||
var source = this;
|
||||
return new AnonymousObservable(function (o) {
|
||||
var s = new root.Set();
|
||||
return source.subscribe(
|
||||
function (x) { s.add(x); },
|
||||
function (e) { o.onError(e); },
|
||||
function () {
|
||||
o.onNext(s);
|
||||
o.onCompleted();
|
||||
});
|
||||
}, source);
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts the observable sequence to a Map if it exists.
|
||||
* @param {Function} keySelector A function which produces the key for the Map.
|
||||
* @param {Function} [elementSelector] An optional function which produces the element for the Map. If not present, defaults to the value from the observable sequence.
|
||||
* @returns {Observable} An observable sequence with a single value of a Map containing the values from the observable sequence.
|
||||
*/
|
||||
observableProto.toMap = function (keySelector, elementSelector) {
|
||||
if (typeof root.Map === 'undefined') { throw new TypeError(); }
|
||||
var source = this;
|
||||
return new AnonymousObservable(function (o) {
|
||||
var m = new root.Map();
|
||||
return source.subscribe(
|
||||
function (x) {
|
||||
var key;
|
||||
try {
|
||||
key = keySelector(x);
|
||||
} catch (e) {
|
||||
o.onError(e);
|
||||
return;
|
||||
}
|
||||
|
||||
var element = x;
|
||||
if (elementSelector) {
|
||||
try {
|
||||
element = elementSelector(x);
|
||||
} catch (e) {
|
||||
o.onError(e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m.set(key, element);
|
||||
},
|
||||
function (e) { o.onError(e); },
|
||||
function () {
|
||||
o.onNext(m);
|
||||
o.onCompleted();
|
||||
});
|
||||
}, source);
|
||||
};
|
||||
|
||||
return Rx;
|
||||
}));
|
1
node_modules/rx/dist/rx.aggregates.map
generated
vendored
Normal file
1
node_modules/rx/dist/rx.aggregates.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3
node_modules/rx/dist/rx.aggregates.min.js
generated
vendored
Normal file
3
node_modules/rx/dist/rx.aggregates.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
9990
node_modules/rx/dist/rx.all.compat.js
generated
vendored
Normal file
9990
node_modules/rx/dist/rx.all.compat.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/rx/dist/rx.all.compat.map
generated
vendored
Normal file
1
node_modules/rx/dist/rx.all.compat.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
6
node_modules/rx/dist/rx.all.compat.min.js
generated
vendored
Normal file
6
node_modules/rx/dist/rx.all.compat.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
9733
node_modules/rx/dist/rx.all.js
generated
vendored
Normal file
9733
node_modules/rx/dist/rx.all.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/rx/dist/rx.all.map
generated
vendored
Normal file
1
node_modules/rx/dist/rx.all.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
6
node_modules/rx/dist/rx.all.min.js
generated
vendored
Normal file
6
node_modules/rx/dist/rx.all.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
582
node_modules/rx/dist/rx.async.compat.js
generated
vendored
Normal file
582
node_modules/rx/dist/rx.async.compat.js
generated
vendored
Normal file
@ -0,0 +1,582 @@
|
||||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
;(function (factory) {
|
||||
var objectTypes = {
|
||||
'boolean': false,
|
||||
'function': true,
|
||||
'object': true,
|
||||
'number': false,
|
||||
'string': false,
|
||||
'undefined': false
|
||||
};
|
||||
|
||||
var root = (objectTypes[typeof window] && window) || this,
|
||||
freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports,
|
||||
freeModule = objectTypes[typeof module] && module && !module.nodeType && module,
|
||||
moduleExports = freeModule && freeModule.exports === freeExports && freeExports,
|
||||
freeGlobal = objectTypes[typeof global] && global;
|
||||
|
||||
if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) {
|
||||
root = freeGlobal;
|
||||
}
|
||||
|
||||
// Because of build optimizers
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['rx.binding', 'exports'], function (Rx, exports) {
|
||||
root.Rx = factory(root, exports, Rx);
|
||||
return root.Rx;
|
||||
});
|
||||
} else if (typeof module === 'object' && module && module.exports === freeExports) {
|
||||
module.exports = factory(root, module.exports, require('./rx'));
|
||||
} else {
|
||||
root.Rx = factory(root, {}, root.Rx);
|
||||
}
|
||||
}.call(this, function (root, exp, Rx, undefined) {
|
||||
|
||||
// Aliases
|
||||
var Observable = Rx.Observable,
|
||||
observableProto = Observable.prototype,
|
||||
observableFromPromise = Observable.fromPromise,
|
||||
observableThrow = Observable.throwException,
|
||||
AnonymousObservable = Rx.AnonymousObservable,
|
||||
AsyncSubject = Rx.AsyncSubject,
|
||||
disposableCreate = Rx.Disposable.create,
|
||||
CompositeDisposable = Rx.CompositeDisposable,
|
||||
immediateScheduler = Rx.Scheduler.immediate,
|
||||
timeoutScheduler = Rx.Scheduler.timeout,
|
||||
isScheduler = Rx.helpers.isScheduler,
|
||||
slice = Array.prototype.slice;
|
||||
|
||||
var fnString = 'function',
|
||||
throwString = 'throw',
|
||||
isObject = Rx.internals.isObject;
|
||||
|
||||
function toThunk(obj, ctx) {
|
||||
if (Array.isArray(obj)) { return objectToThunk.call(ctx, obj); }
|
||||
if (isGeneratorFunction(obj)) { return observableSpawn(obj.call(ctx)); }
|
||||
if (isGenerator(obj)) { return observableSpawn(obj); }
|
||||
if (isObservable(obj)) { return observableToThunk(obj); }
|
||||
if (isPromise(obj)) { return promiseToThunk(obj); }
|
||||
if (typeof obj === fnString) { return obj; }
|
||||
if (isObject(obj) || Array.isArray(obj)) { return objectToThunk.call(ctx, obj); }
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
function objectToThunk(obj) {
|
||||
var ctx = this;
|
||||
|
||||
return function (done) {
|
||||
var keys = Object.keys(obj),
|
||||
pending = keys.length,
|
||||
results = new obj.constructor(),
|
||||
finished;
|
||||
|
||||
if (!pending) {
|
||||
timeoutScheduler.schedule(function () { done(null, results); });
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
run(obj[keys[i]], keys[i]);
|
||||
}
|
||||
|
||||
function run(fn, key) {
|
||||
if (finished) { return; }
|
||||
try {
|
||||
fn = toThunk(fn, ctx);
|
||||
|
||||
if (typeof fn !== fnString) {
|
||||
results[key] = fn;
|
||||
return --pending || done(null, results);
|
||||
}
|
||||
|
||||
fn.call(ctx, function(err, res) {
|
||||
if (finished) { return; }
|
||||
|
||||
if (err) {
|
||||
finished = true;
|
||||
return done(err);
|
||||
}
|
||||
|
||||
results[key] = res;
|
||||
--pending || done(null, results);
|
||||
});
|
||||
} catch (e) {
|
||||
finished = true;
|
||||
done(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function observableToThunk(observable) {
|
||||
return function (fn) {
|
||||
var value, hasValue = false;
|
||||
observable.subscribe(
|
||||
function (v) {
|
||||
value = v;
|
||||
hasValue = true;
|
||||
},
|
||||
fn,
|
||||
function () {
|
||||
hasValue && fn(null, value);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function promiseToThunk(promise) {
|
||||
return function(fn) {
|
||||
promise.then(function(res) {
|
||||
fn(null, res);
|
||||
}, fn);
|
||||
}
|
||||
}
|
||||
|
||||
function isObservable(obj) {
|
||||
return obj && typeof obj.subscribe === fnString;
|
||||
}
|
||||
|
||||
function isGeneratorFunction(obj) {
|
||||
return obj && obj.constructor && obj.constructor.name === 'GeneratorFunction';
|
||||
}
|
||||
|
||||
function isGenerator(obj) {
|
||||
return obj && typeof obj.next === fnString && typeof obj[throwString] === fnString;
|
||||
}
|
||||
|
||||
/*
|
||||
* Spawns a generator function which allows for Promises, Observable sequences, Arrays, Objects, Generators and functions.
|
||||
* @param {Function} The spawning function.
|
||||
* @returns {Function} a function which has a done continuation.
|
||||
*/
|
||||
var observableSpawn = Rx.spawn = function (fn) {
|
||||
var isGenFun = isGeneratorFunction(fn);
|
||||
|
||||
return function (done) {
|
||||
var ctx = this,
|
||||
gen = fn;
|
||||
|
||||
if (isGenFun) {
|
||||
var args = slice.call(arguments),
|
||||
len = args.length,
|
||||
hasCallback = len && typeof args[len - 1] === fnString;
|
||||
|
||||
done = hasCallback ? args.pop() : handleError;
|
||||
gen = fn.apply(this, args);
|
||||
} else {
|
||||
done = done || handleError;
|
||||
}
|
||||
|
||||
next();
|
||||
|
||||
function exit(err, res) {
|
||||
timeoutScheduler.schedule(done.bind(ctx, err, res));
|
||||
}
|
||||
|
||||
function next(err, res) {
|
||||
var ret;
|
||||
|
||||
// multiple args
|
||||
if (arguments.length > 2) {
|
||||
res = slice.call(arguments, 1);
|
||||
}
|
||||
|
||||
if (err) {
|
||||
try {
|
||||
ret = gen[throwString](err);
|
||||
} catch (e) {
|
||||
return exit(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (!err) {
|
||||
try {
|
||||
ret = gen.next(res);
|
||||
} catch (e) {
|
||||
return exit(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret.done) {
|
||||
return exit(null, ret.value);
|
||||
}
|
||||
|
||||
ret.value = toThunk(ret.value, ctx);
|
||||
|
||||
if (typeof ret.value === fnString) {
|
||||
var called = false;
|
||||
try {
|
||||
ret.value.call(ctx, function() {
|
||||
if (called) {
|
||||
return;
|
||||
}
|
||||
|
||||
called = true;
|
||||
next.apply(ctx, arguments);
|
||||
});
|
||||
} catch (e) {
|
||||
timeoutScheduler.schedule(function () {
|
||||
if (called) {
|
||||
return;
|
||||
}
|
||||
|
||||
called = true;
|
||||
next.call(ctx, e);
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Not supported
|
||||
next(new TypeError('Rx.spawn only supports a function, Promise, Observable, Object or Array.'));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function handleError(err) {
|
||||
if (!err) { return; }
|
||||
timeoutScheduler.schedule(function() {
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes the specified function asynchronously on the specified scheduler, surfacing the result through an observable sequence.
|
||||
*
|
||||
* @example
|
||||
* var res = Rx.Observable.start(function () { console.log('hello'); });
|
||||
* var res = Rx.Observable.start(function () { console.log('hello'); }, Rx.Scheduler.timeout);
|
||||
* var res = Rx.Observable.start(function () { this.log('hello'); }, Rx.Scheduler.timeout, console);
|
||||
*
|
||||
* @param {Function} func Function to run asynchronously.
|
||||
* @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout.
|
||||
* @param [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
|
||||
* @returns {Observable} An observable sequence exposing the function's result value, or an exception.
|
||||
*
|
||||
* Remarks
|
||||
* * The function is called immediately, not during the subscription of the resulting sequence.
|
||||
* * Multiple subscriptions to the resulting sequence can observe the function's result.
|
||||
*/
|
||||
Observable.start = function (func, context, scheduler) {
|
||||
return observableToAsync(func, context, scheduler)();
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
|
||||
* @param {Function} function Function to convert to an asynchronous function.
|
||||
* @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout.
|
||||
* @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
|
||||
* @returns {Function} Asynchronous function.
|
||||
*/
|
||||
var observableToAsync = Observable.toAsync = function (func, context, scheduler) {
|
||||
isScheduler(scheduler) || (scheduler = timeoutScheduler);
|
||||
return function () {
|
||||
var args = arguments,
|
||||
subject = new AsyncSubject();
|
||||
|
||||
scheduler.schedule(function () {
|
||||
var result;
|
||||
try {
|
||||
result = func.apply(context, args);
|
||||
} catch (e) {
|
||||
subject.onError(e);
|
||||
return;
|
||||
}
|
||||
subject.onNext(result);
|
||||
subject.onCompleted();
|
||||
});
|
||||
return subject.asObservable();
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a callback function to an observable sequence.
|
||||
*
|
||||
* @param {Function} function Function with a callback as the last parameter to convert to an Observable sequence.
|
||||
* @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
|
||||
* @param {Function} [selector] A selector which takes the arguments from the callback to produce a single item to yield on next.
|
||||
* @returns {Function} A function, when executed with the required parameters minus the callback, produces an Observable sequence with a single value of the arguments to the callback as an array.
|
||||
*/
|
||||
Observable.fromCallback = function (func, context, selector) {
|
||||
return function () {
|
||||
var args = slice.call(arguments, 0);
|
||||
|
||||
return new AnonymousObservable(function (observer) {
|
||||
function handler() {
|
||||
var results = arguments;
|
||||
|
||||
if (selector) {
|
||||
try {
|
||||
results = selector(results);
|
||||
} catch (err) {
|
||||
observer.onError(err);
|
||||
return;
|
||||
}
|
||||
|
||||
observer.onNext(results);
|
||||
} else {
|
||||
if (results.length <= 1) {
|
||||
observer.onNext.apply(observer, results);
|
||||
} else {
|
||||
observer.onNext(results);
|
||||
}
|
||||
}
|
||||
|
||||
observer.onCompleted();
|
||||
}
|
||||
|
||||
args.push(handler);
|
||||
func.apply(context, args);
|
||||
}).publishLast().refCount();
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a Node.js callback style function to an observable sequence. This must be in function (err, ...) format.
|
||||
* @param {Function} func The function to call
|
||||
* @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
|
||||
* @param {Function} [selector] A selector which takes the arguments from the callback minus the error to produce a single item to yield on next.
|
||||
* @returns {Function} An async function which when applied, returns an observable sequence with the callback arguments as an array.
|
||||
*/
|
||||
Observable.fromNodeCallback = function (func, context, selector) {
|
||||
return function () {
|
||||
var args = slice.call(arguments, 0);
|
||||
|
||||
return new AnonymousObservable(function (observer) {
|
||||
function handler(err) {
|
||||
if (err) {
|
||||
observer.onError(err);
|
||||
return;
|
||||
}
|
||||
|
||||
var results = slice.call(arguments, 1);
|
||||
|
||||
if (selector) {
|
||||
try {
|
||||
results = selector(results);
|
||||
} catch (e) {
|
||||
observer.onError(e);
|
||||
return;
|
||||
}
|
||||
observer.onNext(results);
|
||||
} else {
|
||||
if (results.length <= 1) {
|
||||
observer.onNext.apply(observer, results);
|
||||
} else {
|
||||
observer.onNext(results);
|
||||
}
|
||||
}
|
||||
|
||||
observer.onCompleted();
|
||||
}
|
||||
|
||||
args.push(handler);
|
||||
func.apply(context, args);
|
||||
}).publishLast().refCount();
|
||||
};
|
||||
};
|
||||
|
||||
function fixEvent(event) {
|
||||
var stopPropagation = function () {
|
||||
this.cancelBubble = true;
|
||||
};
|
||||
|
||||
var preventDefault = function () {
|
||||
this.bubbledKeyCode = this.keyCode;
|
||||
if (this.ctrlKey) {
|
||||
try {
|
||||
this.keyCode = 0;
|
||||
} catch (e) { }
|
||||
}
|
||||
this.defaultPrevented = true;
|
||||
this.returnValue = false;
|
||||
this.modified = true;
|
||||
};
|
||||
|
||||
event || (event = root.event);
|
||||
if (!event.target) {
|
||||
event.target = event.target || event.srcElement;
|
||||
|
||||
if (event.type == 'mouseover') {
|
||||
event.relatedTarget = event.fromElement;
|
||||
}
|
||||
if (event.type == 'mouseout') {
|
||||
event.relatedTarget = event.toElement;
|
||||
}
|
||||
// Adding stopPropogation and preventDefault to IE
|
||||
if (!event.stopPropagation) {
|
||||
event.stopPropagation = stopPropagation;
|
||||
event.preventDefault = preventDefault;
|
||||
}
|
||||
// Normalize key events
|
||||
switch (event.type) {
|
||||
case 'keypress':
|
||||
var c = ('charCode' in event ? event.charCode : event.keyCode);
|
||||
if (c == 10) {
|
||||
c = 0;
|
||||
event.keyCode = 13;
|
||||
} else if (c == 13 || c == 27) {
|
||||
c = 0;
|
||||
} else if (c == 3) {
|
||||
c = 99;
|
||||
}
|
||||
event.charCode = c;
|
||||
event.keyChar = event.charCode ? String.fromCharCode(event.charCode) : '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
function createListener (element, name, handler) {
|
||||
// Standards compliant
|
||||
if (element.addEventListener) {
|
||||
element.addEventListener(name, handler, false);
|
||||
return disposableCreate(function () {
|
||||
element.removeEventListener(name, handler, false);
|
||||
});
|
||||
}
|
||||
if (element.attachEvent) {
|
||||
// IE Specific
|
||||
var innerHandler = function (event) {
|
||||
handler(fixEvent(event));
|
||||
};
|
||||
element.attachEvent('on' + name, innerHandler);
|
||||
return disposableCreate(function () {
|
||||
element.detachEvent('on' + name, innerHandler);
|
||||
});
|
||||
}
|
||||
// Level 1 DOM Events
|
||||
element['on' + name] = handler;
|
||||
return disposableCreate(function () {
|
||||
element['on' + name] = null;
|
||||
});
|
||||
}
|
||||
|
||||
function createEventListener (el, eventName, handler) {
|
||||
var disposables = new CompositeDisposable();
|
||||
|
||||
// Asume NodeList
|
||||
if (Object.prototype.toString.call(el) === '[object NodeList]') {
|
||||
for (var i = 0, len = el.length; i < len; i++) {
|
||||
disposables.add(createEventListener(el.item(i), eventName, handler));
|
||||
}
|
||||
} else if (el) {
|
||||
disposables.add(createListener(el, eventName, handler));
|
||||
}
|
||||
|
||||
return disposables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration option to determine whether to use native events only
|
||||
*/
|
||||
Rx.config.useNativeEvents = false;
|
||||
|
||||
/**
|
||||
* Creates an observable sequence by adding an event listener to the matching DOMElement or each item in the NodeList.
|
||||
*
|
||||
* @example
|
||||
* var source = Rx.Observable.fromEvent(element, 'mouseup');
|
||||
*
|
||||
* @param {Object} element The DOMElement or NodeList to attach a listener.
|
||||
* @param {String} eventName The event name to attach the observable sequence.
|
||||
* @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.
|
||||
* @returns {Observable} An observable sequence of events from the specified element and the specified event.
|
||||
*/
|
||||
Observable.fromEvent = function (element, eventName, selector) {
|
||||
// Node.js specific
|
||||
if (element.addListener) {
|
||||
return fromEventPattern(
|
||||
function (h) { element.addListener(eventName, h); },
|
||||
function (h) { element.removeListener(eventName, h); },
|
||||
selector);
|
||||
}
|
||||
|
||||
// Use only if non-native events are allowed
|
||||
if (!Rx.config.useNativeEvents) {
|
||||
// Handles jq, Angular.js, Zepto, Marionette
|
||||
if (typeof element.on === 'function' && typeof element.off === 'function') {
|
||||
return fromEventPattern(
|
||||
function (h) { element.on(eventName, h); },
|
||||
function (h) { element.off(eventName, h); },
|
||||
selector);
|
||||
}
|
||||
if (!!root.Ember && typeof root.Ember.addListener === 'function') {
|
||||
return fromEventPattern(
|
||||
function (h) { Ember.addListener(element, eventName, h); },
|
||||
function (h) { Ember.removeListener(element, eventName, h); },
|
||||
selector);
|
||||
}
|
||||
}
|
||||
return new AnonymousObservable(function (observer) {
|
||||
return createEventListener(
|
||||
element,
|
||||
eventName,
|
||||
function handler (e) {
|
||||
var results = e;
|
||||
|
||||
if (selector) {
|
||||
try {
|
||||
results = selector(arguments);
|
||||
} catch (err) {
|
||||
observer.onError(err);
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
observer.onNext(results);
|
||||
});
|
||||
}).publish().refCount();
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates an observable sequence from an event emitter via an addHandler/removeHandler pair.
|
||||
* @param {Function} addHandler The function to add a handler to the emitter.
|
||||
* @param {Function} [removeHandler] The optional function to remove a handler from an emitter.
|
||||
* @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.
|
||||
* @returns {Observable} An observable sequence which wraps an event from an event emitter
|
||||
*/
|
||||
var fromEventPattern = Observable.fromEventPattern = function (addHandler, removeHandler, selector) {
|
||||
return new AnonymousObservable(function (observer) {
|
||||
function innerHandler (e) {
|
||||
var result = e;
|
||||
if (selector) {
|
||||
try {
|
||||
result = selector(arguments);
|
||||
} catch (err) {
|
||||
observer.onError(err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
observer.onNext(result);
|
||||
}
|
||||
|
||||
var returnValue = addHandler(innerHandler);
|
||||
return disposableCreate(function () {
|
||||
if (removeHandler) {
|
||||
removeHandler(innerHandler, returnValue);
|
||||
}
|
||||
});
|
||||
}).publish().refCount();
|
||||
};
|
||||
|
||||
/**
|
||||
* Invokes the asynchronous function, surfacing the result through an observable sequence.
|
||||
* @param {Function} functionAsync Asynchronous function which returns a Promise to run.
|
||||
* @returns {Observable} An observable sequence exposing the function's result value, or an exception.
|
||||
*/
|
||||
Observable.startAsync = function (functionAsync) {
|
||||
var promise;
|
||||
try {
|
||||
promise = functionAsync();
|
||||
} catch (e) {
|
||||
return observableThrow(e);
|
||||
}
|
||||
return observableFromPromise(promise);
|
||||
}
|
||||
|
||||
return Rx;
|
||||
}));
|
1
node_modules/rx/dist/rx.async.compat.map
generated
vendored
Normal file
1
node_modules/rx/dist/rx.async.compat.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3
node_modules/rx/dist/rx.async.compat.min.js
generated
vendored
Normal file
3
node_modules/rx/dist/rx.async.compat.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
514
node_modules/rx/dist/rx.async.js
generated
vendored
Normal file
514
node_modules/rx/dist/rx.async.js
generated
vendored
Normal file
@ -0,0 +1,514 @@
|
||||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
;(function (factory) {
|
||||
var objectTypes = {
|
||||
'boolean': false,
|
||||
'function': true,
|
||||
'object': true,
|
||||
'number': false,
|
||||
'string': false,
|
||||
'undefined': false
|
||||
};
|
||||
|
||||
var root = (objectTypes[typeof window] && window) || this,
|
||||
freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports,
|
||||
freeModule = objectTypes[typeof module] && module && !module.nodeType && module,
|
||||
moduleExports = freeModule && freeModule.exports === freeExports && freeExports,
|
||||
freeGlobal = objectTypes[typeof global] && global;
|
||||
|
||||
if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) {
|
||||
root = freeGlobal;
|
||||
}
|
||||
|
||||
// Because of build optimizers
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['rx.binding', 'exports'], function (Rx, exports) {
|
||||
root.Rx = factory(root, exports, Rx);
|
||||
return root.Rx;
|
||||
});
|
||||
} else if (typeof module === 'object' && module && module.exports === freeExports) {
|
||||
module.exports = factory(root, module.exports, require('./rx'));
|
||||
} else {
|
||||
root.Rx = factory(root, {}, root.Rx);
|
||||
}
|
||||
}.call(this, function (root, exp, Rx, undefined) {
|
||||
|
||||
// Aliases
|
||||
var Observable = Rx.Observable,
|
||||
observableProto = Observable.prototype,
|
||||
observableFromPromise = Observable.fromPromise,
|
||||
observableThrow = Observable.throwException,
|
||||
AnonymousObservable = Rx.AnonymousObservable,
|
||||
AsyncSubject = Rx.AsyncSubject,
|
||||
disposableCreate = Rx.Disposable.create,
|
||||
CompositeDisposable = Rx.CompositeDisposable,
|
||||
immediateScheduler = Rx.Scheduler.immediate,
|
||||
timeoutScheduler = Rx.Scheduler.timeout,
|
||||
isScheduler = Rx.helpers.isScheduler,
|
||||
slice = Array.prototype.slice;
|
||||
|
||||
var fnString = 'function',
|
||||
throwString = 'throw',
|
||||
isObject = Rx.internals.isObject;
|
||||
|
||||
function toThunk(obj, ctx) {
|
||||
if (Array.isArray(obj)) { return objectToThunk.call(ctx, obj); }
|
||||
if (isGeneratorFunction(obj)) { return observableSpawn(obj.call(ctx)); }
|
||||
if (isGenerator(obj)) { return observableSpawn(obj); }
|
||||
if (isObservable(obj)) { return observableToThunk(obj); }
|
||||
if (isPromise(obj)) { return promiseToThunk(obj); }
|
||||
if (typeof obj === fnString) { return obj; }
|
||||
if (isObject(obj) || Array.isArray(obj)) { return objectToThunk.call(ctx, obj); }
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
function objectToThunk(obj) {
|
||||
var ctx = this;
|
||||
|
||||
return function (done) {
|
||||
var keys = Object.keys(obj),
|
||||
pending = keys.length,
|
||||
results = new obj.constructor(),
|
||||
finished;
|
||||
|
||||
if (!pending) {
|
||||
timeoutScheduler.schedule(function () { done(null, results); });
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
run(obj[keys[i]], keys[i]);
|
||||
}
|
||||
|
||||
function run(fn, key) {
|
||||
if (finished) { return; }
|
||||
try {
|
||||
fn = toThunk(fn, ctx);
|
||||
|
||||
if (typeof fn !== fnString) {
|
||||
results[key] = fn;
|
||||
return --pending || done(null, results);
|
||||
}
|
||||
|
||||
fn.call(ctx, function(err, res) {
|
||||
if (finished) { return; }
|
||||
|
||||
if (err) {
|
||||
finished = true;
|
||||
return done(err);
|
||||
}
|
||||
|
||||
results[key] = res;
|
||||
--pending || done(null, results);
|
||||
});
|
||||
} catch (e) {
|
||||
finished = true;
|
||||
done(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function observableToThunk(observable) {
|
||||
return function (fn) {
|
||||
var value, hasValue = false;
|
||||
observable.subscribe(
|
||||
function (v) {
|
||||
value = v;
|
||||
hasValue = true;
|
||||
},
|
||||
fn,
|
||||
function () {
|
||||
hasValue && fn(null, value);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function promiseToThunk(promise) {
|
||||
return function(fn) {
|
||||
promise.then(function(res) {
|
||||
fn(null, res);
|
||||
}, fn);
|
||||
}
|
||||
}
|
||||
|
||||
function isObservable(obj) {
|
||||
return obj && typeof obj.subscribe === fnString;
|
||||
}
|
||||
|
||||
function isGeneratorFunction(obj) {
|
||||
return obj && obj.constructor && obj.constructor.name === 'GeneratorFunction';
|
||||
}
|
||||
|
||||
function isGenerator(obj) {
|
||||
return obj && typeof obj.next === fnString && typeof obj[throwString] === fnString;
|
||||
}
|
||||
|
||||
/*
|
||||
* Spawns a generator function which allows for Promises, Observable sequences, Arrays, Objects, Generators and functions.
|
||||
* @param {Function} The spawning function.
|
||||
* @returns {Function} a function which has a done continuation.
|
||||
*/
|
||||
var observableSpawn = Rx.spawn = function (fn) {
|
||||
var isGenFun = isGeneratorFunction(fn);
|
||||
|
||||
return function (done) {
|
||||
var ctx = this,
|
||||
gen = fn;
|
||||
|
||||
if (isGenFun) {
|
||||
var args = slice.call(arguments),
|
||||
len = args.length,
|
||||
hasCallback = len && typeof args[len - 1] === fnString;
|
||||
|
||||
done = hasCallback ? args.pop() : handleError;
|
||||
gen = fn.apply(this, args);
|
||||
} else {
|
||||
done = done || handleError;
|
||||
}
|
||||
|
||||
next();
|
||||
|
||||
function exit(err, res) {
|
||||
timeoutScheduler.schedule(done.bind(ctx, err, res));
|
||||
}
|
||||
|
||||
function next(err, res) {
|
||||
var ret;
|
||||
|
||||
// multiple args
|
||||
if (arguments.length > 2) {
|
||||
res = slice.call(arguments, 1);
|
||||
}
|
||||
|
||||
if (err) {
|
||||
try {
|
||||
ret = gen[throwString](err);
|
||||
} catch (e) {
|
||||
return exit(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (!err) {
|
||||
try {
|
||||
ret = gen.next(res);
|
||||
} catch (e) {
|
||||
return exit(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret.done) {
|
||||
return exit(null, ret.value);
|
||||
}
|
||||
|
||||
ret.value = toThunk(ret.value, ctx);
|
||||
|
||||
if (typeof ret.value === fnString) {
|
||||
var called = false;
|
||||
try {
|
||||
ret.value.call(ctx, function() {
|
||||
if (called) {
|
||||
return;
|
||||
}
|
||||
|
||||
called = true;
|
||||
next.apply(ctx, arguments);
|
||||
});
|
||||
} catch (e) {
|
||||
timeoutScheduler.schedule(function () {
|
||||
if (called) {
|
||||
return;
|
||||
}
|
||||
|
||||
called = true;
|
||||
next.call(ctx, e);
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Not supported
|
||||
next(new TypeError('Rx.spawn only supports a function, Promise, Observable, Object or Array.'));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function handleError(err) {
|
||||
if (!err) { return; }
|
||||
timeoutScheduler.schedule(function() {
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes the specified function asynchronously on the specified scheduler, surfacing the result through an observable sequence.
|
||||
*
|
||||
* @example
|
||||
* var res = Rx.Observable.start(function () { console.log('hello'); });
|
||||
* var res = Rx.Observable.start(function () { console.log('hello'); }, Rx.Scheduler.timeout);
|
||||
* var res = Rx.Observable.start(function () { this.log('hello'); }, Rx.Scheduler.timeout, console);
|
||||
*
|
||||
* @param {Function} func Function to run asynchronously.
|
||||
* @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout.
|
||||
* @param [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
|
||||
* @returns {Observable} An observable sequence exposing the function's result value, or an exception.
|
||||
*
|
||||
* Remarks
|
||||
* * The function is called immediately, not during the subscription of the resulting sequence.
|
||||
* * Multiple subscriptions to the resulting sequence can observe the function's result.
|
||||
*/
|
||||
Observable.start = function (func, context, scheduler) {
|
||||
return observableToAsync(func, context, scheduler)();
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
|
||||
* @param {Function} function Function to convert to an asynchronous function.
|
||||
* @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout.
|
||||
* @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
|
||||
* @returns {Function} Asynchronous function.
|
||||
*/
|
||||
var observableToAsync = Observable.toAsync = function (func, context, scheduler) {
|
||||
isScheduler(scheduler) || (scheduler = timeoutScheduler);
|
||||
return function () {
|
||||
var args = arguments,
|
||||
subject = new AsyncSubject();
|
||||
|
||||
scheduler.schedule(function () {
|
||||
var result;
|
||||
try {
|
||||
result = func.apply(context, args);
|
||||
} catch (e) {
|
||||
subject.onError(e);
|
||||
return;
|
||||
}
|
||||
subject.onNext(result);
|
||||
subject.onCompleted();
|
||||
});
|
||||
return subject.asObservable();
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a callback function to an observable sequence.
|
||||
*
|
||||
* @param {Function} function Function with a callback as the last parameter to convert to an Observable sequence.
|
||||
* @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
|
||||
* @param {Function} [selector] A selector which takes the arguments from the callback to produce a single item to yield on next.
|
||||
* @returns {Function} A function, when executed with the required parameters minus the callback, produces an Observable sequence with a single value of the arguments to the callback as an array.
|
||||
*/
|
||||
Observable.fromCallback = function (func, context, selector) {
|
||||
return function () {
|
||||
var args = slice.call(arguments, 0);
|
||||
|
||||
return new AnonymousObservable(function (observer) {
|
||||
function handler() {
|
||||
var results = arguments;
|
||||
|
||||
if (selector) {
|
||||
try {
|
||||
results = selector(results);
|
||||
} catch (err) {
|
||||
observer.onError(err);
|
||||
return;
|
||||
}
|
||||
|
||||
observer.onNext(results);
|
||||
} else {
|
||||
if (results.length <= 1) {
|
||||
observer.onNext.apply(observer, results);
|
||||
} else {
|
||||
observer.onNext(results);
|
||||
}
|
||||
}
|
||||
|
||||
observer.onCompleted();
|
||||
}
|
||||
|
||||
args.push(handler);
|
||||
func.apply(context, args);
|
||||
}).publishLast().refCount();
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a Node.js callback style function to an observable sequence. This must be in function (err, ...) format.
|
||||
* @param {Function} func The function to call
|
||||
* @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
|
||||
* @param {Function} [selector] A selector which takes the arguments from the callback minus the error to produce a single item to yield on next.
|
||||
* @returns {Function} An async function which when applied, returns an observable sequence with the callback arguments as an array.
|
||||
*/
|
||||
Observable.fromNodeCallback = function (func, context, selector) {
|
||||
return function () {
|
||||
var args = slice.call(arguments, 0);
|
||||
|
||||
return new AnonymousObservable(function (observer) {
|
||||
function handler(err) {
|
||||
if (err) {
|
||||
observer.onError(err);
|
||||
return;
|
||||
}
|
||||
|
||||
var results = slice.call(arguments, 1);
|
||||
|
||||
if (selector) {
|
||||
try {
|
||||
results = selector(results);
|
||||
} catch (e) {
|
||||
observer.onError(e);
|
||||
return;
|
||||
}
|
||||
observer.onNext(results);
|
||||
} else {
|
||||
if (results.length <= 1) {
|
||||
observer.onNext.apply(observer, results);
|
||||
} else {
|
||||
observer.onNext(results);
|
||||
}
|
||||
}
|
||||
|
||||
observer.onCompleted();
|
||||
}
|
||||
|
||||
args.push(handler);
|
||||
func.apply(context, args);
|
||||
}).publishLast().refCount();
|
||||
};
|
||||
};
|
||||
|
||||
function createListener (element, name, handler) {
|
||||
if (element.addEventListener) {
|
||||
element.addEventListener(name, handler, false);
|
||||
return disposableCreate(function () {
|
||||
element.removeEventListener(name, handler, false);
|
||||
});
|
||||
}
|
||||
throw new Error('No listener found');
|
||||
}
|
||||
|
||||
function createEventListener (el, eventName, handler) {
|
||||
var disposables = new CompositeDisposable();
|
||||
|
||||
// Asume NodeList
|
||||
if (Object.prototype.toString.call(el) === '[object NodeList]') {
|
||||
for (var i = 0, len = el.length; i < len; i++) {
|
||||
disposables.add(createEventListener(el.item(i), eventName, handler));
|
||||
}
|
||||
} else if (el) {
|
||||
disposables.add(createListener(el, eventName, handler));
|
||||
}
|
||||
|
||||
return disposables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration option to determine whether to use native events only
|
||||
*/
|
||||
Rx.config.useNativeEvents = false;
|
||||
|
||||
/**
|
||||
* Creates an observable sequence by adding an event listener to the matching DOMElement or each item in the NodeList.
|
||||
*
|
||||
* @example
|
||||
* var source = Rx.Observable.fromEvent(element, 'mouseup');
|
||||
*
|
||||
* @param {Object} element The DOMElement or NodeList to attach a listener.
|
||||
* @param {String} eventName The event name to attach the observable sequence.
|
||||
* @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.
|
||||
* @returns {Observable} An observable sequence of events from the specified element and the specified event.
|
||||
*/
|
||||
Observable.fromEvent = function (element, eventName, selector) {
|
||||
// Node.js specific
|
||||
if (element.addListener) {
|
||||
return fromEventPattern(
|
||||
function (h) { element.addListener(eventName, h); },
|
||||
function (h) { element.removeListener(eventName, h); },
|
||||
selector);
|
||||
}
|
||||
|
||||
// Use only if non-native events are allowed
|
||||
if (!Rx.config.useNativeEvents) {
|
||||
// Handles jq, Angular.js, Zepto, Marionette
|
||||
if (typeof element.on === 'function' && typeof element.off === 'function') {
|
||||
return fromEventPattern(
|
||||
function (h) { element.on(eventName, h); },
|
||||
function (h) { element.off(eventName, h); },
|
||||
selector);
|
||||
}
|
||||
if (!!root.Ember && typeof root.Ember.addListener === 'function') {
|
||||
return fromEventPattern(
|
||||
function (h) { Ember.addListener(element, eventName, h); },
|
||||
function (h) { Ember.removeListener(element, eventName, h); },
|
||||
selector);
|
||||
}
|
||||
}
|
||||
return new AnonymousObservable(function (observer) {
|
||||
return createEventListener(
|
||||
element,
|
||||
eventName,
|
||||
function handler (e) {
|
||||
var results = e;
|
||||
|
||||
if (selector) {
|
||||
try {
|
||||
results = selector(arguments);
|
||||
} catch (err) {
|
||||
observer.onError(err);
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
observer.onNext(results);
|
||||
});
|
||||
}).publish().refCount();
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates an observable sequence from an event emitter via an addHandler/removeHandler pair.
|
||||
* @param {Function} addHandler The function to add a handler to the emitter.
|
||||
* @param {Function} [removeHandler] The optional function to remove a handler from an emitter.
|
||||
* @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.
|
||||
* @returns {Observable} An observable sequence which wraps an event from an event emitter
|
||||
*/
|
||||
var fromEventPattern = Observable.fromEventPattern = function (addHandler, removeHandler, selector) {
|
||||
return new AnonymousObservable(function (observer) {
|
||||
function innerHandler (e) {
|
||||
var result = e;
|
||||
if (selector) {
|
||||
try {
|
||||
result = selector(arguments);
|
||||
} catch (err) {
|
||||
observer.onError(err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
observer.onNext(result);
|
||||
}
|
||||
|
||||
var returnValue = addHandler(innerHandler);
|
||||
return disposableCreate(function () {
|
||||
if (removeHandler) {
|
||||
removeHandler(innerHandler, returnValue);
|
||||
}
|
||||
});
|
||||
}).publish().refCount();
|
||||
};
|
||||
|
||||
/**
|
||||
* Invokes the asynchronous function, surfacing the result through an observable sequence.
|
||||
* @param {Function} functionAsync Asynchronous function which returns a Promise to run.
|
||||
* @returns {Observable} An observable sequence exposing the function's result value, or an exception.
|
||||
*/
|
||||
Observable.startAsync = function (functionAsync) {
|
||||
var promise;
|
||||
try {
|
||||
promise = functionAsync();
|
||||
} catch (e) {
|
||||
return observableThrow(e);
|
||||
}
|
||||
return observableFromPromise(promise);
|
||||
}
|
||||
|
||||
return Rx;
|
||||
}));
|
1
node_modules/rx/dist/rx.async.map
generated
vendored
Normal file
1
node_modules/rx/dist/rx.async.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3
node_modules/rx/dist/rx.async.min.js
generated
vendored
Normal file
3
node_modules/rx/dist/rx.async.min.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
/* Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.*/
|
||||
(function(a){var b={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},c=b[typeof window]&&window||this,d=b[typeof exports]&&exports&&!exports.nodeType&&exports,e=b[typeof module]&&module&&!module.nodeType&&module,f=(e&&e.exports===d&&d,b[typeof global]&&global);!f||f.global!==f&&f.window!==f||(c=f),"function"==typeof define&&define.amd?define(["rx.binding","exports"],function(b,d){return c.Rx=a(c,d,b),c.Rx}):"object"==typeof module&&module&&module.exports===d?module.exports=a(c,module.exports,require("./rx")):c.Rx=a(c,{},c.Rx)}).call(this,function(a,b,c){function d(a,b){return Array.isArray(a)?e.call(b,a):i(a)?A(a.call(b)):j(a)?A(a):h(a)?f(a):isPromise(a)?g(a):typeof a===x?a:z(a)||Array.isArray(a)?e.call(b,a):a}function e(a){var b=this;return function(c){function e(a,e){if(!f)try{if(a=d(a,b),typeof a!==x)return i[e]=a,--h||c(null,i);a.call(b,function(a,b){if(!f){if(a)return f=!0,c(a);i[e]=b,--h||c(null,i)}})}catch(g){f=!0,c(g)}}var f,g=Object.keys(a),h=g.length,i=new a.constructor;if(!h)return void u.schedule(function(){c(null,i)});for(var j=0,k=g.length;k>j;j++)e(a[g[j]],g[j])}}function f(a){return function(b){var c,d=!1;a.subscribe(function(a){c=a,d=!0},b,function(){d&&b(null,c)})}}function g(a){return function(b){a.then(function(a){b(null,a)},b)}}function h(a){return a&&typeof a.subscribe===x}function i(a){return a&&a.constructor&&"GeneratorFunction"===a.constructor.name}function j(a){return a&&typeof a.next===x&&typeof a[y]===x}function k(a){a&&u.schedule(function(){throw a})}function l(a,b,c){if(a.addEventListener)return a.addEventListener(b,c,!1),s(function(){a.removeEventListener(b,c,!1)});throw new Error("No listener found")}function m(a,b,c){var d=new t;if("[object NodeList]"===Object.prototype.toString.call(a))for(var e=0,f=a.length;f>e;e++)d.add(m(a.item(e),b,c));else a&&d.add(l(a,b,c));return d}var n=c.Observable,o=(n.prototype,n.fromPromise),p=n.throwException,q=c.AnonymousObservable,r=c.AsyncSubject,s=c.Disposable.create,t=c.CompositeDisposable,u=(c.Scheduler.immediate,c.Scheduler.timeout),v=c.helpers.isScheduler,w=Array.prototype.slice,x="function",y="throw",z=c.internals.isObject,A=c.spawn=function(a){var b=i(a);return function(c){function e(a,b){u.schedule(c.bind(g,a,b))}function f(a,b){var c;if(arguments.length>2&&(b=w.call(arguments,1)),a)try{c=h[y](a)}catch(i){return e(i)}if(!a)try{c=h.next(b)}catch(i){return e(i)}if(c.done)return e(null,c.value);if(c.value=d(c.value,g),typeof c.value!==x)f(new TypeError("Rx.spawn only supports a function, Promise, Observable, Object or Array."));else{var j=!1;try{c.value.call(g,function(){j||(j=!0,f.apply(g,arguments))})}catch(i){u.schedule(function(){j||(j=!0,f.call(g,i))})}}}var g=this,h=a;if(b){var i=w.call(arguments),j=i.length,l=j&&typeof i[j-1]===x;c=l?i.pop():k,h=a.apply(this,i)}else c=c||k;f()}};n.start=function(a,b,c){return B(a,b,c)()};var B=n.toAsync=function(a,b,c){return v(c)||(c=u),function(){var d=arguments,e=new r;return c.schedule(function(){var c;try{c=a.apply(b,d)}catch(f){return void e.onError(f)}e.onNext(c),e.onCompleted()}),e.asObservable()}};n.fromCallback=function(a,b,c){return function(){var d=w.call(arguments,0);return new q(function(e){function f(){var a=arguments;if(c){try{a=c(a)}catch(b){return void e.onError(b)}e.onNext(a)}else a.length<=1?e.onNext.apply(e,a):e.onNext(a);e.onCompleted()}d.push(f),a.apply(b,d)}).publishLast().refCount()}},n.fromNodeCallback=function(a,b,c){return function(){var d=w.call(arguments,0);return new q(function(e){function f(a){if(a)return void e.onError(a);var b=w.call(arguments,1);if(c){try{b=c(b)}catch(d){return void e.onError(d)}e.onNext(b)}else b.length<=1?e.onNext.apply(e,b):e.onNext(b);e.onCompleted()}d.push(f),a.apply(b,d)}).publishLast().refCount()}},c.config.useNativeEvents=!1,n.fromEvent=function(b,d,e){if(b.addListener)return C(function(a){b.addListener(d,a)},function(a){b.removeListener(d,a)},e);if(!c.config.useNativeEvents){if("function"==typeof b.on&&"function"==typeof b.off)return C(function(a){b.on(d,a)},function(a){b.off(d,a)},e);if(a.Ember&&"function"==typeof a.Ember.addListener)return C(function(a){Ember.addListener(b,d,a)},function(a){Ember.removeListener(b,d,a)},e)}return new q(function(a){return m(b,d,function(b){var c=b;if(e)try{c=e(arguments)}catch(d){return void a.onError(d)}a.onNext(c)})}).publish().refCount()};var C=n.fromEventPattern=function(a,b,c){return new q(function(d){function e(a){var b=a;if(c)try{b=c(arguments)}catch(e){return void d.onError(e)}d.onNext(b)}var f=a(e);return s(function(){b&&b(e,f)})}).publish().refCount()};return n.startAsync=function(a){var b;try{b=a()}catch(c){return p(c)}return o(b)},c});
|
||||
//# sourceMappingURL=rx.async.map
|
569
node_modules/rx/dist/rx.backpressure.js
generated
vendored
Normal file
569
node_modules/rx/dist/rx.backpressure.js
generated
vendored
Normal file
@ -0,0 +1,569 @@
|
||||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
;(function (factory) {
|
||||
var objectTypes = {
|
||||
'boolean': false,
|
||||
'function': true,
|
||||
'object': true,
|
||||
'number': false,
|
||||
'string': false,
|
||||
'undefined': false
|
||||
};
|
||||
|
||||
var root = (objectTypes[typeof window] && window) || this,
|
||||
freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports,
|
||||
freeModule = objectTypes[typeof module] && module && !module.nodeType && module,
|
||||
moduleExports = freeModule && freeModule.exports === freeExports && freeExports,
|
||||
freeGlobal = objectTypes[typeof global] && global;
|
||||
|
||||
if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) {
|
||||
root = freeGlobal;
|
||||
}
|
||||
|
||||
// Because of build optimizers
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['rx'], function (Rx, exports) {
|
||||
return factory(root, exports, Rx);
|
||||
});
|
||||
} else if (typeof module === 'object' && module && module.exports === freeExports) {
|
||||
module.exports = factory(root, module.exports, require('./rx'));
|
||||
} else {
|
||||
root.Rx = factory(root, {}, root.Rx);
|
||||
}
|
||||
}.call(this, function (root, exp, Rx, undefined) {
|
||||
|
||||
// References
|
||||
var Observable = Rx.Observable,
|
||||
observableProto = Observable.prototype,
|
||||
AnonymousObservable = Rx.AnonymousObservable,
|
||||
AbstractObserver = Rx.internals.AbstractObserver,
|
||||
CompositeDisposable = Rx.CompositeDisposable,
|
||||
Subject = Rx.Subject,
|
||||
Observer = Rx.Observer,
|
||||
disposableEmpty = Rx.Disposable.empty,
|
||||
disposableCreate = Rx.Disposable.create,
|
||||
inherits = Rx.internals.inherits,
|
||||
addProperties = Rx.internals.addProperties,
|
||||
timeoutScheduler = Rx.Scheduler.timeout,
|
||||
currentThreadScheduler = Rx.Scheduler.currentThread,
|
||||
identity = Rx.helpers.identity;
|
||||
|
||||
var objectDisposed = 'Object has been disposed';
|
||||
function checkDisposed() { if (this.isDisposed) { throw new Error(objectDisposed); } }
|
||||
|
||||
/**
|
||||
* Used to pause and resume streams.
|
||||
*/
|
||||
Rx.Pauser = (function (__super__) {
|
||||
inherits(Pauser, __super__);
|
||||
|
||||
function Pauser() {
|
||||
__super__.call(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pauses the underlying sequence.
|
||||
*/
|
||||
Pauser.prototype.pause = function () { this.onNext(false); };
|
||||
|
||||
/**
|
||||
* Resumes the underlying sequence.
|
||||
*/
|
||||
Pauser.prototype.resume = function () { this.onNext(true); };
|
||||
|
||||
return Pauser;
|
||||
}(Subject));
|
||||
|
||||
var PausableObservable = (function (__super__) {
|
||||
|
||||
inherits(PausableObservable, __super__);
|
||||
|
||||
function subscribe(observer) {
|
||||
var conn = this.source.publish(),
|
||||
subscription = conn.subscribe(observer),
|
||||
connection = disposableEmpty;
|
||||
|
||||
var pausable = this.pauser.distinctUntilChanged().subscribe(function (b) {
|
||||
if (b) {
|
||||
connection = conn.connect();
|
||||
} else {
|
||||
connection.dispose();
|
||||
connection = disposableEmpty;
|
||||
}
|
||||
});
|
||||
|
||||
return new CompositeDisposable(subscription, connection, pausable);
|
||||
}
|
||||
|
||||
function PausableObservable(source, pauser) {
|
||||
this.source = source;
|
||||
this.controller = new Subject();
|
||||
|
||||
if (pauser && pauser.subscribe) {
|
||||
this.pauser = this.controller.merge(pauser);
|
||||
} else {
|
||||
this.pauser = this.controller;
|
||||
}
|
||||
|
||||
__super__.call(this, subscribe, source);
|
||||
}
|
||||
|
||||
PausableObservable.prototype.pause = function () {
|
||||
this.controller.onNext(false);
|
||||
};
|
||||
|
||||
PausableObservable.prototype.resume = function () {
|
||||
this.controller.onNext(true);
|
||||
};
|
||||
|
||||
return PausableObservable;
|
||||
|
||||
}(Observable));
|
||||
|
||||
/**
|
||||
* Pauses the underlying observable sequence based upon the observable sequence which yields true/false.
|
||||
* @example
|
||||
* var pauser = new Rx.Subject();
|
||||
* var source = Rx.Observable.interval(100).pausable(pauser);
|
||||
* @param {Observable} pauser The observable sequence used to pause the underlying sequence.
|
||||
* @returns {Observable} The observable sequence which is paused based upon the pauser.
|
||||
*/
|
||||
observableProto.pausable = function (pauser) {
|
||||
return new PausableObservable(this, pauser);
|
||||
};
|
||||
|
||||
function combineLatestSource(source, subject, resultSelector) {
|
||||
return new AnonymousObservable(function (o) {
|
||||
var hasValue = [false, false],
|
||||
hasValueAll = false,
|
||||
isDone = false,
|
||||
values = new Array(2),
|
||||
err;
|
||||
|
||||
function next(x, i) {
|
||||
values[i] = x
|
||||
var res;
|
||||
hasValue[i] = true;
|
||||
if (hasValueAll || (hasValueAll = hasValue.every(identity))) {
|
||||
if (err) {
|
||||
o.onError(err);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
res = resultSelector.apply(null, values);
|
||||
} catch (ex) {
|
||||
o.onError(ex);
|
||||
return;
|
||||
}
|
||||
o.onNext(res);
|
||||
}
|
||||
if (isDone && values[1]) {
|
||||
o.onCompleted();
|
||||
}
|
||||
}
|
||||
|
||||
return new CompositeDisposable(
|
||||
source.subscribe(
|
||||
function (x) {
|
||||
next(x, 0);
|
||||
},
|
||||
function (e) {
|
||||
if (values[1]) {
|
||||
o.onError(e);
|
||||
} else {
|
||||
err = e;
|
||||
}
|
||||
},
|
||||
function () {
|
||||
isDone = true;
|
||||
values[1] && o.onCompleted();
|
||||
}),
|
||||
subject.subscribe(
|
||||
function (x) {
|
||||
next(x, 1);
|
||||
},
|
||||
function (e) { o.onError(e); },
|
||||
function () {
|
||||
isDone = true;
|
||||
next(true, 1);
|
||||
})
|
||||
);
|
||||
}, source);
|
||||
}
|
||||
|
||||
var PausableBufferedObservable = (function (__super__) {
|
||||
|
||||
inherits(PausableBufferedObservable, __super__);
|
||||
|
||||
function subscribe(o) {
|
||||
var q = [], previousShouldFire;
|
||||
|
||||
var subscription =
|
||||
combineLatestSource(
|
||||
this.source,
|
||||
this.pauser.distinctUntilChanged().startWith(false),
|
||||
function (data, shouldFire) {
|
||||
return { data: data, shouldFire: shouldFire };
|
||||
})
|
||||
.subscribe(
|
||||
function (results) {
|
||||
if (previousShouldFire !== undefined && results.shouldFire != previousShouldFire) {
|
||||
previousShouldFire = results.shouldFire;
|
||||
// change in shouldFire
|
||||
if (results.shouldFire) {
|
||||
while (q.length > 0) {
|
||||
o.onNext(q.shift());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
previousShouldFire = results.shouldFire;
|
||||
// new data
|
||||
if (results.shouldFire) {
|
||||
o.onNext(results.data);
|
||||
} else {
|
||||
q.push(results.data);
|
||||
}
|
||||
}
|
||||
},
|
||||
function (err) {
|
||||
// Empty buffer before sending error
|
||||
while (q.length > 0) {
|
||||
o.onNext(q.shift());
|
||||
}
|
||||
o.onError(err);
|
||||
},
|
||||
function () {
|
||||
// Empty buffer before sending completion
|
||||
while (q.length > 0) {
|
||||
o.onNext(q.shift());
|
||||
}
|
||||
o.onCompleted();
|
||||
}
|
||||
);
|
||||
return subscription;
|
||||
}
|
||||
|
||||
function PausableBufferedObservable(source, pauser) {
|
||||
this.source = source;
|
||||
this.controller = new Subject();
|
||||
|
||||
if (pauser && pauser.subscribe) {
|
||||
this.pauser = this.controller.merge(pauser);
|
||||
} else {
|
||||
this.pauser = this.controller;
|
||||
}
|
||||
|
||||
__super__.call(this, subscribe, source);
|
||||
}
|
||||
|
||||
PausableBufferedObservable.prototype.pause = function () {
|
||||
this.controller.onNext(false);
|
||||
};
|
||||
|
||||
PausableBufferedObservable.prototype.resume = function () {
|
||||
this.controller.onNext(true);
|
||||
};
|
||||
|
||||
return PausableBufferedObservable;
|
||||
|
||||
}(Observable));
|
||||
|
||||
/**
|
||||
* Pauses the underlying observable sequence based upon the observable sequence which yields true/false,
|
||||
* and yields the values that were buffered while paused.
|
||||
* @example
|
||||
* var pauser = new Rx.Subject();
|
||||
* var source = Rx.Observable.interval(100).pausableBuffered(pauser);
|
||||
* @param {Observable} pauser The observable sequence used to pause the underlying sequence.
|
||||
* @returns {Observable} The observable sequence which is paused based upon the pauser.
|
||||
*/
|
||||
observableProto.pausableBuffered = function (subject) {
|
||||
return new PausableBufferedObservable(this, subject);
|
||||
};
|
||||
|
||||
var ControlledObservable = (function (__super__) {
|
||||
|
||||
inherits(ControlledObservable, __super__);
|
||||
|
||||
function subscribe (observer) {
|
||||
return this.source.subscribe(observer);
|
||||
}
|
||||
|
||||
function ControlledObservable (source, enableQueue) {
|
||||
__super__.call(this, subscribe, source);
|
||||
this.subject = new ControlledSubject(enableQueue);
|
||||
this.source = source.multicast(this.subject).refCount();
|
||||
}
|
||||
|
||||
ControlledObservable.prototype.request = function (numberOfItems) {
|
||||
if (numberOfItems == null) { numberOfItems = -1; }
|
||||
return this.subject.request(numberOfItems);
|
||||
};
|
||||
|
||||
return ControlledObservable;
|
||||
|
||||
}(Observable));
|
||||
|
||||
var ControlledSubject = (function (__super__) {
|
||||
|
||||
function subscribe (observer) {
|
||||
return this.subject.subscribe(observer);
|
||||
}
|
||||
|
||||
inherits(ControlledSubject, __super__);
|
||||
|
||||
function ControlledSubject(enableQueue) {
|
||||
enableQueue == null && (enableQueue = true);
|
||||
|
||||
__super__.call(this, subscribe);
|
||||
this.subject = new Subject();
|
||||
this.enableQueue = enableQueue;
|
||||
this.queue = enableQueue ? [] : null;
|
||||
this.requestedCount = 0;
|
||||
this.requestedDisposable = disposableEmpty;
|
||||
this.error = null;
|
||||
this.hasFailed = false;
|
||||
this.hasCompleted = false;
|
||||
this.controlledDisposable = disposableEmpty;
|
||||
}
|
||||
|
||||
addProperties(ControlledSubject.prototype, Observer, {
|
||||
onCompleted: function () {
|
||||
this.hasCompleted = true;
|
||||
(!this.enableQueue || this.queue.length === 0) && this.subject.onCompleted();
|
||||
},
|
||||
onError: function (error) {
|
||||
this.hasFailed = true;
|
||||
this.error = error;
|
||||
(!this.enableQueue || this.queue.length === 0) && this.subject.onError(error);
|
||||
},
|
||||
onNext: function (value) {
|
||||
var hasRequested = false;
|
||||
|
||||
if (this.requestedCount === 0) {
|
||||
this.enableQueue && this.queue.push(value);
|
||||
} else {
|
||||
(this.requestedCount !== -1 && this.requestedCount-- === 0) && this.disposeCurrentRequest();
|
||||
hasRequested = true;
|
||||
}
|
||||
hasRequested && this.subject.onNext(value);
|
||||
},
|
||||
_processRequest: function (numberOfItems) {
|
||||
if (this.enableQueue) {
|
||||
while (this.queue.length >= numberOfItems && numberOfItems > 0) {
|
||||
this.subject.onNext(this.queue.shift());
|
||||
numberOfItems--;
|
||||
}
|
||||
|
||||
return this.queue.length !== 0 ?
|
||||
{ numberOfItems: numberOfItems, returnValue: true } :
|
||||
{ numberOfItems: numberOfItems, returnValue: false };
|
||||
}
|
||||
|
||||
if (this.hasFailed) {
|
||||
this.subject.onError(this.error);
|
||||
this.controlledDisposable.dispose();
|
||||
this.controlledDisposable = disposableEmpty;
|
||||
} else if (this.hasCompleted) {
|
||||
this.subject.onCompleted();
|
||||
this.controlledDisposable.dispose();
|
||||
this.controlledDisposable = disposableEmpty;
|
||||
}
|
||||
|
||||
return { numberOfItems: numberOfItems, returnValue: false };
|
||||
},
|
||||
request: function (number) {
|
||||
this.disposeCurrentRequest();
|
||||
var self = this, r = this._processRequest(number);
|
||||
|
||||
var number = r.numberOfItems;
|
||||
if (!r.returnValue) {
|
||||
this.requestedCount = number;
|
||||
this.requestedDisposable = disposableCreate(function () {
|
||||
self.requestedCount = 0;
|
||||
});
|
||||
|
||||
return this.requestedDisposable
|
||||
} else {
|
||||
return disposableEmpty;
|
||||
}
|
||||
},
|
||||
disposeCurrentRequest: function () {
|
||||
this.requestedDisposable.dispose();
|
||||
this.requestedDisposable = disposableEmpty;
|
||||
}
|
||||
});
|
||||
|
||||
return ControlledSubject;
|
||||
}(Observable));
|
||||
|
||||
/**
|
||||
* Attaches a controller to the observable sequence with the ability to queue.
|
||||
* @example
|
||||
* var source = Rx.Observable.interval(100).controlled();
|
||||
* source.request(3); // Reads 3 values
|
||||
* @param {Observable} pauser The observable sequence used to pause the underlying sequence.
|
||||
* @returns {Observable} The observable sequence which is paused based upon the pauser.
|
||||
*/
|
||||
observableProto.controlled = function (enableQueue) {
|
||||
if (enableQueue == null) { enableQueue = true; }
|
||||
return new ControlledObservable(this, enableQueue);
|
||||
};
|
||||
|
||||
var StopAndWaitObservable = (function (__super__) {
|
||||
|
||||
function subscribe (observer) {
|
||||
this.subscription = this.source.subscribe(new StopAndWaitObserver(observer, this, this.subscription));
|
||||
|
||||
var self = this;
|
||||
timeoutScheduler.schedule(function () { self.source.request(1); });
|
||||
|
||||
return this.subscription;
|
||||
}
|
||||
|
||||
inherits(StopAndWaitObservable, __super__);
|
||||
|
||||
function StopAndWaitObservable (source) {
|
||||
__super__.call(this, subscribe, source);
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
var StopAndWaitObserver = (function (__sub__) {
|
||||
|
||||
inherits(StopAndWaitObserver, __sub__);
|
||||
|
||||
function StopAndWaitObserver (observer, observable, cancel) {
|
||||
__sub__.call(this);
|
||||
this.observer = observer;
|
||||
this.observable = observable;
|
||||
this.cancel = cancel;
|
||||
}
|
||||
|
||||
var stopAndWaitObserverProto = StopAndWaitObserver.prototype;
|
||||
|
||||
stopAndWaitObserverProto.completed = function () {
|
||||
this.observer.onCompleted();
|
||||
this.dispose();
|
||||
};
|
||||
|
||||
stopAndWaitObserverProto.error = function (error) {
|
||||
this.observer.onError(error);
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
stopAndWaitObserverProto.next = function (value) {
|
||||
this.observer.onNext(value);
|
||||
|
||||
var self = this;
|
||||
timeoutScheduler.schedule(function () {
|
||||
self.observable.source.request(1);
|
||||
});
|
||||
};
|
||||
|
||||
stopAndWaitObserverProto.dispose = function () {
|
||||
this.observer = null;
|
||||
if (this.cancel) {
|
||||
this.cancel.dispose();
|
||||
this.cancel = null;
|
||||
}
|
||||
__sub__.prototype.dispose.call(this);
|
||||
};
|
||||
|
||||
return StopAndWaitObserver;
|
||||
}(AbstractObserver));
|
||||
|
||||
return StopAndWaitObservable;
|
||||
}(Observable));
|
||||
|
||||
|
||||
/**
|
||||
* Attaches a stop and wait observable to the current observable.
|
||||
* @returns {Observable} A stop and wait observable.
|
||||
*/
|
||||
ControlledObservable.prototype.stopAndWait = function () {
|
||||
return new StopAndWaitObservable(this);
|
||||
};
|
||||
|
||||
var WindowedObservable = (function (__super__) {
|
||||
|
||||
function subscribe (observer) {
|
||||
this.subscription = this.source.subscribe(new WindowedObserver(observer, this, this.subscription));
|
||||
|
||||
var self = this;
|
||||
timeoutScheduler.schedule(function () {
|
||||
self.source.request(self.windowSize);
|
||||
});
|
||||
|
||||
return this.subscription;
|
||||
}
|
||||
|
||||
inherits(WindowedObservable, __super__);
|
||||
|
||||
function WindowedObservable(source, windowSize) {
|
||||
__super__.call(this, subscribe, source);
|
||||
this.source = source;
|
||||
this.windowSize = windowSize;
|
||||
}
|
||||
|
||||
var WindowedObserver = (function (__sub__) {
|
||||
|
||||
inherits(WindowedObserver, __sub__);
|
||||
|
||||
function WindowedObserver(observer, observable, cancel) {
|
||||
this.observer = observer;
|
||||
this.observable = observable;
|
||||
this.cancel = cancel;
|
||||
this.received = 0;
|
||||
}
|
||||
|
||||
var windowedObserverPrototype = WindowedObserver.prototype;
|
||||
|
||||
windowedObserverPrototype.completed = function () {
|
||||
this.observer.onCompleted();
|
||||
this.dispose();
|
||||
};
|
||||
|
||||
windowedObserverPrototype.error = function (error) {
|
||||
this.observer.onError(error);
|
||||
this.dispose();
|
||||
};
|
||||
|
||||
windowedObserverPrototype.next = function (value) {
|
||||
this.observer.onNext(value);
|
||||
|
||||
this.received = ++this.received % this.observable.windowSize;
|
||||
if (this.received === 0) {
|
||||
var self = this;
|
||||
timeoutScheduler.schedule(function () {
|
||||
self.observable.source.request(self.observable.windowSize);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
windowedObserverPrototype.dispose = function () {
|
||||
this.observer = null;
|
||||
if (this.cancel) {
|
||||
this.cancel.dispose();
|
||||
this.cancel = null;
|
||||
}
|
||||
__sub__.prototype.dispose.call(this);
|
||||
};
|
||||
|
||||
return WindowedObserver;
|
||||
}(AbstractObserver));
|
||||
|
||||
return WindowedObservable;
|
||||
}(Observable));
|
||||
|
||||
/**
|
||||
* Creates a sliding windowed observable based upon the window size.
|
||||
* @param {Number} windowSize The number of items in the window
|
||||
* @returns {Observable} A windowed observable based upon the window size.
|
||||
*/
|
||||
ControlledObservable.prototype.windowed = function (windowSize) {
|
||||
return new WindowedObservable(this, windowSize);
|
||||
};
|
||||
|
||||
return Rx;
|
||||
}));
|
1
node_modules/rx/dist/rx.backpressure.map
generated
vendored
Normal file
1
node_modules/rx/dist/rx.backpressure.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3
node_modules/rx/dist/rx.backpressure.min.js
generated
vendored
Normal file
3
node_modules/rx/dist/rx.backpressure.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
483
node_modules/rx/dist/rx.binding.js
generated
vendored
Normal file
483
node_modules/rx/dist/rx.binding.js
generated
vendored
Normal file
@ -0,0 +1,483 @@
|
||||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
;(function (factory) {
|
||||
var objectTypes = {
|
||||
'boolean': false,
|
||||
'function': true,
|
||||
'object': true,
|
||||
'number': false,
|
||||
'string': false,
|
||||
'undefined': false
|
||||
};
|
||||
|
||||
var root = (objectTypes[typeof window] && window) || this,
|
||||
freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports,
|
||||
freeModule = objectTypes[typeof module] && module && !module.nodeType && module,
|
||||
moduleExports = freeModule && freeModule.exports === freeExports && freeExports,
|
||||
freeGlobal = objectTypes[typeof global] && global;
|
||||
|
||||
if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) {
|
||||
root = freeGlobal;
|
||||
}
|
||||
|
||||
// Because of build optimizers
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['rx'], function (Rx, exports) {
|
||||
return factory(root, exports, Rx);
|
||||
});
|
||||
} else if (typeof module === 'object' && module && module.exports === freeExports) {
|
||||
module.exports = factory(root, module.exports, require('./rx'));
|
||||
} else {
|
||||
root.Rx = factory(root, {}, root.Rx);
|
||||
}
|
||||
}.call(this, function (root, exp, Rx, undefined) {
|
||||
|
||||
var Observable = Rx.Observable,
|
||||
observableProto = Observable.prototype,
|
||||
AnonymousObservable = Rx.AnonymousObservable,
|
||||
Subject = Rx.Subject,
|
||||
AsyncSubject = Rx.AsyncSubject,
|
||||
Observer = Rx.Observer,
|
||||
ScheduledObserver = Rx.internals.ScheduledObserver,
|
||||
disposableCreate = Rx.Disposable.create,
|
||||
disposableEmpty = Rx.Disposable.empty,
|
||||
CompositeDisposable = Rx.CompositeDisposable,
|
||||
currentThreadScheduler = Rx.Scheduler.currentThread,
|
||||
isFunction = Rx.helpers.isFunction,
|
||||
inherits = Rx.internals.inherits,
|
||||
addProperties = Rx.internals.addProperties;
|
||||
|
||||
// Utilities
|
||||
var objectDisposed = 'Object has been disposed';
|
||||
function checkDisposed() {
|
||||
if (this.isDisposed) { throw new Error(objectDisposed); }
|
||||
}
|
||||
|
||||
/**
|
||||
* Multicasts the source sequence notifications through an instantiated subject into all uses of the sequence within a selector function. Each
|
||||
* subscription to the resulting sequence causes a separate multicast invocation, exposing the sequence resulting from the selector function's
|
||||
* invocation. For specializations with fixed subject types, see Publish, PublishLast, and Replay.
|
||||
*
|
||||
* @example
|
||||
* 1 - res = source.multicast(observable);
|
||||
* 2 - res = source.multicast(function () { return new Subject(); }, function (x) { return x; });
|
||||
*
|
||||
* @param {Function|Subject} subjectOrSubjectSelector
|
||||
* Factory function to create an intermediate subject through which the source sequence's elements will be multicast to the selector function.
|
||||
* Or:
|
||||
* Subject to push source elements into.
|
||||
*
|
||||
* @param {Function} [selector] Optional selector function which can use the multicasted source sequence subject to the policies enforced by the created subject. Specified only if <paramref name="subjectOrSubjectSelector" is a factory function.
|
||||
* @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
|
||||
*/
|
||||
observableProto.multicast = function (subjectOrSubjectSelector, selector) {
|
||||
var source = this;
|
||||
return typeof subjectOrSubjectSelector === 'function' ?
|
||||
new AnonymousObservable(function (observer) {
|
||||
var connectable = source.multicast(subjectOrSubjectSelector());
|
||||
return new CompositeDisposable(selector(connectable).subscribe(observer), connectable.connect());
|
||||
}, source) :
|
||||
new ConnectableObservable(source, subjectOrSubjectSelector);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence.
|
||||
* This operator is a specialization of Multicast using a regular Subject.
|
||||
*
|
||||
* @example
|
||||
* var resres = source.publish();
|
||||
* var res = source.publish(function (x) { return x; });
|
||||
*
|
||||
* @param {Function} [selector] Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all notifications of the source from the time of the subscription on.
|
||||
* @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
|
||||
*/
|
||||
observableProto.publish = function (selector) {
|
||||
return selector && isFunction(selector) ?
|
||||
this.multicast(function () { return new Subject(); }, selector) :
|
||||
this.multicast(new Subject());
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an observable sequence that shares a single subscription to the underlying sequence.
|
||||
* This operator is a specialization of publish which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed.
|
||||
* @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence.
|
||||
*/
|
||||
observableProto.share = function () {
|
||||
return this.publish().refCount();
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence containing only the last notification.
|
||||
* This operator is a specialization of Multicast using a AsyncSubject.
|
||||
*
|
||||
* @example
|
||||
* var res = source.publishLast();
|
||||
* var res = source.publishLast(function (x) { return x; });
|
||||
*
|
||||
* @param selector [Optional] Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will only receive the last notification of the source.
|
||||
* @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
|
||||
*/
|
||||
observableProto.publishLast = function (selector) {
|
||||
return selector && isFunction(selector) ?
|
||||
this.multicast(function () { return new AsyncSubject(); }, selector) :
|
||||
this.multicast(new AsyncSubject());
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence and starts with initialValue.
|
||||
* This operator is a specialization of Multicast using a BehaviorSubject.
|
||||
*
|
||||
* @example
|
||||
* var res = source.publishValue(42);
|
||||
* var res = source.publishValue(function (x) { return x.select(function (y) { return y * y; }) }, 42);
|
||||
*
|
||||
* @param {Function} [selector] Optional selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive immediately receive the initial value, followed by all notifications of the source from the time of the subscription on.
|
||||
* @param {Mixed} initialValue Initial value received by observers upon subscription.
|
||||
* @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
|
||||
*/
|
||||
observableProto.publishValue = function (initialValueOrSelector, initialValue) {
|
||||
return arguments.length === 2 ?
|
||||
this.multicast(function () {
|
||||
return new BehaviorSubject(initialValue);
|
||||
}, initialValueOrSelector) :
|
||||
this.multicast(new BehaviorSubject(initialValueOrSelector));
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an observable sequence that shares a single subscription to the underlying sequence and starts with an initialValue.
|
||||
* This operator is a specialization of publishValue which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed.
|
||||
* @param {Mixed} initialValue Initial value received by observers upon subscription.
|
||||
* @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence.
|
||||
*/
|
||||
observableProto.shareValue = function (initialValue) {
|
||||
return this.publishValue(initialValue).refCount();
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence replaying notifications subject to a maximum time length for the replay buffer.
|
||||
* This operator is a specialization of Multicast using a ReplaySubject.
|
||||
*
|
||||
* @example
|
||||
* var res = source.replay(null, 3);
|
||||
* var res = source.replay(null, 3, 500);
|
||||
* var res = source.replay(null, 3, 500, scheduler);
|
||||
* var res = source.replay(function (x) { return x.take(6).repeat(); }, 3, 500, scheduler);
|
||||
*
|
||||
* @param selector [Optional] Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all the notifications of the source subject to the specified replay buffer trimming policy.
|
||||
* @param bufferSize [Optional] Maximum element count of the replay buffer.
|
||||
* @param window [Optional] Maximum time length of the replay buffer.
|
||||
* @param scheduler [Optional] Scheduler where connected observers within the selector function will be invoked on.
|
||||
* @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
|
||||
*/
|
||||
observableProto.replay = function (selector, bufferSize, window, scheduler) {
|
||||
return selector && isFunction(selector) ?
|
||||
this.multicast(function () { return new ReplaySubject(bufferSize, window, scheduler); }, selector) :
|
||||
this.multicast(new ReplaySubject(bufferSize, window, scheduler));
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an observable sequence that shares a single subscription to the underlying sequence replaying notifications subject to a maximum time length for the replay buffer.
|
||||
* This operator is a specialization of replay which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed.
|
||||
*
|
||||
* @example
|
||||
* var res = source.shareReplay(3);
|
||||
* var res = source.shareReplay(3, 500);
|
||||
* var res = source.shareReplay(3, 500, scheduler);
|
||||
*
|
||||
|
||||
* @param bufferSize [Optional] Maximum element count of the replay buffer.
|
||||
* @param window [Optional] Maximum time length of the replay buffer.
|
||||
* @param scheduler [Optional] Scheduler where connected observers within the selector function will be invoked on.
|
||||
* @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence.
|
||||
*/
|
||||
observableProto.shareReplay = function (bufferSize, window, scheduler) {
|
||||
return this.replay(null, bufferSize, window, scheduler).refCount();
|
||||
};
|
||||
|
||||
var InnerSubscription = function (subject, observer) {
|
||||
this.subject = subject;
|
||||
this.observer = observer;
|
||||
};
|
||||
|
||||
InnerSubscription.prototype.dispose = function () {
|
||||
if (!this.subject.isDisposed && this.observer !== null) {
|
||||
var idx = this.subject.observers.indexOf(this.observer);
|
||||
this.subject.observers.splice(idx, 1);
|
||||
this.observer = null;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents a value that changes over time.
|
||||
* Observers can subscribe to the subject to receive the last (or initial) value and all subsequent notifications.
|
||||
*/
|
||||
var BehaviorSubject = Rx.BehaviorSubject = (function (__super__) {
|
||||
function subscribe(observer) {
|
||||
checkDisposed.call(this);
|
||||
if (!this.isStopped) {
|
||||
this.observers.push(observer);
|
||||
observer.onNext(this.value);
|
||||
return new InnerSubscription(this, observer);
|
||||
}
|
||||
if (this.hasError) {
|
||||
observer.onError(this.error);
|
||||
} else {
|
||||
observer.onCompleted();
|
||||
}
|
||||
return disposableEmpty;
|
||||
}
|
||||
|
||||
inherits(BehaviorSubject, __super__);
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the BehaviorSubject class which creates a subject that caches its last value and starts with the specified value.
|
||||
* @param {Mixed} value Initial value sent to observers when no other value has been received by the subject yet.
|
||||
*/
|
||||
function BehaviorSubject(value) {
|
||||
__super__.call(this, subscribe);
|
||||
this.value = value,
|
||||
this.observers = [],
|
||||
this.isDisposed = false,
|
||||
this.isStopped = false,
|
||||
this.hasError = false;
|
||||
}
|
||||
|
||||
addProperties(BehaviorSubject.prototype, Observer, {
|
||||
/**
|
||||
* Indicates whether the subject has observers subscribed to it.
|
||||
* @returns {Boolean} Indicates whether the subject has observers subscribed to it.
|
||||
*/
|
||||
hasObservers: function () { return this.observers.length > 0; },
|
||||
/**
|
||||
* Notifies all subscribed observers about the end of the sequence.
|
||||
*/
|
||||
onCompleted: function () {
|
||||
checkDisposed.call(this);
|
||||
if (this.isStopped) { return; }
|
||||
this.isStopped = true;
|
||||
for (var i = 0, os = this.observers.slice(0), len = os.length; i < len; i++) {
|
||||
os[i].onCompleted();
|
||||
}
|
||||
|
||||
this.observers.length = 0;
|
||||
},
|
||||
/**
|
||||
* Notifies all subscribed observers about the exception.
|
||||
* @param {Mixed} error The exception to send to all observers.
|
||||
*/
|
||||
onError: function (error) {
|
||||
checkDisposed.call(this);
|
||||
if (this.isStopped) { return; }
|
||||
this.isStopped = true;
|
||||
this.hasError = true;
|
||||
this.error = error;
|
||||
|
||||
for (var i = 0, os = this.observers.slice(0), len = os.length; i < len; i++) {
|
||||
os[i].onError(error);
|
||||
}
|
||||
|
||||
this.observers.length = 0;
|
||||
},
|
||||
/**
|
||||
* Notifies all subscribed observers about the arrival of the specified element in the sequence.
|
||||
* @param {Mixed} value The value to send to all observers.
|
||||
*/
|
||||
onNext: function (value) {
|
||||
checkDisposed.call(this);
|
||||
if (this.isStopped) { return; }
|
||||
this.value = value;
|
||||
for (var i = 0, os = this.observers.slice(0), len = os.length; i < len; i++) {
|
||||
os[i].onNext(value);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Unsubscribe all observers and release resources.
|
||||
*/
|
||||
dispose: function () {
|
||||
this.isDisposed = true;
|
||||
this.observers = null;
|
||||
this.value = null;
|
||||
this.exception = null;
|
||||
}
|
||||
});
|
||||
|
||||
return BehaviorSubject;
|
||||
}(Observable));
|
||||
|
||||
/**
|
||||
* Represents an object that is both an observable sequence as well as an observer.
|
||||
* Each notification is broadcasted to all subscribed and future observers, subject to buffer trimming policies.
|
||||
*/
|
||||
var ReplaySubject = Rx.ReplaySubject = (function (__super__) {
|
||||
|
||||
function createRemovableDisposable(subject, observer) {
|
||||
return disposableCreate(function () {
|
||||
observer.dispose();
|
||||
!subject.isDisposed && subject.observers.splice(subject.observers.indexOf(observer), 1);
|
||||
});
|
||||
}
|
||||
|
||||
function subscribe(observer) {
|
||||
var so = new ScheduledObserver(this.scheduler, observer),
|
||||
subscription = createRemovableDisposable(this, so);
|
||||
checkDisposed.call(this);
|
||||
this._trim(this.scheduler.now());
|
||||
this.observers.push(so);
|
||||
|
||||
for (var i = 0, len = this.q.length; i < len; i++) {
|
||||
so.onNext(this.q[i].value);
|
||||
}
|
||||
|
||||
if (this.hasError) {
|
||||
so.onError(this.error);
|
||||
} else if (this.isStopped) {
|
||||
so.onCompleted();
|
||||
}
|
||||
|
||||
so.ensureActive();
|
||||
return subscription;
|
||||
}
|
||||
|
||||
inherits(ReplaySubject, __super__);
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the ReplaySubject class with the specified buffer size, window size and scheduler.
|
||||
* @param {Number} [bufferSize] Maximum element count of the replay buffer.
|
||||
* @param {Number} [windowSize] Maximum time length of the replay buffer.
|
||||
* @param {Scheduler} [scheduler] Scheduler the observers are invoked on.
|
||||
*/
|
||||
function ReplaySubject(bufferSize, windowSize, scheduler) {
|
||||
this.bufferSize = bufferSize == null ? Number.MAX_VALUE : bufferSize;
|
||||
this.windowSize = windowSize == null ? Number.MAX_VALUE : windowSize;
|
||||
this.scheduler = scheduler || currentThreadScheduler;
|
||||
this.q = [];
|
||||
this.observers = [];
|
||||
this.isStopped = false;
|
||||
this.isDisposed = false;
|
||||
this.hasError = false;
|
||||
this.error = null;
|
||||
__super__.call(this, subscribe);
|
||||
}
|
||||
|
||||
addProperties(ReplaySubject.prototype, Observer.prototype, {
|
||||
/**
|
||||
* Indicates whether the subject has observers subscribed to it.
|
||||
* @returns {Boolean} Indicates whether the subject has observers subscribed to it.
|
||||
*/
|
||||
hasObservers: function () {
|
||||
return this.observers.length > 0;
|
||||
},
|
||||
_trim: function (now) {
|
||||
while (this.q.length > this.bufferSize) {
|
||||
this.q.shift();
|
||||
}
|
||||
while (this.q.length > 0 && (now - this.q[0].interval) > this.windowSize) {
|
||||
this.q.shift();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Notifies all subscribed observers about the arrival of the specified element in the sequence.
|
||||
* @param {Mixed} value The value to send to all observers.
|
||||
*/
|
||||
onNext: function (value) {
|
||||
checkDisposed.call(this);
|
||||
if (this.isStopped) { return; }
|
||||
var now = this.scheduler.now();
|
||||
this.q.push({ interval: now, value: value });
|
||||
this._trim(now);
|
||||
|
||||
var o = this.observers.slice(0);
|
||||
for (var i = 0, len = o.length; i < len; i++) {
|
||||
var observer = o[i];
|
||||
observer.onNext(value);
|
||||
observer.ensureActive();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Notifies all subscribed observers about the exception.
|
||||
* @param {Mixed} error The exception to send to all observers.
|
||||
*/
|
||||
onError: function (error) {
|
||||
checkDisposed.call(this);
|
||||
if (this.isStopped) { return; }
|
||||
this.isStopped = true;
|
||||
this.error = error;
|
||||
this.hasError = true;
|
||||
var now = this.scheduler.now();
|
||||
this._trim(now);
|
||||
var o = this.observers.slice(0);
|
||||
for (var i = 0, len = o.length; i < len; i++) {
|
||||
var observer = o[i];
|
||||
observer.onError(error);
|
||||
observer.ensureActive();
|
||||
}
|
||||
this.observers = [];
|
||||
},
|
||||
/**
|
||||
* Notifies all subscribed observers about the end of the sequence.
|
||||
*/
|
||||
onCompleted: function () {
|
||||
checkDisposed.call(this);
|
||||
if (this.isStopped) { return; }
|
||||
this.isStopped = true;
|
||||
var now = this.scheduler.now();
|
||||
this._trim(now);
|
||||
var o = this.observers.slice(0);
|
||||
for (var i = 0, len = o.length; i < len; i++) {
|
||||
var observer = o[i];
|
||||
observer.onCompleted();
|
||||
observer.ensureActive();
|
||||
}
|
||||
this.observers = [];
|
||||
},
|
||||
/**
|
||||
* Unsubscribe all observers and release resources.
|
||||
*/
|
||||
dispose: function () {
|
||||
this.isDisposed = true;
|
||||
this.observers = null;
|
||||
}
|
||||
});
|
||||
|
||||
return ReplaySubject;
|
||||
}(Observable));
|
||||
|
||||
var ConnectableObservable = Rx.ConnectableObservable = (function (__super__) {
|
||||
inherits(ConnectableObservable, __super__);
|
||||
|
||||
function ConnectableObservable(source, subject) {
|
||||
var hasSubscription = false,
|
||||
subscription,
|
||||
sourceObservable = source.asObservable();
|
||||
|
||||
this.connect = function () {
|
||||
if (!hasSubscription) {
|
||||
hasSubscription = true;
|
||||
subscription = new CompositeDisposable(sourceObservable.subscribe(subject), disposableCreate(function () {
|
||||
hasSubscription = false;
|
||||
}));
|
||||
}
|
||||
return subscription;
|
||||
};
|
||||
|
||||
__super__.call(this, function (o) { return subject.subscribe(o); });
|
||||
}
|
||||
|
||||
ConnectableObservable.prototype.refCount = function () {
|
||||
var connectableSubscription, count = 0, source = this;
|
||||
return new AnonymousObservable(function (observer) {
|
||||
var shouldConnect = ++count === 1,
|
||||
subscription = source.subscribe(observer);
|
||||
shouldConnect && (connectableSubscription = source.connect());
|
||||
return function () {
|
||||
subscription.dispose();
|
||||
--count === 0 && connectableSubscription.dispose();
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
return ConnectableObservable;
|
||||
}(Observable));
|
||||
|
||||
return Rx;
|
||||
}));
|
1
node_modules/rx/dist/rx.binding.map
generated
vendored
Normal file
1
node_modules/rx/dist/rx.binding.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3
node_modules/rx/dist/rx.binding.min.js
generated
vendored
Normal file
3
node_modules/rx/dist/rx.binding.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
813
node_modules/rx/dist/rx.coincidence.js
generated
vendored
Normal file
813
node_modules/rx/dist/rx.coincidence.js
generated
vendored
Normal file
@ -0,0 +1,813 @@
|
||||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
;(function (factory) {
|
||||
var objectTypes = {
|
||||
'boolean': false,
|
||||
'function': true,
|
||||
'object': true,
|
||||
'number': false,
|
||||
'string': false,
|
||||
'undefined': false
|
||||
};
|
||||
|
||||
var root = (objectTypes[typeof window] && window) || this,
|
||||
freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports,
|
||||
freeModule = objectTypes[typeof module] && module && !module.nodeType && module,
|
||||
moduleExports = freeModule && freeModule.exports === freeExports && freeExports,
|
||||
freeGlobal = objectTypes[typeof global] && global;
|
||||
|
||||
if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) {
|
||||
root = freeGlobal;
|
||||
}
|
||||
|
||||
// Because of build optimizers
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['rx'], function (Rx, exports) {
|
||||
return factory(root, exports, Rx);
|
||||
});
|
||||
} else if (typeof module === 'object' && module && module.exports === freeExports) {
|
||||
module.exports = factory(root, module.exports, require('./rx'));
|
||||
} else {
|
||||
root.Rx = factory(root, {}, root.Rx);
|
||||
}
|
||||
}.call(this, function (root, exp, Rx, undefined) {
|
||||
|
||||
var Observable = Rx.Observable,
|
||||
CompositeDisposable = Rx.CompositeDisposable,
|
||||
RefCountDisposable = Rx.RefCountDisposable,
|
||||
SingleAssignmentDisposable = Rx.SingleAssignmentDisposable,
|
||||
SerialDisposable = Rx.SerialDisposable,
|
||||
Subject = Rx.Subject,
|
||||
observableProto = Observable.prototype,
|
||||
observableEmpty = Observable.empty,
|
||||
observableNever = Observable.never,
|
||||
AnonymousObservable = Rx.AnonymousObservable,
|
||||
observerCreate = Rx.Observer.create,
|
||||
addRef = Rx.internals.addRef,
|
||||
defaultComparer = Rx.internals.isEqual,
|
||||
noop = Rx.helpers.noop,
|
||||
identity = Rx.helpers.identity,
|
||||
isPromise = Rx.helpers.isPromise,
|
||||
observableFromPromise = Observable.fromPromise;
|
||||
|
||||
var Dictionary = (function () {
|
||||
|
||||
var primes = [1, 3, 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381, 32749, 65521, 131071, 262139, 524287, 1048573, 2097143, 4194301, 8388593, 16777213, 33554393, 67108859, 134217689, 268435399, 536870909, 1073741789, 2147483647],
|
||||
noSuchkey = "no such key",
|
||||
duplicatekey = "duplicate key";
|
||||
|
||||
function isPrime(candidate) {
|
||||
if ((candidate & 1) === 0) { return candidate === 2; }
|
||||
var num1 = Math.sqrt(candidate),
|
||||
num2 = 3;
|
||||
while (num2 <= num1) {
|
||||
if (candidate % num2 === 0) { return false; }
|
||||
num2 += 2;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function getPrime(min) {
|
||||
var index, num, candidate;
|
||||
for (index = 0; index < primes.length; ++index) {
|
||||
num = primes[index];
|
||||
if (num >= min) { return num; }
|
||||
}
|
||||
candidate = min | 1;
|
||||
while (candidate < primes[primes.length - 1]) {
|
||||
if (isPrime(candidate)) { return candidate; }
|
||||
candidate += 2;
|
||||
}
|
||||
return min;
|
||||
}
|
||||
|
||||
function stringHashFn(str) {
|
||||
var hash = 757602046;
|
||||
if (!str.length) { return hash; }
|
||||
for (var i = 0, len = str.length; i < len; i++) {
|
||||
var character = str.charCodeAt(i);
|
||||
hash = ((hash << 5) - hash) + character;
|
||||
hash = hash & hash;
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
function numberHashFn(key) {
|
||||
var c2 = 0x27d4eb2d;
|
||||
key = (key ^ 61) ^ (key >>> 16);
|
||||
key = key + (key << 3);
|
||||
key = key ^ (key >>> 4);
|
||||
key = key * c2;
|
||||
key = key ^ (key >>> 15);
|
||||
return key;
|
||||
}
|
||||
|
||||
var getHashCode = (function () {
|
||||
var uniqueIdCounter = 0;
|
||||
|
||||
return function (obj) {
|
||||
if (obj == null) { throw new Error(noSuchkey); }
|
||||
|
||||
// Check for built-ins before tacking on our own for any object
|
||||
if (typeof obj === 'string') { return stringHashFn(obj); }
|
||||
if (typeof obj === 'number') { return numberHashFn(obj); }
|
||||
if (typeof obj === 'boolean') { return obj === true ? 1 : 0; }
|
||||
if (obj instanceof Date) { return numberHashFn(obj.valueOf()); }
|
||||
if (obj instanceof RegExp) { return stringHashFn(obj.toString()); }
|
||||
if (typeof obj.valueOf === 'function') {
|
||||
// Hack check for valueOf
|
||||
var valueOf = obj.valueOf();
|
||||
if (typeof valueOf === 'number') { return numberHashFn(valueOf); }
|
||||
if (typeof obj === 'string') { return stringHashFn(valueOf); }
|
||||
}
|
||||
if (obj.hashCode) { return obj.hashCode(); }
|
||||
|
||||
var id = 17 * uniqueIdCounter++;
|
||||
obj.hashCode = function () { return id; };
|
||||
return id;
|
||||
};
|
||||
}());
|
||||
|
||||
function newEntry() {
|
||||
return { key: null, value: null, next: 0, hashCode: 0 };
|
||||
}
|
||||
|
||||
function Dictionary(capacity, comparer) {
|
||||
if (capacity < 0) { throw new Error('out of range'); }
|
||||
if (capacity > 0) { this._initialize(capacity); }
|
||||
|
||||
this.comparer = comparer || defaultComparer;
|
||||
this.freeCount = 0;
|
||||
this.size = 0;
|
||||
this.freeList = -1;
|
||||
}
|
||||
|
||||
var dictionaryProto = Dictionary.prototype;
|
||||
|
||||
dictionaryProto._initialize = function (capacity) {
|
||||
var prime = getPrime(capacity), i;
|
||||
this.buckets = new Array(prime);
|
||||
this.entries = new Array(prime);
|
||||
for (i = 0; i < prime; i++) {
|
||||
this.buckets[i] = -1;
|
||||
this.entries[i] = newEntry();
|
||||
}
|
||||
this.freeList = -1;
|
||||
};
|
||||
|
||||
dictionaryProto.add = function (key, value) {
|
||||
this._insert(key, value, true);
|
||||
};
|
||||
|
||||
dictionaryProto._insert = function (key, value, add) {
|
||||
if (!this.buckets) { this._initialize(0); }
|
||||
var index3,
|
||||
num = getHashCode(key) & 2147483647,
|
||||
index1 = num % this.buckets.length;
|
||||
for (var index2 = this.buckets[index1]; index2 >= 0; index2 = this.entries[index2].next) {
|
||||
if (this.entries[index2].hashCode === num && this.comparer(this.entries[index2].key, key)) {
|
||||
if (add) { throw new Error(duplicatekey); }
|
||||
this.entries[index2].value = value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (this.freeCount > 0) {
|
||||
index3 = this.freeList;
|
||||
this.freeList = this.entries[index3].next;
|
||||
--this.freeCount;
|
||||
} else {
|
||||
if (this.size === this.entries.length) {
|
||||
this._resize();
|
||||
index1 = num % this.buckets.length;
|
||||
}
|
||||
index3 = this.size;
|
||||
++this.size;
|
||||
}
|
||||
this.entries[index3].hashCode = num;
|
||||
this.entries[index3].next = this.buckets[index1];
|
||||
this.entries[index3].key = key;
|
||||
this.entries[index3].value = value;
|
||||
this.buckets[index1] = index3;
|
||||
};
|
||||
|
||||
dictionaryProto._resize = function () {
|
||||
var prime = getPrime(this.size * 2),
|
||||
numArray = new Array(prime);
|
||||
for (index = 0; index < numArray.length; ++index) { numArray[index] = -1; }
|
||||
var entryArray = new Array(prime);
|
||||
for (index = 0; index < this.size; ++index) { entryArray[index] = this.entries[index]; }
|
||||
for (var index = this.size; index < prime; ++index) { entryArray[index] = newEntry(); }
|
||||
for (var index1 = 0; index1 < this.size; ++index1) {
|
||||
var index2 = entryArray[index1].hashCode % prime;
|
||||
entryArray[index1].next = numArray[index2];
|
||||
numArray[index2] = index1;
|
||||
}
|
||||
this.buckets = numArray;
|
||||
this.entries = entryArray;
|
||||
};
|
||||
|
||||
dictionaryProto.remove = function (key) {
|
||||
if (this.buckets) {
|
||||
var num = getHashCode(key) & 2147483647,
|
||||
index1 = num % this.buckets.length,
|
||||
index2 = -1;
|
||||
for (var index3 = this.buckets[index1]; index3 >= 0; index3 = this.entries[index3].next) {
|
||||
if (this.entries[index3].hashCode === num && this.comparer(this.entries[index3].key, key)) {
|
||||
if (index2 < 0) {
|
||||
this.buckets[index1] = this.entries[index3].next;
|
||||
} else {
|
||||
this.entries[index2].next = this.entries[index3].next;
|
||||
}
|
||||
this.entries[index3].hashCode = -1;
|
||||
this.entries[index3].next = this.freeList;
|
||||
this.entries[index3].key = null;
|
||||
this.entries[index3].value = null;
|
||||
this.freeList = index3;
|
||||
++this.freeCount;
|
||||
return true;
|
||||
} else {
|
||||
index2 = index3;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
dictionaryProto.clear = function () {
|
||||
var index, len;
|
||||
if (this.size <= 0) { return; }
|
||||
for (index = 0, len = this.buckets.length; index < len; ++index) {
|
||||
this.buckets[index] = -1;
|
||||
}
|
||||
for (index = 0; index < this.size; ++index) {
|
||||
this.entries[index] = newEntry();
|
||||
}
|
||||
this.freeList = -1;
|
||||
this.size = 0;
|
||||
};
|
||||
|
||||
dictionaryProto._findEntry = function (key) {
|
||||
if (this.buckets) {
|
||||
var num = getHashCode(key) & 2147483647;
|
||||
for (var index = this.buckets[num % this.buckets.length]; index >= 0; index = this.entries[index].next) {
|
||||
if (this.entries[index].hashCode === num && this.comparer(this.entries[index].key, key)) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
|
||||
dictionaryProto.count = function () {
|
||||
return this.size - this.freeCount;
|
||||
};
|
||||
|
||||
dictionaryProto.tryGetValue = function (key) {
|
||||
var entry = this._findEntry(key);
|
||||
return entry >= 0 ?
|
||||
this.entries[entry].value :
|
||||
undefined;
|
||||
};
|
||||
|
||||
dictionaryProto.getValues = function () {
|
||||
var index = 0, results = [];
|
||||
if (this.entries) {
|
||||
for (var index1 = 0; index1 < this.size; index1++) {
|
||||
if (this.entries[index1].hashCode >= 0) {
|
||||
results[index++] = this.entries[index1].value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
dictionaryProto.get = function (key) {
|
||||
var entry = this._findEntry(key);
|
||||
if (entry >= 0) { return this.entries[entry].value; }
|
||||
throw new Error(noSuchkey);
|
||||
};
|
||||
|
||||
dictionaryProto.set = function (key, value) {
|
||||
this._insert(key, value, false);
|
||||
};
|
||||
|
||||
dictionaryProto.containskey = function (key) {
|
||||
return this._findEntry(key) >= 0;
|
||||
};
|
||||
|
||||
return Dictionary;
|
||||
}());
|
||||
|
||||
/**
|
||||
* Correlates the elements of two sequences based on overlapping durations.
|
||||
*
|
||||
* @param {Observable} right The right observable sequence to join elements for.
|
||||
* @param {Function} leftDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the left observable sequence, used to determine overlap.
|
||||
* @param {Function} rightDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the right observable sequence, used to determine overlap.
|
||||
* @param {Function} resultSelector A function invoked to compute a result element for any two overlapping elements of the left and right observable sequences. The parameters passed to the function correspond with the elements from the left and right source sequences for which overlap occurs.
|
||||
* @returns {Observable} An observable sequence that contains result elements computed from source elements that have an overlapping duration.
|
||||
*/
|
||||
observableProto.join = function (right, leftDurationSelector, rightDurationSelector, resultSelector) {
|
||||
var left = this;
|
||||
return new AnonymousObservable(function (observer) {
|
||||
var group = new CompositeDisposable();
|
||||
var leftDone = false, rightDone = false;
|
||||
var leftId = 0, rightId = 0;
|
||||
var leftMap = new Dictionary(), rightMap = new Dictionary();
|
||||
|
||||
group.add(left.subscribe(
|
||||
function (value) {
|
||||
var id = leftId++;
|
||||
var md = new SingleAssignmentDisposable();
|
||||
|
||||
leftMap.add(id, value);
|
||||
group.add(md);
|
||||
|
||||
var expire = function () {
|
||||
leftMap.remove(id) && leftMap.count() === 0 && leftDone && observer.onCompleted();
|
||||
group.remove(md);
|
||||
};
|
||||
|
||||
var duration;
|
||||
try {
|
||||
duration = leftDurationSelector(value);
|
||||
} catch (e) {
|
||||
observer.onError(e);
|
||||
return;
|
||||
}
|
||||
|
||||
md.setDisposable(duration.take(1).subscribe(noop, observer.onError.bind(observer), expire));
|
||||
|
||||
rightMap.getValues().forEach(function (v) {
|
||||
var result;
|
||||
try {
|
||||
result = resultSelector(value, v);
|
||||
} catch (exn) {
|
||||
observer.onError(exn);
|
||||
return;
|
||||
}
|
||||
|
||||
observer.onNext(result);
|
||||
});
|
||||
},
|
||||
observer.onError.bind(observer),
|
||||
function () {
|
||||
leftDone = true;
|
||||
(rightDone || leftMap.count() === 0) && observer.onCompleted();
|
||||
})
|
||||
);
|
||||
|
||||
group.add(right.subscribe(
|
||||
function (value) {
|
||||
var id = rightId++;
|
||||
var md = new SingleAssignmentDisposable();
|
||||
|
||||
rightMap.add(id, value);
|
||||
group.add(md);
|
||||
|
||||
var expire = function () {
|
||||
rightMap.remove(id) && rightMap.count() === 0 && rightDone && observer.onCompleted();
|
||||
group.remove(md);
|
||||
};
|
||||
|
||||
var duration;
|
||||
try {
|
||||
duration = rightDurationSelector(value);
|
||||
} catch (e) {
|
||||
observer.onError(e);
|
||||
return;
|
||||
}
|
||||
|
||||
md.setDisposable(duration.take(1).subscribe(noop, observer.onError.bind(observer), expire));
|
||||
|
||||
leftMap.getValues().forEach(function (v) {
|
||||
var result;
|
||||
try {
|
||||
result = resultSelector(v, value);
|
||||
} catch (exn) {
|
||||
observer.onError(exn);
|
||||
return;
|
||||
}
|
||||
|
||||
observer.onNext(result);
|
||||
});
|
||||
},
|
||||
observer.onError.bind(observer),
|
||||
function () {
|
||||
rightDone = true;
|
||||
(leftDone || rightMap.count() === 0) && observer.onCompleted();
|
||||
})
|
||||
);
|
||||
return group;
|
||||
}, left);
|
||||
};
|
||||
|
||||
/**
|
||||
* Correlates the elements of two sequences based on overlapping durations, and groups the results.
|
||||
*
|
||||
* @param {Observable} right The right observable sequence to join elements for.
|
||||
* @param {Function} leftDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the left observable sequence, used to determine overlap.
|
||||
* @param {Function} rightDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the right observable sequence, used to determine overlap.
|
||||
* @param {Function} resultSelector A function invoked to compute a result element for any element of the left sequence with overlapping elements from the right observable sequence. The first parameter passed to the function is an element of the left sequence. The second parameter passed to the function is an observable sequence with elements from the right sequence that overlap with the left sequence's element.
|
||||
* @returns {Observable} An observable sequence that contains result elements computed from source elements that have an overlapping duration.
|
||||
*/
|
||||
observableProto.groupJoin = function (right, leftDurationSelector, rightDurationSelector, resultSelector) {
|
||||
var left = this;
|
||||
return new AnonymousObservable(function (observer) {
|
||||
var group = new CompositeDisposable();
|
||||
var r = new RefCountDisposable(group);
|
||||
var leftMap = new Dictionary(), rightMap = new Dictionary();
|
||||
var leftId = 0, rightId = 0;
|
||||
|
||||
function handleError(e) { return function (v) { v.onError(e); }; };
|
||||
|
||||
group.add(left.subscribe(
|
||||
function (value) {
|
||||
var s = new Subject();
|
||||
var id = leftId++;
|
||||
leftMap.add(id, s);
|
||||
|
||||
var result;
|
||||
try {
|
||||
result = resultSelector(value, addRef(s, r));
|
||||
} catch (e) {
|
||||
leftMap.getValues().forEach(handleError(e));
|
||||
observer.onError(e);
|
||||
return;
|
||||
}
|
||||
observer.onNext(result);
|
||||
|
||||
rightMap.getValues().forEach(function (v) { s.onNext(v); });
|
||||
|
||||
var md = new SingleAssignmentDisposable();
|
||||
group.add(md);
|
||||
|
||||
var expire = function () {
|
||||
leftMap.remove(id) && s.onCompleted();
|
||||
group.remove(md);
|
||||
};
|
||||
|
||||
var duration;
|
||||
try {
|
||||
duration = leftDurationSelector(value);
|
||||
} catch (e) {
|
||||
leftMap.getValues().forEach(handleError(e));
|
||||
observer.onError(e);
|
||||
return;
|
||||
}
|
||||
|
||||
md.setDisposable(duration.take(1).subscribe(
|
||||
noop,
|
||||
function (e) {
|
||||
leftMap.getValues().forEach(handleError(e));
|
||||
observer.onError(e);
|
||||
},
|
||||
expire)
|
||||
);
|
||||
},
|
||||
function (e) {
|
||||
leftMap.getValues().forEach(handleError(e));
|
||||
observer.onError(e);
|
||||
},
|
||||
observer.onCompleted.bind(observer))
|
||||
);
|
||||
|
||||
group.add(right.subscribe(
|
||||
function (value) {
|
||||
var id = rightId++;
|
||||
rightMap.add(id, value);
|
||||
|
||||
var md = new SingleAssignmentDisposable();
|
||||
group.add(md);
|
||||
|
||||
var expire = function () {
|
||||
rightMap.remove(id);
|
||||
group.remove(md);
|
||||
};
|
||||
|
||||
var duration;
|
||||
try {
|
||||
duration = rightDurationSelector(value);
|
||||
} catch (e) {
|
||||
leftMap.getValues().forEach(handleError(e));
|
||||
observer.onError(e);
|
||||
return;
|
||||
}
|
||||
md.setDisposable(duration.take(1).subscribe(
|
||||
noop,
|
||||
function (e) {
|
||||
leftMap.getValues().forEach(handleError(e));
|
||||
observer.onError(e);
|
||||
},
|
||||
expire)
|
||||
);
|
||||
|
||||
leftMap.getValues().forEach(function (v) { v.onNext(value); });
|
||||
},
|
||||
function (e) {
|
||||
leftMap.getValues().forEach(handleError(e));
|
||||
observer.onError(e);
|
||||
})
|
||||
);
|
||||
|
||||
return r;
|
||||
}, left);
|
||||
};
|
||||
|
||||
/**
|
||||
* Projects each element of an observable sequence into zero or more buffers.
|
||||
*
|
||||
* @param {Mixed} bufferOpeningsOrClosingSelector Observable sequence whose elements denote the creation of new windows, or, a function invoked to define the boundaries of the produced windows (a new window is started when the previous one is closed, resulting in non-overlapping windows).
|
||||
* @param {Function} [bufferClosingSelector] A function invoked to define the closing of each produced window. If a closing selector function is specified for the first parameter, this parameter is ignored.
|
||||
* @returns {Observable} An observable sequence of windows.
|
||||
*/
|
||||
observableProto.buffer = function (bufferOpeningsOrClosingSelector, bufferClosingSelector) {
|
||||
return this.window.apply(this, arguments).selectMany(function (x) { return x.toArray(); });
|
||||
};
|
||||
|
||||
/**
|
||||
* Projects each element of an observable sequence into zero or more windows.
|
||||
*
|
||||
* @param {Mixed} windowOpeningsOrClosingSelector Observable sequence whose elements denote the creation of new windows, or, a function invoked to define the boundaries of the produced windows (a new window is started when the previous one is closed, resulting in non-overlapping windows).
|
||||
* @param {Function} [windowClosingSelector] A function invoked to define the closing of each produced window. If a closing selector function is specified for the first parameter, this parameter is ignored.
|
||||
* @returns {Observable} An observable sequence of windows.
|
||||
*/
|
||||
observableProto.window = function (windowOpeningsOrClosingSelector, windowClosingSelector) {
|
||||
if (arguments.length === 1 && typeof arguments[0] !== 'function') {
|
||||
return observableWindowWithBoundaries.call(this, windowOpeningsOrClosingSelector);
|
||||
}
|
||||
return typeof windowOpeningsOrClosingSelector === 'function' ?
|
||||
observableWindowWithClosingSelector.call(this, windowOpeningsOrClosingSelector) :
|
||||
observableWindowWithOpenings.call(this, windowOpeningsOrClosingSelector, windowClosingSelector);
|
||||
};
|
||||
|
||||
function observableWindowWithOpenings(windowOpenings, windowClosingSelector) {
|
||||
return windowOpenings.groupJoin(this, windowClosingSelector, observableEmpty, function (_, win) {
|
||||
return win;
|
||||
});
|
||||
}
|
||||
|
||||
function observableWindowWithBoundaries(windowBoundaries) {
|
||||
var source = this;
|
||||
return new AnonymousObservable(function (observer) {
|
||||
var win = new Subject(),
|
||||
d = new CompositeDisposable(),
|
||||
r = new RefCountDisposable(d);
|
||||
|
||||
observer.onNext(addRef(win, r));
|
||||
|
||||
d.add(source.subscribe(function (x) {
|
||||
win.onNext(x);
|
||||
}, function (err) {
|
||||
win.onError(err);
|
||||
observer.onError(err);
|
||||
}, function () {
|
||||
win.onCompleted();
|
||||
observer.onCompleted();
|
||||
}));
|
||||
|
||||
isPromise(windowBoundaries) && (windowBoundaries = observableFromPromise(windowBoundaries));
|
||||
|
||||
d.add(windowBoundaries.subscribe(function (w) {
|
||||
win.onCompleted();
|
||||
win = new Subject();
|
||||
observer.onNext(addRef(win, r));
|
||||
}, function (err) {
|
||||
win.onError(err);
|
||||
observer.onError(err);
|
||||
}, function () {
|
||||
win.onCompleted();
|
||||
observer.onCompleted();
|
||||
}));
|
||||
|
||||
return r;
|
||||
}, source);
|
||||
}
|
||||
|
||||
function observableWindowWithClosingSelector(windowClosingSelector) {
|
||||
var source = this;
|
||||
return new AnonymousObservable(function (observer) {
|
||||
var m = new SerialDisposable(),
|
||||
d = new CompositeDisposable(m),
|
||||
r = new RefCountDisposable(d),
|
||||
win = new Subject();
|
||||
observer.onNext(addRef(win, r));
|
||||
d.add(source.subscribe(function (x) {
|
||||
win.onNext(x);
|
||||
}, function (err) {
|
||||
win.onError(err);
|
||||
observer.onError(err);
|
||||
}, function () {
|
||||
win.onCompleted();
|
||||
observer.onCompleted();
|
||||
}));
|
||||
|
||||
function createWindowClose () {
|
||||
var windowClose;
|
||||
try {
|
||||
windowClose = windowClosingSelector();
|
||||
} catch (e) {
|
||||
observer.onError(e);
|
||||
return;
|
||||
}
|
||||
|
||||
isPromise(windowClose) && (windowClose = observableFromPromise(windowClose));
|
||||
|
||||
var m1 = new SingleAssignmentDisposable();
|
||||
m.setDisposable(m1);
|
||||
m1.setDisposable(windowClose.take(1).subscribe(noop, function (err) {
|
||||
win.onError(err);
|
||||
observer.onError(err);
|
||||
}, function () {
|
||||
win.onCompleted();
|
||||
win = new Subject();
|
||||
observer.onNext(addRef(win, r));
|
||||
createWindowClose();
|
||||
}));
|
||||
}
|
||||
|
||||
createWindowClose();
|
||||
return r;
|
||||
}, source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new observable that triggers on the second and subsequent triggerings of the input observable.
|
||||
* The Nth triggering of the input observable passes the arguments from the N-1th and Nth triggering as a pair.
|
||||
* The argument passed to the N-1th triggering is held in hidden internal state until the Nth triggering occurs.
|
||||
* @returns {Observable} An observable that triggers on successive pairs of observations from the input observable as an array.
|
||||
*/
|
||||
observableProto.pairwise = function () {
|
||||
var source = this;
|
||||
return new AnonymousObservable(function (observer) {
|
||||
var previous, hasPrevious = false;
|
||||
return source.subscribe(
|
||||
function (x) {
|
||||
if (hasPrevious) {
|
||||
observer.onNext([previous, x]);
|
||||
} else {
|
||||
hasPrevious = true;
|
||||
}
|
||||
previous = x;
|
||||
},
|
||||
observer.onError.bind(observer),
|
||||
observer.onCompleted.bind(observer));
|
||||
}, source);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns two observables which partition the observations of the source by the given function.
|
||||
* The first will trigger observations for those values for which the predicate returns true.
|
||||
* The second will trigger observations for those values where the predicate returns false.
|
||||
* The predicate is executed once for each subscribed observer.
|
||||
* Both also propagate all error observations arising from the source and each completes
|
||||
* when the source completes.
|
||||
* @param {Function} predicate
|
||||
* The function to determine which output Observable will trigger a particular observation.
|
||||
* @returns {Array}
|
||||
* An array of observables. The first triggers when the predicate returns true,
|
||||
* and the second triggers when the predicate returns false.
|
||||
*/
|
||||
observableProto.partition = function(predicate, thisArg) {
|
||||
return [
|
||||
this.filter(predicate, thisArg),
|
||||
this.filter(function (x, i, o) { return !predicate.call(thisArg, x, i, o); })
|
||||
];
|
||||
};
|
||||
|
||||
/**
|
||||
* Groups the elements of an observable sequence according to a specified key selector function and comparer and selects the resulting elements by using a specified function.
|
||||
*
|
||||
* @example
|
||||
* var res = observable.groupBy(function (x) { return x.id; });
|
||||
* 2 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; });
|
||||
* 3 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function (x) { return x.toString(); });
|
||||
* @param {Function} keySelector A function to extract the key for each element.
|
||||
* @param {Function} [elementSelector] A function to map each source element to an element in an observable group.
|
||||
* @param {Function} [comparer] Used to determine whether the objects are equal.
|
||||
* @returns {Observable} A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
|
||||
*/
|
||||
observableProto.groupBy = function (keySelector, elementSelector, comparer) {
|
||||
return this.groupByUntil(keySelector, elementSelector, observableNever, comparer);
|
||||
};
|
||||
|
||||
/**
|
||||
* Groups the elements of an observable sequence according to a specified key selector function.
|
||||
* A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same
|
||||
* key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
|
||||
*
|
||||
* @example
|
||||
* var res = observable.groupByUntil(function (x) { return x.id; }, null, function () { return Rx.Observable.never(); });
|
||||
* 2 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function () { return Rx.Observable.never(); });
|
||||
* 3 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function () { return Rx.Observable.never(); }, function (x) { return x.toString(); });
|
||||
* @param {Function} keySelector A function to extract the key for each element.
|
||||
* @param {Function} durationSelector A function to signal the expiration of a group.
|
||||
* @param {Function} [comparer] Used to compare objects. When not specified, the default comparer is used.
|
||||
* @returns {Observable}
|
||||
* A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
|
||||
* If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encoutered.
|
||||
*
|
||||
*/
|
||||
observableProto.groupByUntil = function (keySelector, elementSelector, durationSelector, comparer) {
|
||||
var source = this;
|
||||
elementSelector || (elementSelector = identity);
|
||||
comparer || (comparer = defaultComparer);
|
||||
return new AnonymousObservable(function (observer) {
|
||||
function handleError(e) { return function (item) { item.onError(e); }; }
|
||||
var map = new Dictionary(0, comparer),
|
||||
groupDisposable = new CompositeDisposable(),
|
||||
refCountDisposable = new RefCountDisposable(groupDisposable);
|
||||
|
||||
groupDisposable.add(source.subscribe(function (x) {
|
||||
var key;
|
||||
try {
|
||||
key = keySelector(x);
|
||||
} catch (e) {
|
||||
map.getValues().forEach(handleError(e));
|
||||
observer.onError(e);
|
||||
return;
|
||||
}
|
||||
|
||||
var fireNewMapEntry = false,
|
||||
writer = map.tryGetValue(key);
|
||||
if (!writer) {
|
||||
writer = new Subject();
|
||||
map.set(key, writer);
|
||||
fireNewMapEntry = true;
|
||||
}
|
||||
|
||||
if (fireNewMapEntry) {
|
||||
var group = new GroupedObservable(key, writer, refCountDisposable),
|
||||
durationGroup = new GroupedObservable(key, writer);
|
||||
try {
|
||||
duration = durationSelector(durationGroup);
|
||||
} catch (e) {
|
||||
map.getValues().forEach(handleError(e));
|
||||
observer.onError(e);
|
||||
return;
|
||||
}
|
||||
|
||||
observer.onNext(group);
|
||||
|
||||
var md = new SingleAssignmentDisposable();
|
||||
groupDisposable.add(md);
|
||||
|
||||
var expire = function () {
|
||||
map.remove(key) && writer.onCompleted();
|
||||
groupDisposable.remove(md);
|
||||
};
|
||||
|
||||
md.setDisposable(duration.take(1).subscribe(
|
||||
noop,
|
||||
function (exn) {
|
||||
map.getValues().forEach(handleError(exn));
|
||||
observer.onError(exn);
|
||||
},
|
||||
expire)
|
||||
);
|
||||
}
|
||||
|
||||
var element;
|
||||
try {
|
||||
element = elementSelector(x);
|
||||
} catch (e) {
|
||||
map.getValues().forEach(handleError(e));
|
||||
observer.onError(e);
|
||||
return;
|
||||
}
|
||||
|
||||
writer.onNext(element);
|
||||
}, function (ex) {
|
||||
map.getValues().forEach(handleError(ex));
|
||||
observer.onError(ex);
|
||||
}, function () {
|
||||
map.getValues().forEach(function (item) { item.onCompleted(); });
|
||||
observer.onCompleted();
|
||||
}));
|
||||
|
||||
return refCountDisposable;
|
||||
}, source);
|
||||
};
|
||||
|
||||
var GroupedObservable = (function (__super__) {
|
||||
inherits(GroupedObservable, __super__);
|
||||
|
||||
function subscribe(observer) {
|
||||
return this.underlyingObservable.subscribe(observer);
|
||||
}
|
||||
|
||||
function GroupedObservable(key, underlyingObservable, mergedDisposable) {
|
||||
__super__.call(this, subscribe);
|
||||
this.key = key;
|
||||
this.underlyingObservable = !mergedDisposable ?
|
||||
underlyingObservable :
|
||||
new AnonymousObservable(function (observer) {
|
||||
return new CompositeDisposable(mergedDisposable.getDisposable(), underlyingObservable.subscribe(observer));
|
||||
});
|
||||
}
|
||||
|
||||
return GroupedObservable;
|
||||
}(Observable));
|
||||
|
||||
return Rx;
|
||||
}));
|
1
node_modules/rx/dist/rx.coincidence.map
generated
vendored
Normal file
1
node_modules/rx/dist/rx.coincidence.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3
node_modules/rx/dist/rx.coincidence.min.js
generated
vendored
Normal file
3
node_modules/rx/dist/rx.coincidence.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
4961
node_modules/rx/dist/rx.compat.js
generated
vendored
Normal file
4961
node_modules/rx/dist/rx.compat.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/rx/dist/rx.compat.map
generated
vendored
Normal file
1
node_modules/rx/dist/rx.compat.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
4
node_modules/rx/dist/rx.compat.min.js
generated
vendored
Normal file
4
node_modules/rx/dist/rx.compat.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
587
node_modules/rx/dist/rx.experimental.js
generated
vendored
Normal file
587
node_modules/rx/dist/rx.experimental.js
generated
vendored
Normal file
@ -0,0 +1,587 @@
|
||||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
;(function (factory) {
|
||||
var objectTypes = {
|
||||
'boolean': false,
|
||||
'function': true,
|
||||
'object': true,
|
||||
'number': false,
|
||||
'string': false,
|
||||
'undefined': false
|
||||
};
|
||||
|
||||
var root = (objectTypes[typeof window] && window) || this,
|
||||
freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports,
|
||||
freeModule = objectTypes[typeof module] && module && !module.nodeType && module,
|
||||
moduleExports = freeModule && freeModule.exports === freeExports && freeExports,
|
||||
freeGlobal = objectTypes[typeof global] && global;
|
||||
|
||||
if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) {
|
||||
root = freeGlobal;
|
||||
}
|
||||
|
||||
// Because of build optimizers
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['rx'], function (Rx, exports) {
|
||||
return factory(root, exports, Rx);
|
||||
});
|
||||
} else if (typeof module === 'object' && module && module.exports === freeExports) {
|
||||
module.exports = factory(root, module.exports, require('./rx'));
|
||||
} else {
|
||||
root.Rx = factory(root, {}, root.Rx);
|
||||
}
|
||||
}.call(this, function (root, exp, Rx, undefined) {
|
||||
|
||||
// Aliases
|
||||
var Observable = Rx.Observable,
|
||||
observableProto = Observable.prototype,
|
||||
AnonymousObservable = Rx.AnonymousObservable,
|
||||
observableConcat = Observable.concat,
|
||||
observableDefer = Observable.defer,
|
||||
observableEmpty = Observable.empty,
|
||||
disposableEmpty = Rx.Disposable.empty,
|
||||
CompositeDisposable = Rx.CompositeDisposable,
|
||||
SerialDisposable = Rx.SerialDisposable,
|
||||
SingleAssignmentDisposable = Rx.SingleAssignmentDisposable,
|
||||
Enumerator = Rx.internals.Enumerator,
|
||||
Enumerable = Rx.internals.Enumerable,
|
||||
enumerableOf = Enumerable.of,
|
||||
immediateScheduler = Rx.Scheduler.immediate,
|
||||
currentThreadScheduler = Rx.Scheduler.currentThread,
|
||||
slice = Array.prototype.slice,
|
||||
AsyncSubject = Rx.AsyncSubject,
|
||||
Observer = Rx.Observer,
|
||||
inherits = Rx.internals.inherits,
|
||||
bindCallback = Rx.internals.bindCallback,
|
||||
addProperties = Rx.internals.addProperties,
|
||||
helpers = Rx.helpers,
|
||||
noop = helpers.noop,
|
||||
isPromise = helpers.isPromise,
|
||||
isScheduler = helpers.isScheduler,
|
||||
observableFromPromise = Observable.fromPromise;
|
||||
|
||||
// Utilities
|
||||
function argsOrArray(args, idx) {
|
||||
return args.length === 1 && Array.isArray(args[idx]) ?
|
||||
args[idx] :
|
||||
slice.call(args);
|
||||
}
|
||||
|
||||
// Shim in iterator support
|
||||
var $iterator$ = (typeof Symbol === 'function' && Symbol.iterator) ||
|
||||
'_es6shim_iterator_';
|
||||
// Bug for mozilla version
|
||||
if (root.Set && typeof new root.Set()['@@iterator'] === 'function') {
|
||||
$iterator$ = '@@iterator';
|
||||
}
|
||||
|
||||
var doneEnumerator = Rx.doneEnumerator = { done: true, value: undefined };
|
||||
|
||||
var isIterable = Rx.helpers.isIterable = function (o) {
|
||||
return o[$iterator$] !== undefined;
|
||||
}
|
||||
|
||||
var isArrayLike = Rx.helpers.isArrayLike = function (o) {
|
||||
return o && o.length !== undefined;
|
||||
}
|
||||
|
||||
Rx.helpers.iterator = $iterator$;
|
||||
|
||||
function enumerableWhile(condition, source) {
|
||||
return new Enumerable(function () {
|
||||
return new Enumerator(function () {
|
||||
return condition() ?
|
||||
{ done: false, value: source } :
|
||||
{ done: true, value: undefined };
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an observable sequence that is the result of invoking the selector on the source sequence, without sharing subscriptions.
|
||||
* This operator allows for a fluent style of writing queries that use the same sequence multiple times.
|
||||
*
|
||||
* @param {Function} selector Selector function which can use the source sequence as many times as needed, without sharing subscriptions to the source sequence.
|
||||
* @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
|
||||
*/
|
||||
observableProto.letBind = observableProto['let'] = function (func) {
|
||||
return func(this);
|
||||
};
|
||||
|
||||
/**
|
||||
* Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers <IE9
|
||||
*
|
||||
* @example
|
||||
* 1 - res = Rx.Observable.if(condition, obs1);
|
||||
* 2 - res = Rx.Observable.if(condition, obs1, obs2);
|
||||
* 3 - res = Rx.Observable.if(condition, obs1, scheduler);
|
||||
* @param {Function} condition The condition which determines if the thenSource or elseSource will be run.
|
||||
* @param {Observable} thenSource The observable sequence or Promise that will be run if the condition function returns true.
|
||||
* @param {Observable} [elseSource] The observable sequence or Promise that will be run if the condition function returns false. If this is not provided, it defaults to Rx.Observabe.Empty with the specified scheduler.
|
||||
* @returns {Observable} An observable sequence which is either the thenSource or elseSource.
|
||||
*/
|
||||
Observable['if'] = Observable.ifThen = function (condition, thenSource, elseSourceOrScheduler) {
|
||||
return observableDefer(function () {
|
||||
elseSourceOrScheduler || (elseSourceOrScheduler = observableEmpty());
|
||||
|
||||
isPromise(thenSource) && (thenSource = observableFromPromise(thenSource));
|
||||
isPromise(elseSourceOrScheduler) && (elseSourceOrScheduler = observableFromPromise(elseSourceOrScheduler));
|
||||
|
||||
// Assume a scheduler for empty only
|
||||
typeof elseSourceOrScheduler.now === 'function' && (elseSourceOrScheduler = observableEmpty(elseSourceOrScheduler));
|
||||
return condition() ? thenSource : elseSourceOrScheduler;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Concatenates the observable sequences obtained by running the specified result selector for each element in source.
|
||||
* There is an alias for this method called 'forIn' for browsers <IE9
|
||||
* @param {Array} sources An array of values to turn into an observable sequence.
|
||||
* @param {Function} resultSelector A function to apply to each item in the sources array to turn it into an observable sequence.
|
||||
* @returns {Observable} An observable sequence from the concatenated observable sequences.
|
||||
*/
|
||||
Observable['for'] = Observable.forIn = function (sources, resultSelector, thisArg) {
|
||||
return enumerableOf(sources, resultSelector, thisArg).concat();
|
||||
};
|
||||
|
||||
/**
|
||||
* Repeats source as long as condition holds emulating a while loop.
|
||||
* There is an alias for this method called 'whileDo' for browsers <IE9
|
||||
*
|
||||
* @param {Function} condition The condition which determines if the source will be repeated.
|
||||
* @param {Observable} source The observable sequence that will be run if the condition function returns true.
|
||||
* @returns {Observable} An observable sequence which is repeated as long as the condition holds.
|
||||
*/
|
||||
var observableWhileDo = Observable['while'] = Observable.whileDo = function (condition, source) {
|
||||
isPromise(source) && (source = observableFromPromise(source));
|
||||
return enumerableWhile(condition, source).concat();
|
||||
};
|
||||
|
||||
/**
|
||||
* Repeats source as long as condition holds emulating a do while loop.
|
||||
*
|
||||
* @param {Function} condition The condition which determines if the source will be repeated.
|
||||
* @param {Observable} source The observable sequence that will be run if the condition function returns true.
|
||||
* @returns {Observable} An observable sequence which is repeated as long as the condition holds.
|
||||
*/
|
||||
observableProto.doWhile = function (condition) {
|
||||
return observableConcat([this, observableWhileDo(condition, this)]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Uses selector to determine which source in sources to use.
|
||||
* There is an alias 'switchCase' for browsers <IE9.
|
||||
*
|
||||
* @example
|
||||
* 1 - res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 });
|
||||
* 1 - res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, obs0);
|
||||
* 1 - res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, scheduler);
|
||||
*
|
||||
* @param {Function} selector The function which extracts the value for to test in a case statement.
|
||||
* @param {Array} sources A object which has keys which correspond to the case statement labels.
|
||||
* @param {Observable} [elseSource] The observable sequence or Promise that will be run if the sources are not matched. If this is not provided, it defaults to Rx.Observabe.empty with the specified scheduler.
|
||||
*
|
||||
* @returns {Observable} An observable sequence which is determined by a case statement.
|
||||
*/
|
||||
Observable['case'] = Observable.switchCase = function (selector, sources, defaultSourceOrScheduler) {
|
||||
return observableDefer(function () {
|
||||
isPromise(defaultSourceOrScheduler) && (defaultSourceOrScheduler = observableFromPromise(defaultSourceOrScheduler));
|
||||
defaultSourceOrScheduler || (defaultSourceOrScheduler = observableEmpty());
|
||||
|
||||
typeof defaultSourceOrScheduler.now === 'function' && (defaultSourceOrScheduler = observableEmpty(defaultSourceOrScheduler));
|
||||
|
||||
var result = sources[selector()];
|
||||
isPromise(result) && (result = observableFromPromise(result));
|
||||
|
||||
return result || defaultSourceOrScheduler;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Expands an observable sequence by recursively invoking selector.
|
||||
*
|
||||
* @param {Function} selector Selector function to invoke for each produced element, resulting in another sequence to which the selector will be invoked recursively again.
|
||||
* @param {Scheduler} [scheduler] Scheduler on which to perform the expansion. If not provided, this defaults to the current thread scheduler.
|
||||
* @returns {Observable} An observable sequence containing all the elements produced by the recursive expansion.
|
||||
*/
|
||||
observableProto.expand = function (selector, scheduler) {
|
||||
isScheduler(scheduler) || (scheduler = immediateScheduler);
|
||||
var source = this;
|
||||
return new AnonymousObservable(function (observer) {
|
||||
var q = [],
|
||||
m = new SerialDisposable(),
|
||||
d = new CompositeDisposable(m),
|
||||
activeCount = 0,
|
||||
isAcquired = false;
|
||||
|
||||
var ensureActive = function () {
|
||||
var isOwner = false;
|
||||
if (q.length > 0) {
|
||||
isOwner = !isAcquired;
|
||||
isAcquired = true;
|
||||
}
|
||||
if (isOwner) {
|
||||
m.setDisposable(scheduler.scheduleRecursive(function (self) {
|
||||
var work;
|
||||
if (q.length > 0) {
|
||||
work = q.shift();
|
||||
} else {
|
||||
isAcquired = false;
|
||||
return;
|
||||
}
|
||||
var m1 = new SingleAssignmentDisposable();
|
||||
d.add(m1);
|
||||
m1.setDisposable(work.subscribe(function (x) {
|
||||
observer.onNext(x);
|
||||
var result = null;
|
||||
try {
|
||||
result = selector(x);
|
||||
} catch (e) {
|
||||
observer.onError(e);
|
||||
}
|
||||
q.push(result);
|
||||
activeCount++;
|
||||
ensureActive();
|
||||
}, observer.onError.bind(observer), function () {
|
||||
d.remove(m1);
|
||||
activeCount--;
|
||||
if (activeCount === 0) {
|
||||
observer.onCompleted();
|
||||
}
|
||||
}));
|
||||
self();
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
q.push(source);
|
||||
activeCount++;
|
||||
ensureActive();
|
||||
return d;
|
||||
}, this);
|
||||
};
|
||||
|
||||
/**
|
||||
* Runs all observable sequences in parallel and collect their last elements.
|
||||
*
|
||||
* @example
|
||||
* 1 - res = Rx.Observable.forkJoin([obs1, obs2]);
|
||||
* 1 - res = Rx.Observable.forkJoin(obs1, obs2, ...);
|
||||
* @returns {Observable} An observable sequence with an array collecting the last elements of all the input sequences.
|
||||
*/
|
||||
Observable.forkJoin = function () {
|
||||
var allSources = argsOrArray(arguments, 0);
|
||||
return new AnonymousObservable(function (subscriber) {
|
||||
var count = allSources.length;
|
||||
if (count === 0) {
|
||||
subscriber.onCompleted();
|
||||
return disposableEmpty;
|
||||
}
|
||||
var group = new CompositeDisposable(),
|
||||
finished = false,
|
||||
hasResults = new Array(count),
|
||||
hasCompleted = new Array(count),
|
||||
results = new Array(count);
|
||||
|
||||
for (var idx = 0; idx < count; idx++) {
|
||||
(function (i) {
|
||||
var source = allSources[i];
|
||||
isPromise(source) && (source = observableFromPromise(source));
|
||||
group.add(
|
||||
source.subscribe(
|
||||
function (value) {
|
||||
if (!finished) {
|
||||
hasResults[i] = true;
|
||||
results[i] = value;
|
||||
}
|
||||
},
|
||||
function (e) {
|
||||
finished = true;
|
||||
subscriber.onError(e);
|
||||
group.dispose();
|
||||
},
|
||||
function () {
|
||||
if (!finished) {
|
||||
if (!hasResults[i]) {
|
||||
subscriber.onCompleted();
|
||||
return;
|
||||
}
|
||||
hasCompleted[i] = true;
|
||||
for (var ix = 0; ix < count; ix++) {
|
||||
if (!hasCompleted[ix]) { return; }
|
||||
}
|
||||
finished = true;
|
||||
subscriber.onNext(results);
|
||||
subscriber.onCompleted();
|
||||
}
|
||||
}));
|
||||
})(idx);
|
||||
}
|
||||
|
||||
return group;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Runs two observable sequences in parallel and combines their last elemenets.
|
||||
*
|
||||
* @param {Observable} second Second observable sequence.
|
||||
* @param {Function} resultSelector Result selector function to invoke with the last elements of both sequences.
|
||||
* @returns {Observable} An observable sequence with the result of calling the selector function with the last elements of both input sequences.
|
||||
*/
|
||||
observableProto.forkJoin = function (second, resultSelector) {
|
||||
var first = this;
|
||||
|
||||
return new AnonymousObservable(function (observer) {
|
||||
var leftStopped = false, rightStopped = false,
|
||||
hasLeft = false, hasRight = false,
|
||||
lastLeft, lastRight,
|
||||
leftSubscription = new SingleAssignmentDisposable(), rightSubscription = new SingleAssignmentDisposable();
|
||||
|
||||
isPromise(second) && (second = observableFromPromise(second));
|
||||
|
||||
leftSubscription.setDisposable(
|
||||
first.subscribe(function (left) {
|
||||
hasLeft = true;
|
||||
lastLeft = left;
|
||||
}, function (err) {
|
||||
rightSubscription.dispose();
|
||||
observer.onError(err);
|
||||
}, function () {
|
||||
leftStopped = true;
|
||||
if (rightStopped) {
|
||||
if (!hasLeft) {
|
||||
observer.onCompleted();
|
||||
} else if (!hasRight) {
|
||||
observer.onCompleted();
|
||||
} else {
|
||||
var result;
|
||||
try {
|
||||
result = resultSelector(lastLeft, lastRight);
|
||||
} catch (e) {
|
||||
observer.onError(e);
|
||||
return;
|
||||
}
|
||||
observer.onNext(result);
|
||||
observer.onCompleted();
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
rightSubscription.setDisposable(
|
||||
second.subscribe(function (right) {
|
||||
hasRight = true;
|
||||
lastRight = right;
|
||||
}, function (err) {
|
||||
leftSubscription.dispose();
|
||||
observer.onError(err);
|
||||
}, function () {
|
||||
rightStopped = true;
|
||||
if (leftStopped) {
|
||||
if (!hasLeft) {
|
||||
observer.onCompleted();
|
||||
} else if (!hasRight) {
|
||||
observer.onCompleted();
|
||||
} else {
|
||||
var result;
|
||||
try {
|
||||
result = resultSelector(lastLeft, lastRight);
|
||||
} catch (e) {
|
||||
observer.onError(e);
|
||||
return;
|
||||
}
|
||||
observer.onNext(result);
|
||||
observer.onCompleted();
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
return new CompositeDisposable(leftSubscription, rightSubscription);
|
||||
}, first);
|
||||
};
|
||||
|
||||
/**
|
||||
* Comonadic bind operator.
|
||||
* @param {Function} selector A transform function to apply to each element.
|
||||
* @param {Object} scheduler Scheduler used to execute the operation. If not specified, defaults to the ImmediateScheduler.
|
||||
* @returns {Observable} An observable sequence which results from the comonadic bind operation.
|
||||
*/
|
||||
observableProto.manySelect = function (selector, scheduler) {
|
||||
isScheduler(scheduler) || (scheduler = immediateScheduler);
|
||||
var source = this;
|
||||
return observableDefer(function () {
|
||||
var chain;
|
||||
|
||||
return source
|
||||
.map(function (x) {
|
||||
var curr = new ChainObservable(x);
|
||||
|
||||
chain && chain.onNext(x);
|
||||
chain = curr;
|
||||
|
||||
return curr;
|
||||
})
|
||||
.tap(
|
||||
noop,
|
||||
function (e) { chain && chain.onError(e); },
|
||||
function () { chain && chain.onCompleted(); }
|
||||
)
|
||||
.observeOn(scheduler)
|
||||
.map(selector);
|
||||
}, source);
|
||||
};
|
||||
|
||||
var ChainObservable = (function (__super__) {
|
||||
|
||||
function subscribe (observer) {
|
||||
var self = this, g = new CompositeDisposable();
|
||||
g.add(currentThreadScheduler.schedule(function () {
|
||||
observer.onNext(self.head);
|
||||
g.add(self.tail.mergeAll().subscribe(observer));
|
||||
}));
|
||||
|
||||
return g;
|
||||
}
|
||||
|
||||
inherits(ChainObservable, __super__);
|
||||
|
||||
function ChainObservable(head) {
|
||||
__super__.call(this, subscribe);
|
||||
this.head = head;
|
||||
this.tail = new AsyncSubject();
|
||||
}
|
||||
|
||||
addProperties(ChainObservable.prototype, Observer, {
|
||||
onCompleted: function () {
|
||||
this.onNext(Observable.empty());
|
||||
},
|
||||
onError: function (e) {
|
||||
this.onNext(Observable.throwException(e));
|
||||
},
|
||||
onNext: function (v) {
|
||||
this.tail.onNext(v);
|
||||
this.tail.onCompleted();
|
||||
}
|
||||
});
|
||||
|
||||
return ChainObservable;
|
||||
|
||||
}(Observable));
|
||||
|
||||
/*
|
||||
* Performs a exclusive waiting for the first to finish before subscribing to another observable.
|
||||
* Observables that come in between subscriptions will be dropped on the floor.
|
||||
* @returns {Observable} A exclusive observable with only the results that happen when subscribed.
|
||||
*/
|
||||
observableProto.exclusive = function () {
|
||||
var sources = this;
|
||||
return new AnonymousObservable(function (observer) {
|
||||
var hasCurrent = false,
|
||||
isStopped = false,
|
||||
m = new SingleAssignmentDisposable(),
|
||||
g = new CompositeDisposable();
|
||||
|
||||
g.add(m);
|
||||
|
||||
m.setDisposable(sources.subscribe(
|
||||
function (innerSource) {
|
||||
if (!hasCurrent) {
|
||||
hasCurrent = true;
|
||||
|
||||
isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
|
||||
|
||||
var innerSubscription = new SingleAssignmentDisposable();
|
||||
g.add(innerSubscription);
|
||||
|
||||
innerSubscription.setDisposable(innerSource.subscribe(
|
||||
observer.onNext.bind(observer),
|
||||
observer.onError.bind(observer),
|
||||
function () {
|
||||
g.remove(innerSubscription);
|
||||
hasCurrent = false;
|
||||
if (isStopped && g.length === 1) {
|
||||
observer.onCompleted();
|
||||
}
|
||||
}));
|
||||
}
|
||||
},
|
||||
observer.onError.bind(observer),
|
||||
function () {
|
||||
isStopped = true;
|
||||
if (!hasCurrent && g.length === 1) {
|
||||
observer.onCompleted();
|
||||
}
|
||||
}));
|
||||
|
||||
return g;
|
||||
}, this);
|
||||
};
|
||||
|
||||
/*
|
||||
* Performs a exclusive map waiting for the first to finish before subscribing to another observable.
|
||||
* Observables that come in between subscriptions will be dropped on the floor.
|
||||
* @param {Function} selector Selector to invoke for every item in the current subscription.
|
||||
* @param {Any} [thisArg] An optional context to invoke with the selector parameter.
|
||||
* @returns {Observable} An exclusive observable with only the results that happen when subscribed.
|
||||
*/
|
||||
observableProto.exclusiveMap = function (selector, thisArg) {
|
||||
var sources = this,
|
||||
selectorFunc = bindCallback(selector, thisArg, 3);
|
||||
return new AnonymousObservable(function (observer) {
|
||||
var index = 0,
|
||||
hasCurrent = false,
|
||||
isStopped = true,
|
||||
m = new SingleAssignmentDisposable(),
|
||||
g = new CompositeDisposable();
|
||||
|
||||
g.add(m);
|
||||
|
||||
m.setDisposable(sources.subscribe(
|
||||
function (innerSource) {
|
||||
|
||||
if (!hasCurrent) {
|
||||
hasCurrent = true;
|
||||
|
||||
innerSubscription = new SingleAssignmentDisposable();
|
||||
g.add(innerSubscription);
|
||||
|
||||
isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
|
||||
|
||||
innerSubscription.setDisposable(innerSource.subscribe(
|
||||
function (x) {
|
||||
var result;
|
||||
try {
|
||||
result = selectorFunc(x, index++, innerSource);
|
||||
} catch (e) {
|
||||
observer.onError(e);
|
||||
return;
|
||||
}
|
||||
|
||||
observer.onNext(result);
|
||||
},
|
||||
function (e) { observer.onError(e); },
|
||||
function () {
|
||||
g.remove(innerSubscription);
|
||||
hasCurrent = false;
|
||||
|
||||
if (isStopped && g.length === 1) {
|
||||
observer.onCompleted();
|
||||
}
|
||||
}));
|
||||
}
|
||||
},
|
||||
function (e) { observer.onError(e); },
|
||||
function () {
|
||||
isStopped = true;
|
||||
if (g.length === 1 && !hasCurrent) {
|
||||
observer.onCompleted();
|
||||
}
|
||||
}));
|
||||
return g;
|
||||
}, this);
|
||||
};
|
||||
|
||||
return Rx;
|
||||
}));
|
1
node_modules/rx/dist/rx.experimental.map
generated
vendored
Normal file
1
node_modules/rx/dist/rx.experimental.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3
node_modules/rx/dist/rx.experimental.min.js
generated
vendored
Normal file
3
node_modules/rx/dist/rx.experimental.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
317
node_modules/rx/dist/rx.joinpatterns.js
generated
vendored
Normal file
317
node_modules/rx/dist/rx.joinpatterns.js
generated
vendored
Normal file
@ -0,0 +1,317 @@
|
||||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
;(function (factory) {
|
||||
var objectTypes = {
|
||||
'boolean': false,
|
||||
'function': true,
|
||||
'object': true,
|
||||
'number': false,
|
||||
'string': false,
|
||||
'undefined': false
|
||||
};
|
||||
|
||||
var root = (objectTypes[typeof window] && window) || this,
|
||||
freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports,
|
||||
freeModule = objectTypes[typeof module] && module && !module.nodeType && module,
|
||||
moduleExports = freeModule && freeModule.exports === freeExports && freeExports,
|
||||
freeGlobal = objectTypes[typeof global] && global;
|
||||
|
||||
if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) {
|
||||
root = freeGlobal;
|
||||
}
|
||||
|
||||
// Because of build optimizers
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['rx'], function (Rx, exports) {
|
||||
return factory(root, exports, Rx);
|
||||
});
|
||||
} else if (typeof module === 'object' && module && module.exports === freeExports) {
|
||||
module.exports = factory(root, module.exports, require('./rx'));
|
||||
} else {
|
||||
root.Rx = factory(root, {}, root.Rx);
|
||||
}
|
||||
}.call(this, function (root, exp, Rx, undefined) {
|
||||
|
||||
// Aliases
|
||||
var Observable = Rx.Observable,
|
||||
observableProto = Observable.prototype,
|
||||
AnonymousObservable = Rx.AnonymousObservable,
|
||||
observableThrow = Observable.throwException,
|
||||
observerCreate = Rx.Observer.create,
|
||||
SingleAssignmentDisposable = Rx.SingleAssignmentDisposable,
|
||||
CompositeDisposable = Rx.CompositeDisposable,
|
||||
AbstractObserver = Rx.internals.AbstractObserver,
|
||||
noop = Rx.helpers.noop,
|
||||
defaultComparer = Rx.internals.isEqual,
|
||||
inherits = Rx.internals.inherits,
|
||||
Enumerable = Rx.internals.Enumerable,
|
||||
Enumerator = Rx.internals.Enumerator,
|
||||
$iterator$ = Rx.iterator,
|
||||
doneEnumerator = Rx.doneEnumerator,
|
||||
slice = Array.prototype.slice;
|
||||
|
||||
// Utilities
|
||||
function argsOrArray(args, idx) {
|
||||
return args.length === 1 && Array.isArray(args[idx]) ?
|
||||
args[idx] :
|
||||
slice.call(args);
|
||||
}
|
||||
|
||||
/** @private */
|
||||
var Map = root.Map || (function () {
|
||||
|
||||
function Map() {
|
||||
this._keys = [];
|
||||
this._values = [];
|
||||
}
|
||||
|
||||
Map.prototype.get = function (key) {
|
||||
var i = this._keys.indexOf(key);
|
||||
return i !== -1 ? this._values[i] : undefined;
|
||||
};
|
||||
|
||||
Map.prototype.set = function (key, value) {
|
||||
var i = this._keys.indexOf(key);
|
||||
i !== -1 && (this._values[i] = value);
|
||||
this._values[this._keys.push(key) - 1] = value;
|
||||
};
|
||||
|
||||
Map.prototype.forEach = function (callback, thisArg) {
|
||||
for (var i = 0, len = this._keys.length; i < len; i++) {
|
||||
callback.call(thisArg, this._values[i], this._keys[i]);
|
||||
}
|
||||
};
|
||||
|
||||
return Map;
|
||||
}());
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* Represents a join pattern over observable sequences.
|
||||
*/
|
||||
function Pattern(patterns) {
|
||||
this.patterns = patterns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a pattern that matches the current plan matches and when the specified observable sequences has an available value.
|
||||
* @param other Observable sequence to match in addition to the current pattern.
|
||||
* @return {Pattern} Pattern object that matches when all observable sequences in the pattern have an available value.
|
||||
*/
|
||||
Pattern.prototype.and = function (other) {
|
||||
return new Pattern(this.patterns.concat(other));
|
||||
};
|
||||
|
||||
/**
|
||||
* Matches when all observable sequences in the pattern (specified using a chain of and operators) have an available value and projects the values.
|
||||
* @param {Function} selector Selector that will be invoked with available values from the source sequences, in the same order of the sequences in the pattern.
|
||||
* @return {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator.
|
||||
*/
|
||||
Pattern.prototype.thenDo = function (selector) {
|
||||
return new Plan(this, selector);
|
||||
};
|
||||
|
||||
function Plan(expression, selector) {
|
||||
this.expression = expression;
|
||||
this.selector = selector;
|
||||
}
|
||||
|
||||
Plan.prototype.activate = function (externalSubscriptions, observer, deactivate) {
|
||||
var self = this;
|
||||
var joinObservers = [];
|
||||
for (var i = 0, len = this.expression.patterns.length; i < len; i++) {
|
||||
joinObservers.push(planCreateObserver(externalSubscriptions, this.expression.patterns[i], observer.onError.bind(observer)));
|
||||
}
|
||||
var activePlan = new ActivePlan(joinObservers, function () {
|
||||
var result;
|
||||
try {
|
||||
result = self.selector.apply(self, arguments);
|
||||
} catch (e) {
|
||||
observer.onError(e);
|
||||
return;
|
||||
}
|
||||
observer.onNext(result);
|
||||
}, function () {
|
||||
for (var j = 0, jlen = joinObservers.length; j < jlen; j++) {
|
||||
joinObservers[j].removeActivePlan(activePlan);
|
||||
}
|
||||
deactivate(activePlan);
|
||||
});
|
||||
for (i = 0, len = joinObservers.length; i < len; i++) {
|
||||
joinObservers[i].addActivePlan(activePlan);
|
||||
}
|
||||
return activePlan;
|
||||
};
|
||||
|
||||
function planCreateObserver(externalSubscriptions, observable, onError) {
|
||||
var entry = externalSubscriptions.get(observable);
|
||||
if (!entry) {
|
||||
var observer = new JoinObserver(observable, onError);
|
||||
externalSubscriptions.set(observable, observer);
|
||||
return observer;
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
function ActivePlan(joinObserverArray, onNext, onCompleted) {
|
||||
this.joinObserverArray = joinObserverArray;
|
||||
this.onNext = onNext;
|
||||
this.onCompleted = onCompleted;
|
||||
this.joinObservers = new Map();
|
||||
for (var i = 0, len = this.joinObserverArray.length; i < len; i++) {
|
||||
var joinObserver = this.joinObserverArray[i];
|
||||
this.joinObservers.set(joinObserver, joinObserver);
|
||||
}
|
||||
}
|
||||
|
||||
ActivePlan.prototype.dequeue = function () {
|
||||
this.joinObservers.forEach(function (v) { v.queue.shift(); });
|
||||
};
|
||||
|
||||
ActivePlan.prototype.match = function () {
|
||||
var i, len, hasValues = true;
|
||||
for (i = 0, len = this.joinObserverArray.length; i < len; i++) {
|
||||
if (this.joinObserverArray[i].queue.length === 0) {
|
||||
hasValues = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (hasValues) {
|
||||
var firstValues = [],
|
||||
isCompleted = false;
|
||||
for (i = 0, len = this.joinObserverArray.length; i < len; i++) {
|
||||
firstValues.push(this.joinObserverArray[i].queue[0]);
|
||||
this.joinObserverArray[i].queue[0].kind === 'C' && (isCompleted = true);
|
||||
}
|
||||
if (isCompleted) {
|
||||
this.onCompleted();
|
||||
} else {
|
||||
this.dequeue();
|
||||
var values = [];
|
||||
for (i = 0, len = firstValues.length; i < firstValues.length; i++) {
|
||||
values.push(firstValues[i].value);
|
||||
}
|
||||
this.onNext.apply(this, values);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var JoinObserver = (function (__super__) {
|
||||
|
||||
inherits(JoinObserver, __super__);
|
||||
|
||||
function JoinObserver(source, onError) {
|
||||
__super__.call(this);
|
||||
this.source = source;
|
||||
this.onError = onError;
|
||||
this.queue = [];
|
||||
this.activePlans = [];
|
||||
this.subscription = new SingleAssignmentDisposable();
|
||||
this.isDisposed = false;
|
||||
}
|
||||
|
||||
var JoinObserverPrototype = JoinObserver.prototype;
|
||||
|
||||
JoinObserverPrototype.next = function (notification) {
|
||||
if (!this.isDisposed) {
|
||||
if (notification.kind === 'E') {
|
||||
this.onError(notification.exception);
|
||||
return;
|
||||
}
|
||||
this.queue.push(notification);
|
||||
var activePlans = this.activePlans.slice(0);
|
||||
for (var i = 0, len = activePlans.length; i < len; i++) {
|
||||
activePlans[i].match();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
JoinObserverPrototype.error = noop;
|
||||
JoinObserverPrototype.completed = noop;
|
||||
|
||||
JoinObserverPrototype.addActivePlan = function (activePlan) {
|
||||
this.activePlans.push(activePlan);
|
||||
};
|
||||
|
||||
JoinObserverPrototype.subscribe = function () {
|
||||
this.subscription.setDisposable(this.source.materialize().subscribe(this));
|
||||
};
|
||||
|
||||
JoinObserverPrototype.removeActivePlan = function (activePlan) {
|
||||
this.activePlans.splice(this.activePlans.indexOf(activePlan), 1);
|
||||
this.activePlans.length === 0 && this.dispose();
|
||||
};
|
||||
|
||||
JoinObserverPrototype.dispose = function () {
|
||||
__super__.prototype.dispose.call(this);
|
||||
if (!this.isDisposed) {
|
||||
this.isDisposed = true;
|
||||
this.subscription.dispose();
|
||||
}
|
||||
};
|
||||
|
||||
return JoinObserver;
|
||||
} (AbstractObserver));
|
||||
|
||||
/**
|
||||
* Creates a pattern that matches when both observable sequences have an available value.
|
||||
*
|
||||
* @param right Observable sequence to match with the current sequence.
|
||||
* @return {Pattern} Pattern object that matches when both observable sequences have an available value.
|
||||
*/
|
||||
observableProto.and = function (right) {
|
||||
return new Pattern([this, right]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Matches when the observable sequence has an available value and projects the value.
|
||||
*
|
||||
* @param selector Selector that will be invoked for values in the source sequence.
|
||||
* @returns {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator.
|
||||
*/
|
||||
observableProto.thenDo = function (selector) {
|
||||
return new Pattern([this]).thenDo(selector);
|
||||
};
|
||||
|
||||
/**
|
||||
* Joins together the results from several patterns.
|
||||
*
|
||||
* @param plans A series of plans (specified as an Array of as a series of arguments) created by use of the Then operator on patterns.
|
||||
* @returns {Observable} Observable sequence with the results form matching several patterns.
|
||||
*/
|
||||
Observable.when = function () {
|
||||
var plans = argsOrArray(arguments, 0);
|
||||
return new AnonymousObservable(function (observer) {
|
||||
var activePlans = [],
|
||||
externalSubscriptions = new Map();
|
||||
var outObserver = observerCreate(
|
||||
observer.onNext.bind(observer),
|
||||
function (err) {
|
||||
externalSubscriptions.forEach(function (v) { v.onError(err); });
|
||||
observer.onError(err);
|
||||
},
|
||||
observer.onCompleted.bind(observer)
|
||||
);
|
||||
try {
|
||||
for (var i = 0, len = plans.length; i < len; i++) {
|
||||
activePlans.push(plans[i].activate(externalSubscriptions, outObserver, function (activePlan) {
|
||||
var idx = activePlans.indexOf(activePlan);
|
||||
activePlans.splice(idx, 1);
|
||||
activePlans.length === 0 && observer.onCompleted();
|
||||
}));
|
||||
}
|
||||
} catch (e) {
|
||||
observableThrow(e).subscribe(observer);
|
||||
}
|
||||
var group = new CompositeDisposable();
|
||||
externalSubscriptions.forEach(function (joinObserver) {
|
||||
joinObserver.subscribe();
|
||||
group.add(joinObserver);
|
||||
});
|
||||
|
||||
return group;
|
||||
});
|
||||
};
|
||||
|
||||
return Rx;
|
||||
}));
|
1
node_modules/rx/dist/rx.joinpatterns.map
generated
vendored
Normal file
1
node_modules/rx/dist/rx.joinpatterns.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3
node_modules/rx/dist/rx.joinpatterns.min.js
generated
vendored
Normal file
3
node_modules/rx/dist/rx.joinpatterns.min.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
/* Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.*/
|
||||
(function(a){var b={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},c=b[typeof window]&&window||this,d=b[typeof exports]&&exports&&!exports.nodeType&&exports,e=b[typeof module]&&module&&!module.nodeType&&module,f=(e&&e.exports===d&&d,b[typeof global]&&global);!f||f.global!==f&&f.window!==f||(c=f),"function"==typeof define&&define.amd?define(["rx"],function(b,d){return a(c,d,b)}):"object"==typeof module&&module&&module.exports===d?module.exports=a(c,module.exports,require("./rx")):c.Rx=a(c,{},c.Rx)}).call(this,function(a,b,c,d){function e(a,b){return 1===a.length&&Array.isArray(a[b])?a[b]:t.call(a)}function f(a){this.patterns=a}function g(a,b){this.expression=a,this.selector=b}function h(a,b,c){var d=a.get(b);if(!d){var e=new v(b,c);return a.set(b,e),e}return d}function i(a,b,c){this.joinObserverArray=a,this.onNext=b,this.onCompleted=c,this.joinObservers=new u;for(var d=0,e=this.joinObserverArray.length;e>d;d++){var f=this.joinObserverArray[d];this.joinObservers.set(f,f)}}var j=c.Observable,k=j.prototype,l=c.AnonymousObservable,m=j.throwException,n=c.Observer.create,o=c.SingleAssignmentDisposable,p=c.CompositeDisposable,q=c.internals.AbstractObserver,r=c.helpers.noop,s=(c.internals.isEqual,c.internals.inherits),t=(c.internals.Enumerable,c.internals.Enumerator,c.iterator,c.doneEnumerator,Array.prototype.slice),u=a.Map||function(){function a(){this._keys=[],this._values=[]}return a.prototype.get=function(a){var b=this._keys.indexOf(a);return-1!==b?this._values[b]:d},a.prototype.set=function(a,b){var c=this._keys.indexOf(a);-1!==c&&(this._values[c]=b),this._values[this._keys.push(a)-1]=b},a.prototype.forEach=function(a,b){for(var c=0,d=this._keys.length;d>c;c++)a.call(b,this._values[c],this._keys[c])},a}();f.prototype.and=function(a){return new f(this.patterns.concat(a))},f.prototype.thenDo=function(a){return new g(this,a)},g.prototype.activate=function(a,b,c){for(var d=this,e=[],f=0,g=this.expression.patterns.length;g>f;f++)e.push(h(a,this.expression.patterns[f],b.onError.bind(b)));var j=new i(e,function(){var a;try{a=d.selector.apply(d,arguments)}catch(c){return void b.onError(c)}b.onNext(a)},function(){for(var a=0,b=e.length;b>a;a++)e[a].removeActivePlan(j);c(j)});for(f=0,g=e.length;g>f;f++)e[f].addActivePlan(j);return j},i.prototype.dequeue=function(){this.joinObservers.forEach(function(a){a.queue.shift()})},i.prototype.match=function(){var a,b,c=!0;for(a=0,b=this.joinObserverArray.length;b>a;a++)if(0===this.joinObserverArray[a].queue.length){c=!1;break}if(c){var d=[],e=!1;for(a=0,b=this.joinObserverArray.length;b>a;a++)d.push(this.joinObserverArray[a].queue[0]),"C"===this.joinObserverArray[a].queue[0].kind&&(e=!0);if(e)this.onCompleted();else{this.dequeue();var f=[];for(a=0,b=d.length;a<d.length;a++)f.push(d[a].value);this.onNext.apply(this,f)}}};var v=function(a){function b(b,c){a.call(this),this.source=b,this.onError=c,this.queue=[],this.activePlans=[],this.subscription=new o,this.isDisposed=!1}s(b,a);var c=b.prototype;return c.next=function(a){if(!this.isDisposed){if("E"===a.kind)return void this.onError(a.exception);this.queue.push(a);for(var b=this.activePlans.slice(0),c=0,d=b.length;d>c;c++)b[c].match()}},c.error=r,c.completed=r,c.addActivePlan=function(a){this.activePlans.push(a)},c.subscribe=function(){this.subscription.setDisposable(this.source.materialize().subscribe(this))},c.removeActivePlan=function(a){this.activePlans.splice(this.activePlans.indexOf(a),1),0===this.activePlans.length&&this.dispose()},c.dispose=function(){a.prototype.dispose.call(this),this.isDisposed||(this.isDisposed=!0,this.subscription.dispose())},b}(q);return k.and=function(a){return new f([this,a])},k.thenDo=function(a){return new f([this]).thenDo(a)},j.when=function(){var a=e(arguments,0);return new l(function(b){var c=[],d=new u,e=n(b.onNext.bind(b),function(a){d.forEach(function(b){b.onError(a)}),b.onError(a)},b.onCompleted.bind(b));try{for(var f=0,g=a.length;g>f;f++)c.push(a[f].activate(d,e,function(a){var d=c.indexOf(a);c.splice(d,1),0===c.length&&b.onCompleted()}))}catch(h){m(h).subscribe(b)}var i=new p;return d.forEach(function(a){a.subscribe(),i.add(a)}),i})},c});
|
||||
//# sourceMappingURL=rx.joinpatterns.map
|
4772
node_modules/rx/dist/rx.js
generated
vendored
Normal file
4772
node_modules/rx/dist/rx.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
5650
node_modules/rx/dist/rx.lite.compat.js
generated
vendored
Normal file
5650
node_modules/rx/dist/rx.lite.compat.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/rx/dist/rx.lite.compat.map
generated
vendored
Normal file
1
node_modules/rx/dist/rx.lite.compat.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
4
node_modules/rx/dist/rx.lite.compat.min.js
generated
vendored
Normal file
4
node_modules/rx/dist/rx.lite.compat.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
633
node_modules/rx/dist/rx.lite.extras.js
generated
vendored
Normal file
633
node_modules/rx/dist/rx.lite.extras.js
generated
vendored
Normal file
@ -0,0 +1,633 @@
|
||||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
;(function (factory) {
|
||||
var objectTypes = {
|
||||
'boolean': false,
|
||||
'function': true,
|
||||
'object': true,
|
||||
'number': false,
|
||||
'string': false,
|
||||
'undefined': false
|
||||
};
|
||||
|
||||
var root = (objectTypes[typeof window] && window) || this,
|
||||
freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports,
|
||||
freeModule = objectTypes[typeof module] && module && !module.nodeType && module,
|
||||
moduleExports = freeModule && freeModule.exports === freeExports && freeExports,
|
||||
freeGlobal = objectTypes[typeof global] && global;
|
||||
|
||||
if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) {
|
||||
root = freeGlobal;
|
||||
}
|
||||
|
||||
// Because of build optimizers
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['rx'], function (Rx, exports) {
|
||||
return factory(root, exports, Rx);
|
||||
});
|
||||
} else if (typeof module === 'object' && module && module.exports === freeExports) {
|
||||
module.exports = factory(root, module.exports, require('./rx'));
|
||||
} else {
|
||||
root.Rx = factory(root, {}, root.Rx);
|
||||
}
|
||||
}.call(this, function (root, exp, Rx, undefined) {
|
||||
|
||||
// References
|
||||
var Observable = Rx.Observable,
|
||||
observableProto = Observable.prototype,
|
||||
observableNever = Observable.never,
|
||||
observableThrow = Observable.throwException,
|
||||
AnonymousObservable = Rx.AnonymousObservable,
|
||||
AnonymousObserver = Rx.AnonymousObserver,
|
||||
notificationCreateOnNext = Rx.Notification.createOnNext,
|
||||
notificationCreateOnError = Rx.Notification.createOnError,
|
||||
notificationCreateOnCompleted = Rx.Notification.createOnCompleted,
|
||||
Observer = Rx.Observer,
|
||||
Subject = Rx.Subject,
|
||||
internals = Rx.internals,
|
||||
helpers = Rx.helpers,
|
||||
ScheduledObserver = internals.ScheduledObserver,
|
||||
SerialDisposable = Rx.SerialDisposable,
|
||||
SingleAssignmentDisposable = Rx.SingleAssignmentDisposable,
|
||||
CompositeDisposable = Rx.CompositeDisposable,
|
||||
RefCountDisposable = Rx.RefCountDisposable,
|
||||
disposableEmpty = Rx.Disposable.empty,
|
||||
immediateScheduler = Rx.Scheduler.immediate,
|
||||
defaultKeySerializer = helpers.defaultKeySerializer,
|
||||
addRef = Rx.internals.addRef,
|
||||
identity = helpers.identity,
|
||||
isPromise = helpers.isPromise,
|
||||
inherits = internals.inherits,
|
||||
bindCallback = internals.bindCallback,
|
||||
noop = helpers.noop,
|
||||
isScheduler = helpers.isScheduler,
|
||||
observableFromPromise = Observable.fromPromise,
|
||||
slice = Array.prototype.slice;
|
||||
|
||||
function argsOrArray(args, idx) {
|
||||
return args.length === 1 && Array.isArray(args[idx]) ?
|
||||
args[idx] :
|
||||
slice.call(args);
|
||||
}
|
||||
|
||||
var argumentOutOfRange = 'Argument out of range';
|
||||
|
||||
function ScheduledDisposable(scheduler, disposable) {
|
||||
this.scheduler = scheduler;
|
||||
this.disposable = disposable;
|
||||
this.isDisposed = false;
|
||||
}
|
||||
|
||||
ScheduledDisposable.prototype.dispose = function () {
|
||||
var parent = this;
|
||||
this.scheduler.schedule(function () {
|
||||
if (!parent.isDisposed) {
|
||||
parent.isDisposed = true;
|
||||
parent.disposable.dispose();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var CheckedObserver = (function (_super) {
|
||||
inherits(CheckedObserver, _super);
|
||||
|
||||
function CheckedObserver(observer) {
|
||||
_super.call(this);
|
||||
this._observer = observer;
|
||||
this._state = 0; // 0 - idle, 1 - busy, 2 - done
|
||||
}
|
||||
|
||||
var CheckedObserverPrototype = CheckedObserver.prototype;
|
||||
|
||||
CheckedObserverPrototype.onNext = function (value) {
|
||||
this.checkAccess();
|
||||
try {
|
||||
this._observer.onNext(value);
|
||||
} catch (e) {
|
||||
throw e;
|
||||
} finally {
|
||||
this._state = 0;
|
||||
}
|
||||
};
|
||||
|
||||
CheckedObserverPrototype.onError = function (err) {
|
||||
this.checkAccess();
|
||||
try {
|
||||
this._observer.onError(err);
|
||||
} catch (e) {
|
||||
throw e;
|
||||
} finally {
|
||||
this._state = 2;
|
||||
}
|
||||
};
|
||||
|
||||
CheckedObserverPrototype.onCompleted = function () {
|
||||
this.checkAccess();
|
||||
try {
|
||||
this._observer.onCompleted();
|
||||
} catch (e) {
|
||||
throw e;
|
||||
} finally {
|
||||
this._state = 2;
|
||||
}
|
||||
};
|
||||
|
||||
CheckedObserverPrototype.checkAccess = function () {
|
||||
if (this._state === 1) { throw new Error('Re-entrancy detected'); }
|
||||
if (this._state === 2) { throw new Error('Observer completed'); }
|
||||
if (this._state === 0) { this._state = 1; }
|
||||
};
|
||||
|
||||
return CheckedObserver;
|
||||
}(Observer));
|
||||
|
||||
var ObserveOnObserver = (function (__super__) {
|
||||
inherits(ObserveOnObserver, __super__);
|
||||
|
||||
function ObserveOnObserver(scheduler, observer, cancel) {
|
||||
__super__.call(this, scheduler, observer);
|
||||
this._cancel = cancel;
|
||||
}
|
||||
|
||||
ObserveOnObserver.prototype.next = function (value) {
|
||||
__super__.prototype.next.call(this, value);
|
||||
this.ensureActive();
|
||||
};
|
||||
|
||||
ObserveOnObserver.prototype.error = function (e) {
|
||||
__super__.prototype.error.call(this, e);
|
||||
this.ensureActive();
|
||||
};
|
||||
|
||||
ObserveOnObserver.prototype.completed = function () {
|
||||
__super__.prototype.completed.call(this);
|
||||
this.ensureActive();
|
||||
};
|
||||
|
||||
ObserveOnObserver.prototype.dispose = function () {
|
||||
__super__.prototype.dispose.call(this);
|
||||
this._cancel && this._cancel.dispose();
|
||||
this._cancel = null;
|
||||
};
|
||||
|
||||
return ObserveOnObserver;
|
||||
})(ScheduledObserver);
|
||||
|
||||
/**
|
||||
* Checks access to the observer for grammar violations. This includes checking for multiple OnError or OnCompleted calls, as well as reentrancy in any of the observer methods.
|
||||
* If a violation is detected, an Error is thrown from the offending observer method call.
|
||||
*
|
||||
* @returns An observer that checks callbacks invocations against the observer grammar and, if the checks pass, forwards those to the specified observer.
|
||||
*/
|
||||
Observer.prototype.checked = function () { return new CheckedObserver(this); };
|
||||
|
||||
/**
|
||||
* Schedules the invocation of observer methods on the given scheduler.
|
||||
* @param {Scheduler} scheduler Scheduler to schedule observer messages on.
|
||||
* @returns {Observer} Observer whose messages are scheduled on the given scheduler.
|
||||
*/
|
||||
Observer.notifyOn = function (scheduler) {
|
||||
return new ObserveOnObserver(scheduler, this);
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates an observer from a notification callback.
|
||||
* @param {Function} handler Action that handles a notification.
|
||||
* @returns The observer object that invokes the specified handler using a notification corresponding to each message it receives.
|
||||
*/
|
||||
Observer.fromNotifier = function (handler, thisArg) {
|
||||
var handlerFunc = bindCallback(handler, thisArg, 1);
|
||||
return new AnonymousObserver(function (x) {
|
||||
return handlerFunc(notificationCreateOnNext(x));
|
||||
}, function (e) {
|
||||
return handlerFunc(notificationCreateOnError(e));
|
||||
}, function () {
|
||||
return handlerFunc(notificationCreateOnCompleted());
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a notification callback from an observer.
|
||||
* @returns The action that forwards its input notification to the underlying observer.
|
||||
*/
|
||||
Observer.prototype.toNotifier = function () {
|
||||
var observer = this;
|
||||
return function (n) { return n.accept(observer); };
|
||||
};
|
||||
|
||||
/**
|
||||
* Hides the identity of an observer.
|
||||
* @returns An observer that hides the identity of the specified observer.
|
||||
*/
|
||||
Observer.prototype.asObserver = function () {
|
||||
var source = this;
|
||||
return new AnonymousObserver(
|
||||
function (x) { source.onNext(x); },
|
||||
function (e) { source.onError(e); },
|
||||
function () { source.onCompleted(); }
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Wraps the source sequence in order to run its observer callbacks on the specified scheduler.
|
||||
*
|
||||
* This only invokes observer callbacks on a scheduler. In case the subscription and/or unsubscription actions have side-effects
|
||||
* that require to be run on a scheduler, use subscribeOn.
|
||||
*
|
||||
* @param {Scheduler} scheduler Scheduler to notify observers on.
|
||||
* @returns {Observable} The source sequence whose observations happen on the specified scheduler.
|
||||
*/
|
||||
observableProto.observeOn = function (scheduler) {
|
||||
var source = this;
|
||||
return new AnonymousObservable(function (observer) {
|
||||
return source.subscribe(new ObserveOnObserver(scheduler, observer));
|
||||
}, source);
|
||||
};
|
||||
|
||||
/**
|
||||
* Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler. This operation is not commonly used;
|
||||
* see the remarks section for more information on the distinction between subscribeOn and observeOn.
|
||||
|
||||
* This only performs the side-effects of subscription and unsubscription on the specified scheduler. In order to invoke observer
|
||||
* callbacks on a scheduler, use observeOn.
|
||||
|
||||
* @param {Scheduler} scheduler Scheduler to perform subscription and unsubscription actions on.
|
||||
* @returns {Observable} The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler.
|
||||
*/
|
||||
observableProto.subscribeOn = function (scheduler) {
|
||||
var source = this;
|
||||
return new AnonymousObservable(function (observer) {
|
||||
var m = new SingleAssignmentDisposable(), d = new SerialDisposable();
|
||||
d.setDisposable(m);
|
||||
m.setDisposable(scheduler.schedule(function () {
|
||||
d.setDisposable(new ScheduledDisposable(scheduler, source.subscribe(observer)));
|
||||
}));
|
||||
return d;
|
||||
}, source);
|
||||
};
|
||||
|
||||
/**
|
||||
* Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler to send out observer messages.
|
||||
*
|
||||
* @example
|
||||
* var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; });
|
||||
* var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; }, Rx.Scheduler.timeout);
|
||||
* @param {Mixed} initialState Initial state.
|
||||
* @param {Function} condition Condition to terminate generation (upon returning false).
|
||||
* @param {Function} iterate Iteration step function.
|
||||
* @param {Function} resultSelector Selector function for results produced in the sequence.
|
||||
* @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not provided, defaults to Scheduler.currentThread.
|
||||
* @returns {Observable} The generated sequence.
|
||||
*/
|
||||
Observable.generate = function (initialState, condition, iterate, resultSelector, scheduler) {
|
||||
isScheduler(scheduler) || (scheduler = currentThreadScheduler);
|
||||
return new AnonymousObservable(function (observer) {
|
||||
var first = true, state = initialState;
|
||||
return scheduler.scheduleRecursive(function (self) {
|
||||
var hasResult, result;
|
||||
try {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
state = iterate(state);
|
||||
}
|
||||
hasResult = condition(state);
|
||||
if (hasResult) {
|
||||
result = resultSelector(state);
|
||||
}
|
||||
} catch (exception) {
|
||||
observer.onError(exception);
|
||||
return;
|
||||
}
|
||||
if (hasResult) {
|
||||
observer.onNext(result);
|
||||
self();
|
||||
} else {
|
||||
observer.onCompleted();
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence's lifetime.
|
||||
* @param {Function} resourceFactory Factory function to obtain a resource object.
|
||||
* @param {Function} observableFactory Factory function to obtain an observable sequence that depends on the obtained resource.
|
||||
* @returns {Observable} An observable sequence whose lifetime controls the lifetime of the dependent resource object.
|
||||
*/
|
||||
Observable.using = function (resourceFactory, observableFactory) {
|
||||
return new AnonymousObservable(function (observer) {
|
||||
var disposable = disposableEmpty, resource, source;
|
||||
try {
|
||||
resource = resourceFactory();
|
||||
resource && (disposable = resource);
|
||||
source = observableFactory(resource);
|
||||
} catch (exception) {
|
||||
return new CompositeDisposable(observableThrow(exception).subscribe(observer), disposable);
|
||||
}
|
||||
return new CompositeDisposable(source.subscribe(observer), disposable);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Propagates the observable sequence or Promise that reacts first.
|
||||
* @param {Observable} rightSource Second observable sequence or Promise.
|
||||
* @returns {Observable} {Observable} An observable sequence that surfaces either of the given sequences, whichever reacted first.
|
||||
*/
|
||||
observableProto.amb = function (rightSource) {
|
||||
var leftSource = this;
|
||||
return new AnonymousObservable(function (observer) {
|
||||
var choice,
|
||||
leftChoice = 'L', rightChoice = 'R',
|
||||
leftSubscription = new SingleAssignmentDisposable(),
|
||||
rightSubscription = new SingleAssignmentDisposable();
|
||||
|
||||
isPromise(rightSource) && (rightSource = observableFromPromise(rightSource));
|
||||
|
||||
function choiceL() {
|
||||
if (!choice) {
|
||||
choice = leftChoice;
|
||||
rightSubscription.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
function choiceR() {
|
||||
if (!choice) {
|
||||
choice = rightChoice;
|
||||
leftSubscription.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
leftSubscription.setDisposable(leftSource.subscribe(function (left) {
|
||||
choiceL();
|
||||
if (choice === leftChoice) {
|
||||
observer.onNext(left);
|
||||
}
|
||||
}, function (err) {
|
||||
choiceL();
|
||||
if (choice === leftChoice) {
|
||||
observer.onError(err);
|
||||
}
|
||||
}, function () {
|
||||
choiceL();
|
||||
if (choice === leftChoice) {
|
||||
observer.onCompleted();
|
||||
}
|
||||
}));
|
||||
|
||||
rightSubscription.setDisposable(rightSource.subscribe(function (right) {
|
||||
choiceR();
|
||||
if (choice === rightChoice) {
|
||||
observer.onNext(right);
|
||||
}
|
||||
}, function (err) {
|
||||
choiceR();
|
||||
if (choice === rightChoice) {
|
||||
observer.onError(err);
|
||||
}
|
||||
}, function () {
|
||||
choiceR();
|
||||
if (choice === rightChoice) {
|
||||
observer.onCompleted();
|
||||
}
|
||||
}));
|
||||
|
||||
return new CompositeDisposable(leftSubscription, rightSubscription);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Propagates the observable sequence or Promise that reacts first.
|
||||
*
|
||||
* @example
|
||||
* var = Rx.Observable.amb(xs, ys, zs);
|
||||
* @returns {Observable} An observable sequence that surfaces any of the given sequences, whichever reacted first.
|
||||
*/
|
||||
Observable.amb = function () {
|
||||
var acc = observableNever(),
|
||||
items = argsOrArray(arguments, 0);
|
||||
function func(previous, current) {
|
||||
return previous.amb(current);
|
||||
}
|
||||
for (var i = 0, len = items.length; i < len; i++) {
|
||||
acc = func(acc, items[i]);
|
||||
}
|
||||
return acc;
|
||||
};
|
||||
|
||||
/**
|
||||
* Continues an observable sequence that is terminated normally or by an exception with the next observable sequence.
|
||||
* @param {Observable} second Second observable sequence used to produce results after the first sequence terminates.
|
||||
* @returns {Observable} An observable sequence that concatenates the first and second sequence, even if the first sequence terminates exceptionally.
|
||||
*/
|
||||
observableProto.onErrorResumeNext = function (second) {
|
||||
if (!second) { throw new Error('Second observable is required'); }
|
||||
return onErrorResumeNext([this, second]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Continues an observable sequence that is terminated normally or by an exception with the next observable sequence.
|
||||
*
|
||||
* @example
|
||||
* 1 - res = Rx.Observable.onErrorResumeNext(xs, ys, zs);
|
||||
* 1 - res = Rx.Observable.onErrorResumeNext([xs, ys, zs]);
|
||||
* @returns {Observable} An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.
|
||||
*/
|
||||
var onErrorResumeNext = Observable.onErrorResumeNext = function () {
|
||||
var sources = argsOrArray(arguments, 0);
|
||||
return new AnonymousObservable(function (observer) {
|
||||
var pos = 0, subscription = new SerialDisposable(),
|
||||
cancelable = immediateScheduler.scheduleRecursive(function (self) {
|
||||
var current, d;
|
||||
if (pos < sources.length) {
|
||||
current = sources[pos++];
|
||||
isPromise(current) && (current = observableFromPromise(current));
|
||||
d = new SingleAssignmentDisposable();
|
||||
subscription.setDisposable(d);
|
||||
d.setDisposable(current.subscribe(observer.onNext.bind(observer), self, self));
|
||||
} else {
|
||||
observer.onCompleted();
|
||||
}
|
||||
});
|
||||
return new CompositeDisposable(subscription, cancelable);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Projects each element of an observable sequence into zero or more buffers which are produced based on element count information.
|
||||
*
|
||||
* @example
|
||||
* var res = xs.bufferWithCount(10);
|
||||
* var res = xs.bufferWithCount(10, 1);
|
||||
* @param {Number} count Length of each buffer.
|
||||
* @param {Number} [skip] Number of elements to skip between creation of consecutive buffers. If not provided, defaults to the count.
|
||||
* @returns {Observable} An observable sequence of buffers.
|
||||
*/
|
||||
observableProto.bufferWithCount = function (count, skip) {
|
||||
if (typeof skip !== 'number') {
|
||||
skip = count;
|
||||
}
|
||||
return this.windowWithCount(count, skip).selectMany(function (x) {
|
||||
return x.toArray();
|
||||
}).where(function (x) {
|
||||
return x.length > 0;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Projects each element of an observable sequence into zero or more windows which are produced based on element count information.
|
||||
*
|
||||
* var res = xs.windowWithCount(10);
|
||||
* var res = xs.windowWithCount(10, 1);
|
||||
* @param {Number} count Length of each window.
|
||||
* @param {Number} [skip] Number of elements to skip between creation of consecutive windows. If not specified, defaults to the count.
|
||||
* @returns {Observable} An observable sequence of windows.
|
||||
*/
|
||||
observableProto.windowWithCount = function (count, skip) {
|
||||
var source = this;
|
||||
+count || (count = 0);
|
||||
Math.abs(count) === Infinity && (count = 0);
|
||||
if (count <= 0) { throw new Error(argumentOutOfRange); }
|
||||
skip == null && (skip = count);
|
||||
+skip || (skip = 0);
|
||||
Math.abs(skip) === Infinity && (skip = 0);
|
||||
|
||||
if (skip <= 0) { throw new Error(argumentOutOfRange); }
|
||||
return new AnonymousObservable(function (observer) {
|
||||
var m = new SingleAssignmentDisposable(),
|
||||
refCountDisposable = new RefCountDisposable(m),
|
||||
n = 0,
|
||||
q = [];
|
||||
|
||||
function createWindow () {
|
||||
var s = new Subject();
|
||||
q.push(s);
|
||||
observer.onNext(addRef(s, refCountDisposable));
|
||||
}
|
||||
|
||||
createWindow();
|
||||
|
||||
m.setDisposable(source.subscribe(
|
||||
function (x) {
|
||||
for (var i = 0, len = q.length; i < len; i++) { q[i].onNext(x); }
|
||||
var c = n - count + 1;
|
||||
c >= 0 && c % skip === 0 && q.shift().onCompleted();
|
||||
++n % skip === 0 && createWindow();
|
||||
},
|
||||
function (e) {
|
||||
while (q.length > 0) { q.shift().onError(e); }
|
||||
observer.onError(e);
|
||||
},
|
||||
function () {
|
||||
while (q.length > 0) { q.shift().onCompleted(); }
|
||||
observer.onCompleted();
|
||||
}
|
||||
));
|
||||
return refCountDisposable;
|
||||
}, source);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an array with the specified number of contiguous elements from the end of an observable sequence.
|
||||
*
|
||||
* @description
|
||||
* This operator accumulates a buffer with a length enough to store count elements. Upon completion of the
|
||||
* source sequence, this buffer is produced on the result sequence.
|
||||
* @param {Number} count Number of elements to take from the end of the source sequence.
|
||||
* @returns {Observable} An observable sequence containing a single array with the specified number of elements from the end of the source sequence.
|
||||
*/
|
||||
observableProto.takeLastBuffer = function (count) {
|
||||
var source = this;
|
||||
return new AnonymousObservable(function (o) {
|
||||
var q = [];
|
||||
return source.subscribe(function (x) {
|
||||
q.push(x);
|
||||
q.length > count && q.shift();
|
||||
}, function (e) { o.onError(e); }, function () {
|
||||
o.onNext(q);
|
||||
o.onCompleted();
|
||||
});
|
||||
}, source);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the elements of the specified sequence or the specified value in a singleton sequence if the sequence is empty.
|
||||
*
|
||||
* var res = obs = xs.defaultIfEmpty();
|
||||
* 2 - obs = xs.defaultIfEmpty(false);
|
||||
*
|
||||
* @memberOf Observable#
|
||||
* @param defaultValue The value to return if the sequence is empty. If not provided, this defaults to null.
|
||||
* @returns {Observable} An observable sequence that contains the specified default value if the source is empty; otherwise, the elements of the source itself.
|
||||
*/
|
||||
observableProto.defaultIfEmpty = function (defaultValue) {
|
||||
var source = this;
|
||||
defaultValue === undefined && (defaultValue = null);
|
||||
return new AnonymousObservable(function (observer) {
|
||||
var found = false;
|
||||
return source.subscribe(function (x) {
|
||||
found = true;
|
||||
observer.onNext(x);
|
||||
},
|
||||
function (e) { observer.onError(e); },
|
||||
function () {
|
||||
!found && observer.onNext(defaultValue);
|
||||
observer.onCompleted();
|
||||
});
|
||||
}, source);
|
||||
};
|
||||
|
||||
// Swap out for Array.findIndex
|
||||
function arrayIndexOfComparer(array, item, comparer) {
|
||||
for (var i = 0, len = array.length; i < len; i++) {
|
||||
if (comparer(array[i], item)) { return i; }
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
function HashSet(comparer) {
|
||||
this.comparer = comparer;
|
||||
this.set = [];
|
||||
}
|
||||
HashSet.prototype.push = function(value) {
|
||||
var retValue = arrayIndexOfComparer(this.set, value, this.comparer) === -1;
|
||||
retValue && this.set.push(value);
|
||||
return retValue;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an observable sequence that contains only distinct elements according to the keySelector and the comparer.
|
||||
* Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.
|
||||
*
|
||||
* @example
|
||||
* var res = obs = xs.distinct();
|
||||
* 2 - obs = xs.distinct(function (x) { return x.id; });
|
||||
* 2 - obs = xs.distinct(function (x) { return x.id; }, function (a,b) { return a === b; });
|
||||
* @param {Function} [keySelector] A function to compute the comparison key for each element.
|
||||
* @param {Function} [comparer] Used to compare items in the collection.
|
||||
* @returns {Observable} An observable sequence only containing the distinct elements, based on a computed key value, from the source sequence.
|
||||
*/
|
||||
observableProto.distinct = function (keySelector, comparer) {
|
||||
var source = this;
|
||||
comparer || (comparer = defaultComparer);
|
||||
return new AnonymousObservable(function (o) {
|
||||
var hashSet = new HashSet(comparer);
|
||||
return source.subscribe(function (x) {
|
||||
var key = x;
|
||||
|
||||
if (keySelector) {
|
||||
try {
|
||||
key = keySelector(x);
|
||||
} catch (e) {
|
||||
o.onError(e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
hashSet.push(key) && o.onNext(x);
|
||||
},
|
||||
function (e) { o.onError(e); }, function () { o.onCompleted(); });
|
||||
}, this);
|
||||
};
|
||||
|
||||
return Rx;
|
||||
}));
|
1
node_modules/rx/dist/rx.lite.extras.map
generated
vendored
Normal file
1
node_modules/rx/dist/rx.lite.extras.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3
node_modules/rx/dist/rx.lite.extras.min.js
generated
vendored
Normal file
3
node_modules/rx/dist/rx.lite.extras.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
5393
node_modules/rx/dist/rx.lite.js
generated
vendored
Normal file
5393
node_modules/rx/dist/rx.lite.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/rx/dist/rx.lite.map
generated
vendored
Normal file
1
node_modules/rx/dist/rx.lite.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
4
node_modules/rx/dist/rx.lite.min.js
generated
vendored
Normal file
4
node_modules/rx/dist/rx.lite.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/rx/dist/rx.map
generated
vendored
Normal file
1
node_modules/rx/dist/rx.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
4
node_modules/rx/dist/rx.min.js
generated
vendored
Normal file
4
node_modules/rx/dist/rx.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
72
node_modules/rx/dist/rx.sorting.js
generated
vendored
Normal file
72
node_modules/rx/dist/rx.sorting.js
generated
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
;(function (factory) {
|
||||
var objectTypes = {
|
||||
'boolean': false,
|
||||
'function': true,
|
||||
'object': true,
|
||||
'number': false,
|
||||
'string': false,
|
||||
'undefined': false
|
||||
};
|
||||
|
||||
var root = (objectTypes[typeof window] && window) || this,
|
||||
freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports,
|
||||
freeModule = objectTypes[typeof module] && module && !module.nodeType && module,
|
||||
moduleExports = freeModule && freeModule.exports === freeExports && freeExports,
|
||||
freeGlobal = objectTypes[typeof global] && global;
|
||||
|
||||
if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) {
|
||||
root = freeGlobal;
|
||||
}
|
||||
|
||||
// Because of build optimizers
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['rx'], function (Rx, exports) {
|
||||
return factory(root, exports, Rx);
|
||||
});
|
||||
} else if (typeof module === 'object' && module && module.exports === freeExports) {
|
||||
module.exports = factory(root, module.exports, require('./rx'));
|
||||
} else {
|
||||
root.Rx = factory(root, {}, root.Rx);
|
||||
}
|
||||
}.call(this, function (root, exp, Rx, undefined) {
|
||||
|
||||
var Observable = Rx.Observable,
|
||||
observableProto = Observable.prototype,
|
||||
AnonymousObservable = Rx.AnonymousObservable,
|
||||
observableNever = Observable.never,
|
||||
isEqual = Rx.internals.isEqual,
|
||||
defaultSubComparer = Rx.helpers.defaultSubComparer;
|
||||
|
||||
/**
|
||||
* jortSort checks if your inputs are sorted. Note that this is only for a sequence with an end.
|
||||
* See http://jort.technology/ for full details.
|
||||
* @returns {Observable} An observable which has a single value of true if sorted, else false.
|
||||
*/
|
||||
observableProto.jortSort = function () {
|
||||
return this.jortSortUntil(observableNever());
|
||||
};
|
||||
|
||||
/**
|
||||
* jortSort checks if your inputs are sorted until another Observable sequence fires.
|
||||
* See http://jort.technology/ for full details.
|
||||
* @returns {Observable} An observable which has a single value of true if sorted, else false.
|
||||
*/
|
||||
observableProto.jortSortUntil = function (other) {
|
||||
var source = this;
|
||||
return new AnonymousObservable(function (observer) {
|
||||
var arr = [];
|
||||
return source.takeUntil(other).subscribe(
|
||||
arr.push.bind(arr),
|
||||
observer.onError.bind(observer),
|
||||
function () {
|
||||
var sorted = arr.slice(0).sort(defaultSubComparer);
|
||||
observer.onNext(isEqual(arr, sorted));
|
||||
observer.onCompleted();
|
||||
});
|
||||
}, source);
|
||||
};
|
||||
|
||||
return Rx;
|
||||
}));
|
1
node_modules/rx/dist/rx.sorting.map
generated
vendored
Normal file
1
node_modules/rx/dist/rx.sorting.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"rx.sorting.min.js","sources":["rx.sorting.js"],"names":["factory","objectTypes","boolean","function","object","number","string","undefined","root","window","this","freeExports","exports","nodeType","freeModule","module","freeGlobal","global","define","amd","Rx","require","call","exp","Observable","observableProto","prototype","AnonymousObservable","observableNever","never","isEqual","internals","defaultSubComparer","helpers","jortSort","jortSortUntil","other","source","observer","arr","takeUntil","subscribe","push","bind","onError","sorted","slice","sort","onNext","onCompleted"],"mappings":";CAEE,SAAUA,GACR,GAAIC,IACAC,WAAW,EACXC,YAAY,EACZC,QAAU,EACVC,QAAU,EACVC,QAAU,EACVC,WAAa,GAGbC,EAAQP,QAAmBQ,UAAWA,QAAWC,KACjDC,EAAcV,QAAmBW,WAAYA,UAAYA,QAAQC,UAAYD,QAC7EE,EAAab,QAAmBc,UAAWA,SAAWA,OAAOF,UAAYE,OAEzEC,GADgBF,GAAcA,EAAWF,UAAYD,GAAeA,EACvDV,QAAmBgB,UAAWA,SAE3CD,GAAeA,EAAWC,SAAWD,GAAcA,EAAWP,SAAWO,IACzER,EAAOQ,GAIW,kBAAXE,SAAyBA,OAAOC,IACvCD,QAAQ,MAAO,SAAUE,EAAIR,GACzB,MAAOZ,GAAQQ,EAAMI,EAASQ,KAET,gBAAXL,SAAuBA,QAAUA,OAAOH,UAAYD,EAClEI,OAAOH,QAAUZ,EAAQQ,EAAMO,OAAOH,QAASS,QAAQ,SAEvDb,EAAKY,GAAKpB,EAAQQ,KAAUA,EAAKY,MAEvCE,KAAKZ,KAAM,SAAUF,EAAMe,EAAKH,GAEhC,GAAII,GAAaJ,EAAGI,WAClBC,EAAkBD,EAAWE,UAC7BC,EAAsBP,EAAGO,oBACzBC,EAAkBJ,EAAWK,MAC7BC,EAAUV,EAAGW,UAAUD,QACvBE,EAAqBZ,EAAGa,QAAQD,kBA+BhC,OAxBFP,GAAgBS,SAAW,WACzB,MAAOxB,MAAKyB,cAAcP,MAQ5BH,EAAgBU,cAAgB,SAAUC,GACxC,GAAIC,GAAS3B,IACb,OAAO,IAAIiB,GAAoB,SAAUW,GACvC,GAAIC,KACJ,OAAOF,GAAOG,UAAUJ,GAAOK,UAC7BF,EAAIG,KAAKC,KAAKJ,GACdD,EAASM,QAAQD,KAAKL,GACtB,WACE,GAAIO,GAASN,EAAIO,MAAM,GAAGC,KAAKf,EAC/BM,GAASU,OAAOlB,EAAQS,EAAKM,IAC7BP,EAASW,iBAEZZ,IAGIjB"}
|
3
node_modules/rx/dist/rx.sorting.min.js
generated
vendored
Normal file
3
node_modules/rx/dist/rx.sorting.min.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
/* Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.*/
|
||||
(function(a){var b={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},c=b[typeof window]&&window||this,d=b[typeof exports]&&exports&&!exports.nodeType&&exports,e=b[typeof module]&&module&&!module.nodeType&&module,f=(e&&e.exports===d&&d,b[typeof global]&&global);!f||f.global!==f&&f.window!==f||(c=f),"function"==typeof define&&define.amd?define(["rx"],function(b,d){return a(c,d,b)}):"object"==typeof module&&module&&module.exports===d?module.exports=a(c,module.exports,require("./rx")):c.Rx=a(c,{},c.Rx)}).call(this,function(a,b,c){var d=c.Observable,e=d.prototype,f=c.AnonymousObservable,g=d.never,h=c.internals.isEqual,i=c.helpers.defaultSubComparer;return e.jortSort=function(){return this.jortSortUntil(g())},e.jortSortUntil=function(a){var b=this;return new f(function(c){var d=[];return b.takeUntil(a).subscribe(d.push.bind(d),c.onError.bind(c),function(){var a=d.slice(0).sort(i);c.onNext(h(d,a)),c.onCompleted()})},b)},c});
|
||||
//# sourceMappingURL=rx.sorting.map
|
530
node_modules/rx/dist/rx.testing.js
generated
vendored
Normal file
530
node_modules/rx/dist/rx.testing.js
generated
vendored
Normal file
@ -0,0 +1,530 @@
|
||||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
;(function (factory) {
|
||||
var objectTypes = {
|
||||
'boolean': false,
|
||||
'function': true,
|
||||
'object': true,
|
||||
'number': false,
|
||||
'string': false,
|
||||
'undefined': false
|
||||
};
|
||||
|
||||
var root = (objectTypes[typeof window] && window) || this,
|
||||
freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports,
|
||||
freeModule = objectTypes[typeof module] && module && !module.nodeType && module,
|
||||
moduleExports = freeModule && freeModule.exports === freeExports && freeExports,
|
||||
freeGlobal = objectTypes[typeof global] && global;
|
||||
|
||||
if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) {
|
||||
root = freeGlobal;
|
||||
}
|
||||
|
||||
// Because of build optimizers
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['rx.virtualtime', 'exports'], function (Rx, exports) {
|
||||
root.Rx = factory(root, exports, Rx);
|
||||
return root.Rx;
|
||||
});
|
||||
} else if (typeof module === 'object' && module && module.exports === freeExports) {
|
||||
module.exports = factory(root, module.exports, require('./rx.all'));
|
||||
} else {
|
||||
root.Rx = factory(root, {}, root.Rx);
|
||||
}
|
||||
}.call(this, function (root, exp, Rx, undefined) {
|
||||
|
||||
// Defaults
|
||||
var Observer = Rx.Observer,
|
||||
Observable = Rx.Observable,
|
||||
Notification = Rx.Notification,
|
||||
VirtualTimeScheduler = Rx.VirtualTimeScheduler,
|
||||
Disposable = Rx.Disposable,
|
||||
disposableEmpty = Disposable.empty,
|
||||
disposableCreate = Disposable.create,
|
||||
CompositeDisposable = Rx.CompositeDisposable,
|
||||
SingleAssignmentDisposable = Rx.SingleAssignmentDisposable,
|
||||
slice = Array.prototype.slice,
|
||||
inherits = Rx.internals.inherits,
|
||||
defaultComparer = Rx.internals.isEqual;
|
||||
|
||||
function argsOrArray(args, idx) {
|
||||
return args.length === 1 && Array.isArray(args[idx]) ?
|
||||
args[idx] :
|
||||
slice.call(args);
|
||||
}
|
||||
|
||||
function OnNextPredicate(predicate) {
|
||||
this.predicate = predicate;
|
||||
};
|
||||
|
||||
OnNextPredicate.prototype.equals = function (other) {
|
||||
if (other === this) { return true; }
|
||||
if (other == null) { return false; }
|
||||
if (other.kind !== 'N') { return false; }
|
||||
return this.predicate(other.value);
|
||||
};
|
||||
|
||||
function OnErrorPredicate(predicate) {
|
||||
this.predicate = predicate;
|
||||
};
|
||||
|
||||
OnErrorPredicate.prototype.equals = function (other) {
|
||||
if (other === this) { return true; }
|
||||
if (other == null) { return false; }
|
||||
if (other.kind !== 'E') { return false; }
|
||||
return this.predicate(other.exception);
|
||||
};
|
||||
|
||||
var ReactiveTest = Rx.ReactiveTest = {
|
||||
/** Default virtual time used for creation of observable sequences in unit tests. */
|
||||
created: 100,
|
||||
/** Default virtual time used to subscribe to observable sequences in unit tests. */
|
||||
subscribed: 200,
|
||||
/** Default virtual time used to dispose subscriptions in unit tests. */
|
||||
disposed: 1000,
|
||||
|
||||
/**
|
||||
* Factory method for an OnNext notification record at a given time with a given value or a predicate function.
|
||||
*
|
||||
* 1 - ReactiveTest.onNext(200, 42);
|
||||
* 2 - ReactiveTest.onNext(200, function (x) { return x.length == 2; });
|
||||
*
|
||||
* @param ticks Recorded virtual time the OnNext notification occurs.
|
||||
* @param value Recorded value stored in the OnNext notification or a predicate.
|
||||
* @return Recorded OnNext notification.
|
||||
*/
|
||||
onNext: function (ticks, value) {
|
||||
return typeof value === 'function' ?
|
||||
new Recorded(ticks, new OnNextPredicate(value)) :
|
||||
new Recorded(ticks, Notification.createOnNext(value));
|
||||
},
|
||||
/**
|
||||
* Factory method for an OnError notification record at a given time with a given error.
|
||||
*
|
||||
* 1 - ReactiveTest.onNext(200, new Error('error'));
|
||||
* 2 - ReactiveTest.onNext(200, function (e) { return e.message === 'error'; });
|
||||
*
|
||||
* @param ticks Recorded virtual time the OnError notification occurs.
|
||||
* @param exception Recorded exception stored in the OnError notification.
|
||||
* @return Recorded OnError notification.
|
||||
*/
|
||||
onError: function (ticks, error) {
|
||||
return typeof error === 'function' ?
|
||||
new Recorded(ticks, new OnErrorPredicate(error)) :
|
||||
new Recorded(ticks, Notification.createOnError(error));
|
||||
},
|
||||
/**
|
||||
* Factory method for an OnCompleted notification record at a given time.
|
||||
*
|
||||
* @param ticks Recorded virtual time the OnCompleted notification occurs.
|
||||
* @return Recorded OnCompleted notification.
|
||||
*/
|
||||
onCompleted: function (ticks) {
|
||||
return new Recorded(ticks, Notification.createOnCompleted());
|
||||
},
|
||||
/**
|
||||
* Factory method for a subscription record based on a given subscription and disposal time.
|
||||
*
|
||||
* @param start Virtual time indicating when the subscription was created.
|
||||
* @param end Virtual time indicating when the subscription was disposed.
|
||||
* @return Subscription object.
|
||||
*/
|
||||
subscribe: function (start, end) {
|
||||
return new Subscription(start, end);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new object recording the production of the specified value at the given virtual time.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Number} time Virtual time the value was produced on.
|
||||
* @param {Mixed} value Value that was produced.
|
||||
* @param {Function} comparer An optional comparer.
|
||||
*/
|
||||
var Recorded = Rx.Recorded = function (time, value, comparer) {
|
||||
this.time = time;
|
||||
this.value = value;
|
||||
this.comparer = comparer || defaultComparer;
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks whether the given recorded object is equal to the current instance.
|
||||
*
|
||||
* @param {Recorded} other Recorded object to check for equality.
|
||||
* @returns {Boolean} true if both objects are equal; false otherwise.
|
||||
*/
|
||||
Recorded.prototype.equals = function (other) {
|
||||
return this.time === other.time && this.comparer(this.value, other.value);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a string representation of the current Recorded value.
|
||||
*
|
||||
* @returns {String} String representation of the current Recorded value.
|
||||
*/
|
||||
Recorded.prototype.toString = function () {
|
||||
return this.value.toString() + '@' + this.time;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new subscription object with the given virtual subscription and unsubscription time.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Number} subscribe Virtual time at which the subscription occurred.
|
||||
* @param {Number} unsubscribe Virtual time at which the unsubscription occurred.
|
||||
*/
|
||||
var Subscription = Rx.Subscription = function (start, end) {
|
||||
this.subscribe = start;
|
||||
this.unsubscribe = end || Number.MAX_VALUE;
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks whether the given subscription is equal to the current instance.
|
||||
* @param other Subscription object to check for equality.
|
||||
* @returns {Boolean} true if both objects are equal; false otherwise.
|
||||
*/
|
||||
Subscription.prototype.equals = function (other) {
|
||||
return this.subscribe === other.subscribe && this.unsubscribe === other.unsubscribe;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a string representation of the current Subscription value.
|
||||
* @returns {String} String representation of the current Subscription value.
|
||||
*/
|
||||
Subscription.prototype.toString = function () {
|
||||
return '(' + this.subscribe + ', ' + (this.unsubscribe === Number.MAX_VALUE ? 'Infinite' : this.unsubscribe) + ')';
|
||||
};
|
||||
|
||||
/** @private */
|
||||
var MockDisposable = Rx.MockDisposable = function (scheduler) {
|
||||
this.scheduler = scheduler;
|
||||
this.disposes = [];
|
||||
this.disposes.push(this.scheduler.clock);
|
||||
};
|
||||
|
||||
/*
|
||||
* @memberOf MockDisposable#
|
||||
* @prviate
|
||||
*/
|
||||
MockDisposable.prototype.dispose = function () {
|
||||
this.disposes.push(this.scheduler.clock);
|
||||
};
|
||||
|
||||
var MockObserver = (function (__super__) {
|
||||
inherits(MockObserver, __super__);
|
||||
|
||||
function MockObserver(scheduler) {
|
||||
__super__.call(this);
|
||||
this.scheduler = scheduler;
|
||||
this.messages = [];
|
||||
}
|
||||
|
||||
var MockObserverPrototype = MockObserver.prototype;
|
||||
|
||||
MockObserverPrototype.onNext = function (value) {
|
||||
this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnNext(value)));
|
||||
};
|
||||
|
||||
MockObserverPrototype.onError = function (exception) {
|
||||
this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnError(exception)));
|
||||
};
|
||||
|
||||
MockObserverPrototype.onCompleted = function () {
|
||||
this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnCompleted()));
|
||||
};
|
||||
|
||||
return MockObserver;
|
||||
})(Observer);
|
||||
|
||||
function MockPromise(scheduler, messages) {
|
||||
var self = this;
|
||||
this.scheduler = scheduler;
|
||||
this.messages = messages;
|
||||
this.subscriptions = [];
|
||||
this.observers = [];
|
||||
for (var i = 0, len = this.messages.length; i < len; i++) {
|
||||
var message = this.messages[i],
|
||||
notification = message.value;
|
||||
(function (innerNotification) {
|
||||
scheduler.scheduleAbsoluteWithState(null, message.time, function () {
|
||||
var obs = self.observers.slice(0);
|
||||
|
||||
for (var j = 0, jLen = obs.length; j < jLen; j++) {
|
||||
innerNotification.accept(obs[j]);
|
||||
}
|
||||
return disposableEmpty;
|
||||
});
|
||||
})(notification);
|
||||
}
|
||||
}
|
||||
|
||||
MockPromise.prototype.then = function (onResolved, onRejected) {
|
||||
var self = this;
|
||||
|
||||
this.subscriptions.push(new Subscription(this.scheduler.clock));
|
||||
var index = this.subscriptions.length - 1;
|
||||
|
||||
var newPromise;
|
||||
|
||||
var observer = Rx.Observer.create(
|
||||
function (x) {
|
||||
var retValue = onResolved(x);
|
||||
if (retValue && typeof retValue.then === 'function') {
|
||||
newPromise = retValue;
|
||||
} else {
|
||||
var ticks = self.scheduler.clock;
|
||||
newPromise = new MockPromise(self.scheduler, [Rx.ReactiveTest.onNext(ticks, undefined), Rx.ReactiveTest.onCompleted(ticks)]);
|
||||
}
|
||||
var idx = self.observers.indexOf(observer);
|
||||
self.observers.splice(idx, 1);
|
||||
self.subscriptions[index] = new Subscription(self.subscriptions[index].subscribe, self.scheduler.clock);
|
||||
},
|
||||
function (err) {
|
||||
onRejected(err);
|
||||
var idx = self.observers.indexOf(observer);
|
||||
self.observers.splice(idx, 1);
|
||||
self.subscriptions[index] = new Subscription(self.subscriptions[index].subscribe, self.scheduler.clock);
|
||||
}
|
||||
);
|
||||
this.observers.push(observer);
|
||||
|
||||
return newPromise || new MockPromise(this.scheduler, this.messages);
|
||||
};
|
||||
|
||||
var HotObservable = (function (__super__) {
|
||||
|
||||
function subscribe(observer) {
|
||||
var observable = this;
|
||||
this.observers.push(observer);
|
||||
this.subscriptions.push(new Subscription(this.scheduler.clock));
|
||||
var index = this.subscriptions.length - 1;
|
||||
return disposableCreate(function () {
|
||||
var idx = observable.observers.indexOf(observer);
|
||||
observable.observers.splice(idx, 1);
|
||||
observable.subscriptions[index] = new Subscription(observable.subscriptions[index].subscribe, observable.scheduler.clock);
|
||||
});
|
||||
}
|
||||
|
||||
inherits(HotObservable, __super__);
|
||||
|
||||
function HotObservable(scheduler, messages) {
|
||||
__super__.call(this, subscribe);
|
||||
var message, notification, observable = this;
|
||||
this.scheduler = scheduler;
|
||||
this.messages = messages;
|
||||
this.subscriptions = [];
|
||||
this.observers = [];
|
||||
for (var i = 0, len = this.messages.length; i < len; i++) {
|
||||
message = this.messages[i];
|
||||
notification = message.value;
|
||||
(function (innerNotification) {
|
||||
scheduler.scheduleAbsoluteWithState(null, message.time, function () {
|
||||
var obs = observable.observers.slice(0);
|
||||
|
||||
for (var j = 0, jLen = obs.length; j < jLen; j++) {
|
||||
innerNotification.accept(obs[j]);
|
||||
}
|
||||
return disposableEmpty;
|
||||
});
|
||||
})(notification);
|
||||
}
|
||||
}
|
||||
|
||||
return HotObservable;
|
||||
})(Observable);
|
||||
|
||||
var ColdObservable = (function (__super__) {
|
||||
|
||||
function subscribe(observer) {
|
||||
var message, notification, observable = this;
|
||||
this.subscriptions.push(new Subscription(this.scheduler.clock));
|
||||
var index = this.subscriptions.length - 1;
|
||||
var d = new CompositeDisposable();
|
||||
for (var i = 0, len = this.messages.length; i < len; i++) {
|
||||
message = this.messages[i];
|
||||
notification = message.value;
|
||||
(function (innerNotification) {
|
||||
d.add(observable.scheduler.scheduleRelativeWithState(null, message.time, function () {
|
||||
innerNotification.accept(observer);
|
||||
return disposableEmpty;
|
||||
}));
|
||||
})(notification);
|
||||
}
|
||||
return disposableCreate(function () {
|
||||
observable.subscriptions[index] = new Subscription(observable.subscriptions[index].subscribe, observable.scheduler.clock);
|
||||
d.dispose();
|
||||
});
|
||||
}
|
||||
|
||||
inherits(ColdObservable, __super__);
|
||||
|
||||
function ColdObservable(scheduler, messages) {
|
||||
__super__.call(this, subscribe);
|
||||
this.scheduler = scheduler;
|
||||
this.messages = messages;
|
||||
this.subscriptions = [];
|
||||
}
|
||||
|
||||
return ColdObservable;
|
||||
})(Observable);
|
||||
|
||||
/** Virtual time scheduler used for testing applications and libraries built using Reactive Extensions. */
|
||||
Rx.TestScheduler = (function (__super__) {
|
||||
inherits(TestScheduler, __super__);
|
||||
|
||||
function baseComparer(x, y) {
|
||||
return x > y ? 1 : (x < y ? -1 : 0);
|
||||
}
|
||||
|
||||
function TestScheduler() {
|
||||
__super__.call(this, 0, baseComparer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedules an action to be executed at the specified virtual time.
|
||||
*
|
||||
* @param state State passed to the action to be executed.
|
||||
* @param dueTime Absolute virtual time at which to execute the action.
|
||||
* @param action Action to be executed.
|
||||
* @return Disposable object used to cancel the scheduled action (best effort).
|
||||
*/
|
||||
TestScheduler.prototype.scheduleAbsoluteWithState = function (state, dueTime, action) {
|
||||
dueTime <= this.clock && (dueTime = this.clock + 1);
|
||||
return __super__.prototype.scheduleAbsoluteWithState.call(this, state, dueTime, action);
|
||||
};
|
||||
/**
|
||||
* Adds a relative virtual time to an absolute virtual time value.
|
||||
*
|
||||
* @param absolute Absolute virtual time value.
|
||||
* @param relative Relative virtual time value to add.
|
||||
* @return Resulting absolute virtual time sum value.
|
||||
*/
|
||||
TestScheduler.prototype.add = function (absolute, relative) {
|
||||
return absolute + relative;
|
||||
};
|
||||
/**
|
||||
* Converts the absolute virtual time value to a DateTimeOffset value.
|
||||
*
|
||||
* @param absolute Absolute virtual time value to convert.
|
||||
* @return Corresponding DateTimeOffset value.
|
||||
*/
|
||||
TestScheduler.prototype.toDateTimeOffset = function (absolute) {
|
||||
return new Date(absolute).getTime();
|
||||
};
|
||||
/**
|
||||
* Converts the TimeSpan value to a relative virtual time value.
|
||||
*
|
||||
* @param timeSpan TimeSpan value to convert.
|
||||
* @return Corresponding relative virtual time value.
|
||||
*/
|
||||
TestScheduler.prototype.toRelative = function (timeSpan) {
|
||||
return timeSpan;
|
||||
};
|
||||
/**
|
||||
* Starts the test scheduler and uses the specified virtual times to invoke the factory function, subscribe to the resulting sequence, and dispose the subscription.
|
||||
*
|
||||
* @param create Factory method to create an observable sequence.
|
||||
* @param created Virtual time at which to invoke the factory to create an observable sequence.
|
||||
* @param subscribed Virtual time at which to subscribe to the created observable sequence.
|
||||
* @param disposed Virtual time at which to dispose the subscription.
|
||||
* @return Observer with timestamped recordings of notification messages that were received during the virtual time window when the subscription to the source sequence was active.
|
||||
*/
|
||||
TestScheduler.prototype.startWithTiming = function (create, created, subscribed, disposed) {
|
||||
var observer = this.createObserver(), source, subscription;
|
||||
|
||||
this.scheduleAbsoluteWithState(null, created, function () {
|
||||
source = create();
|
||||
return disposableEmpty;
|
||||
});
|
||||
|
||||
this.scheduleAbsoluteWithState(null, subscribed, function () {
|
||||
subscription = source.subscribe(observer);
|
||||
return disposableEmpty;
|
||||
});
|
||||
|
||||
this.scheduleAbsoluteWithState(null, disposed, function () {
|
||||
subscription.dispose();
|
||||
return disposableEmpty;
|
||||
});
|
||||
|
||||
this.start();
|
||||
|
||||
return observer;
|
||||
};
|
||||
|
||||
/**
|
||||
* Starts the test scheduler and uses the specified virtual time to dispose the subscription to the sequence obtained through the factory function.
|
||||
* Default virtual times are used for factory invocation and sequence subscription.
|
||||
*
|
||||
* @param create Factory method to create an observable sequence.
|
||||
* @param disposed Virtual time at which to dispose the subscription.
|
||||
* @return Observer with timestamped recordings of notification messages that were received during the virtual time window when the subscription to the source sequence was active.
|
||||
*/
|
||||
TestScheduler.prototype.startWithDispose = function (create, disposed) {
|
||||
return this.startWithTiming(create, ReactiveTest.created, ReactiveTest.subscribed, disposed);
|
||||
};
|
||||
|
||||
/**
|
||||
* Starts the test scheduler and uses default virtual times to invoke the factory function, to subscribe to the resulting sequence, and to dispose the subscription.
|
||||
*
|
||||
* @param create Factory method to create an observable sequence.
|
||||
* @return Observer with timestamped recordings of notification messages that were received during the virtual time window when the subscription to the source sequence was active.
|
||||
*/
|
||||
TestScheduler.prototype.startWithCreate = function (create) {
|
||||
return this.startWithTiming(create, ReactiveTest.created, ReactiveTest.subscribed, ReactiveTest.disposed);
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a hot observable using the specified timestamped notification messages either as an array or arguments.
|
||||
* @param messages Notifications to surface through the created sequence at their specified absolute virtual times.
|
||||
* @return Hot observable sequence that can be used to assert the timing of subscriptions and notifications.
|
||||
*/
|
||||
TestScheduler.prototype.createHotObservable = function () {
|
||||
var messages = argsOrArray(arguments, 0);
|
||||
return new HotObservable(this, messages);
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a cold observable using the specified timestamped notification messages either as an array or arguments.
|
||||
* @param messages Notifications to surface through the created sequence at their specified virtual time offsets from the sequence subscription time.
|
||||
* @return Cold observable sequence that can be used to assert the timing of subscriptions and notifications.
|
||||
*/
|
||||
TestScheduler.prototype.createColdObservable = function () {
|
||||
var messages = argsOrArray(arguments, 0);
|
||||
return new ColdObservable(this, messages);
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a resolved promise with the given value and ticks
|
||||
* @param {Number} ticks The absolute time of the resolution.
|
||||
* @param {Any} value The value to yield at the given tick.
|
||||
* @returns {MockPromise} A mock Promise which fulfills with the given value.
|
||||
*/
|
||||
TestScheduler.prototype.createResolvedPromise = function (ticks, value) {
|
||||
return new MockPromise(this, [Rx.ReactiveTest.onNext(ticks, value), Rx.ReactiveTest.onCompleted(ticks)]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a rejected promise with the given reason and ticks
|
||||
* @param {Number} ticks The absolute time of the resolution.
|
||||
* @param {Any} reason The reason for rejection to yield at the given tick.
|
||||
* @returns {MockPromise} A mock Promise which rejects with the given reason.
|
||||
*/
|
||||
TestScheduler.prototype.createRejectedPromise = function (ticks, reason) {
|
||||
return new MockPromise(this, [Rx.ReactiveTest.onError(ticks, reason)]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates an observer that records received notification messages and timestamps those.
|
||||
* @return Observer that can be used to assert the timing of received notifications.
|
||||
*/
|
||||
TestScheduler.prototype.createObserver = function () {
|
||||
return new MockObserver(this);
|
||||
};
|
||||
|
||||
return TestScheduler;
|
||||
})(VirtualTimeScheduler);
|
||||
|
||||
return Rx;
|
||||
}));
|
1
node_modules/rx/dist/rx.testing.map
generated
vendored
Normal file
1
node_modules/rx/dist/rx.testing.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3
node_modules/rx/dist/rx.testing.min.js
generated
vendored
Normal file
3
node_modules/rx/dist/rx.testing.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1126
node_modules/rx/dist/rx.time.js
generated
vendored
Normal file
1126
node_modules/rx/dist/rx.time.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/rx/dist/rx.time.map
generated
vendored
Normal file
1
node_modules/rx/dist/rx.time.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3
node_modules/rx/dist/rx.time.min.js
generated
vendored
Normal file
3
node_modules/rx/dist/rx.time.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
320
node_modules/rx/dist/rx.virtualtime.js
generated
vendored
Normal file
320
node_modules/rx/dist/rx.virtualtime.js
generated
vendored
Normal file
@ -0,0 +1,320 @@
|
||||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
;(function (factory) {
|
||||
var objectTypes = {
|
||||
'boolean': false,
|
||||
'function': true,
|
||||
'object': true,
|
||||
'number': false,
|
||||
'string': false,
|
||||
'undefined': false
|
||||
};
|
||||
|
||||
var root = (objectTypes[typeof window] && window) || this,
|
||||
freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports,
|
||||
freeModule = objectTypes[typeof module] && module && !module.nodeType && module,
|
||||
moduleExports = freeModule && freeModule.exports === freeExports && freeExports,
|
||||
freeGlobal = objectTypes[typeof global] && global;
|
||||
|
||||
if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) {
|
||||
root = freeGlobal;
|
||||
}
|
||||
|
||||
// Because of build optimizers
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['rx'], function (Rx, exports) {
|
||||
return factory(root, exports, Rx);
|
||||
});
|
||||
} else if (typeof module === 'object' && module && module.exports === freeExports) {
|
||||
module.exports = factory(root, module.exports, require('./rx'));
|
||||
} else {
|
||||
root.Rx = factory(root, {}, root.Rx);
|
||||
}
|
||||
}.call(this, function (root, exp, Rx, undefined) {
|
||||
|
||||
// Aliases
|
||||
var Scheduler = Rx.Scheduler,
|
||||
PriorityQueue = Rx.internals.PriorityQueue,
|
||||
ScheduledItem = Rx.internals.ScheduledItem,
|
||||
SchedulePeriodicRecursive = Rx.internals.SchedulePeriodicRecursive,
|
||||
disposableEmpty = Rx.Disposable.empty,
|
||||
inherits = Rx.internals.inherits,
|
||||
defaultSubComparer = Rx.helpers.defaultSubComparer;
|
||||
|
||||
/** Provides a set of extension methods for virtual time scheduling. */
|
||||
Rx.VirtualTimeScheduler = (function (__super__) {
|
||||
|
||||
function notImplemented() {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
|
||||
function localNow() {
|
||||
return this.toDateTimeOffset(this.clock);
|
||||
}
|
||||
|
||||
function scheduleNow(state, action) {
|
||||
return this.scheduleAbsoluteWithState(state, this.clock, action);
|
||||
}
|
||||
|
||||
function scheduleRelative(state, dueTime, action) {
|
||||
return this.scheduleRelativeWithState(state, this.toRelative(dueTime), action);
|
||||
}
|
||||
|
||||
function scheduleAbsolute(state, dueTime, action) {
|
||||
return this.scheduleRelativeWithState(state, this.toRelative(dueTime - this.now()), action);
|
||||
}
|
||||
|
||||
function invokeAction(scheduler, action) {
|
||||
action();
|
||||
return disposableEmpty;
|
||||
}
|
||||
|
||||
inherits(VirtualTimeScheduler, __super__);
|
||||
|
||||
/**
|
||||
* Creates a new virtual time scheduler with the specified initial clock value and absolute time comparer.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Number} initialClock Initial value for the clock.
|
||||
* @param {Function} comparer Comparer to determine causality of events based on absolute time.
|
||||
*/
|
||||
function VirtualTimeScheduler(initialClock, comparer) {
|
||||
this.clock = initialClock;
|
||||
this.comparer = comparer;
|
||||
this.isEnabled = false;
|
||||
this.queue = new PriorityQueue(1024);
|
||||
__super__.call(this, localNow, scheduleNow, scheduleRelative, scheduleAbsolute);
|
||||
}
|
||||
|
||||
var VirtualTimeSchedulerPrototype = VirtualTimeScheduler.prototype;
|
||||
|
||||
/**
|
||||
* Adds a relative time value to an absolute time value.
|
||||
* @param {Number} absolute Absolute virtual time value.
|
||||
* @param {Number} relative Relative virtual time value to add.
|
||||
* @return {Number} Resulting absolute virtual time sum value.
|
||||
*/
|
||||
VirtualTimeSchedulerPrototype.add = notImplemented;
|
||||
|
||||
/**
|
||||
* Converts an absolute time to a number
|
||||
* @param {Any} The absolute time.
|
||||
* @returns {Number} The absolute time in ms
|
||||
*/
|
||||
VirtualTimeSchedulerPrototype.toDateTimeOffset = notImplemented;
|
||||
|
||||
/**
|
||||
* Converts the TimeSpan value to a relative virtual time value.
|
||||
* @param {Number} timeSpan TimeSpan value to convert.
|
||||
* @return {Number} Corresponding relative virtual time value.
|
||||
*/
|
||||
VirtualTimeSchedulerPrototype.toRelative = notImplemented;
|
||||
|
||||
/**
|
||||
* Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be emulated using recursive scheduling.
|
||||
* @param {Mixed} state Initial state passed to the action upon the first iteration.
|
||||
* @param {Number} period Period for running the work periodically.
|
||||
* @param {Function} action Action to be executed, potentially updating the state.
|
||||
* @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort).
|
||||
*/
|
||||
VirtualTimeSchedulerPrototype.schedulePeriodicWithState = function (state, period, action) {
|
||||
var s = new SchedulePeriodicRecursive(this, state, period, action);
|
||||
return s.start();
|
||||
};
|
||||
|
||||
/**
|
||||
* Schedules an action to be executed after dueTime.
|
||||
* @param {Mixed} state State passed to the action to be executed.
|
||||
* @param {Number} dueTime Relative time after which to execute the action.
|
||||
* @param {Function} action Action to be executed.
|
||||
* @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
|
||||
*/
|
||||
VirtualTimeSchedulerPrototype.scheduleRelativeWithState = function (state, dueTime, action) {
|
||||
var runAt = this.add(this.clock, dueTime);
|
||||
return this.scheduleAbsoluteWithState(state, runAt, action);
|
||||
};
|
||||
|
||||
/**
|
||||
* Schedules an action to be executed at dueTime.
|
||||
* @param {Number} dueTime Relative time after which to execute the action.
|
||||
* @param {Function} action Action to be executed.
|
||||
* @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
|
||||
*/
|
||||
VirtualTimeSchedulerPrototype.scheduleRelative = function (dueTime, action) {
|
||||
return this.scheduleRelativeWithState(action, dueTime, invokeAction);
|
||||
};
|
||||
|
||||
/**
|
||||
* Starts the virtual time scheduler.
|
||||
*/
|
||||
VirtualTimeSchedulerPrototype.start = function () {
|
||||
if (!this.isEnabled) {
|
||||
this.isEnabled = true;
|
||||
do {
|
||||
var next = this.getNext();
|
||||
if (next !== null) {
|
||||
this.comparer(next.dueTime, this.clock) > 0 && (this.clock = next.dueTime);
|
||||
next.invoke();
|
||||
} else {
|
||||
this.isEnabled = false;
|
||||
}
|
||||
} while (this.isEnabled);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Stops the virtual time scheduler.
|
||||
*/
|
||||
VirtualTimeSchedulerPrototype.stop = function () {
|
||||
this.isEnabled = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Advances the scheduler's clock to the specified time, running all work till that point.
|
||||
* @param {Number} time Absolute time to advance the scheduler's clock to.
|
||||
*/
|
||||
VirtualTimeSchedulerPrototype.advanceTo = function (time) {
|
||||
var dueToClock = this.comparer(this.clock, time);
|
||||
if (this.comparer(this.clock, time) > 0) {
|
||||
throw new Error(argumentOutOfRange);
|
||||
}
|
||||
if (dueToClock === 0) {
|
||||
return;
|
||||
}
|
||||
if (!this.isEnabled) {
|
||||
this.isEnabled = true;
|
||||
do {
|
||||
var next = this.getNext();
|
||||
if (next !== null && this.comparer(next.dueTime, time) <= 0) {
|
||||
this.comparer(next.dueTime, this.clock) > 0 && (this.clock = next.dueTime);
|
||||
next.invoke();
|
||||
} else {
|
||||
this.isEnabled = false;
|
||||
}
|
||||
} while (this.isEnabled);
|
||||
this.clock = time;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Advances the scheduler's clock by the specified relative time, running all work scheduled for that timespan.
|
||||
* @param {Number} time Relative time to advance the scheduler's clock by.
|
||||
*/
|
||||
VirtualTimeSchedulerPrototype.advanceBy = function (time) {
|
||||
var dt = this.add(this.clock, time),
|
||||
dueToClock = this.comparer(this.clock, dt);
|
||||
if (dueToClock > 0) { throw new Error(argumentOutOfRange); }
|
||||
if (dueToClock === 0) { return; }
|
||||
|
||||
this.advanceTo(dt);
|
||||
};
|
||||
|
||||
/**
|
||||
* Advances the scheduler's clock by the specified relative time.
|
||||
* @param {Number} time Relative time to advance the scheduler's clock by.
|
||||
*/
|
||||
VirtualTimeSchedulerPrototype.sleep = function (time) {
|
||||
var dt = this.add(this.clock, time);
|
||||
if (this.comparer(this.clock, dt) >= 0) { throw new Error(argumentOutOfRange); }
|
||||
|
||||
this.clock = dt;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the next scheduled item to be executed.
|
||||
* @returns {ScheduledItem} The next scheduled item.
|
||||
*/
|
||||
VirtualTimeSchedulerPrototype.getNext = function () {
|
||||
while (this.queue.length > 0) {
|
||||
var next = this.queue.peek();
|
||||
if (next.isCancelled()) {
|
||||
this.queue.dequeue();
|
||||
} else {
|
||||
return next;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Schedules an action to be executed at dueTime.
|
||||
* @param {Scheduler} scheduler Scheduler to execute the action on.
|
||||
* @param {Number} dueTime Absolute time at which to execute the action.
|
||||
* @param {Function} action Action to be executed.
|
||||
* @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
|
||||
*/
|
||||
VirtualTimeSchedulerPrototype.scheduleAbsolute = function (dueTime, action) {
|
||||
return this.scheduleAbsoluteWithState(action, dueTime, invokeAction);
|
||||
};
|
||||
|
||||
/**
|
||||
* Schedules an action to be executed at dueTime.
|
||||
* @param {Mixed} state State passed to the action to be executed.
|
||||
* @param {Number} dueTime Absolute time at which to execute the action.
|
||||
* @param {Function} action Action to be executed.
|
||||
* @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
|
||||
*/
|
||||
VirtualTimeSchedulerPrototype.scheduleAbsoluteWithState = function (state, dueTime, action) {
|
||||
var self = this;
|
||||
|
||||
function run(scheduler, state1) {
|
||||
self.queue.remove(si);
|
||||
return action(scheduler, state1);
|
||||
}
|
||||
|
||||
var si = new ScheduledItem(this, state, run, dueTime, this.comparer);
|
||||
this.queue.enqueue(si);
|
||||
|
||||
return si.disposable;
|
||||
};
|
||||
|
||||
return VirtualTimeScheduler;
|
||||
}(Scheduler));
|
||||
|
||||
/** Provides a virtual time scheduler that uses Date for absolute time and number for relative time. */
|
||||
Rx.HistoricalScheduler = (function (__super__) {
|
||||
inherits(HistoricalScheduler, __super__);
|
||||
|
||||
/**
|
||||
* Creates a new historical scheduler with the specified initial clock value.
|
||||
* @constructor
|
||||
* @param {Number} initialClock Initial value for the clock.
|
||||
* @param {Function} comparer Comparer to determine causality of events based on absolute time.
|
||||
*/
|
||||
function HistoricalScheduler(initialClock, comparer) {
|
||||
var clock = initialClock == null ? 0 : initialClock;
|
||||
var cmp = comparer || defaultSubComparer;
|
||||
__super__.call(this, clock, cmp);
|
||||
}
|
||||
|
||||
var HistoricalSchedulerProto = HistoricalScheduler.prototype;
|
||||
|
||||
/**
|
||||
* Adds a relative time value to an absolute time value.
|
||||
* @param {Number} absolute Absolute virtual time value.
|
||||
* @param {Number} relative Relative virtual time value to add.
|
||||
* @return {Number} Resulting absolute virtual time sum value.
|
||||
*/
|
||||
HistoricalSchedulerProto.add = function (absolute, relative) {
|
||||
return absolute + relative;
|
||||
};
|
||||
|
||||
HistoricalSchedulerProto.toDateTimeOffset = function (absolute) {
|
||||
return new Date(absolute).getTime();
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts the TimeSpan value to a relative virtual time value.
|
||||
* @memberOf HistoricalScheduler
|
||||
* @param {Number} timeSpan TimeSpan value to convert.
|
||||
* @return {Number} Corresponding relative virtual time value.
|
||||
*/
|
||||
HistoricalSchedulerProto.toRelative = function (timeSpan) {
|
||||
return timeSpan;
|
||||
};
|
||||
|
||||
return HistoricalScheduler;
|
||||
}(Rx.VirtualTimeScheduler));
|
||||
|
||||
return Rx;
|
||||
}));
|
1
node_modules/rx/dist/rx.virtualtime.map
generated
vendored
Normal file
1
node_modules/rx/dist/rx.virtualtime.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"rx.virtualtime.min.js","sources":["rx.virtualtime.js"],"names":["factory","objectTypes","boolean","function","object","number","string","undefined","root","window","this","freeExports","exports","nodeType","freeModule","module","freeGlobal","global","define","amd","Rx","require","call","exp","Scheduler","PriorityQueue","internals","ScheduledItem","SchedulePeriodicRecursive","disposableEmpty","Disposable","empty","inherits","defaultSubComparer","helpers","VirtualTimeScheduler","__super__","notImplemented","Error","localNow","toDateTimeOffset","clock","scheduleNow","state","action","scheduleAbsoluteWithState","scheduleRelative","dueTime","scheduleRelativeWithState","toRelative","scheduleAbsolute","now","invokeAction","scheduler","initialClock","comparer","isEnabled","queue","VirtualTimeSchedulerPrototype","prototype","add","schedulePeriodicWithState","period","s","start","runAt","next","getNext","invoke","stop","advanceTo","time","dueToClock","argumentOutOfRange","advanceBy","dt","sleep","length","peek","isCancelled","dequeue","run","state1","self","remove","si","enqueue","disposable","HistoricalScheduler","cmp","HistoricalSchedulerProto","absolute","relative","Date","getTime","timeSpan"],"mappings":";CAEE,SAAUA,GACR,GAAIC,IACAC,WAAW,EACXC,YAAY,EACZC,QAAU,EACVC,QAAU,EACVC,QAAU,EACVC,WAAa,GAGbC,EAAQP,QAAmBQ,UAAWA,QAAWC,KACjDC,EAAcV,QAAmBW,WAAYA,UAAYA,QAAQC,UAAYD,QAC7EE,EAAab,QAAmBc,UAAWA,SAAWA,OAAOF,UAAYE,OAEzEC,GADgBF,GAAcA,EAAWF,UAAYD,GAAeA,EACvDV,QAAmBgB,UAAWA,SAE3CD,GAAeA,EAAWC,SAAWD,GAAcA,EAAWP,SAAWO,IACzER,EAAOQ,GAIW,kBAAXE,SAAyBA,OAAOC,IACvCD,QAAQ,MAAO,SAAUE,EAAIR,GACzB,MAAOZ,GAAQQ,EAAMI,EAASQ,KAET,gBAAXL,SAAuBA,QAAUA,OAAOH,UAAYD,EAClEI,OAAOH,QAAUZ,EAAQQ,EAAMO,OAAOH,QAASS,QAAQ,SAEvDb,EAAKY,GAAKpB,EAAQQ,KAAUA,EAAKY,MAEvCE,KAAKZ,KAAM,SAAUF,EAAMe,EAAKH,GAGjC,GAAII,GAAYJ,EAAGI,UAClBC,EAAgBL,EAAGM,UAAUD,cAC7BE,EAAgBP,EAAGM,UAAUC,cAC7BC,EAA6BR,EAAGM,UAAUE,0BAC1CC,EAAkBT,EAAGU,WAAWC,MAChCC,EAAWZ,EAAGM,UAAUM,SACtBC,EAAqBb,EAAGc,QAAQD,kBAqRhC,OAlRFb,GAAGe,qBAAwB,SAAUC,GAEnC,QAASC,KACL,KAAM,IAAIC,OAAM,mBAGpB,QAASC,KACP,MAAO7B,MAAK8B,iBAAiB9B,KAAK+B,OAGpC,QAASC,GAAYC,EAAOC,GAC1B,MAAOlC,MAAKmC,0BAA0BF,EAAOjC,KAAK+B,MAAOG,GAG3D,QAASE,GAAiBH,EAAOI,EAASH,GACxC,MAAOlC,MAAKsC,0BAA0BL,EAAOjC,KAAKuC,WAAWF,GAAUH,GAGzE,QAASM,GAAiBP,EAAOI,EAASH,GACxC,MAAOlC,MAAKsC,0BAA0BL,EAAOjC,KAAKuC,WAAWF,EAAUrC,KAAKyC,OAAQP,GAGtF,QAASQ,GAAaC,EAAWT,GAE/B,MADAA,KACOf,EAYT,QAASM,GAAqBmB,EAAcC,GAC1C7C,KAAK+B,MAAQa,EACb5C,KAAK6C,SAAWA,EAChB7C,KAAK8C,WAAY,EACjB9C,KAAK+C,MAAQ,GAAIhC,GAAc,MAC/BW,EAAUd,KAAKZ,KAAM6B,EAAUG,EAAaI,EAAkBI,GAdhElB,EAASG,EAAsBC,EAiB/B,IAAIsB,GAAgCvB,EAAqBwB,SAsLzD,OA9KAD,GAA8BE,IAAMvB,EAOpCqB,EAA8BlB,iBAAmBH,EAOjDqB,EAA8BT,WAAaZ,EAS3CqB,EAA8BG,0BAA4B,SAAUlB,EAAOmB,EAAQlB,GACjF,GAAImB,GAAI,GAAInC,GAA0BlB,KAAMiC,EAAOmB,EAAQlB,EAC3D,OAAOmB,GAAEC,SAUXN,EAA8BV,0BAA4B,SAAUL,EAAOI,EAASH,GAClF,GAAIqB,GAAQvD,KAAKkD,IAAIlD,KAAK+B,MAAOM,EACjC,OAAOrC,MAAKmC,0BAA0BF,EAAOsB,EAAOrB,IAStDc,EAA8BZ,iBAAmB,SAAUC,EAASH,GAClE,MAAOlC,MAAKsC,0BAA0BJ,EAAQG,EAASK,IAMzDM,EAA8BM,MAAQ,WACpC,IAAKtD,KAAK8C,UAAW,CACnB9C,KAAK8C,WAAY,CACjB,GAAG,CACD,GAAIU,GAAOxD,KAAKyD,SACH,QAATD,GACFxD,KAAK6C,SAASW,EAAKnB,QAASrC,KAAK+B,OAAS,IAAM/B,KAAK+B,MAAQyB,EAAKnB,SAClEmB,EAAKE,UAEL1D,KAAK8C,WAAY,QAEZ9C,KAAK8C,aAOlBE,EAA8BW,KAAO,WACnC3D,KAAK8C,WAAY,GAOnBE,EAA8BY,UAAY,SAAUC,GAClD,GAAIC,GAAa9D,KAAK6C,SAAS7C,KAAK+B,MAAO8B,EAC3C,IAAI7D,KAAK6C,SAAS7C,KAAK+B,MAAO8B,GAAQ,EACpC,KAAM,IAAIjC,OAAMmC,mBAElB,IAAmB,IAAfD,IAGC9D,KAAK8C,UAAW,CACnB9C,KAAK8C,WAAY,CACjB,GAAG,CACD,GAAIU,GAAOxD,KAAKyD,SACH,QAATD,GAAiBxD,KAAK6C,SAASW,EAAKnB,QAASwB,IAAS,GACxD7D,KAAK6C,SAASW,EAAKnB,QAASrC,KAAK+B,OAAS,IAAM/B,KAAK+B,MAAQyB,EAAKnB,SAClEmB,EAAKE,UAEL1D,KAAK8C,WAAY,QAEZ9C,KAAK8C,UACd9C,MAAK+B,MAAQ8B,IAQjBb,EAA8BgB,UAAY,SAAUH,GAClD,GAAII,GAAKjE,KAAKkD,IAAIlD,KAAK+B,MAAO8B,GAC1BC,EAAa9D,KAAK6C,SAAS7C,KAAK+B,MAAOkC,EAC3C,IAAIH,EAAa,EAAK,KAAM,IAAIlC,OAAMmC,mBACnB,KAAfD,GAEJ9D,KAAK4D,UAAUK,IAOjBjB,EAA8BkB,MAAQ,SAAUL,GAC9C,GAAII,GAAKjE,KAAKkD,IAAIlD,KAAK+B,MAAO8B,EAC9B,IAAI7D,KAAK6C,SAAS7C,KAAK+B,MAAOkC,IAAO,EAAK,KAAM,IAAIrC,OAAMmC,mBAE1D/D,MAAK+B,MAAQkC,GAOfjB,EAA8BS,QAAU,WACtC,KAAOzD,KAAK+C,MAAMoB,OAAS,GAAG,CAC5B,GAAIX,GAAOxD,KAAK+C,MAAMqB,MACtB,KAAIZ,EAAKa,cAGP,MAAOb,EAFPxD,MAAK+C,MAAMuB,UAKf,MAAO,OAUTtB,EAA8BR,iBAAmB,SAAUH,EAASH,GAClE,MAAOlC,MAAKmC,0BAA0BD,EAAQG,EAASK,IAUzDM,EAA8Bb,0BAA4B,SAAUF,EAAOI,EAASH,GAGlF,QAASqC,GAAI5B,EAAW6B,GAEtB,MADAC,GAAK1B,MAAM2B,OAAOC,GACXzC,EAAOS,EAAW6B,GAJ3B,GAAIC,GAAOzE,KAOP2E,EAAK,GAAI1D,GAAcjB,KAAMiC,EAAOsC,EAAKlC,EAASrC,KAAK6C,SAG3D,OAFA7C,MAAK+C,MAAM6B,QAAQD,GAEZA,EAAGE,YAGLpD,GACPX,GAGFJ,EAAGoE,oBAAuB,SAAUpD,GASlC,QAASoD,GAAoBlC,EAAcC,GACzC,GAAId,GAAwB,MAAhBa,EAAuB,EAAIA,EACnCmC,EAAMlC,GAAYtB,CACtBG,GAAUd,KAAKZ,KAAM+B,EAAOgD,GAX9BzD,EAASwD,EAAqBpD,EAc9B,IAAIsD,GAA2BF,EAAoB7B,SA0BnD,OAlBA+B,GAAyB9B,IAAM,SAAU+B,EAAUC,GACjD,MAAOD,GAAWC,GAGpBF,EAAyBlD,iBAAmB,SAAUmD,GACpD,MAAO,IAAIE,MAAKF,GAAUG,WAS5BJ,EAAyBzC,WAAa,SAAU8C,GAC9C,MAAOA,IAGFP,GACPpE,EAAGe,sBAEIf"}
|
3
node_modules/rx/dist/rx.virtualtime.min.js
generated
vendored
Normal file
3
node_modules/rx/dist/rx.virtualtime.min.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
/* Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.*/
|
||||
(function(a){var b={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},c=b[typeof window]&&window||this,d=b[typeof exports]&&exports&&!exports.nodeType&&exports,e=b[typeof module]&&module&&!module.nodeType&&module,f=(e&&e.exports===d&&d,b[typeof global]&&global);!f||f.global!==f&&f.window!==f||(c=f),"function"==typeof define&&define.amd?define(["rx"],function(b,d){return a(c,d,b)}):"object"==typeof module&&module&&module.exports===d?module.exports=a(c,module.exports,require("./rx")):c.Rx=a(c,{},c.Rx)}).call(this,function(a,b,c){var d=c.Scheduler,e=c.internals.PriorityQueue,f=c.internals.ScheduledItem,g=c.internals.SchedulePeriodicRecursive,h=c.Disposable.empty,i=c.internals.inherits,j=c.helpers.defaultSubComparer;return c.VirtualTimeScheduler=function(a){function b(){throw new Error("Not implemented")}function c(){return this.toDateTimeOffset(this.clock)}function d(a,b){return this.scheduleAbsoluteWithState(a,this.clock,b)}function j(a,b,c){return this.scheduleRelativeWithState(a,this.toRelative(b),c)}function k(a,b,c){return this.scheduleRelativeWithState(a,this.toRelative(b-this.now()),c)}function l(a,b){return b(),h}function m(b,f){this.clock=b,this.comparer=f,this.isEnabled=!1,this.queue=new e(1024),a.call(this,c,d,j,k)}i(m,a);var n=m.prototype;return n.add=b,n.toDateTimeOffset=b,n.toRelative=b,n.schedulePeriodicWithState=function(a,b,c){var d=new g(this,a,b,c);return d.start()},n.scheduleRelativeWithState=function(a,b,c){var d=this.add(this.clock,b);return this.scheduleAbsoluteWithState(a,d,c)},n.scheduleRelative=function(a,b){return this.scheduleRelativeWithState(b,a,l)},n.start=function(){if(!this.isEnabled){this.isEnabled=!0;do{var a=this.getNext();null!==a?(this.comparer(a.dueTime,this.clock)>0&&(this.clock=a.dueTime),a.invoke()):this.isEnabled=!1}while(this.isEnabled)}},n.stop=function(){this.isEnabled=!1},n.advanceTo=function(a){var b=this.comparer(this.clock,a);if(this.comparer(this.clock,a)>0)throw new Error(argumentOutOfRange);if(0!==b&&!this.isEnabled){this.isEnabled=!0;do{var c=this.getNext();null!==c&&this.comparer(c.dueTime,a)<=0?(this.comparer(c.dueTime,this.clock)>0&&(this.clock=c.dueTime),c.invoke()):this.isEnabled=!1}while(this.isEnabled);this.clock=a}},n.advanceBy=function(a){var b=this.add(this.clock,a),c=this.comparer(this.clock,b);if(c>0)throw new Error(argumentOutOfRange);0!==c&&this.advanceTo(b)},n.sleep=function(a){var b=this.add(this.clock,a);if(this.comparer(this.clock,b)>=0)throw new Error(argumentOutOfRange);this.clock=b},n.getNext=function(){for(;this.queue.length>0;){var a=this.queue.peek();if(!a.isCancelled())return a;this.queue.dequeue()}return null},n.scheduleAbsolute=function(a,b){return this.scheduleAbsoluteWithState(b,a,l)},n.scheduleAbsoluteWithState=function(a,b,c){function d(a,b){return e.queue.remove(g),c(a,b)}var e=this,g=new f(this,a,d,b,this.comparer);return this.queue.enqueue(g),g.disposable},m}(d),c.HistoricalScheduler=function(a){function b(b,c){var d=null==b?0:b,e=c||j;a.call(this,d,e)}i(b,a);var c=b.prototype;return c.add=function(a,b){return a+b},c.toDateTimeOffset=function(a){return new Date(a).getTime()},c.toRelative=function(a){return a},b}(c.VirtualTimeScheduler),c});
|
||||
//# sourceMappingURL=rx.virtualtime.map
|
Reference in New Issue
Block a user