Skip to content

micro-js/memoize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

memoize

Build status Git tag NPM version Code style

Create a function that memoizes the result of a `fn`.

Installation

$ npm install @f/memoize

Usage

var memoize = require('@f/memoize')

var slow = memoize(function (num) {
  var calc = 0
  for (var i = 0; i < num; ++i) {
    calc += i
  }
  return calc
})

// slow
slow(100) // => 4950

// fast
slow(100) // => 4950

API

memoize(fn)

  • fn - a function to memoize

Returns: memoized function

License

MIT

About

Create a function that memoizes the result a function.

Resources

Stars

Watchers

Forks

Packages

No packages published