Files
30-seconds-of-code/node_modules/mdast-util-toc/lib/is-closing-heading.js
2019-08-20 15:52:05 +02:00

25 lines
594 B
JavaScript

/**
* @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;
}