Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

normalized-fs

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

normalized-fs

A drop-in replacement for fs that normalizes its behavior

  • 1.0.0-alpha.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

normalized-fs

GitHub license Build Status Coverage Dependencies

A drop-in replacement for fs that aims to normalize the behavior across different platforms and environments, and to make filesystem access more resilient to errors.

Improvements over fs module

  • Queues up open and readdir calls, and retries them once something closes if there is an EMFILE error from too many file descriptors.
  • Fixes lchmod for Node versions prior to 0.6.2.
  • Implements fs.lutimes if possible. Otherwise it becomes a noop.
  • Ignores EINVAL and EPERM errors in chown, fchown or lchown if the user isn't root.
  • Makes lchmod and lchown become noops, if not available.
  • Retries reading a file if read results in EAGAIN error.

Installation

npm

$ npm install normalized-fs

yarn

$ yarn add normalized-fs

Usage

// import just like with fs
import fs from 'normalized-fs';

// now go and do stuff with it...
fs.readFileSync('some-file-or-whatever');

Global patching

If you want to patch the global fs module (or any other fs-like module) you can do this:

NOTE: This should only ever be done at the top-level application layer, in order to delay on EMFILE errors from any fs-using dependencies. You should not do this in a library, because it can cause unexpected delays in other parts of the program.

import realFs from 'fs';
import nfs from 'normalized-fs';
nfs.normalize(realFs);

Credits

Big thanks to isaacs who created graceful-fs which this package is based upon.

Keywords

FAQs

Package last updated on 24 Jan 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc