# @unified-latex/unified-latex-util-scan

> Functions for modifying a unified-latex AST

Latest version **1.8.4** (published 2026-04-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install @unified-latex/unified-latex-util-scan
pnpm add @unified-latex/unified-latex-util-scan
yarn add @unified-latex/unified-latex-util-scan
bun add @unified-latex/unified-latex-util-scan
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.8.4 |
| Published | 2026-04-03 |
| First published | 2022-05-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 31 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 127 |
| Author | Jason Siefken |
| Maintainers | siefkenj |
| Keywords | pegjs, latex, parser, prettier, unified-latex, unified |

## Links

- npm: https://www.npmjs.com/package/@unified-latex/unified-latex-util-scan
- Repository: https://github.com/siefkenj/unified-latex
- Homepage: https://github.com/siefkenj/unified-latex#readme
- Issues: https://github.com/siefkenj/unified-latex/issues
- npm.io page: https://npm.io/package/@unified-latex/unified-latex-util-scan

## Dependencies (4)

- [trie-prefix-tree](https://npm.io/package/trie-prefix-tree.md) ^1.5.1
- [@unified-latex/unified-latex-types](https://npm.io/package/@unified-latex/unified-latex-types.md) ^1.8.4
- [@unified-latex/unified-latex-util-match](https://npm.io/package/@unified-latex/unified-latex-util-match.md) ^1.8.4
- [@unified-latex/unified-latex-util-print-raw](https://npm.io/package/@unified-latex/unified-latex-util-print-raw.md) ^1.8.4

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.8.4 (latest) — 2026-04-03
- 1.8.0 — 2024-08-22
- 1.7.1 — 2024-03-19
- 1.7.0 — 2024-02-25
- 1.6.1 — 2024-02-18
- 1.6.0 — 2024-01-17
- 1.4.2 — 2023-09-30
- 1.4.0 — 2023-06-20
- 1.3.1 — 2023-03-05
- 1.3.0 — 2023-02-06
- 1.2.2 — 2022-12-15
- 1.2.1 — 2022-11-23
- 1.2.0 — 2022-11-13
- 1.1.0 — 2022-11-06
- 1.0.12 — 2022-06-03
- … 7 more at https://npm.io/package/@unified-latex/unified-latex-util-scan/versions

## README

<!-- DO NOT MODIFY -->
<!-- This file was autogenerated by build-docs.ts -->
<!-- Edit the docstring in index.ts and regenerate -->
<!-- rather than editing this file directly. -->
# unified-latex-util-scan

## What is this?

Functions to analyze `unified-latex` Abstract Syntax Tree (AST).

## When should I use this?

If you want to look for particular AST nodes in an array; useful when making plugins.

## Install

```bash
npm install @unified-latex/unified-latex-util-scan
```

This package contains both esm and commonjs exports. To explicitly access the esm export,
import the `.js` file. To explicitly access the commonjs export, import the `.cjs` file.

# Functions

## `prefixMatch(nodes, prefixes, options)`

Efficiently search for a large number of strings using a prefix-tree.
The longest match is returned.

```typescript
function prefixMatch(nodes: Ast.Node[], prefixes: string | string[] | { dump(spacer?: number): string; tree(): any; addWord(word: string): ReturnType<typeof Trie>; removeWord(word: string): ReturnType<typeof Trie>; ... 7 more ...; getSubAnagrams(word: string): string[]; }, options: { startIndex?: number; matchSubstrings?: boolean; assumeOneCharStrings?: boolean; }): { match: string; endNodeIndex: number; endNodePartialMatch: string | null; }
```

**Parameters**

| Param    | Type                              |
| :------- | :-------------------------------- |
| nodes    | `Ast.Node[]`                      |
| prefixes | <span color='gray'>Omitted</span> |
| options  | <span color='gray'>Omitted</span> |

## `scan(nodes, token, options)`

Scan `nodes` looking for the first occurrence of `token`.
If `options.onlySkipWhitespaceAndComments==true`, then the scan
will only skip whitespace/comment nodes.

```typescript
function scan(
  nodes: (Ast.Node | Ast.Argument)[],
  token: string | Ast.Node | Ast.Argument,
  options: {
    startIndex?: number;
    onlySkipWhitespaceAndComments?: boolean;
    allowSubstringMatches?: boolean;
  }
): number;
```

**Parameters**

| Param   | Type                              |
| :------ | :-------------------------------- |
| nodes   | `(Ast.Node \| Ast.Argument)[]`    |
| token   | <span color='gray'>Omitted</span> |
| options | <span color='gray'>Omitted</span> |

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