Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

dirent-from-stats

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dirent-from-stats

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

latest
Source
npmnpm
Version
2.0.9
Version published
Maintainers
1
Created
Source

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);
    }
  }
}

Keywords

dirent

FAQs

Package last updated on 12 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts