# classtrate

> A small utility for stripping unwanted classes from HTML strings.

Latest version **0.2.0** (published 2022-06-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install classtrate
pnpm add classtrate
yarn add classtrate
bun add classtrate
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2022-06-22 |
| First published | 2022-06-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 11.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Matt Pfeffer |
| Maintainers | mattpfeffer |

## Links

- npm: https://www.npmjs.com/package/classtrate
- Repository: https://github.com/mattpfeffer/classtrate
- Homepage: https://github.com/mattpfeffer/classtrate#readme
- Issues: https://github.com/mattpfeffer/classtrate/issues
- npm.io page: https://npm.io/package/classtrate

## Dependencies (2)

- [minimatch](https://npm.io/package/minimatch.md) ^5.1.0
- [typescript](https://npm.io/package/typescript.md) ^4.7.3

## Recent versions

- 0.2.0 (latest) — 2022-06-22
- 0.1.0 — 2022-06-17

## README

# 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()](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll)
so support for **ES2021** or higher is required.

_See [Caniuse](https://caniuse.com/mdn-javascript_builtins_string_replaceall)_

## Installation

Install the package:

```sh
# Using npm
npm install classtrate

# Using Yarn
yarn add classtrate
```

## Usage

Import and filter with a string or glob:

```js
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

---
_Source: https://npm.io/package/classtrate · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
