0.0.0 • Published 5 years ago

memorize-one v0.0.0

Weekly downloads
676
License
MIT
Repository
github
Last release
5 years ago

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