Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on Apr 25, 2024 via pnpm

p-locate 5.0.0

Get the first fulfilled promise that satisfies the provided testing function
Package summary
Share
0
issues
1
license
3
MIT
Package created
20 Nov 2016
Version published
10 Aug 2020
Maintainers
1
Total deps
3
Direct deps
1
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
3 Packages, Including:
p-limit@3.1.0
p-locate@5.0.0
yocto-queue@0.1.0
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

1
All Dependencies CSV
β“˜ This is a list of p-locate 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
p-limit3.1.03.19 kBMIT
prod

Visualizations

Frequently Asked Questions

What does p-locate do?

p-locate is a popular npm package that is designed to return the first fulfilled promise that meets certain specified conditions, in effect making it similar to an asynchronous version of the Array#find utility in JavaScript. It provides a powerful utility for managing JavaScript promises, especially in scenarios where you need to parse through a series of promises and return the first one that satisfies a given testing function.

How do you use p-locate?

Using p-locate in your JavaScript project involves first installing the package via npm with the command npm install p-locate. Once installed, you can use it by importing it into your project and calling the pLocate function with an array of values or promises and a tester function. The tester function returns a Boolean value indicating whether a given element satisfies certain conditions.

Here is a simple usage example:

import {pathExists} from 'path-exists';
import pLocate from 'p-locate';

const files = [
	'unicorn.png',
	'rainbow.png', // Only this one actually exists on disk
	'pony.png'
];

const foundPath = await pLocate(files, file => pathExists(file));

console.log(foundPath);
//=> 'rainbow'

In this example, the pLocate function is used to find the first file in the files array that exists on the disk.

Where are the p-locate docs?

The official p-locate documentation can be found on its GitHub page at git+https://github.com/sindresorhus/p-locate.git. The readme file on this page provides detailed descriptions of how to install and use the package, as well as its API which outlines all the functions and options that p-locate offers. This is a great resource for developers who want to understand how to use p-locate effectively in their projects to manage JavaScript promises.