@curi/helpers
About
The @curi/helpers
package provides functions that may be useful in a Curi application.
Installation
UMD scripts script are also available through Unpkg. You can access the package's exports using window.CuriHelpers
.
API
once
once
is a simple caching function. It takes a function as its argument and returns a new function. The first time the returned function is called, it will call the function passed to it and return its result. Every call after that will re-use the result from the first call.
The once
function is useful for any async functions that only need to be called once.
preferDefault
When using dynamic import syntax (import("someModule")
), the resolved module is a module object containing all of the exports from that module. If the module has a default export (export default ...
), that will be the module's default
property. The preferDefault
function will resolve with the default
property of the module if it exists and with the module if it does not.