source: trip-planner-front/node_modules/locate-path/readme.md@ eed0bf8

Last change on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

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