memorize-one

0.0.0 • Public • Published

memorize-one

Memorition function which return cache result when identity inputs.

NPM version NPM downloads CircleCI

Install

yarn add memorize-one

Usage

const memorizeOne = require('memorize-one')
 
let i = 0
const fn = () => ++i
 
const memoFn = memorizeOne(fn)
memoFn('input') // 1
memoFn('input') // 1
 
const a = { age: 1 }
a.obj = a
 
const b = { age: 1 }
b.obj = b
 
memoFn(a) // 2
memoFn(b) // 2
 
//=> foo

Contributing

  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

Author

memorize-one © Eliaztray, Released under the MIT License.
Authored and maintained by Eliaztray with help from contributors (list).

eliaztray · GitHub @Eliaztray · Twitter @eliaztray

Readme

Keywords

none

Package Sidebar

Install

npm i memorize-one

Weekly Downloads

59

Version

0.0.0

License

MIT

Unpacked Size

4.91 kB

Total Files

5

Last publish

Collaborators

  • eliaztray