0.0.1 • Published 2 years ago

@mdxvac/remark-utils v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@mdxvac/remark-utils

Type guards for remark.

Content

What is this?

This is an NPM package providing type guards for remark types.

When should I use this?

If you want to check unknown remark nodes for their type and use them in a type-safe manner.

Install

This package is ESM only. In Node.js (version 12.20+, 14.14+, or 16.0+), install with npm:

npm install -D @mdxvac/remark-utils

Use

import { isHeading } from '@mdxvac/remark-utils';

if (isHeading(node)) {
  // This is type-safe now
  if (node.depth > 2) {
    ...
  }
}