Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

funcrate

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

funcrate

A library provides container for resolving async functions later

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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.

Keywords

FAQs

Package last updated on 21 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc