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/recursive-readdir
Advanced tools
TypeScript definitions for recursive-readdir
@types/recursive-readdir is a TypeScript type definition package for the recursive-readdir library, which allows you to read directories recursively, filtering files and directories based on custom criteria.
Read all files in a directory recursively
This feature allows you to read all files in a directory and its subdirectories recursively. The callback function receives an error object and an array of file paths.
const recursive = require('recursive-readdir');
recursive('path/to/directory', (err, files) => {
if (err) {
console.error(err);
} else {
console.log(files);
}
});
Filter files based on custom criteria
This feature allows you to filter files and directories based on custom criteria. In this example, the 'node_modules' directory is ignored.
const recursive = require('recursive-readdir');
const ignoreFunc = (file, stats) => {
return stats.isDirectory() && file === 'node_modules';
};
recursive('path/to/directory', [ignoreFunc], (err, files) => {
if (err) {
console.error(err);
} else {
console.log(files);
}
});
readdirp is a recursive version of fs.readdir with additional features like filtering and streaming. It provides a more flexible API compared to recursive-readdir.
klaw is a file system walker that reads directories recursively and supports filtering and streaming. It is similar to recursive-readdir but offers more advanced features like custom filters and event-based processing.
fs-extra is a module that extends the native Node.js fs module with additional methods, including recursive directory reading. It provides a comprehensive set of file system utilities beyond just reading directories.
npm install --save @types/recursive-readdir
This package contains type definitions for recursive-readdir (https://github.com/jergason/recursive-readdir/).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/recursive-readdir.
/// <reference types="node" />
import * as fs from "fs";
declare namespace RecursiveReaddir {
type IgnoreFunction = (file: string, stats: fs.Stats) => boolean;
type Ignores = ReadonlyArray<string | IgnoreFunction>;
type Callback = (error: Error, files: string[]) => void;
interface readDir {
(path: string, ignores?: Ignores): Promise<string[]>;
(path: string, callback: Callback): void;
(path: string, ignores: Ignores, callback: Callback): void;
}
}
declare var recursiveReadDir: RecursiveReaddir.readDir;
export = recursiveReadDir;
These definitions were written by Micah Zoltu.
FAQs
TypeScript definitions for recursive-readdir
We found that @types/recursive-readdir 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.