This package provides TypeScript type guards for Mdast nodes.
npm install @accuser/mdast-util-type-guards
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
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.
Test if the given value is a valid Node
with an Association
(https://github.com/syntax-tree/mdast/#association).
-
value
(unknown
)- value to check.
Returns true
if value
is a valid Node
with an Association
(https://github.com/syntax-tree/mdast/#association).
Test if the given value is a valid block content Node
.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid block content Node
.
Test if the given value is a valid Blockquote
node.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid Blockquote
node.
Test if the given value is a valid Break
node.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid Break
node.
Test if the given value is a valid Code
node.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid Code
node.
Test if the given value is a valid definition content Node
.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid definition content Node
.
Test if the given value is a valid Definition
node.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid Definition
node.
Test if a given value is a valid Delete
node.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid Delete
node.
Test if a given value is a valid Emphasis
node.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid Emphasis
node.
Test if a given value is a valid FootnoteDefinition
node.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid FootnoteDefinition
node.
Test if a given value is a valid FootnoteReference
node.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid FootnoteReference
node.
Test if a given value is a valid Heading
node.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid Heading
node.
Test if a given value is a valid Html
node.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid Html
node.
Test if a given value is a valid Image
node.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid Image
node.
Test if a given value is a valid Image
node.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid Image
node.
Test if a given value is a valid InlineCode
node.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid InlineCode
node.
Test if a given value is a valid LinkReference
node.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid LinkReference
node.
Test if a given value is a valid Link
node.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid Link
node.
Test if a given value is a valid List
node.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid List
node.
Test if a given value is a valid list content Node
.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid list content Node
.
Test if a given value is a valid ListItem
node.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid ListItem
node.
Test is a given value is a valid Literal
node.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid Unist literal value.
Test if a given value is a valid Node
.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid Node
.
Test if a given value is a valid Paragraph
node.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid Paragraph
node.
Test is a given value is a valid Parent
node.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid Parent
node.
Test if the given value is a valid phrasing content Node
.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid phrasing content Node
.
Test if a given value is a valid Node
with a Reference
.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid Node
with a Reference
.
Test if a given value is a valid Node
with a Resource
.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid Node
with a Resource
.
Test if a given value is a valid Root
node.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid Root
node.
Test if the given value is a valid root content Node
.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid root content Node
.
Test if the given value is a valid row content Node
.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid row content Node
.
Test if a given value is a valid Strong
node.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid Strong
node.
Test if a given value is a valid Table
node.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid Table
node.
Test if the given value is a valid table content Node
.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid table content Node
.
Test if a given value is a valid TableCell
node.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid TableCell
node.
Test if a given value is a valid TableRow
node.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid TableRow
node.
Test if a given value is a valid Text
node.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid Text
node.
Test if a given value is a valid ThematicBreak
node.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid ThematicBreak
node.
Test if a given value is a valid Yaml
node.
-
value
(unknown
)- value to check.
Returns true
if value
is a valid Yaml
node.
npm test