Clean up the oopsie. Rebuild the blank exercises.

This commit is contained in:
Michael Frank
2021-05-09 00:39:21 +12:00
parent b984cb4c6f
commit d28d80c46f
1565 changed files with 27186 additions and 199003 deletions
+15 -16
View File
@@ -1,24 +1,23 @@
'use strict';
var fs = require('fs');
var Promise = require('pinkie-promise');
const fs = require('fs');
const {promisify} = require('util');
module.exports = function (fp) {
var fn = typeof fs.access === 'function' ? fs.access : fs.stat;
return new Promise(function (resolve) {
fn(fp, function (err) {
resolve(!err);
});
});
};
module.exports.sync = function (fp) {
var fn = typeof fs.accessSync === 'function' ? fs.accessSync : fs.statSync;
const pAccess = promisify(fs.access);
module.exports = async path => {
try {
fn(fp);
await pAccess(path);
return true;
} catch (err) {
} catch (_) {
return false;
}
};
module.exports.sync = path => {
try {
fs.accessSync(path);
return true;
} catch (_) {
return false;
}
};
+4 -16
View File
@@ -1,21 +1,9 @@
The MIT License (MIT)
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+18 -19
View File
@@ -1,27 +1,27 @@
{
"_from": "path-exists@^2.0.0",
"_id": "path-exists@2.1.0",
"_from": "path-exists@^4.0.0",
"_id": "path-exists@4.0.0",
"_inBundle": false,
"_integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=",
"_integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
"_location": "/path-exists",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "path-exists@^2.0.0",
"raw": "path-exists@^4.0.0",
"name": "path-exists",
"escapedName": "path-exists",
"rawSpec": "^2.0.0",
"rawSpec": "^4.0.0",
"saveSpec": null,
"fetchSpec": "^2.0.0"
"fetchSpec": "^4.0.0"
},
"_requiredBy": [
"/find-up"
],
"_resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz",
"_shasum": "0feb6c64f0fc518d9a754dd5efb62c7022761f4b",
"_spec": "path-exists@^2.0.0",
"_where": "/Users/cloyd/coderrr/odin/javascript-exercises/node_modules/find-up",
"_resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
"_shasum": "513bdbe2d3b95d7762e8c1137efa195c6c61b5b3",
"_spec": "path-exists@^4.0.0",
"_where": "/home/michael/projects/javascript-exercises/node_modules/find-up",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
@@ -31,20 +31,19 @@
"url": "https://github.com/sindresorhus/path-exists/issues"
},
"bundleDependencies": false,
"dependencies": {
"pinkie-promise": "^2.0.0"
},
"deprecated": false,
"description": "Check if a path exists",
"devDependencies": {
"ava": "*",
"xo": "*"
"ava": "^1.4.1",
"tsd": "^0.7.2",
"xo": "^0.24.0"
},
"engines": {
"node": ">=0.10.0"
"node": ">=8"
},
"files": [
"index.js"
"index.js",
"index.d.ts"
],
"homepage": "https://github.com/sindresorhus/path-exists#readme",
"keywords": [
@@ -66,7 +65,7 @@
"url": "git+https://github.com/sindresorhus/path-exists.git"
},
"scripts": {
"test": "xo && ava"
"test": "xo && ava && tsd"
},
"version": "2.1.0"
"version": "4.0.0"
}
+16 -9
View File
@@ -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)