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

appolo-utils

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

appolo-utils - npm Package Compare versions

Comparing version 0.0.27 to 0.0.28

37

lib/promises.js

@@ -107,2 +107,39 @@ "use strict";

}
static some(promises, counter = 1) {
return new Promise((resolve) => {
let settled = [];
counter = Math.min(Math.max(Math.floor(counter), 1), promises.length);
for (let i = 0; i < promises.length; i++) {
promises[i]
.then(value => (settled.push({ status: "fulfilled", value }) === counter) && resolve(settled))
.catch(reason => (settled.push({ status: "rejected", reason }) === counter) && resolve(settled));
}
});
}
static someResolved(promises, counter = 1) {
return new Promise((resolve, reject) => {
let resolved = [], rejected = [];
counter = Math.min(Math.max(Math.floor(counter), 1), promises.length);
for (let i = 0; i < promises.length; i++) {
promises[i]
.then(value => (resolved.push({ status: "fulfilled", value }) === counter
|| resolved.length + rejected.length === promises.length) && resolve(resolved))
.catch(reason => (rejected.push({ status: "rejected", reason }) + resolved.length === promises.length)
&& resolve(resolved));
}
});
}
static someRejected(promises, counter = 1) {
return new Promise((resolve, reject) => {
let resolved = [], rejected = [];
counter = Math.min(Math.max(Math.floor(counter), 1), promises.length);
for (let i = 0; i < promises.length; i++) {
promises[i]
.then(value => (resolved.push({ status: "fulfilled", value }) + rejected.length === promises.length)
&& resolve(rejected))
.catch(reason => (rejected.push({ status: "rejected", reason }) === counter
|| resolved.length + rejected.length === promises.length) && resolve(rejected));
}
});
}
}

@@ -109,0 +146,0 @@ exports.Promises = Promises;

51

lib/promises.ts

@@ -130,3 +130,3 @@ type Resolvable<R> = R | PromiseLike<R>

public static allSettled<T>(promises: Promise<T>[]):Promise< ({ status: "fulfilled"; value: T; } | { status: "rejected"; reason: any; })[]> {
public static allSettled<T>(promises: Promise<T>[]): Promise<({ status: "fulfilled"; value: T; } | { status: "rejected"; reason: any; })[]> {

@@ -145,2 +145,51 @@ let settled = [];

}
public static some<T>(promises: Promise<T>[], counter: number = 1): Promise<({ status: "fulfilled"; value: T; } | { status: "rejected"; reason: any; })[]> {
return new Promise((resolve) => {
let settled = [];
counter = Math.min(Math.max(Math.floor(counter), 1), promises.length);
for (let i = 0; i < promises.length; i++) {
promises[i]
.then(value => (settled.push({status: "fulfilled", value}) === counter) && resolve(settled))
.catch(reason => (settled.push({status: "rejected", reason}) === counter) && resolve(settled));
}
})
}
public static someResolved<T>(promises: Promise<T>[], counter: number = 1): Promise<({ status: "fulfilled"; value: T; })[]> {
return new Promise((resolve, reject) => {
let resolved = [], rejected = [];
counter = Math.min(Math.max(Math.floor(counter), 1), promises.length);
for (let i = 0; i < promises.length; i++) {
promises[i]
.then(value => (resolved.push({status: "fulfilled", value}) === counter
|| resolved.length + rejected.length === promises.length) && resolve(resolved))
.catch(reason => (rejected.push({status: "rejected", reason}) + resolved.length === promises.length)
&& resolve(resolved))
}
})
}
public static someRejected<T>(promises: Promise<T>[], counter: number = 1): Promise<({ status: "fulfilled"; value: T; })[]> {
return new Promise((resolve, reject) => {
let resolved = [], rejected = [];
counter = Math.min(Math.max(Math.floor(counter), 1), promises.length);
for (let i = 0; i < promises.length; i++) {
promises[i]
.then(value => (resolved.push({status: "fulfilled", value}) + rejected.length === promises.length)
&& resolve(rejected))
.catch(reason => (rejected.push({status: "rejected", reason}) === counter
|| resolved.length + rejected.length === promises.length) && resolve(rejected))
}
})
}
}

@@ -147,0 +196,0 @@

2

package.json

@@ -17,3 +17,3 @@ {

"main": "./index.js",
"version": "0.0.27",
"version": "0.0.28",
"license": "MIT",

@@ -20,0 +20,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

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