Skip to content
Sync Function Memoizer
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.gitignore
.npmignore
.travis.yml
README.md
index.js
package.json
test.js

README.md

memoize-sync Build Status

Returns a memoized version of a function.

Install

$ npm install memoize-sync

Usage

function work(n){
    console.log("doing some work")
    return n + 10
}

var memoizedWork = memoize(myfunc)

memoizedWork(10)
// "doing some work"
// => 20

memoizedWork(10)
// => 20

memoizedWork(20);
// "doing some work"
// => 30

memoizedWork(20);
// => 30

Using Hasher

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
}
Something went wrong with that request. Please try again.