Skip to content
@toolx-dev

ToolX

Simplifying your daily file processing needs with a versatile library of Tools.

ToolX logo


npm package node compatibility NPM Downloads


ToolX

ToolX is structured around two core concepts: Tool and Pipeline. It offers a unified method for file processing through various methods such as media compression, transformation, etc. It enables the export of processed files. Pipelines in ToolX allow the integration of multiple tools where the output of one tool serves as the input for the next.

These are the tools you can use from the ToolX suite, each offering specialized functionalities to enhance and streamline your development projects.

  • 🧩 ToolCombine - npm Combines multiple images into composite images, assigning each to a specific RGB color channel.
  • 📊 ToolJSON - npm JSON file handling by efficiently rewriting them in a minified format.
  • ToolRemove - npm Adept at removing selected files, enhancing workflow efficiency.
  • 🌟 ToolSharp - npm Employs the sharp library for sophisticated and effective image transformation tasks.
  • 🖼️ ToolSvg - npm Specializing in SVG manipulation and optimization, with SVGO library's power.
  • 🗜️ ToolImagemin - npm Provides efficient image compression and optimization.

Demo

Edit ToolX - Basic demo

Quick CLI Usage

ToolX can be quickly used via the CLI with the npx command. For example:

npx @toolx/combine

Or, after installing a tool globally,

npm i @toolx/combine -g

you can directly use it in the CLI:

toolx-combine

In both methods, input files are taken from the current directory, and results are saved in the same directory. You can change the input folder, output folder, and options using the --options, -i, and -o parameters. More details can be found here.

CLI Wizard (Work in Progress)

ToolX also offers a CLI wizard for a guided usage of all library tools. This method can be accessed by using @toolx/cli and is currently under development, so future changes are expected.

Using ToolX in Code

ToolX can be installed using npm for direct code usage. For example:

import ToolSharp from "@toolx/sharp";

const tool = new ToolSharp(
    { api: { png: true }, ext: '.png'},
    `${process.cwd()}/in/**/*`,
    `${process.cwd()}/out/`
);
tool.run();

Details on creating a tool and further information are available here. Remember to refer to the input path pattern using fast-glob syntax, detailed here.

Combining Tools with Pipeline

Tools can be combined using Pipeline, where the output of one tool becomes the input for the next. For instance, a tool to transform an image format, followed by composing the image into a spritesheet, and finally compressing it. More about Pipeline can be found here.

Future Implementations

Plans include web-based usage and an app to support the project financially, expected by the first half of 2024.

For more information, visit the ToolX GitHub project page: ToolX on GitHub.

Overview

This section provides an overview of how to use ToolX's Tool and Pipeline components effectively.

  • Tool: Represents an individual utility focused on a specific task, such as file transformation, data processing, etc.
  • Pipeline: A sequence of Tool instances, arranged to form a workflow for processing data through multiple stages.

Using Tools

Each Tool in ToolX is a standalone module with its own set of functionalities.

Argument Structure for Tools

When invoking the run method of a ToolX tool, the arguments are typically as follows:

  1. Options: An object containing configuration settings for the tool. These settings vary depending on the tool's functionality.
  2. Input Path: The path to the files or data to be processed. This supports fast-glob patterns, allowing the tool to handle multiple files.
  3. Output Path: The destination path for the processed files or data.

Example: ToolSvg

ToolSvg is used for SVG file optimization. It leverages the SVGO library for this purpose.

import ToolSvg from '@toolx/svg';

// Initialize the tool with options
const toolSvg = new ToolSvg({
    settings: {
        // SVGO settings
        floatPrecision: 3,
        transformPrecision: 3,
        multipass: true,
    }
});

// Run the tool
toolSvg.run(options, inputPath, outputPath).then(() => {
    console.log('SVG optimization complete');
});

Example: Custom pipeline

In this example, we demonstrate the creation of a custom pipeline using the ToolX library. The pipeline integrates two tools: ToolSharp and ToolSvg.

import { Pipeline } from '@toolx/core';
import ToolSharp from '@toolx/sharp';
import ToolSvg from '@toolx/svg';

// Initialize the pipeline with optional configurations
const pipeline = new Pipeline();

// Compose the pipeline with desired tools
// ToolSharp for image processing and ToolSvg for SVG optimization
pipeline.compose(
    new ToolSharp({
        // ToolSharp specific options
    }),
    new ToolSvg({
        // ToolSvg specific options
    })
);

// Prepare options for pipeline execution
const executionOptions = {
    // General options for the entire pipeline
};

// Execute the pipeline with input and output paths
pipeline.run(executionOptions, inputPath, outputPath).then(() => {
    console.log('Custom pipeline processing complete');
});

Conclusion

ToolX provides a flexible and powerful system for handling various file manipulation and processing tasks. By understanding how to use individual Tool instances and combining them into Pipeline workflows, you can efficiently manage complex data processing tasks.

For more detailed information on individual tools and pipelines, refer to the respective documentation.

Pinned

  1. .github .github Public

Repositories

Showing 6 of 6 repositories
  • toolx Public

    ToolX provides a flexible and powerful system for handling various file manipulation and processing tasks.

    JavaScript 3 1 4 0 Updated Mar 23, 2024
  • ketargs Public

    Converts object properties into CLI-style flags and parameters

    JavaScript 0 MIT 0 0 0 Updated Jan 7, 2024
  • mena Public

    A customizable progress bar for console applications.

    TypeScript 0 MIT 0 0 0 Updated Dec 30, 2023
  • calime Public

    A Node.js class for stylish console text with colors, gradients, and multiple text styles. Easy chaining for seamless styling.

    TypeScript 0 MIT 0 0 0 Updated Dec 29, 2023
  • .github Public
    0 0 0 0 Updated Dec 22, 2023
  • mustargs Public

    CLI arguments parser in Node.js applications

    TypeScript 0 MIT 0 0 0 Updated Dec 22, 2023

People

This organization has no public members. You must be a member to see who’s a part of this organization.

Top languages

Loading…

Most used topics

Loading…