packages/vremark-toc/mdast-util-toc/lib/contents.js
function contents(map, tight) {
    var minDepth = Infinity;
    var index = -1;
    var length = map.length;
    var table;

    /*
     * Find minimum depth.
     */

    while (++index < length) {
        if (map[index].depth < minDepth) {
            minDepth = map[index].depth;
        }
    }

    /*
     * Normalize depth.
     */

    index = -1;

    while (++index < length) {
        map[index].depth -= minDepth - 1;
    }

    /*
     * Construct the main list.
     */

    table = list();

    /*
     * Add TOC to list.
     */

    index = -1;

    while (++index < length) {
        insert(map[index], table, tight);
    }

    return table;
}
function contents(map, tight) {
    var minDepth = Infinity;
    var index = -1;
    var length = map.length;
    var table;

    /*
     * Find minimum depth.
     */

    while (++index < length) {
        if (map[index].depth < minDepth) {
            minDepth = map[index].depth;
        }
    }

    /*
     * Normalize depth.
     */

    index = -1;

    while (++index < length) {
        map[index].depth -= minDepth - 1;
    }

    /*
     * Construct the main list.
     */

    table = list();

    /*
     * Add TOC to list.
     */

    index = -1;

    while (++index < length) {
        insert(map[index], table, tight);
    }

    return table;
}
function contents ( map , tight ) { var minDepth = Infinity ; var index = - 1 ; var length = map . length ; var table ; /*
     * Find minimum depth.
     */ while ( ++ index < length ) { if ( map [ index ] . depth < minDepth ) { minDepth = map [ index ] . depth ; } } /*
     * Normalize depth.
     */ index = - 1 ; while ( ++ index < length ) { map [ index ] . depth -= minDepth - 1 ; } /*
     * Construct the main list.
     */ table = list ( ) ; /*
     * Add TOC to list.
     */ index = - 1 ; while ( ++ index < length ) { insert ( map [ index ] , table , tight ) ; } return table ; }
Transform a list of heading objects to a markdown list.

@param {Array.<Object>} map - Heading-map to insert.
@param {boolean?} [tight] - Prefer tight list-items.
@return {Object} - List node.
Transform a list of heading objects to a markdown list .