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 0.0.7 to 0.0.8

27

lib/promish.js

@@ -227,13 +227,18 @@ 'use strict';

// any - the first to resolve, wins - else reject with all of the errors
Promish.any = Promise.any || function(promises) {
// some - the first n to resolve, win - else reject with all of the errors
Promish.some = Promise.some || function(promises, n) {
return new Promish(function(resolve, reject) {
var values = [];
var rejects = [];
var countDown = promises.length;
promises.forEach(function(promise, index) {
promises.forEach(function(promise) {
promise
.then(resolve)
.then(function(value) {
values.push(value);
if (values.length >= n) {
resolve(values);
}
})
.catch(function(error) {
rejects[index] = error;
if (--countDown === 0){
rejects.push(error);
if (rejects.length > promises.length - n){
reject(rejects);

@@ -246,2 +251,10 @@ }

// any - the first to resolve, wins - else reject with all of the errors
Promish.any = Promise.any || function(promises) {
return Promish.some(promises, 1)
.then(function(values) {
return values[0];
});
};
// old-style for ease of adoption

@@ -248,0 +261,0 @@ Promish.defer = function() {

{
"name": "promish",
"version": "0.0.7",
"version": "0.0.8",
"description": "ES6 Promise Shim",

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

@@ -23,3 +23,3 @@ # Promish

<ul>
<li>Bugfixes and Documentation</li>
<li><a href="some">Some</a></li>
</ul>

@@ -381,2 +381,17 @@

## Some
Resolve on first N successful promises or reject with array of errors.
```javascript
Promish.some([promise1, promise2, promise3], 2)
.then(function(values) {
// first 2 successful promises...
})
.catch(function(errors) {
// at least 2 promises failed
});
```
## Any

@@ -383,0 +398,0 @@

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