Calculate the number of nodes in a Unist tree.
npm:
npm install unist-util-size
var h = require('hastscript')
var size = require('unist-util-size')
var tree = h('div', [
h('p', [
'Some ',
h('strong', 'importance'),
' and ',
h('em', 'emphasis'),
'.'
]),
h('pre', h('code', 'bar()'))
])
console.log(size(tree)) // => 11
console.log(size(tree.children[0])) // => 7
console.log(size(tree.children[0].children[0])) // => 0
Calculate the number of nodes in node
.
The result is excluding the given node itself.
See contributing.md
in syntax-tree/unist
for ways to get
started.
This organisation has a Code of Conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.