https://github.com/raininfall/cache-last
cache last function call result
https://github.com/raininfall/cache-last
Last synced: about 2 months ago
JSON representation
cache last function call result
- Host: GitHub
- URL: https://github.com/raininfall/cache-last
- Owner: raininfall
- Created: 2017-04-11T07:03:16.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-11T07:04:50.000Z (about 9 years ago)
- Last Synced: 2026-05-02T01:36:16.214Z (about 2 months ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Cache-Last
It's customed ** memoize ** in [lodash](https://lodash.com) that only cache last call.
See details in [here](https://lodash.com/docs/4.17.4#memoize)
## Example
```js
var cacheLast = require('cache-last').default;
function slowFunction(n) {
for(var i = 0; i < n; i++) ;
return n;
}
var fn = cacheLast(slowFunction);
fn(1000000000); // first run, slow
fn(1000000000); // cached, faster
```