Socket
Socket
Sign inDemoInstall

@js-bits/xpromise

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@js-bits/xpromise

Extendable Promise


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

Extendable Promise

Allows extension of JavaScript's standard, built-in Promise class and decouples an asynchronous operation that ties an outcome to a promise from the constructor.

Installation

Install with npm:

npm install @js-bits/xpromise

Install with yarn:

yarn add @js-bits/xpromise

Import where you need it:

import ExtendablePromise from '@js-bits/xpromise';

or require for CommonJS:

const ExtendablePromise = require('@js-bits/xpromise');

How to use

class MyPromise extends ExtendablePromise {
  // do whatever you need
}

const myPromise = new MyPromise((resolve, reject) => {
  console.log('executed', resolve, reject);
});
console.log(myPromise instanceof Promise); // true
myPromise.execute(); // 'executed' [Function (anonymous)] [Function (anonymous)]
myPromise.then(result => {
  console.log(result); // 123
});
myPromise.resolve(123);

Notes

  • Does not include any polyfills, which means that Internet Explorer is not supported.
  • Alternative solution

Keywords

FAQs

Package last updated on 02 Oct 2022

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