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:
+16
-9
@@ -2,7 +2,9 @@
|
||||
|
||||
> Check if a path exists
|
||||
|
||||
Because [`fs.exists()`](https://nodejs.org/api/fs.html#fs_fs_exists_path_callback) is being [deprecated](https://github.com/iojs/io.js/issues/103), but there's still a genuine use-case of being able to check if a path exists for other purposes than doing IO with it.
|
||||
NOTE: `fs.existsSync` has been un-deprecated in Node.js since 6.8.0. If you only need to check synchronously, this module is not needed.
|
||||
|
||||
While [`fs.exists()`](https://nodejs.org/api/fs.html#fs_fs_exists_path_callback) is being [deprecated](https://github.com/iojs/io.js/issues/103), there's still a genuine use-case of being able to check if a path exists for other purposes than doing IO with it.
|
||||
|
||||
Never use this before handling a file though:
|
||||
|
||||
@@ -12,7 +14,7 @@ Never use this before handling a file though:
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save path-exists
|
||||
$ npm install path-exists
|
||||
```
|
||||
|
||||
|
||||
@@ -20,12 +22,12 @@ $ npm install --save path-exists
|
||||
|
||||
```js
|
||||
// foo.js
|
||||
var pathExists = require('path-exists');
|
||||
const pathExists = require('path-exists');
|
||||
|
||||
pathExists('foo.js').then(function (exists) {
|
||||
console.log(exists);
|
||||
(async () => {
|
||||
console.log(await pathExists('foo.js'));
|
||||
//=> true
|
||||
});
|
||||
})();
|
||||
```
|
||||
|
||||
|
||||
@@ -33,13 +35,18 @@ pathExists('foo.js').then(function (exists) {
|
||||
|
||||
### pathExists(path)
|
||||
|
||||
Returns a promise that resolves to a boolean of whether the path exists.
|
||||
Returns a `Promise<boolean>` of whether the path exists.
|
||||
|
||||
### pathExists.sync(path)
|
||||
|
||||
Returns a boolean of whether the path exists.
|
||||
Returns a `boolean` of whether the path exists.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [path-exists-cli](https://github.com/sindresorhus/path-exists-cli) - CLI for this module
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](http://sindresorhus.com)
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
|
||||
Reference in New Issue
Block a user