New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

global-promise

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

global-promise

A helper library to create a promise to be resolved/rejected from your other parts of codebase

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status NPM version NPM total downloads Contributors License

Global Promise

A helper library to create a promise to be resolved/rejected from your other parts of codebase globally.

Installation

Install it from npm:

$ npm install global-promise

or

$ yarn add global-promise

Motivation

Sometimes, we create a promise and we needed to resolve/reject it from other part of codebase globally. We can achieve the same by implementing event driven code using EventTarget or EventEmitter , but it will require a lot of code.

Solve it with GPromise with a few of lines of code:

import * as GPromise from 'global-promise';


// Creates a promise to be settled from other parts of code.
GPromise.create('my_id')
  .then((val) => {
    console.log( `Promise with 'my_id' id is resolved with: ${val}` );
  });


// In your other part of code:
setTimeout(() => {
  // Resolve the promise we have just created with id 'my_id' above from other part of your codebase.
  GPromise.resolve('my_id', 'my_value');
}, 2000);

Test

Run:

yarn test

Contributing

Your PRs and stars are always welcome.

Keywords

FAQs

Package last updated on 08 May 2020

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