@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:
isAsscoiation
isBlockquote
isBreak
isCode
isDefinition
isDelete
isEmphasis
isFootnoteDefinition
isFootnoteReference
isHeading
isHTML
isImage
isImageReference
isInlineCode
isLinkReference
isLink
isList
isListItem
isLiteral
isNode
isParagraph
isParent
isReference
isResource
isStrong
isTable
isTableCell
isTableRow
isText
isThematicBreak
isYaml
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