doc/api/helpers/readme.md
Helper functions for the Reactive Extensions for JavaScript
Rx.helpers.defaultComparerRx.helpers.defaultSubComparerRx.helpers.defaultErrorRx.helpers.identityRx.helpers.isPromiseRx.helpers.noopRx.helpers.defaultComparer(x, y)<a href="#rxhelpersdefaultcomparerx-y">#</a>Ⓢ [Ⓣ][1]
The default equality comparer, used when a comparer is not supplied to a function. Uses an internal deep equality check.
x (Any): The first value to comparey (Any): The second value to compare(Boolean): true if equal; else false.
var comparer = Rx.helpers.defaultComparer;
// Should return true
var x = 42, y = 42
console.log(comparer(x, y));
// => true
// Should return false
var x = new Date(0), y = new Date();
console.log(comparer(x, y));
// => false
Rx.helpers.defaultSubcomparer(x, y)<a href="#rxhelpersdefaultsubcomparerx-y">#</a>Ⓢ [Ⓣ][1]
The default comparer to determine whether one object is greater, less than or equal to another.
x (Any): The first value to comparey (Any): The second value to compare(Number): Returns 1 if x is greater than y, -1 if y is greater than x, and 0 if the objects are equal.
var comparer = Rx.helpers.defaultSubcomparer;
// Should return 0
var x = 42, y = 42
console.log(comparer(x, y));
// => 0
// Should return -1
var x = new Date(0), y = new Date();
console.log(comparer(x, y));
// => -1
// Should return 1
var x = 43, y = 42;
console.log(comparer(x, y));
// => 1
Rx.helpers.defaultError(err)<a href="#rxhelpersdefaulterror">#</a>Ⓢ [Ⓣ][1]
Throws the specified error
err (Any): The error to throwvar defaultError = Rx.helpers.defaultError;
// Returns its value
defaultError(new Error('woops'))
// => Error: woops
Rx.helpers.identity(x)<a href="#rxhelpersidentityx">#</a>Ⓢ [Ⓣ][1]
A function which returns its value unmodified.
x (Any): The value to return.(Any): The value given as the parameter.
var identity = Rx.helpers.identity;
// Returns its value
var x = identity(42);
console.log(x);
// => 42
Rx.helpers.isPromise(p)<a href="#rxhelpersispromisep">#</a>Ⓢ [Ⓣ][1]
A function which determines whether the object is a Promise.
p (Any): The object to determine whether it is a promise.(Boolean): true if the object is a Promise else false
var isPromise = Rx.helpers.isPromise;
var p = RSVP.Promise(function (res) { res(42); });
console.log(isPromise(p));
// => true
Rx.helpers.noop()<a href="#rxhelpersnoop">#</a>Ⓢ [Ⓣ][1]
A function which does nothing
var noop = Rx.helpers.noop;
// This does nothing!
noop();