unist utility to calculate the number of nodes in a 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, 'element')) // => 5
Calculate the number of nodes in tree
.
number
— Number of exclusive descendants passing test
in
tree
.
unist-util-source
— Get the source of a node or position
See contributing.md
in syntax-tree/.github
for ways to get
started.
See support.md
for ways to get help.
This project has a Code of Conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.