mirror of
https://github.com/10h30/odin-javascript-exercises.git
synced 2026-07-12 11:16:09 +09:00
Clean up the oopsie. Rebuild the blank exercises.
This commit is contained in:
+34
-11
@@ -6,7 +6,7 @@
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save locate-path
|
||||
$ npm install locate-path
|
||||
```
|
||||
|
||||
|
||||
@@ -19,24 +19,24 @@ const locatePath = require('locate-path');
|
||||
|
||||
const files = [
|
||||
'unicorn.png',
|
||||
'rainbow.png', // only this one actually exists on disk
|
||||
'rainbow.png', // Only this one actually exists on disk
|
||||
'pony.png'
|
||||
];
|
||||
|
||||
locatePath(files).then(foundPath => {
|
||||
console.log(foundPath);
|
||||
(async () => {
|
||||
console(await locatePath(files));
|
||||
//=> 'rainbow'
|
||||
});
|
||||
})();
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### locatePath(input, [options])
|
||||
### locatePath(paths, [options])
|
||||
|
||||
Returns a `Promise` for the first path that exists or `undefined` if none exists.
|
||||
Returns a `Promise<string>` for the first path that exists or `undefined` if none exists.
|
||||
|
||||
#### input
|
||||
#### paths
|
||||
|
||||
Type: `Iterable<string>`
|
||||
|
||||
@@ -59,7 +59,7 @@ Number of concurrently pending promises.
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
Preserve `input` order when searching.
|
||||
Preserve `paths` order when searching.
|
||||
|
||||
Disable this to improve performance if you don't care about the order.
|
||||
|
||||
@@ -70,11 +70,26 @@ Default: `process.cwd()`
|
||||
|
||||
Current working directory.
|
||||
|
||||
### locatePath.sync(input, [options])
|
||||
##### type
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `file`<br>
|
||||
Values: `file` `directory`
|
||||
|
||||
The type of paths that can match.
|
||||
|
||||
##### allowSymlinks
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
Allow symbolic links to match if they point to the chosen path type.
|
||||
|
||||
### locatePath.sync(paths, [options])
|
||||
|
||||
Returns the first path that exists or `undefined` if none exists.
|
||||
|
||||
#### input
|
||||
#### paths
|
||||
|
||||
Type: `Iterable<string>`
|
||||
|
||||
@@ -88,6 +103,14 @@ Type: `Object`
|
||||
|
||||
Same as above.
|
||||
|
||||
##### type
|
||||
|
||||
Same as above.
|
||||
|
||||
##### allowSymlinks
|
||||
|
||||
Same as above.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
|
||||
Reference in New Issue
Block a user