@ptkhanh94npm/harum-rerum-harum

1.0.0 • Public • Published

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 @ptkhanh94npm/harum-rerum-harum

Install with yarn:

yarn add @ptkhanh94npm/harum-rerum-harum

Import where you need it:

import ExtendablePromise from '@ptkhanh94npm/harum-rerum-harum';

or require for CommonJS:

const ExtendablePromise = require('@ptkhanh94npm/harum-rerum-harum');

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

Package Sidebar

Install

npm i @ptkhanh94npm/harum-rerum-harum

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

8.52 kB

Total Files

10

Last publish

Collaborators

  • skylerlabsventure