[Pkg-javascript-commits] [node-async] 63/480: added memoize to README

Jonas Smedegaard js at moszumanska.debian.org
Fri May 2 08:58:12 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 8175ac57de9985917c87b3d15faccee7708293d4
Author: Caolan McMahon <caolan at caolanmcmahon.com>
Date:   Wed Nov 24 20:14:20 2010 +0000

    added memoize to README
---
 README.md | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/README.md b/README.md
index 4faed71..b212910 100644
--- a/README.md
+++ b/README.md
@@ -95,6 +95,7 @@ So far its been tested in IE6, IE7, IE8, FF3.6 and Chrome 5. Usage:
 
 ### Utils
 
+* [memoize](#memoize)
 * [log](#log)
 * [dir](#dir)
 * [noConflict](#noConflict)
@@ -871,6 +872,34 @@ __Example__
 
 ## Utils
 
+<a name="memoize" />
+### memoize(fn, [hasher])
+
+Caches the results of an async function. When creating a hash to store function
+results against, the callback is omitted from the hash and an optional hash
+function can be used.
+
+__Arguments__
+
+* fn - the function you to proxy and cache results from.
+* hasher - an optional function for generating a custom hash for storing
+  results, it has all the arguments applied to it apart from the callback, and
+  must be synchronous.
+
+__Example__
+
+    var slow_fn = function (name, callback) {
+        // do something
+        callback(null, result);
+    };
+    var fn = async.memoize(slow_fn);
+
+    // fn can now be used as if it were slow_fn
+    fn('some name', function () {
+        // callback
+    });
+
+
 <a name="log" />
 ### log(function, arguments)
 

-- 
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