1.5.1 • Published 2 years ago

dirent-from-stats v1.5.1

Weekly downloads
4
License
MIT
Repository
github
Last release
2 years ago

dirent-from-stats

Create fs.Dirents from fs.Stats for compatiblity on earlier versions of Node.js.

It will inherit from fs.Dirent if it exists; otherwise, it will create a new base Dirent class.

var assert = require('assert');
var DirentFromStats = require('dirent-from-stats');
var fs = require('fs');
var each = require('async-each');

var DirentBase = DirentFromStats.DirentBase;
var TEST_DIR = path.resolve(path.join(__dirname, '..', '..', '.tmp', 'test'));

function create(root, name, callback) {
  return fs.lstat(path.join(root, name), function (err, stats) {
    err ? callback(err) : callback(null, new DirentFromStats(name, stats));
  });
}

fs.readdir(__dirname, function (err, names) {
  each(names, create.bind(null, TEST_DIR), function (err, dirents) {
    for (var index in dirents) {
      assert.ok(dirents[index] instanceof DirentBase);
      assert.ok(!fs.Dirent || dirents[index] instanceof fs.Dirent);
    }
  }
}
1.5.1

2 years ago

1.5.0

5 years ago

1.4.0

5 years ago

1.3.3

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.0.0

5 years ago