Package Exports
- unist-util-is
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-util-is) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
unist-util-is

Unist utility to check if a node passes a test. Useful when working with mdast or retext.
Installation
npm:
npm install unist-util-is
unist-util-is is also available for bower, component, and duo, and as an AMD, CommonJS, and globals module, uncompressed and compressed.
Usage
var is = require('.');
var node = {
'type': 'strong'
};
var parent = {
'type': 'paragraph',
'children': [node]
};
function test(node, n) {
return n === 5
}
is(null, node); // true
is('strong', node); // true
is('emphasis', node); // false
is(node, node) // true
is(node, {type: 'strong'}) // false
is(test, node); // false
is(test, node, 4, parent); // false
is(test, node, 5, parent); // true
API
is(test, node[, index, parent[, context]])
Utility to check if a node passes a test.
Parameters:
test
(Function
,string
, orNode
, optional) — When not given, return is returntrue
.Passing a
string
is equal to passingfunction (node) {return node.type === test}
.Passing a
node
is equal to passingfunction (node) {return node === test}
.node
(Node
) — Node to test;index
(number
, optional) — Position ofnode
inparent
;parent
(Node
, optional) — Parent ofnode
;context
(*
, optional) — Parent ofnode
.
Returns: boolean
, whether test
passed.
function test(node[, index, parent])
Parameters:
node
(Node
) — Node to test;index
(number
?) — Position ofnode
inparent
.parent
(Node
?) — Parent ofnode
.
Context: The to is
given context.
Returns: boolean?
, whether this iteration passes.