Skip to content

Commit

Permalink
Merge pull request #9 from AmrSaber/dev
Browse files Browse the repository at this point in the history
Update description and return type
  • Loading branch information
AmrSaber authored Jun 10, 2021
2 parents 167aff0 + d59a9eb commit f26ee3a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 28 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "async-short-circuit",
"version": "1.1.0",
"version": "1.1.1",
"description": "Short circuit logic for boolean promises",
"main": "src/index.js",
"types": "src/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* @returns a promise that resolves with the result of ANDing the given promises.
*/
export function asyncAnd(promises: Promise[]): Promise;
export function asyncAnd(promises: Promise[]): Promise<any>;


/**
Expand All @@ -25,4 +25,4 @@ export function asyncAnd(promises: Promise[]): Promise;
*
* @returns a promise that resolves with the result of ORing the given promises.
*/
export function asyncOr(promises: Promise[]): Promise;
export function asyncOr(promises: Promise[]): Promise<any>;
24 changes: 0 additions & 24 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
/**
* Performs logical AND among the given promises with short-circuit logic.
* Returns the result of ANDing the results of all the given promises,
* but stops as soon as the first false value is resolved and returns that value.
*
* Note that this considers the resolve time precedence and not the promises order,
* unless all the promises resolve to true, then it will consider the order to perform the AND manually.
*
* @param {[Promise]} promises
*
* @returns {Promise<Any>}
*/
function asyncAnd(promises) {
return new Promise((resolve, reject) => {
const notify = value => { if (!value) { resolve(value); } else { return value; } };
Expand All @@ -23,18 +11,6 @@ function asyncAnd(promises) {
});
}

/**
* Performs logical OR among the given promises with short-circuit logic.
* Returns the result of ORing the results of all the given promises,
* but stops as soon as the first truthy value is resolved and returns that value.
*
* Note that this considers the resolve time precedence and not the promises order,
* unless all the promises resolve to false, then it will consider the order to perform the OR manually.
*
* @param {[Promise]} promises
*
* @returns {Promise<Any>}
*/
function asyncOr(promises) {
return new Promise((resolve, reject) => {
const notify = value => { if (value) { resolve(value); } else { return value; } };
Expand Down

0 comments on commit f26ee3a

Please sign in to comment.