Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@types/graceful-fs
Advanced tools
TypeScript definitions for graceful-fs
@types/graceful-fs provides TypeScript type definitions for the graceful-fs package, which is a drop-in replacement for the native Node.js fs module with improvements to handle EMFILE errors (too many open files) gracefully.
Reading Files
This feature allows you to read the contents of a file asynchronously. The graceful-fs package ensures that the operation handles too many open files errors gracefully.
const fs = require('graceful-fs');
fs.readFile('example.txt', 'utf8', (err, data) => {
if (err) throw err;
console.log(data);
});
Writing Files
This feature allows you to write data to a file asynchronously. The graceful-fs package ensures that the operation handles too many open files errors gracefully.
const fs = require('graceful-fs');
fs.writeFile('example.txt', 'Hello, world!', (err) => {
if (err) throw err;
console.log('File has been saved!');
});
Appending to Files
This feature allows you to append data to a file asynchronously. The graceful-fs package ensures that the operation handles too many open files errors gracefully.
const fs = require('graceful-fs');
fs.appendFile('example.txt', 'Appending some text.', (err) => {
if (err) throw err;
console.log('Text has been appended!');
});
Deleting Files
This feature allows you to delete a file asynchronously. The graceful-fs package ensures that the operation handles too many open files errors gracefully.
const fs = require('graceful-fs');
fs.unlink('example.txt', (err) => {
if (err) throw err;
console.log('File has been deleted!');
});
fs-extra is a package that extends the native Node.js fs module with additional methods and promises support. It provides more functionality than graceful-fs, such as copying, moving, and ensuring directories and files. However, it does not specifically focus on handling too many open files errors.
node-fs is a package that provides additional file system methods for Node.js. It includes features like recursive directory creation and symbolic link support. While it offers more functionality than the native fs module, it does not specifically address too many open files errors like graceful-fs.
fs.promises is a built-in module in Node.js that provides promise-based versions of the fs module's methods. It offers a modern, promise-based API for file system operations but does not include the enhancements for handling too many open files errors that graceful-fs provides.
npm install --save @types/graceful-fs
This package contains type definitions for graceful-fs (https://github.com/isaacs/node-graceful-fs).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/graceful-fs.
/// <reference types="node" />
export * from "fs";
/**
* Use this method to patch the global fs module (or any other fs-like module).
* 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.
* @param fsModule The reference to the fs module or an fs-like module.
*/
export function gracefulify<T>(fsModule: T): T;
These definitions were written by Bart van der Schoor, and BendingBender.
FAQs
TypeScript definitions for graceful-fs
The npm package @types/graceful-fs receives a total of 18,298,718 weekly downloads. As such, @types/graceful-fs popularity was classified as popular.
We found that @types/graceful-fs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.