Socket
Socket
Sign inDemoInstall

faked-promise

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    faked-promise

Create a promise that can be resolved and rejected outside of it


Version published
Weekly downloads
60
decreased by-42.86%
Maintainers
1
Install size
4.95 kB
Created
Weekly downloads
 

Readme

Source

faked-promise Build Status npm package coverage thanks

Create a promise that can be resolved and rejected programatically outside of it

It basically extracts the resolve and reject callbacks so you can call them whenever you need. ⚠️ The promise can only be resolved once, it's still a regular Promise after all.

Installation

npm i faked-promise

Usage

faked-promise exports one single function that takes no arguments and returns an array with 3 elements:

  • A real promise
  • Its resolve callback
  • Its reject callback

Meaning you can control exactly when the promise is resolved or rejected:

const fakePromise = require('faked-promise')

const [promise, resolve, reject] = fakePromise()
promise.then(() => {})
resolve('any value')

License

MIT

Keywords

FAQs

Last updated on 27 Sep 2019

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc