An open API service indexing awesome lists of open source software.

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

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
```