Package Exports
- unist-builder
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (unist-builder) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
unist-builder
Helper for creating unist trees with hyperscript-like syntax.
Example
var u = require('unist-builder');
u('root', [
u('subtree', { id: 1 }),
u('subtree', { id: 2 }, [
u('node', [
u('leaf', 'leaf-1'),
u('leaf', 'leaf-2')
]),
u('leaf', { id: 3 }, 'leaf-3')
])
])
results in the following tree:
{
"type": "root",
"children": [
{
"type": "subtree",
"id": 1
},
{
"type": "subtree",
"id": 2,
"children": [
{
"type": "node",
"children": [
{
"type": "leaf",
"value": "leaf-1"
},
{
"type": "leaf",
"value": "leaf-2"
}
]
},
{
"type": "leaf",
"id": 3,
"value": "leaf-3"
}
]
}
]
}
API
u(type, [props], [value])
type
: String
props
: Object
value
: String
Creates a node from props
and optional value
.
u(type, [props], children)
type
: String
props
: Object
children
: Array
Creates a node from props
and given child nodes.
Install
npm install unist-builder
License
MIT