.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / locate-path / readme.md
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 --save locate-path
10 ```
11
12
13 ## Usage
14
15 Here we find the first file that exists on disk, in array order.
16
17 ```js
18 const locatePath = require('locate-path');
19
20 const files = [
21         'unicorn.png',
22         'rainbow.png', // only this one actually exists on disk
23         'pony.png'
24 ];
25
26 locatePath(files).then(foundPath => {
27         console.log(foundPath);
28         //=> 'rainbow'
29 });
30 ```
31
32
33 ## API
34
35 ### locatePath(input, [options])
36
37 Returns a `Promise` for the first path that exists or `undefined` if none exists.
38
39 #### input
40
41 Type: `Iterable<string>`
42
43 Paths to check.
44
45 #### options
46
47 Type: `Object`
48
49 ##### concurrency
50
51 Type: `number`<br>
52 Default: `Infinity`<br>
53 Minimum: `1`
54
55 Number of concurrently pending promises.
56
57 ##### preserveOrder
58
59 Type: `boolean`<br>
60 Default: `true`
61
62 Preserve `input` order when searching.
63
64 Disable this to improve performance if you don't care about the order.
65
66 ##### cwd
67
68 Type: `string`<br>
69 Default: `process.cwd()`
70
71 Current working directory.
72
73 ### locatePath.sync(input, [options])
74
75 Returns the first path that exists or `undefined` if none exists.
76
77 #### input
78
79 Type: `Iterable<string>`
80
81 Paths to check.
82
83 #### options
84
85 Type: `Object`
86
87 ##### cwd
88
89 Same as above.
90
91
92 ## Related
93
94 - [path-exists](https://github.com/sindresorhus/path-exists) - Check if a path exists
95
96
97 ## License
98
99 MIT © [Sindre Sorhus](https://sindresorhus.com)