From 2fb9fa4b87ed6a2d5c2aaa7162c57129f206c72f Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Sat, 28 Apr 2012 20:26:06 -0700 Subject: [PATCH] Replace deferred.node with makeNodeResolver Per @rauschma's sound advice. Fixes #55. --- CHANGES.md | 4 ++++ README.md | 6 +++--- q.js | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index a04a823f..a877c5df 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,8 @@ removed. Use ``sender(op)``. - WARNING: The deprecated ``node`` export will be removed. Use ``nbind``. + - WARNING: The deprecated ``deferred.node()`` interface will be + removed. Use ``deferred.makeNodeResolver()``. ## Next minor @@ -15,6 +17,8 @@ backward-incompatibility since it is a change of an undocumented and unspecified public behavior, but if you happened to depend on the exception being a string, you will need to revise your code. + - Added ``deferred.makeNodeResolver()`` to replace the more cryptic + ``deferred.node()`` method. ## 0.8.3 diff --git a/README.md b/README.md index a1d1e89f..9051215d 100644 --- a/README.md +++ b/README.md @@ -584,12 +584,12 @@ return Q.call(function () { ### Adapting Node -There is a ``node`` method on deferreds that is handy for the NodeJS -callback pattern. +There is a ``makeNodeResolver`` method on deferreds that is handy for +the NodeJS callback pattern. ```javascript var deferred = Q.defer(); -FS.readFile("foo.txt", "utf-8", deferred.node()); +FS.readFile("foo.txt", "utf-8", deferred.makeNodeResolver()); return deferred.promise; ``` diff --git a/q.js b/q.js index d85f35f3..eeef7371 100644 --- a/q.js +++ b/q.js @@ -208,7 +208,8 @@ function defer() { return deferred; } -defer.prototype.node = function () { +defer.prototype.node = // XXX deprecated +defer.prototype.makeNodeResolver = function () { var self = this; return function (error, value) { if (error) {