pinky-promises

1.4.1 • Public • Published


npm npm npm npm npm npm

Pinky Promises are the most lightweight alternatives to the modern web promises API, with support for all browsers and platforms and no dependencies.

Node package · Buy me a Coffee

Made with ♥ by Jeffrey Lanters



Installation

Install using NPM for your JS or TS project.

$ npm install pinky-promises --save

JavaScript Usage

const { PinkyPromise } = require("pinky-promises");
import { PinkyPromise } from "pinky-promises";
 
getUser() {
  return new PinkyPromise((resolve, reject) => {
    // Do something ASYNC ...
    resolve({ ... });
    reject(error);
  });
}
 
getUser()
  .then(value => {})
  .catch(reason => {})
  .finally(_ => {});

Consuming

// Consume let's you cancel a unfulfilled promise.
const promise = getUser();
promise.consume();

Typings

Typings included!

const getUserData = (): PinkyPromise<IUserData> => {
  // Use a generic to define the resolve type
  return new PinkyPromise<IUserData>((resolve, reject) => {
    // ...
  });
};

Package Sidebar

Install

npm i pinky-promises

Weekly Downloads

3

Version

1.4.1

License

ISC

Unpacked Size

11.9 kB

Total Files

6

Last publish

Collaborators

  • jefflanters