Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

classtrate

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

classtrate

A small utility for stripping unwanted classes from HTML strings.

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

classtrate

A small utility for stripping unwanted classes from HTML strings ✂️

When do you need this?

Working with genereated HTML can be a pain; you don't always have control of the output and when you need to use that markup somewhere else you often have to perform some clean up first. This library allows you to filter specific vendor generated classes (or IDs) to make working with HTML strings easier. Some possible use cases:

  • Reducing document size prior to HTML minification
  • Preventing class collisions and other conflicts
  • Cleaning output for user operations like copying and pasting

Minimum Requirements

This library makes use of String.prototype.replaceAll() so support for ES2021 or higher is required.

See Caniuse

Installation

Install the package:

# Using npm
npm install classtrate

# Using Yarn
yarn add classtrate

Usage

Import and filter with a string or glob:

import { filter } from 'classtrate'; // require() also supported

const source = '<h1 class="br-fGy7jw my-class">My Heading</h1>'; // String of janky HTML
const pattern = 'br-*'; // or []

const output = filter(source, pattern); // <h1 class="my-class">My Heading</h1>

Features

Supports these glob features:

  • Brace Expansion
  • Extended glob matching
  • "Globstar" ** matching

FAQs

Package last updated on 22 Jun 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc