[Pkg-javascript-commits] [node-async] 368/480: async.memoize() preserves async nature of function
Jonas Smedegaard
js at moszumanska.debian.org
Fri May 2 08:58:43 UTC 2014
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository node-async.
commit 5d16b9133793f288e1d98d530ae5665c271b7ace
Author: Ryan Graham <r.m.graham at gmail.com>
Date: Sat Nov 23 22:23:57 2013 -0800
async.memoize() preserves async nature of function
async.memoize() should assume that the given function is asynchronous,
and should maintain that when giving cached results by using
async.nextTick().
See also http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony
Fixes #304
---
lib/async.js | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/async.js b/lib/async.js
index cb6320d..dda4afb 100755
--- a/lib/async.js
+++ b/lib/async.js
@@ -840,7 +840,9 @@
var callback = args.pop();
var key = hasher.apply(null, args);
if (key in memo) {
- callback.apply(null, memo[key]);
+ async.nextTick(function () {
+ callback.apply(null, memo[key]);
+ });
}
else if (key in queues) {
queues[key].push(callback);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-async.git
More information about the Pkg-javascript-commits
mailing list