mirror of
https://github.com/10h30/odin-javascript-exercises.git
synced 2026-07-13 03:36:07 +09:00
Clean up the oopsie. Rebuild the blank exercises.
This commit is contained in:
+10
-6
@@ -8,7 +8,7 @@ Think of it like an async version of [`Array#find`](https://developer.mozilla.or
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save p-locate
|
||||
$ npm install p-locate
|
||||
```
|
||||
|
||||
|
||||
@@ -22,14 +22,16 @@ const pLocate = require('p-locate');
|
||||
|
||||
const files = [
|
||||
'unicorn.png',
|
||||
'rainbow.png', // only this one actually exists on disk
|
||||
'rainbow.png', // Only this one actually exists on disk
|
||||
'pony.png'
|
||||
];
|
||||
|
||||
pLocate(files, file => pathExists(file)).then(foundPath => {
|
||||
(async () => {
|
||||
const foundPath = await pLocate(files, file => pathExists(file));
|
||||
|
||||
console.log(foundPath);
|
||||
//=> 'rainbow'
|
||||
});
|
||||
})();
|
||||
```
|
||||
|
||||
*The above is just an example. Use [`locate-path`](https://github.com/sindresorhus/locate-path) if you need this.*
|
||||
@@ -43,13 +45,15 @@ Returns a `Promise` that is fulfilled when `tester` resolves to `true` or the it
|
||||
|
||||
#### input
|
||||
|
||||
Type: `Iterable<Promise|any>`
|
||||
Type: `Iterable<Promise | unknown>`
|
||||
|
||||
An iterable of promises/values to test.
|
||||
|
||||
#### tester(element)
|
||||
|
||||
Type: `Function`
|
||||
|
||||
Expected to return a `Promise<boolean>` or boolean.
|
||||
This function will receive resolved values from `input` and is expected to return a `Promise<boolean>` or `boolean`.
|
||||
|
||||
#### options
|
||||
|
||||
|
||||
Reference in New Issue
Block a user