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

svg-fill

v2.0.4

Published

Fills all shapes of an SVG in single colour

Downloads

4,263

Readme

SVG Fill

Fills all shapes of an SVG in single colour.

Illustration of an SVG shape being filled with a color

:warning: Currently uses a naive solution that simply adds a fill attribute with the chosen fill color to the SVG element. For SVGs without styling attributes, such as ones to be composed into a symbol sprite, this should work fine. For anything else, the results will be hit and miss.

Usage

Requirements

  • Node.js >= 14

Installation

npm install --save svg-fill

API

Simple usage:

const SvgFill = require('svg-fill').default;

// Instantiante SvgFill with your chosen fill
// color:
const svgFill = new SvgFill('#FF0000');

// SvgFill expects SVG data as a string or Buffer
const originalSvgData = '<svg>....</svg>';

// Color your SVG!
const coloredSvgData = svgFill.fillSvg(originalSvgData);

Alternatively, SvgFill can provide a transform stream that you can pipe your SVG data into:

const fs = require('fs');
const SvgFill = require('svg-fill').default;

// Same setup as above
const svgFill = new SvgFill('#FF0000');

// E.g. read an SVG file, pipe it through SvgFill
// and save the result to another file:
fs.createReadStream('in.svg')
  .pipe(svgFill.fillSvgStream())
  .pipe(fs.createWriteStream('out.svg'));

Development

Setup

Clone this repo and npm install its dependencies:

git clone [email protected]:c1rrus/svg-fill.git

cd svg-fill/

npm install

Building

npm run build

This will transpile the TypeScript source code (in the src/) directory and output the results to dist/.

For development convenience, you can alternatively watch the source files and automatically trigger rebuilds when they change:

npm run watch

Running tests

npm run test

We use Jest for the tests. Each module's unit tests is located alongside its [module name].ts file as [module name].test.ts.

Linting

To help keep code consistent and avoid common gotchas, we lint our code using typescript-eslint. To run it do:

npm run lint

Commit message formatting

All commit messages must follow the Conventional Commits standard as we use automated release tools that rely on this. Commit messages are linted to check this and your CI builds will fail if your messages don't conform.

To make composing suitable commit messages easier, this repo is Commitizen friendly. We strongly recommend using commitizen rather than using git directly. To use it, simply run:

npm run commit

...and follow the prompts in your terminal.