Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update readme examples to ES6 #214

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions readme.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ synchronously
asynchronously resolve:

```js
var resolve = require('resolve');
resolve('tap', { basedir: __dirname }, function (err, res) {
const resolve = require('resolve');
resolve('tap', { basedir: __dirname }, (err, res) => {
if (err) console.error(err);
else console.log(res);
});
Expand All @@ -27,8 +27,8 @@ $ node example/async.js
synchronously resolve:

```js
var resolve = require('resolve');
var res = resolve.sync('tap', { basedir: __dirname });
const resolve = require('resolve');
const res = resolve.sync('tap', { basedir: __dirname });
console.log(res);
```

Expand All @@ -40,7 +40,7 @@ $ node example/sync.js
# methods

```js
var resolve = require('resolve');
const resolve = require('resolve');
```

## resolve(id, opts={}, cb)
Expand Down Expand Up @@ -99,17 +99,17 @@ default `opts` values:
basedir: __dirname,
extensions: ['.js'],
readFile: fs.readFile,
isFile: function isFile(file, cb) {
fs.stat(file, function (err, stat) {
isFile(file, cb) {
fs.stat(file, (err, stat) => {
if (!err) {
return cb(null, stat.isFile() || stat.isFIFO());
}
if (err.code === 'ENOENT' || err.code === 'ENOTDIR') return cb(null, false);
return cb(err);
});
},
isDirectory: function isDirectory(dir, cb) {
fs.stat(dir, function (err, stat) {
isDirectory(dir, cb) {
fs.stat(dir, (err, stat) => {
if (!err) {
return cb(null, stat.isDirectory());
}
Expand Down Expand Up @@ -177,18 +177,20 @@ default `opts` values:
basedir: __dirname,
extensions: ['.js'],
readFileSync: fs.readFileSync,
isFile: function isFile(file) {
isFile(file) {
let stat;
try {
var stat = fs.statSync(file);
stat = fs.statSync(file);
} catch (e) {
if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) return false;
throw e;
}
return stat.isFile() || stat.isFIFO();
},
isDirectory: function isDirectory(dir) {
isDirectory(dir) {
let stat;
try {
var stat = fs.statSync(dir);
stat = fs.statSync(dir);
} catch (e) {
if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) return false;
throw e;
Expand Down