index.js
function is(test, node, index, parent, context) {
  var hasParent = parent !== null && parent !== undefined
  var hasIndex = index !== null && index !== undefined
  var check = convert(test)

  if (
    hasIndex &&
    (typeof index !== 'number' || index < 0 || index === Infinity)
  ) {
    throw new Error('Expected positive finite index or child node')
  }

  if (hasParent && (!is(null, parent) || !parent.children)) {
    throw new Error('Expected parent node')
  }

  if (!node || !node.type || typeof node.type !== 'string') {
    return false
  }

  if (hasParent !== hasIndex) {
    throw new Error('Expected both parent and index')
  }

  return Boolean(check.call(context, node, index, parent))
}
function is(test, node, index, parent, context) {
  var hasParent = parent !== null && parent !== undefined
  var hasIndex = index !== null && index !== undefined
  var check = convert(test)

  if (
    hasIndex &&
    (typeof index !== 'number' || index < 0 || index === Infinity)
  ) {
    throw new Error('Expected positive finite index or child node')
  }

  if (hasParent && (!is(null, parent) || !parent.children)) {
    throw new Error('Expected parent node')
  }

  if (!node || !node.type || typeof node.type !== 'string') {
    return false
  }

  if (hasParent !== hasIndex) {
    throw new Error('Expected both parent and index')
  }

  return Boolean(check.call(context, node, index, parent))
}
function is ( test , node , index , parent , context ) { var hasParent = parent !== null && parent !== undefined var hasIndex = index !== null && index !== undefined var check = convert ( test ) if ( hasIndex && ( typeof index !== 'number' || index < 0 || index === Infinity ) ) { throw new Error ( 'Expected positive finite index or child node' ) } if ( hasParent && ( ! is ( null , parent ) || ! parent . children ) ) { throw new Error ( 'Expected parent node' ) } if ( ! node || ! node . type || typeof node . type !== 'string' ) { return false } if ( hasParent !== hasIndex ) { throw new Error ( 'Expected both parent and index' ) } return Boolean ( check . call ( context , node , index , parent ) ) }
Assert if `test` passes for `node`.   When a `parent` node is known the `index` of node.
Assert if test passes for node . When a parent node is known the index of node .