Socket
Socket
Sign inDemoInstall

pinkie

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 2.0.0

30

index.js

@@ -8,5 +8,5 @@ 'use strict';

var NOOP = function () {};
var isNode = typeof process !== 'undefined' && typeof process.emit === 'function';
// async calls
var asyncSetTimer = typeof setImmediate !== 'undefined' ? setImmediate : setTimeout;
var asyncSetTimer = typeof setImmediate === 'undefined' ? setTimeout : setImmediate;
var asyncQueue = [];

@@ -87,3 +87,4 @@ var asyncTimer;

if (value && (typeof value === 'function' || typeof value === 'object')) {
var then = value.then; // then should be retrived only once
// then should be retrieved only once
var then = value.then;

@@ -95,6 +96,6 @@ if (typeof then === 'function') {

if (value !== val) {
if (value === val) {
fulfill(promise, val);
} else {
resolve(promise, val);
} else {
fulfill(promise, val);
}

@@ -160,4 +161,11 @@ }

publish(promise);
if (!promise._handled && isNode) {
process.emit('unhandledRejection', promise._data, promise);
}
}
function notifyRejectionHandled(promise) {
process.emit('rejectionHandled', promise);
}
/**

@@ -186,2 +194,3 @@ * @class

_data: undefined,
_handled: false,

@@ -196,2 +205,9 @@ then: function (onFulfillment, onRejection) {

if (onRejection && !this._handled) {
this._handled = true;
if (this._state === REJECTED && isNode) {
asyncCall(notifyRejectionHandled, this);
}
}
if (this._state === FULFILLED || this._state === REJECTED) {

@@ -208,3 +224,3 @@ // already resolved, call callback async

'catch': function (onRejection) {
catch: function (onRejection) {
return this.then(null, onRejection);

@@ -211,0 +227,0 @@ }

{
"name": "pinkie",
"version": "1.0.0",
"description": "Itty bitty little wittle twinkie pinkie ES6 Promise implementation",
"version": "2.0.0",
"description": "Itty bitty little widdle twinkie pinkie ES2015 Promise implementation",
"license": "MIT",

@@ -16,3 +16,4 @@ "repository": "floatdrop/pinkie",

"scripts": {
"test": "mocha"
"test": "xo && nyc mocha",
"coverage": "nyc report --reporter=text-lcov | coveralls"
},

@@ -24,9 +25,13 @@ "files": [

"promise",
"promises",
"es2015",
"es6"
],
"dependencies": {},
"devDependencies": {
"coveralls": "^2.11.4",
"mocha": "*",
"promises-aplus-tests": "*"
"nyc": "^3.2.2",
"promises-aplus-tests": "*",
"xo": "^0.10.1"
}
}
<h1 align="center">
<br>
<img width="300" src="https://rawgit.com/floatdrop/pinkie/master/media/logo.png" alt="pinkie">
<img width="256" src="media/logo.png" alt="pinkie">
<br>

@@ -8,9 +8,9 @@ <br>

> Itty bitty little wittle twinkie pinkie [ES6 Promise](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-promise-objects) implementation
> Itty bitty little widdle twinkie pinkie [ES2015 Promise](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-promise-objects) implementation
[![Build Status](https://travis-ci.org/floatdrop/pinkie.svg?branch=master)](https://travis-ci.org/floatdrop/pinkie)
[![Build Status](https://travis-ci.org/floatdrop/pinkie.svg?branch=master)](https://travis-ci.org/floatdrop/pinkie) [![Coverage Status](https://coveralls.io/repos/floatdrop/pinkie/badge.svg?branch=master&service=github)](https://coveralls.io/github/floatdrop/pinkie?branch=master)
There are [tons of Promise implementations](https://github.com/sorrycc/awesome-javascript#control-flow) out there, but all of them focused on browser compatibility and often bloated with functionality.
There are [tons of Promise implementations](https://github.com/promises-aplus/promises-spec/blob/master/implementations.md#standalone) out there, but all of them focus on browser compatibility and are often bloated with functionality.
This module focused to be exactly Promise specification polyfill (like [native-promise-only](https://github.com/getify/native-promise-only)), but in NodeJS land (it should be browserify-able thou).
This module is an exact Promise specification polyfill (like [native-promise-only](https://github.com/getify/native-promise-only)), but in Node.js land (it should be browserify-able though).

@@ -28,8 +28,10 @@

```js
var fs = require('fs');
var Promise = require('pinkie');
new Promise(function (resolve, reject) {
got('google.com', function (err, data) {
fs.readFile('foo.json', 'utf8', function (err, data) {
if (err) {
return reject(err);
reject(err);
return;
}

@@ -46,3 +48,3 @@

`pinkie` exports bare [ES6 Promise](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-promise-objects) implementation. In case you forgot:
`pinkie` exports bare [ES2015 Promise](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-promise-objects) implementation and polyfills [Node.js rejection events](https://nodejs.org/api/process.html#process_event_unhandledrejection). In case you forgot:

@@ -58,3 +60,3 @@ #### new Promise(executor)

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

@@ -77,4 +79,10 @@ #### pinkie.all(promises)

## Related
- [pinkie-promise](https://github.com/floatdrop/pinkie-promise) - Returns the native Promise or this module
## License
MIT © [Vsevolod Strukchinsky](http://github.com/floatdrop)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc