memoize-sync
Advanced tools
Comparing version 0.0.0 to 0.0.1
{ | ||
"name": "memoize-sync", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"description": "Return a memoized version of function.", | ||
@@ -13,7 +13,7 @@ "main": "index.js", | ||
"repository": { | ||
"url": "git@github.com:azer\/memoize-sync.git", | ||
"url": "git@github.com:azer/memoize-sync.git", | ||
"type": "git" | ||
}, | ||
"author": "Azer Ko\u00e7ulu <azer@kodfabrik.com>", | ||
"author": "Azer Koçulu <azer@kodfabrik.com>", | ||
"license": "BSD" | ||
} |
@@ -20,2 +20,3 @@ ## memoize-sync | ||
var memoizedWork = memoize(myfunc) | ||
memoizedWork(10) | ||
@@ -37,2 +38,31 @@ // "doing some work" | ||
![](https://dl.dropbox.com/s/9q2p5mrqnajys22/npmel.jpg?token_hash=AAHqttN9DiGl63ma8KRw-G0cdalaiMzrvrOPGnOfDslDjw) | ||
#### Using Hasher | ||
```js | ||
var memoizedWork = memoize(work, hasher) | ||
memoizedWork('hello', 'world') | ||
// doing some work | ||
memoizedWork('hello', 'world') | ||
// => hello world | ||
memoizedWork('hello', 'kitty') | ||
// doing some work | ||
// => hello kitty | ||
memoizedWork('hello', 'kitty') | ||
// => hello kitty | ||
function hasher(first, last){ | ||
return first + ', ' + last | ||
} | ||
function work(first, last){ | ||
console.log('doing some work') | ||
return first + ', ' + last | ||
} | ||
``` | ||
![](http://distilleryimage2.s3.amazonaws.com/3e14d1ae8e4711e2af7822000a1fb04e_6.jpg) |
1674
67