Generated using TypeDoc
Generated using TypeDoc
The function By
takes in a file pattern or an array of file patterns, a set
+of input and output paths, and a map of results, and returns the updated map
+of results after matching the file patterns with the input paths.
File is either a single file pattern or an array of file
+patterns. These patterns are used to match files in the input directory
+(Input
) that will be processed.
Paths is an array of tuples that represent the input and +output paths. +Each tuple contains two elements: the input path and the output path.
+Map object that stores the mapping between the output file +paths and their corresponding input file paths. It is used to keep track of +the files that have been processed and their respective destinations.
+Generated using TypeDoc
The function converts a given number of bytes into a human-readable format with appropriate units +(e.g., KB, MB, GB).
+The Bytes
parameter is the number of bytes that you want to convert to a
+human-readable format.
Optional
Decimals: numberThe Decimals
parameter is an optional parameter that specifies the number
+of decimal places to round the result to. If not provided, it defaults to 2.
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Merges multiple objects of type Ts using the provided merge functions and built-in metadata.
+Rest
...Objects: TsGenerated using TypeDoc
The function Not
filters out files from the File
array based on the provided Pattern
+parameter.
The Pattern
parameter is of type Option["Exclude"]
. It represents the patterns
+or filters that will be used to exclude certain files from the Results
array.
The Results
parameter is expected to be an array of results from a plan. Each element
+in the array should be an array itself, with two elements. The first element represents the file
+name, and the second element represents the file content.
Generated using TypeDoc
Merges multiple objects of type Ts using the provided merge functions and built-in metadata.
+Rest
...Objects: TsGenerated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Optional
opts: StatOptions & { Fulfills with the {fs.Stats} object for the given path
.
v10.0.0
+Optional
opts: StatOptionsGenerated using TypeDoc
Generated using TypeDoc
Pipe
allows you to process files in a pipeline, making it easy to perform
+various operations on them.
To get started with Pipe
, follow these steps:
Install the Pipe
package using npm:
npm install -D -E @playform/pipe
+
+Create a new pipe instance using the following code in your Index.ts file:
+Index.ts
await new (await import("@playform/pipe")).default().In("./Input");
+
+With Pipe
, you can use the Pipe method to perform operations on files within
+the pipe. Here's an example of how to use it in your Index.ts:
Index.ts
await(
await(
await new (await import("@playform/pipe")).default().In("./Input")
).By("**/*.md")
).Pipe({
// Append some content to all of the text files
Wrote: (On) => (On.Buffer += "LICENSE [MIT]"),
});
+
+Pipe
provides default callbacks for file processing. These callbacks can be
+customized to suit your specific needs. Here are the default callbacks:
await new (await import("@playform/pipe")).default().Pipe({
// Read the file into a buffer
Read: async ({ Input }) => await fs.promises.readFile(Input, "utf-8"),
// Wrote the buffer into a file
Wrote: async ({ Buffer }) => Buffer,
// Passed the file through a check
Passed: async (On) => On && true,
// Failed processing the file
Failed: async ({ Input }) => `Error: Cannot process file ${Input}!`,
// Accomplished processing the file
Accomplished: async ({ Input, Output }) =>
`Processed ${Input} in ${Output}.`,
// Fulfilled the whole plan
Fulfilled: async ({ File }) =>
`Successfully processed a total of ${File} ${
File === 1 ? "file" : "files"
}.`,
// Changed the plan
Changed: async (Plan) => Plan,
});
+
+You can add multiple paths to your pipe by specifying an array as the Path
+variable:
Index.ts
await new (await import("@playform/pipe")).default().In([
"./Input",
"./Input2",
]);
+
+Pipe
will allow you to provide a map of paths for different input and output
+directories, making it easy to control where files are read from and written to:
Index.ts
await new (await import("@playform/pipe")).default().In(
new Map([["./Input", "./Output"]])
);
+
+You can filter files to exclude specific ones from your Pipe
. Filters can be
+an array of regular expressions or a single match. You can also use functions to
+match on file names:
Index.ts
await new (await import("@playform/pipe")).default().Not([
"File.txt",
(File: string) => File === "./Input/File.txt",
]);
+
+You can control the logging level by setting the Logger
parameter. The default
+value is 2
, but you can set it to 0
if you don't want to see debug messages:
Index.ts
new (await import("@playform/pipe")).default(0);
+
+See CHANGELOG.md for a history of changes to this component.
+Generated using TypeDoc
Generated using TypeDoc
The function By
takes in a file pattern or an array of file patterns, a set
+of input and output paths, and a map of results, and returns the updated map
+of results after matching the file patterns with the input paths.
File is either a single file pattern or an array of file
+patterns. These patterns are used to match files in the input directory
+(Input
) that will be processed.
Paths is an array of tuples that represent the input and +output paths. +Each tuple contains two elements: the input path and the output path.
+Map object that stores the mapping between the output file +paths and their corresponding input file paths. It is used to keep track of +the files that have been processed and their respective destinations.
+Generated using TypeDoc
The function converts a given number of bytes into a human-readable format with appropriate units +(e.g., KB, MB, GB).
+The Bytes
parameter is the number of bytes that you want to convert to a
+human-readable format.
Optional
Decimals: numberThe Decimals
parameter is an optional parameter that specifies the number
+of decimal places to round the result to. If not provided, it defaults to 2.
Generated using TypeDoc
The function By
takes a file pattern or an array of file patterns and returns a promise that
+resolves to the results of executing the patterns on the specified paths.
parameter is of type Pattern
or
+Pattern[]
. It represents the file or files that you want to search for. The Pattern
type is a
+string pattern that can include wildcards to match multiple files.
The function In
takes a path and updates the Plan.Paths
property with the input and output
+paths.
The function Not
takes a File
parameter and excludes it from the Plan.Results
array.
The function Pipe
is a TypeScript async function that takes an optional Action
+parameter and returns the result of calling Pipe with this.Plan
and Action.
Optional
Action: InterfaceThe Action parameter is an optional parameter that +specifies the execution strategy to be used in the Pipe function. It has a default value of +Default.Pipe, which means that if no Action parameter is provided when calling the Pipe +function, it will use the default execution strategy.
+Generated using TypeDoc
Generated using TypeDoc
Optional
AccomplishedAttaches a callback for actions that are accomplished.
+The file on which an action was accomplished.
+Optional
ChangedAttaches a callback for actions that result in changes to the plan.
+Optional
FailedAttaches a callback for handling failures in the Action.
+The input file being processed.
+The error encountered during execution.
+Optional
FulfilledAttaches a callback for the fulfillment of the Action.
+Optional
PassedAttaches a callback for actions that check if a file can pass through the pipe.
+Optional
ReadAttaches a callback for reading from a file.
+Optional
WroteAttaches a callback for writing to a file.
+Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Merges multiple objects of type Ts using the provided merge functions and built-in metadata.
+Rest
...Objects: TsGenerated using TypeDoc
Optional
ActionAction pipe configuration.
+Optional
CacheConfiguration for the target cache.
+{ Search: "./", Folder: "./Cache" }
+
+Optional
ExcludeCriteria for excluding files.
+Optional
FileFile patterns to be matched.
+Optional
LoggerDebugging level.
+2
+
+Optional
PathConfiguration for the target path(s).
+"./Target"
+
+Generated using TypeDoc
Represents the cache configuration.
+The number of files in the execution plan.
+biome-ignore lint/suspicious/noExplicitAny:
+The debugging level for the execution plan.
+The file currently being operated on.
+Mapping of input paths to output paths.
+Mapping of result paths to corresponding input paths.
+Generated using TypeDoc
The function Not
filters out files from the File
array based on the provided Pattern
+parameter.
The Pattern
parameter is of type Option["Exclude"]
. It represents the patterns
+or filters that will be used to exclude certain files from the Results
array.
The Results
parameter is expected to be an array of results from a plan. Each element
+in the array should be an array itself, with two elements. The first element represents the file
+name, and the second element represents the file content.
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Const
Generated using TypeDoc
Generated using TypeDoc
Const
Generated using TypeDoc
biome-ignore lint/complexity/useSimplifiedLogicExpression:
+Generated using TypeDoc
biome-ignore lint/complexity/useSimplifiedLogicExpression:
+Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
biome-ignore lint/suspicious/noExplicitAny:
+