@posandu/uselocal
v1.0.2
Published
Use cached results if something goes wrong
Downloads
2
Maintainers
Readme
useLocal
Use cache if something went wrong
Example
Install library.
npm i @posandu/uselocal
Import it and use it.
import useLocal from "@posandu/uselocal";
function throwRandomly() {
if (Math.random() < 0.5) {
throw new Error("Something went wrong");
}
return "Hello";
}
console.log(useLocal(throwRandomly));
button.addEventListener("click", () => {
console.log(useLocal(throwRandomly));
});
Args
useLocal(function, ...args) // returns result after calling function with args