
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
files-pipe
Advanced tools
First, install the files-pipe
component like so:
npm install -D -E files-pipe
Then, create a new pipe from this component:
index.ts
import { files } from "files-pipe";
await new files().in("./input");
The files-pipe
will now provide you with a pipe
method which you can use to
execute the callback on each file from the pipe.
index.ts
import { files } from "files-pipe";
await (
await (await new files().in("./input")).by("**/*.md")
).pipe({
// Prepend some content to all of the text files
wrote: (ongoing) => (ongoing.buffer += "LICENSE [MIT]"),
});
These are the defaults for each callback.
import { files } from "files-pipe";
await new files().pipe({
// Writes the buffer into a file
wrote: async (ongoing) => ongoing.buffer,
// Reads the file into a buffer
read: async (ongoing) =>
await fs.promises.readFile(ongoing.inputPath, "utf-8"),
// Checks if the file has passed any checks
passed: async (ongoing) => true,
// When file cannot be processed
failed: async (inputPath) => `Error: Cannot process file ${inputPath}!`,
// When the file is processed
accomplished: async (ongoing) =>
`Processed ${ongoing.inputPath} in ${ongoing.outputPath}.`,
// When the whole plan is fulfilled
fulfilled: async (plan) =>
`Successfully processed a total of ${plan.files} ${
plan.files === 1 ? "file" : "files"
}.`,
// When the plan has changed
changed: async (plan) => plan,
});
You can add multiple paths to your pipe by specifying an array as the path
variable.
index.ts
import { files } from "files-pipe";
await new files().in(["./input", "./input2"]);
You can also provide a map of paths for different input output directories.
index.ts
import { files } from "files-pipe";
await new files().in(new Map([["./input", "./output"]]));
You can provide a filter to exclude files from your pipe. A filter can be an array of regexes or a single match. You can use functions, as well to match on file names.
index.ts
import { files } from "files-pipe";
await new files().not([
"my-awesome.file",
(file: string) => file === "./input/this-file-will-not-be-processed.txt",
]);
Set logger
to 0
if you do not want to see debug messages. Default is 2
.
index.ts
import { files } from "files-pipe";
new files(0);
See CHANGELOG.md for a history of changes to this component.
FAQs
🧪 File Pipe.
The npm package files-pipe receives a total of 1,834 weekly downloads. As such, files-pipe popularity was classified as popular.
We found that files-pipe 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
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.