Skip to content

Why can unist-util-filter filter only with inequality but not equality? #133

Answered by wooorm
ooker777 asked this question in Q&A
Discussion options

You must be logged in to vote

That is not what filter does. https://github.com/syntax-tree/unist-util-filter#what-is-this (deep link to readme).

As christian mentioned a couple times, you want to walk the tree, traverse the tree, with unist-util-visit:

const headings = []

visit(tree, function (node) {
  if (node.type === 'heading') {
    headings.push(node)
  }
})

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@ooker777
Comment options

@wooorm
Comment options

Answer selected by ooker777
@ooker777
Comment options

@wooorm
Comment options

@ooker777
Comment options

@wooorm
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants