source: imaps-frontend/node_modules/locate-path/readme.md@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 2.2 KB
Line 
1# locate-path [![Build Status](https://travis-ci.com/sindresorhus/locate-path.svg?branch=master)](https://travis-ci.com/github/sindresorhus/locate-path)
2
3> Get the first path that exists on disk of multiple paths
4
5## Install
6
7```
8$ npm install locate-path
9```
10
11## Usage
12
13Here we find the first file that exists on disk, in array order.
14
15```js
16const locatePath = require('locate-path');
17
18const files = [
19 'unicorn.png',
20 'rainbow.png', // Only this one actually exists on disk
21 'pony.png'
22];
23
24(async () => {
25 console(await locatePath(files));
26 //=> 'rainbow'
27})();
28```
29
30## API
31
32### locatePath(paths, options?)
33
34Returns a `Promise<string>` for the first path that exists or `undefined` if none exists.
35
36#### paths
37
38Type: `Iterable<string>`
39
40Paths to check.
41
42#### options
43
44Type: `object`
45
46##### concurrency
47
48Type: `number`\
49Default: `Infinity`\
50Minimum: `1`
51
52Number of concurrently pending promises.
53
54##### preserveOrder
55
56Type: `boolean`\
57Default: `true`
58
59Preserve `paths` order when searching.
60
61Disable this to improve performance if you don't care about the order.
62
63##### cwd
64
65Type: `string`\
66Default: `process.cwd()`
67
68Current working directory.
69
70##### type
71
72Type: `string`\
73Default: `'file'`\
74Values: `'file' | 'directory'`
75
76The type of paths that can match.
77
78##### allowSymlinks
79
80Type: `boolean`\
81Default: `true`
82
83Allow symbolic links to match if they point to the chosen path type.
84
85### locatePath.sync(paths, options?)
86
87Returns the first path that exists or `undefined` if none exists.
88
89#### paths
90
91Type: `Iterable<string>`
92
93Paths to check.
94
95#### options
96
97Type: `object`
98
99##### cwd
100
101Same as above.
102
103##### type
104
105Same as above.
106
107##### allowSymlinks
108
109Same as above.
110
111## Related
112
113- [path-exists](https://github.com/sindresorhus/path-exists) - Check if a path exists
114
115---
116
117<div align="center">
118 <b>
119 <a href="https://tidelift.com/subscription/pkg/npm-locate-path?utm_source=npm-locate-path&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
120 </b>
121 <br>
122 <sub>
123 Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
124 </sub>
125</div>
Note: See TracBrowser for help on using the repository browser.