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 🙏

© 2025 – Pkg Stats / Ryan Hefner

simplify-svg-path

v1.0.1

Published

Minimal path simplification library based on Skia's PathOps

Downloads

399

Readme

SimplifySvgPath

A minimal path simplification library based on Skia's PathOps

This is a fork of google/skia - specifically a stripped-down version focusing only on SVG path simplification.

About

This package provides a tiny WebAssembly build of Skia's powerful PathOps functionality, allowing you to simplify SVG paths by removing self-intersections and overlaps. The entire WASM bundle is only ~260KB, making it suitable for use in browsers and Node.js applications.

Installation

npm install simplify-svg-path

Features

  • Simple API - Easy-to-use functions for path simplification
  • 🎯 Tiny Size - Only ~260KB WASM bundle
  • 🚀 Fast - Powered by Skia's battle-tested PathOps
  • 🌐 Universal - Works in Node.js and browsers
  • 📦 Self-contained - No external dependencies

Quick Start

import SimplifySvgPathInit from 'simplify-svg-path';

async function main() {
  // Initialize the module
  const SimplifySvgPath = await SimplifySvgPathInit();

  // Convenience helper: takes an SVG path string, returns simplified string
  const simplified = SimplifySvgPath.simplifySvgPath('M0 0L100 100L100 0L0 100Z');
  console.log(simplified);

  // Or use the Path API for more control:
  const path = SimplifySvgPath.Path.MakeFromSVGString('M0 0L100 100L100 0L0 100Z');
  const simplifiedPath = path.simplify();
  if (simplifiedPath) {
    console.log(simplifiedPath.toSVGString());
  }
}

main();

API

simplifySvgPath(svgPathString)

A convenience function that takes an SVG path string and returns the simplified path string.

  • Parameters
    • svgPathString (string) - An SVG path data string
    • fillType (optional, enum) - Fill type for the path (default is Winding)
  • Returns: Simplified SVG path string, or null if the path is invalid

Fill Types

An enumeration with supported fill types:

  • Winding - Non-zero winding fill rule
  • EvenOdd - Even-odd fill rule

Path API

For more advanced usage:

  • Path.MakeFromSVGString(svgPath) - Create a path from SVG path data
  • Path.MakeFromSVGString(svgPath, fillType) - Create a path with specified fill type
  • path.toSVGString() - Convert path back to SVG string format
  • path.simplify() - Simplify the path by removing self-intersections and overlaps
  • path.getFillType() - Get the fill type of the path
  • path.setFillType(fillType) - Set the fill type of the path

TypeScript

TypeScript definitions are included in the package.

import SimplifySvgPathInit from 'simplify-svg-path';

const SimplifySvgPath = await SimplifySvgPathInit();
const result = SimplifySvgPath.simplifySvgPath('M0 0L10 10');

Repository Structure

.
├── skia/                         # Skia source code (submodule or fork)
│   └── modules/simplifypath/     # Our minimal PathOps module
│       ├── compile.sh            # Build script for the WASM module
│       ├── path_simplify_bindings.cpp
│       ├── pathops.js
│       ├── BUILD.gn
│       └── BUILD.bazel
├── simplify-svg-path/            # NPM package
│   ├── dist/                     # Build outputs (generated)
│   │   ├── simplifypath.js
│   │   ├── simplifypath.wasm
│   │   └── index.d.ts
│   ├── test.js
│   ├── package.json
│   ├── LICENSE
│   └── README.md
├── setup.sh                      # Setup script (sync dependencies)
├── build.sh                      # Build script (compile and copy)
└── README.md                     # This file

Setup

Prerequisites

  • Python 3.12+
  • Node.js 22+

Initial Setup

  1. Clone this repository:

    git clone https://github.com/hylimo/simplify-svg-path.git
    cd simplify-svg-path
  2. Run the setup script to sync Skia dependencies:

    ./setup.sh

    This will run python3 tools/git-sync-deps inside the Skia directory to fetch all required dependencies.

Building

To build the SimplifySvgPath module:

./build.sh

This will:

  1. Navigate to skia/modules/simplifypath/
  2. Run the compile script to build the WASM module
  3. Copy the generated simplifypath.js and simplifypath.wasm files to simplify-svg-path/dist/
  4. Copy this README to simplify-svg-path/

The built files will be available in simplify-svg-path/dist/.

Testing

After building, you can run the test suite:

cd simplify-svg-path
npm test

CI/CD

This repository includes GitHub Actions workflows:

  • .github/workflows/build.yml - Builds and tests on push/PR
  • .github/workflows/publish.yml - Publishes to NPM on releases

To publish a new version:

  1. Update the version in simplify-svg-path/package.json
  2. Create a new GitHub release
  3. The publish workflow will automatically build and publish to NPM

License

This project is based on Skia and is licensed under the BSD-3-Clause license, the same as Skia.

Original Skia license text:

Copyright (c) 2011 Google Inc. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

  * Redistributions of source code must retain the above copyright
    notice, this list of conditions and the following disclaimer.

  * Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimer in
    the documentation and/or other materials provided with the
    distribution.

  * Neither the name of the copyright holder nor the names of its
    contributors may be used to endorse or promote products derived
    from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

See LICENSE for the full Skia license.

Attribution

This is a fork and minimal build of google/skia. All credit for the PathOps implementation goes to the Skia team at Google.

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

Links