JSPM

funcrate

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q26560F
  • License MIT

A library provides container for resolving async functions later

Package Exports

  • funcrate

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (funcrate) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Funcrate

version-widget build-widget bundle-size-widget

A library provides container for resolving async functions later.

import { createCrate } from "funcrate";

const crate = createCrate();

// async function in crate can be invoked immediately
crate.add(1, 2).then(console.log); // → 3 (shown after crate registered)

// entity in crate can registered later
const asyncFunctions = {
  async add(a, b) {
    await new Promise(r => setTimeout(r, 100));
    return a + b;
  }
};
crate.register(asyncFunctions);

API

createCrate(): Crate

  • @return: an empty 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.