npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@accuser/mdast-util-type-guards

v1.2.0

Published

TypeScript type guards for `mdast` nodes.

Downloads

1

Readme

TypeScript Type Guards for Unist Nodes

This package provides TypeScript type guards for Mdast nodes.

Installation

npm install @accuser/mdast-util-type-guards

Usage

import { isText } from '@accuser/mdast-util-type-guards';

const value = {
  type: 'text',
  value: 'Hello, world!'
};

isNode(value); // true, value is Node
isLiteral(value); // true, value is Literal
isBlockContent(value); // false
isPhrasingContent(value); // true, value is PhrasingContent
isText(value); // true, value is Text

API

This package exports the identifiers:

There is no default export.

isAssociation(value: unknown): value is Association

Test if the given value is a valid Node with an Association(https://github.com/syntax-tree/mdast/#association).

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid Node with an Association(https://github.com/syntax-tree/mdast/#association).

isBlockContent(value: unknown): value is BlockContent

Test if the given value is a valid block content Node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid block content Node.

isBlockquote(value: unknown): value is Blockquote

Test if the given value is a valid Blockquote node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid Blockquote node.

isBreak(value: unknown): value is Break

Test if the given value is a valid Break node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid Break node.

isCode(value: unknown): value is Code

Test if the given value is a valid Code node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid Code node.

isDefinitionContent(value: unknown): value is DefinitionContent

Test if the given value is a valid definition content Node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid definition content Node.

isDefinition(value: unknown): value is Definition

Test if the given value is a valid Definition node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid Definition node.

isDelete(value: unknown): value is Delete

Test if a given value is a valid Delete node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid Delete node.

isEmphasis(value: unknown): value is Emphasis

Test if a given value is a valid Emphasis node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid Emphasis node.

isFootnoteDefinition(value: unknown): value is FootnoteDefinition

Test if a given value is a valid FootnoteDefinition node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid FootnoteDefinition node.

isFootnoteReference(value: unknown): value is FootnoteReference

Test if a given value is a valid FootnoteReference node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid FootnoteReference node.

isHeading(value: unknown): value is Heading

Test if a given value is a valid Heading node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid Heading node.

isHTML(value: unknown): value is HTML

Test if a given value is a valid Html node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid Html node.

isImage(value: unknown): value is Image

Test if a given value is a valid Image node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid Image node.

isImageReference(value: unknown): value is ImageReference

Test if a given value is a valid Image node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid Image node.

isInlineCode(value: unknown): value is InlineCode

Test if a given value is a valid InlineCode node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid InlineCode node.

isLinkReference(value: unknown): value is LinkReference

Test if a given value is a valid LinkReference node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid LinkReference node.

isLink(value: unknown): value is Link

Test if a given value is a valid Link node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid Link node.

isList(value: unknown): value is List

Test if a given value is a valid List node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid List node.

isListContent(value: unknown): value is ListContent

Test if a given value is a valid list content Node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid list content Node.

isListItem(value: unknown): value is ListItem

Test if a given value is a valid ListItem node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid ListItem node.

isLiteral(value: unknown): value is Literal

Test is a given value is a valid Literal node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid Unist literal value.

isNode(value: unknown): value is Node

Test if a given value is a valid Node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid Node.

isParagraph(value: unknown): value is Paragraph

Test if a given value is a valid Paragraph node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid Paragraph node.

isParent(value: unknown): value is Parent

Test is a given value is a valid Parent node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid Parent node.

isPhrasingContent(value: unknown): value is PhrasingContent

Test if the given value is a valid phrasing content Node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid phrasing content Node.

isReference(value: unknown): value is Reference

Test if a given value is a valid Node with a Reference.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid Node with a Reference.

isResource(value: unknown): value is Resource

Test if a given value is a valid Node with a Resource.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid Node with a Resource.

isRoot(value: unknown): value is Root

Test if a given value is a valid Root node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid Root node.

isRootContent(value: unknown): value is RootContent

Test if the given value is a valid root content Node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid root content Node.

isRowContent(value: unknown): value is RowContent

Test if the given value is a valid row content Node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid row content Node.

isStrong(value: unknown): value is Strong

Test if a given value is a valid Strong node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid Strong node.

isTable(value: unknown): value is Table

Test if a given value is a valid Table node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid Table node.

isTableContent(value: unknown): value is TableContent

Test if the given value is a valid table content Node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid table content Node.

isTableCell(value: unknown): value is TableCell

Test if a given value is a valid TableCell node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid TableCell node.

isTableRow(value: unknown): value is TableRow

Test if a given value is a valid TableRow node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid TableRow node.

isText(value: unknown): value is Text

Test if a given value is a valid Text node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid Text node.

isThematicBreak(value: unknown): value is ThematicBreak

Test if a given value is a valid ThematicBreak node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid ThematicBreak node.

isYaml(value: unknown): value is Yaml

Test if a given value is a valid Yaml node.

Parameters
  • value (unknown)
    • value to check.
Returns

Returns true if value is a valid Yaml node.

Tests

npm test

License

MIT