Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

promish

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promish - npm Package Compare versions

Comparing version 4.2.1 to 4.2.2

README.md

74

lib/promish.js

@@ -13,3 +13,3 @@ 'use strict';

class Promish {
class Promish extends Promise {
constructor(f) {

@@ -19,49 +19,20 @@ if (f instanceof Promish) {

} else if ((f instanceof Promise) || (f.then instanceof Function)) {
// wraping other promise
this.inner = f;
super(function(resolve, reject) {
f.then(resolve, reject);
});
} else if (f instanceof Error) {
// sugar for 'rethrow'
this.inner = new Promise((resolve,reject) => reject(f));
super(function(resolve, reject) {
reject(f);
});
} else if (f instanceof Function) {
this.inner = new Promise(f);
super(f);
} else {
// anything else, resolve with value
this.inner = new Promise(resolve => resolve(f));
super(function(resolve, reject) {
resolve(f);
});
}
}
then(t, r) {
var self = this;
return new Promish(function(resolve, reject) {
self.inner.then(
function (value) {
if (t) {
try {
resolve(t(value));
}
catch(e) {
reject(e);
}
} else {
resolve(value);
}
},
function(error) {
if (r) {
try {
//console.log('calling onReject with ', error)
resolve(r(error));
}
catch(e) {
//console.log('caught handler exception', e)
reject(e);
}
} else {
reject(error);
}
}
);
});
}
finally(h) {

@@ -73,2 +44,3 @@ function fin() { return h(); }

catch() {
// extend catch with type-aware or matcher handling
var args = Array.from(arguments);

@@ -100,3 +72,3 @@ var h = args.pop();

// no match was found send this error to the next promise handler in the chain
return new Promish(function(resolve, reject) { reject(error); });
return new Promish((resolve, reject) => reject(error));
});

@@ -121,17 +93,2 @@ }

// Wrap Promise.all
static all(promises) {
return new Promish(Promise.all(promises));
}
// Turn a value into a promish
static resolve(value) {
return new Promish(resolve => resolve(value));
}
// Turn an error into a rejected promish
static reject(error) {
return new Promish((resolve,reject) => reject(error));
}
// Wrap a synchronous method and resolve with its return value

@@ -146,7 +103,2 @@ static method(f) {

// Wrap Promise.race
static race(promises) {
return new Promish(Promise.race(promises));
};
//

@@ -153,0 +105,0 @@ static apply(f, args) {

{
"name": "promish",
"version": "4.2.1",
"version": "4.2.2",
"description": "ES6 Promise Shim",

@@ -5,0 +5,0 @@ "private": false,

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc