You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

pinkie

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pinkie

Itty bitty little widdle twinkie pinkie ES2015 Promise implementation


Version published
Weekly downloads
12M
decreased by-0.45%
Maintainers
1
Install size
11.1 kB
Created
Weekly downloads
 

Package description

What is pinkie?

The 'pinkie' npm package is a lightweight promise implementation that follows the Promises/A+ specification. It is primarily used for handling asynchronous operations in environments where native promises are not available or when a minimalistic promise library is preferred.

What are pinkie's main functionalities?

Promise creation and resolution

This code demonstrates how to create a new promise using pinkie and resolve it with a value. The 'then' method is used to handle the resolved value.

const pinkie = require('pinkie');

const promise = new pinkie((resolve, reject) => {
  resolve('Success!');
});

promise.then(result => console.log(result));

Promise rejection and error handling

This example shows how to create a promise that gets rejected with an error and how to handle the error using the 'catch' method.

const pinkie = require('pinkie');

const promise = new pinkie((resolve, reject) => {
  reject(new Error('Failed!'));
});

promise.catch(error => console.error(error.message));

Other packages similar to pinkie

Readme

Source


pinkie

Itty bitty little widdle twinkie pinkie ES2015 Promise implementation

Build Status Coverage Status

There are tons of Promise implementations out there, but all of them focus on browser compatibility and are often bloated with functionality.

This module is an exact Promise specification polyfill (like native-promise-only), but in Node.js land (it should be browserify-able though).

Install

$ npm install --save pinkie

Usage

var fs = require('fs');
var Promise = require('pinkie');

new Promise(function (resolve, reject) {
	fs.readFile('foo.json', 'utf8', function (err, data) {
		if (err) {
			reject(err);
			return;
		}

		resolve(data);
	});
});
//=> Promise

API

pinkie exports bare ES2015 Promise implementation and polyfills Node.js rejection events. In case you forgot:

new Promise(executor)

Returns new instance of Promise.

executor

Required
Type: function

Function with two arguments resolve and reject. The first argument fulfills the promise, the second argument rejects it.

pinkie.all(promises)

Returns a promise that resolves when all of the promises in the promises Array argument have resolved.

pinkie.race(promises)

Returns a promise that resolves or rejects as soon as one of the promises in the promises Array resolves or rejects, with the value or reason from that promise.

pinkie.reject(reason)

Returns a Promise object that is rejected with the given reason.

pinkie.resolve(value)

Returns a Promise object that is resolved with the given value. If the value is a thenable (i.e. has a then method), the returned promise will "follow" that thenable, adopting its eventual state; otherwise the returned promise will be fulfilled with the value.

  • pinkie-promise - Returns the native Promise or this module

License

MIT © Vsevolod Strukchinsky

Keywords

FAQs

Package last updated on 01 Feb 2016

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc