Comparing version 2.1.16 to 2.1.17
{ | ||
"name": "Rx", | ||
"version": "2.1.16", | ||
"version": "2.1.17", | ||
"main": [ | ||
@@ -5,0 +5,0 @@ "rx.js", |
@@ -5,3 +5,3 @@ { | ||
"description": "Library for composing asynchronous and event-based operations in JavaScript", | ||
"version": "2.1.16", | ||
"version": "2.1.17", | ||
"homepage": "http://rx.codeplex.com", | ||
@@ -8,0 +8,0 @@ "author": { |
@@ -16,9 +16,4 @@ var Rx = require('./rx'); | ||
/** | ||
* 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. | ||
* Converts a callback function to an observable sequence. | ||
* | ||
* @example | ||
* 1 - res = Rx.Node.fromCallback(function (x, y) { return x + y; })(4, 3); | ||
* 2 - res = Rx.Node.fromCallback(function (x, y) { return x + y; }, Rx.Scheduler.timeout)(4, 3); | ||
* 2 - res = Rx.Node.fromCallback(function (x) { this.log(x); }, Rx.Scheduler.timeout, console)('hello'); | ||
* | ||
* @param {Function} function Function to convert to an asynchronous function. | ||
@@ -29,4 +24,22 @@ * @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout. | ||
*/ | ||
fromCallback: Rx.Observable.toAsync, | ||
fromCallback: function (func, scheduler, context) { | ||
scheduler || (scheduler = Rx.Scheduler.timeout); | ||
return function () { | ||
var args = slice.call(arguments, 0), | ||
subject = new Rx.AsyncSubject(); | ||
scheduler.schedule(function () { | ||
function handler() { | ||
subject.onNext(arguments); | ||
subject.onCompleted(); | ||
} | ||
args.push(handler); | ||
func.apply(context, args); | ||
}); | ||
return subject.asObservable(); | ||
}; | ||
}, | ||
/** | ||
@@ -33,0 +46,0 @@ * Converts a Node.js callback style function to an observable sequence. This must be in function (err, ...) format. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
745652
14037