Library for composing asynchronous and event-based operations in JavaScript using Observable sequences and fluent query operators
—
Operators for aggregating observable sequences including reduce, count, min, max, and statistical operations.
Reduces the observable sequence to a single value.
/**
* Applies an accumulator function over the sequence and returns the final result
* @param {function} accumulator - Accumulator function taking current accumulation and next value
* @param {*} [seed] - Initial accumulator value
* @returns {Observable} Observable sequence containing the final accumulated result
*/
observable.reduce = function(accumulator, seed);
observable.aggregate = function(accumulator, seed); // Alias for reduceUsage Example:
var source = Rx.Observable.range(1, 5);
var sum = source.reduce(function(acc, x) { return acc + x; }, 0);
// Emits: 15 (1+2+3+4+5)Counts the number of elements in the sequence.
/**
* Returns the count of elements in the observable sequence
* @param {function} [predicate] - Function to test each element
* @param {*} [thisArg] - Object to use as this when executing predicate
* @returns {Observable} Observable sequence containing the count
*/
observable.count = function(predicate, thisArg);Computes the sum of numeric values.
/**
* Computes the sum of a sequence of numeric values
* @param {function} [keySelector] - Function to transform elements before summing
* @param {*} [thisArg] - Object to use as this when executing keySelector
* @returns {Observable} Observable sequence containing the sum
*/
observable.sum = function(keySelector, thisArg);Computes the average of numeric values.
/**
* Computes the average of a sequence of numeric values
* @param {function} [keySelector] - Function to transform elements before averaging
* @param {*} [thisArg] - Object to use as this when executing keySelector
* @returns {Observable} Observable sequence containing the average
*/
observable.average = function(keySelector, thisArg);Finds the minimum or maximum value.
/**
* Returns the minimum value in the sequence
* @param {function} [comparer] - Comparer function to determine order
* @returns {Observable} Observable sequence containing the minimum value
*/
observable.min = function(comparer);
/**
* Returns the maximum value in the sequence
* @param {function} [comparer] - Comparer function to determine order
* @returns {Observable} Observable sequence containing the maximum value
*/
observable.max = function(comparer);Finds elements with minimum or maximum key values.
/**
* Returns elements with the minimum key value
* @param {function} keySelector - Function to compute comparison key
* @param {function} [comparer] - Comparer function for keys
* @returns {Observable} Observable sequence containing elements with minimum key
*/
observable.minBy = function(keySelector, comparer);
/**
* Returns elements with the maximum key value
* @param {function} keySelector - Function to compute comparison key
* @param {function} [comparer] - Comparer function for keys
* @returns {Observable} Observable sequence containing elements with maximum key
*/
observable.maxBy = function(keySelector, comparer);Gets the first or last element.
/**
* Returns the first element in the sequence
* @param {function} [predicate] - Function to test each element
* @param {*} [thisArg] - Object to use as this when executing predicate
* @returns {Observable} Observable sequence containing the first element
*/
observable.first = function(predicate, thisArg);
/**
* Returns the last element in the sequence
* @param {function} [predicate] - Function to test each element
* @param {*} [thisArg] - Object to use as this when executing predicate
* @returns {Observable} Observable sequence containing the last element
*/
observable.last = function(predicate, thisArg);Gets the first or last element, or a default value.
/**
* Returns the first element or a default value if none found
* @param {function} [predicate] - Function to test each element
* @param {*} [defaultValue] - Default value if no element found
* @param {*} [thisArg] - Object to use as this when executing predicate
* @returns {Observable} Observable sequence containing the first element or default
*/
observable.firstOrDefault = function(predicate, defaultValue, thisArg);
/**
* Returns the last element or a default value if none found
* @param {function} [predicate] - Function to test each element
* @param {*} [defaultValue] - Default value if no element found
* @param {*} [thisArg] - Object to use as this when executing predicate
* @returns {Observable} Observable sequence containing the last element or default
*/
observable.lastOrDefault = function(predicate, defaultValue, thisArg);Tests whether any or all elements match a predicate.
/**
* Tests whether any element matches the specified predicate
* @param {function} [predicate] - Function to test each element
* @param {*} [thisArg] - Object to use as this when executing predicate
* @returns {Observable} Observable sequence containing boolean result
*/
observable.some = function(predicate, thisArg);
observable.any = function(predicate, thisArg); // Alias for some
/**
* Tests whether all elements match the specified predicate
* @param {function} [predicate] - Function to test each element
* @param {*} [thisArg] - Object to use as this when executing predicate
* @returns {Observable} Observable sequence containing boolean result
*/
observable.every = function(predicate, thisArg);
observable.all = function(predicate, thisArg); // Alias for everyTests whether the sequence contains a specific value.
/**
* Tests whether the sequence contains the specified value
* @param {*} value - Value to search for
* @param {number} [fromIndex] - Index to start searching from
* @returns {Observable} Observable sequence containing boolean result
*/
observable.contains = function(value, fromIndex);
observable.includes = function(value, fromIndex); // Alias for containsTests whether the sequence is empty.
/**
* Tests whether the sequence is empty
* @returns {Observable} Observable sequence containing boolean result
*/
observable.isEmpty = function();Converts the sequence to an array.
/**
* Creates an array from the observable sequence
* @returns {Observable} Observable sequence containing the array
*/
observable.toArray = function();Tests whether two sequences are equal.
/**
* Tests whether two sequences are equal
* @param {Observable} other - Other sequence to compare with
* @param {function} [comparer] - Function to compare elements for equality
* @returns {Observable} Observable sequence containing boolean result
*/
observable.sequenceEqual = function(other, comparer);