@tiaanduplessis/memofy

1.0.0 • Public • Published

memofy

Memoize a function


Built with ❤︎ by tiaanduplessis and contributors

Table of Contents

Table of Contents Install Usage Contribute License

Install

$ npm install @tiaanduplessis/memofy
# OR
$ yarn add @tiaanduplessis/memofy

Usage

const memofy = require('@tiaanduplessis/memofy')

const add = (...args) => args.reduce((a, b) => a + b)
const memofyAdd = memofy(add)

console.log(memofyAdd(1, 2, 3)) // Result of 6 added to cache
console.log(memofyAdd(1, 2, 3)) // Hits cache
console.log(memofyAdd(1, 2, 5)) // Result of 8 added to cache
console.log(memofyAdd(1, 2, 3)) // Hits cache
console.log(memofyAdd(1, 2, 5)) // Hits cache

Contributing

Contributions are welcome!

  1. Fork it.
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Or open up a issue.

License

Licensed under the MIT License.

Dependencies (0)

    Dev Dependencies (4)

    Package Sidebar

    Install

    npm i @tiaanduplessis/memofy

    Weekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • tiaanduplessis