Socket
Socket
Sign inDemoInstall

p-locate

Package Overview
Dependencies
2
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 3.0.0

13

index.js

@@ -11,3 +11,6 @@ 'use strict';

// the input can also be a promise, so we `Promise.all()` them both
// The input can also be a promise, so we `Promise.resolve()` it
const testElement = (el, tester) => Promise.resolve(el).then(tester);
// The input can also be a promise, so we `Promise.all()` them both
const finder = el => Promise.all(el).then(val => val[1] === true && Promise.reject(new EndError(val[0])));

@@ -23,11 +26,11 @@

// start all the promises concurrently with optional limit
const items = Array.from(iterable).map(el => [el, limit(() => Promise.resolve(el).then(tester))]);
// Start all the promises concurrently with optional limit
const items = [...iterable].map(el => [el, limit(testElement, el, tester)]);
// check the promises either serially or concurrently
// Check the promises either serially or concurrently
const checkLimit = pLimit(opts.preserveOrder ? 1 : Infinity);
return Promise.all(items.map(el => checkLimit(() => finder(el))))
return Promise.all(items.map(el => checkLimit(finder, el)))
.then(() => {})
.catch(err => err instanceof EndError ? err.value : Promise.reject(err));
};
{
"name": "p-locate",
"version": "2.0.0",
"description": "Get the first fulfilled promise that satisfies the provided testing function",
"license": "MIT",
"repository": "sindresorhus/p-locate",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"promise",
"locate",
"find",
"finder",
"search",
"searcher",
"test",
"array",
"collection",
"iterable",
"iterator",
"race",
"fulfilled",
"fastest",
"async",
"await",
"promises",
"bluebird"
],
"dependencies": {
"p-limit": "^1.1.0"
},
"devDependencies": {
"ava": "*",
"delay": "^1.3.1",
"in-range": "^1.0.0",
"time-span": "^1.0.0",
"xo": "*"
},
"xo": {
"esnext": true
}
"name": "p-locate",
"version": "3.0.0",
"description": "Get the first fulfilled promise that satisfies the provided testing function",
"license": "MIT",
"repository": "sindresorhus/p-locate",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=6"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"promise",
"locate",
"find",
"finder",
"search",
"searcher",
"test",
"array",
"collection",
"iterable",
"iterator",
"race",
"fulfilled",
"fastest",
"async",
"await",
"promises",
"bluebird"
],
"dependencies": {
"p-limit": "^2.0.0"
},
"devDependencies": {
"ava": "*",
"delay": "^3.0.0",
"in-range": "^1.0.0",
"time-span": "^2.0.0",
"xo": "*"
}
}

@@ -11,3 +11,3 @@ # p-locate [![Build Status](https://travis-ci.org/sindresorhus/p-locate.svg?branch=master)](https://travis-ci.org/sindresorhus/p-locate)

```
$ npm install --save p-locate
$ npm install p-locate
```

@@ -26,10 +26,12 @@

'unicorn.png',
'rainbow.png', // only this one actually exists on disk
'rainbow.png', // Only this one actually exists on disk
'pony.png'
];
pLocate(files, file => pathExists(file)).then(foundPath => {
(async () => {
const foundPath = await pLocate(files, file => pathExists(file));
console.log(foundPath);
//=> 'rainbow'
});
})();
```

@@ -36,0 +38,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc