1.4.1 • Published 6 years ago

pinky-promises v1.4.1

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

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) => {
    // ...
  });
};
1.4.1

6 years ago

1.4.0

6 years ago

1.3.3

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.0.0

6 years ago

0.0.1

6 years ago