1. faked-promise
Create a promise that can be resolved and rejected outside of it
faked-promise
Package: faked-promise
Created by: posva
Last modified: Mon, 02 May 2022 03:17:09 GMT
Version: 2.2.2
License: MIT
Downloads: 487
Repository: https://github.com/posva/faked-promise

Install

npm install faked-promise
yarn add faked-promise

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

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin