Funcrate
A library provides container for resolving async functions later.
import { createCrate } from "funcrate";
const crate = createCrate();
crate.add(1, 2).then(console.log);
const asyncFunctions = {
async add(a, b) {
await new Promise(r => setTimeout(r, 100));
return a + b;
}
};
crate.register(asyncFunctions);
API
createCrate(): Crate
Creates a crate. While it already has async, those are not resolved until entity registered.
Crate.get(): T
- @return: proxy value that can be considered as registered value
Gets proxy value that can be considered as registered value.
Crate.register(value: T)
- @param
value
: entity in crate
Registers entity in crate. Entity must be an object that has only functions return any type Promise.