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

@nodesuite/defer

Package Overview
Dependencies
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nodesuite/defer

Deferred Promise resolution tools.

  • 0.3.19
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source
nodesuite

@nodesuite/defer

Summary

Simple deferred Promise generator.

Installation

pnpm install @nodesuite/defer

Usage

import { defer } from "@nodesuite/defer"

import { someEventfulEmitter } from "./events"

const { resolve, reject, untilResolved } = defer()


// Define async work...
someEventfulEmitter.on("someEvent", resolve)

// ...or some alternative trigger...
const secondEmitter = new EventEmitter()
secondEmitter.on("secondEvent", resolve)

// ...or abstract resoltion conditons...
class Foo {
	
  #resolve
	#reject
  
	public constructor({ resolve, reject }) {
    this.#resolve = resolve
		this.#reject = reject
	}
  
  public someSuccessFunction() {
    return this.#resolve()
	}
  
  public someFailureFunction() {
    return this.#reject()
	}
  
}

const foo = new Foo({ resolve, reject })

// Reject the master promise...
someEventfulEmitter.on("error", () => foo.someFailureFunction())

// Can await resolution of promise from any source.
await untilResolved()



Keywords

FAQs

Package last updated on 01 Jan 2023

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