1.0.2 • Published 2 years ago

@posandu/uselocal v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

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