npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@toolx/svg

v1.0.6

Published

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

Downloads

3

Readme

ToolSvg Documentation

ToolSvg.js is a specialized component of the ToolX library, focused on SVG file manipulation and optimization. Leveraging the capabilities of the SVGO (SVG Optimizer) library, ToolSvg.js offers efficient and powerful means to process and optimize SVG files. This document details its functionalities, including how SVGO is utilized for SVG optimization, and provides usage examples both as a standalone tool and within a pipeline.

:::tip The ToolSvg class integrates the SVGO library, a renowned tool for SVG optimization. SVGO employs a variety of optimization techniques to reduce the size of SVG files and improve their performance. The integration with SVGO in ToolSvg allows users to take advantage of these optimizations within the ToolX environment, enhancing the efficiency and effectiveness of SVG processing. :::

Props

The ToolSvg class accepts options to configure its behavior and the SVG optimization process. These options are passed to the svgo library.

settings {#settings}

The settings option allows customization of various SVG optimization parameters. These are directly passed to the svgo library. Some of the settings include:

  • floatPrecision: Control the precision of floating point numbers.
  • transformPrecision: Control the precision of transformation expressions.

options {#options}

  • multipass: Enable or disable multiple optimization passes.

Usage

Direct Usage

import ToolSvg from '@toolx/svg';

// Example usage
const toolSvg = new ToolSvg({
    multipass: true,
    settings: {
        floatPrecision: 5,
        transformPrecision: 5,
        // Other svgo settings
    }
});

// Running the tool
toolSvg.run(options, inputFile, outputFile).then(() => {
    console.log('SVG optimization complete');
});

Usage in Pipeline

import { Pipeline } from '@toolx/core';
import ToolSvg from '@toolx/svg';
import ToolOther from '@toolx/other'; // Example of another tool

// Setting up the pipeline
const pipeline = new Pipeline();
pipeline.compose(
    new ToolOther(/* ToolOther options */),
    new ToolSvg({
        multipass: true,
        settings: {
            floatPrecision: 3,
            transformPrecision: 3,
            // Other svgo settings
        }
    })
);

// Running the pipeline
pipeline.run(options, inputPath, outputPath).then(() => {
    console.log('SVG processing complete');
});

External Library: svgo

ToolSvg utilizes the svgo library for SVG optimization. The settings provided in the settings option are used to configure svgo. For more information on svgo settings, refer to the svgo documentation.