This package provides TypeScript type guards for Unist nodes.
npm install @accuser/unist-util-type-guards
import { isNode } from '@accuser/unist-util-type-guards';
const node = {
type: 'leaf',
value: 'Leaf'
};
isNode(node); // true, node is Node
isLiteral(node); // true, node is Literal
isParent(node); // false
This package exports the following identifiers:
There is no default export.
Test is the given value is a valid Literal
.
value
(unknown
)- value to check.
Returns true
if value
is a valid Literal
.
Test is a given value is a valid Parent
with exactly one child.
value
(unknown
)- value to check.
Returns true
if value
is a valid Parent
with exactly one child.
Test is a given value is a valid Parent
with more than one child.
value
(unknown
)- value to check.
Returns true
if value
is a valid Parent
with more than one child.
Test is a given value is a valid Node
.
value
(unknown
)- value to check.
Returns true
if value
is a valid Node
.
Test is a given value is a valid Parent
with no children.
value
(unknown
)- value to check.
Returns true
if value
is a valid Parent
with no children.
Test is a given value is a valid Parent
.
node
(unknown
)- value to check.
Returns true
if value
is a valid Parent
.
npm test