New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

p-any

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

p-any - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

index.d.ts

17

index.js
'use strict';
const pSome = require('p-some');
const PCancelable = require('p-cancelable');
module.exports = (iterable, opts) => pSome(iterable, Object.assign({}, opts, {count: 1})).then(values => values[0]);
const pAny = (iterable, options) => {
const anyCancelable = pSome(iterable, {...options, count: 1});
return PCancelable.fn(async onCancel => {
onCancel(() => {
anyCancelable.cancel();
});
const [value] = await anyCancelable;
return value;
})();
};
module.exports = pAny;
module.exports.default = pAny;
module.exports.AggregateError = pSome.AggregateError;

94

package.json
{
"name": "p-any",
"version": "1.1.0",
"description": "Wait for any promise to be fulfilled",
"license": "MIT",
"repository": "sindresorhus/p-any",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"promise",
"any",
"resolved",
"wait",
"collection",
"iterable",
"iterator",
"race",
"fulfilled",
"fastest",
"one",
"single",
"async",
"await",
"promises",
"bluebird"
],
"dependencies": {
"p-some": "^2.0.0"
},
"devDependencies": {
"ava": "*",
"delay": "^2.0.0",
"xo": "*"
}
"name": "p-any",
"version": "2.0.0",
"description": "Wait for any promise to be fulfilled",
"license": "MIT",
"repository": "sindresorhus/p-any",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=8"
},
"scripts": {
"test": "xo && ava && tsd-check"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"promise",
"any",
"resolved",
"wait",
"collection",
"iterable",
"iterator",
"race",
"fulfilled",
"fastest",
"one",
"single",
"async",
"await",
"promises",
"bluebird"
],
"dependencies": {
"p-cancelable": "^1.1.0",
"p-some": "^4.0.0",
"type-fest": "^0.1.0"
},
"devDependencies": {
"ava": "^1.3.1",
"delay": "^4.1.0",
"tsd-check": "^0.3.0",
"xo": "^0.24.0"
}
}

@@ -25,10 +25,12 @@ # p-any [![Build Status](https://travis-ci.org/sindresorhus/p-any.svg?branch=master)](https://travis-ci.org/sindresorhus/p-any)

pAny([
got.head('github.com').then(() => 'github'),
got.head('google.com').then(() => 'google'),
got.head('twitter.com').then(() => 'twitter'),
]).then(first => {
(async () => {
const first = await pAny([
got.head('https://github.com').then(() => 'github'),
got.head('https://google.com').then(() => 'google'),
got.head('https://twitter.com').then(() => 'twitter'),
]);
console.log(first);
//=> 'google'
});
})();
```

@@ -41,3 +43,3 @@

Returns a `Promise` that is fulfilled when any promise from `input` is fulfilled. If all the `input` promises reject, it will reject with an [`AggregateError`](https://github.com/sindresorhus/aggregate-error) error.
Returns a [cancelable `Promise`](https://github.com/sindresorhus/p-cancelable) that is fulfilled when any promise from `input` is fulfilled. If all the `input` promises reject, it will reject with an [`AggregateError`](https://github.com/sindresorhus/aggregate-error) error.

@@ -44,0 +46,0 @@ #### input

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