/**
 * @author Titus Wormer
 * @copyright 2015 Titus Wormer
 * @license MIT
 * @module mdast:toc
 * @fileoverview Generate a Table of Contents (TOC) from a given Markdown file.
 */

/* Expose. */
module.exports = isClosingHeading;

/* Constants. */
var HEADING = 'heading';

/**
 * Check if `node` is the next heading.
 *
 * @param {Node} node - Node to check.
 * @param {number} depth - Depth of opening heading.
 * @return {boolean} - Whether znode is a closing heading.
 */
function isClosingHeading(node, depth) {
    return depth && node && node.type === HEADING && node.depth <= depth;
}
