@tiaanduplessis/memofy
v1.0.0
Published
Memoize a function
Downloads
3
Readme
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!
- Fork it.
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Or open up a issue.
License
Licensed under the MIT License.