<commit_before># unist-util-remove

[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]

[**unist**][unist] utility to modify the given tree by removing all nodes that
pass the given test.

## Install

[npm][]:

```sh
npm install unist-util-remove
```

## Usage

```js
var u = require('unist-builder')
var remove = require('unist-util-remove')

var tree = u('root', [
  u('leaf', '1'),
  u('node', [
    u('leaf', '2'),
    u('node', [u('leaf', '3'), u('other', '4')]),
    u('node', [u('leaf', '5')])
  ]),
  u('leaf', '6')
])

// Remove all nodes of type `leaf`.
remove(tree, 'leaf')

console.dir(tree, {depth: null})
```

Yields: (note the parent of `5` is also removed, due to `opts.cascade`)

```js
{
  type: 'root',<commit_msg>Fix typo<commit_after># unist-util-remove

[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]

[**unist**][unist] utility to modify the given tree by removing all nodes that
pass the given test.

## Install

[npm][]:

```sh
npm install unist-util-remove
```

## Usage

```js
var u = require('unist-builder')
var remove = require('unist-util-remove')

var tree = u('root', [
  u('leaf', '1'),
  u('node', [
    u('leaf', '2'),
    u('node', [u('leaf', '3'), u('other', '4')]),
    u('node', [u('leaf', '5')])
  ]),
  u('leaf', '6')
])

// Remove all nodes of type `leaf`.
remove(tree, 'leaf')

console.dir(tree, {depth: null})
```

Yields: (note the parent of `5` is also removed, due to `options.cascade`)

```js
{
  type: 'root',
{'fraction_non_alphanumeric': 0.24452554744525548, 'fraction_numerical': 0.00851581508515815, 'mean_word_length': 4.711805555555555, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4454007', 'n_tokens_mistral': 661, 'n_tokens_neox': 636, 'n_words': 160}