TypeScript type guards for `unist` nodes.
npm install @accuser/unist-util-type-guardsThis package provides TypeScript type guards for Unist nodes.
``sh`
npm install @accuser/unist-util-type-guards
`ts
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:
- isLiteral
- isMonoparous
- isMultiparous
- isNode
- isNulliparous
- isParent
There is no default export.
Test is the given value is a valid Literal.
###### Parameters
* value (unknown)
- value to check.
###### Returns
Returns true if value is a valid Literal.
Test is a given value is a valid Parent with exactly one child.
###### Parameters
* value (unknown)
- value to check.
###### Returns
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.
###### Parameters
* value (unknown)
- value to check.
###### Returns
Returns true if value is a valid Parent with more than one child.
Test is a given value is a valid Node.
###### Parameters
* value (unknown)
- value to check.
###### Returns
Returns true if value is a valid Node.
Test is a given value is a valid Parent with no children.
###### Parameters
* value (unknown)
- value to check.
###### Returns
Returns true if value is a valid Parent with no children.
Test is a given value is a valid Parent.
###### Parameters
* node (unknown)
- value to check.
###### Returns
Returns true if value is a valid Parent.
`sh``
npm test