@truepic/queryql
Version:
Easily add filtering, sorting, and pagination to your REST API through your old friend: the query string!
14 lines (11 loc) • 327 B
JavaScript
// Caches the return value of the first call to the function and returns that on
// subsequent calls. Only works with functions without arguments.
module.exports = (func, bind = undefined) => {
let cache = undefined
return () => {
if (cache === undefined) {
cache = func.call(bind)
}
return cache
}
}