https://github.com/rubiin/memoize
A simple and easy to use memoize lib for deno
https://github.com/rubiin/memoize
deno typescript
Last synced: about 1 month ago
JSON representation
A simple and easy to use memoize lib for deno
- Host: GitHub
- URL: https://github.com/rubiin/memoize
- Owner: rubiin
- Created: 2020-05-10T17:55:23.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-05-10T17:56:39.000Z (about 6 years ago)
- Last Synced: 2025-01-23T23:50:02.233Z (over 1 year ago)
- Topics: deno, typescript
- Language: TypeScript
- Homepage:
- Size: 1.95 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
## Usage
```js
const add = (a, b) => a + b;
const memoizedFn = memoize(add);
memoizedFn(1, 2); // 3
memoizedFn(1, 2); // 3
// Add function is not executed: previous result is returned
memoizedFn(2, 3); // 5
// Add function is called to get new value
memoizedFn(2, 3); // 5
// Add function is not executed: previous result is returned
memoizedFn(1, 2); // 3
// Add function is called to get new value.
// While this was previously cached,
// it is not the latest so the cached result is lost
```