https://github.com/luwes/memo
Memoization with shallowly comparing object arguments
https://github.com/luwes/memo
memoization
Last synced: about 1 year ago
JSON representation
Memoization with shallowly comparing object arguments
- Host: GitHub
- URL: https://github.com/luwes/memo
- Owner: luwes
- Created: 2020-01-17T00:40:28.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-06-17T23:36:33.000Z (almost 2 years ago)
- Last Synced: 2025-04-11T23:49:32.306Z (about 1 year ago)
- Topics: memoization
- Language: JavaScript
- Size: 188 KB
- Stars: 12
- Watchers: 2
- Forks: 1
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# memo
Memoization with shallowly comparing object arguments with support for document fragments.
Based on [fast-memoize.js](https://github.com/caiogondim/fast-memoize.js) by Caio Gondim.
```sh
npm i memo
```
```js
import { memo } from 'memo';
let called = 0
const memoized = memo(
a => {
called++
return a
}
)
let obj = { a: 9 }
console.log(memoized(obj) === obj)
console.log(memoized({ a: 9 }) === obj)
console.log(called === 1)
let obj2 = { a: 7 }
console.log(memoized(obj2) === obj2)
console.log(called === 2)
```