1.0.3 • Published 7 years ago

cachefn v1.0.3

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

cachefn

Decorate async (Promise.returning) functions with an expiring cache so costly operations don't need to be run all the time.

API

cachedFunction(func, timeout = Infinity, thisArg = undefined)

Returns a CachedFunction that will call func once until the cache expires. timeout is the timeout in milliseconds until the cache expires. the function will be called with thisArg as its this argument.

CachedFunction()

Returns a promise with the last value returned by the original function, unless the cache has expired, in which case it calls the function and returns a promise to the result.

CachedFunction#exec()

Run the original function, ignoring any cache. Calling it will store the result on the cache, overriding any previous result and timeout.

CachedFunction#clear()

Clear the cache. The next time the function is run, it will call the original function no matter what.

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago