
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
A Node.js library for recursively listing files and directories with customizable filtering and sorting options.
fs-visitor
is a Node.js library that provides a simple API to recursively list files and directories with various filtering and sorting options.
npm install fs-visitor
const { processVisitor } = require("fs-visitor");
// Example: List all files and directories in the current directory
const entries = processVisitor("./");
console.log(entries);
// Example: List only TypeScript files with a depth of 2
const tsFilter = (entry) => entry.type === "file" && entry.name.endsWith(".ts");
const options = { deep: 2, filterEntry: tsFilter };
const tsEntries = processVisitor("./src", options);
console.log(tsEntries);
Entry
type Entry = {
key: string;
type: "directory" | "file" | string;
name: string;
absolute: string;
relative: string;
};
Represents an entry (file or directory) returned by processVisitor
.
FilterEntry
type FilterEntry = (entry: Entry) => boolean;
A function used for filtering entries based on custom criteria.
Options
type Options = {
deep?: number;
filterEntry?: FilterEntry | FilterEntry[];
withDirectory?: boolean;
sorter?: (a: Entry, b: Entry) => number;
relativePrefix?: string;
useSlash?: boolean;
};
Options to customize the behavior of processVisitor
.
deep
: Maximum depth to scan.filterEntry
: A single or an array of FilterEntry
functions.withDirectory
: Include directories in the result.sorter
: Custom function to sort entries.relativePrefix
: Prefix to add to relative paths.useSlash
: Use forward slash /
as a directory separator.processVisitor
export const processVisitor = (
directory: string,
options: Options = {}
) => Entry[];
The main method that lists files and directories based on the provided options.
import { processVisitor } from "fs-visitor";
const entries = processVisitor("./");
console.log(entries);
import { processVisitor } from "fs-visitor";
const entries = processVisitor("./src", {
deep: 2,
filterEntry: (entry) => {
return entry.type === "file" && entry.name.endsWith(".ts");
},
});
console.log(entries);
This example use minimatch
and expose a simple function createFileEntry
in filter
file
import { processVisitor } from "fs-visitor";
import { createFileEntry } from "fs-visitor/filter";
const filterEntry = createFileEntry({
include: "**/*.ts",
exclude: ["**/Config*", "**/Defined*"],
});
const entries = processVisitor("./src/widget", { filterEntry });
console.log(entries);
Feel free to contribute to this project, report issues, or suggest improvements. Your feedback is highly appreciated.
This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
A Node.js library for recursively listing files and directories with customizable filtering and sorting options.
The npm package fs-visitor receives a total of 0 weekly downloads. As such, fs-visitor popularity was classified as not popular.
We found that fs-visitor demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.