1- 'use strict'
2-
3- var extend = require ( 'extend' )
4-
5- module . exports = contents
1+ import extend from 'extend'
62
73// Transform a list of heading objects to a markdown list.
8- function contents ( map , tight , prefix , ordered ) {
9- var table = { type : 'list' , ordered : ordered , spread : false , children : [ ] }
10- var minDepth = Number . POSITIVE_INFINITY
11- var index = - 1
4+ export function contents ( map , tight , prefix , ordered ) {
5+ const table = { type : 'list' , ordered, spread : false , children : [ ] }
6+ let minDepth = Number . POSITIVE_INFINITY
7+ let index = - 1
128
139 // Find minimum depth.
1410 while ( ++ index < map . length ) {
@@ -35,11 +31,11 @@ function contents(map, tight, prefix, ordered) {
3531}
3632
3733// Insert an entry into `parent`.
34+ // eslint-disable-next-line max-params
3835function insert ( entry , parent , tight , prefix , ordered ) {
39- var siblings = parent . children
40- var tail = siblings [ siblings . length - 1 ]
41- var index = - 1
42- var item
36+ const siblings = parent . children
37+ const tail = siblings [ siblings . length - 1 ]
38+ let index = - 1
4339
4440 if ( entry . depth === 1 ) {
4541 siblings . push ( {
@@ -65,13 +61,13 @@ function insert(entry, parent, tight, prefix, ordered) {
6561 entry . depth --
6662 insert ( entry , tail , tight , prefix , ordered )
6763 } else if ( parent . type === 'list' ) {
68- item = { type : 'listItem' , spread : false , children : [ ] }
64+ const item = { type : 'listItem' , spread : false , children : [ ] }
6965 siblings . push ( item )
7066 insert ( entry , item , tight , prefix , ordered )
7167 } else {
72- item = {
68+ const item = {
7369 type : 'list' ,
74- ordered : ordered ,
70+ ordered,
7571 spread : false ,
7672 children : [ ]
7773 }
@@ -95,8 +91,8 @@ function insert(entry, parent, tight, prefix, ordered) {
9591}
9692
9793function all ( children ) {
98- var result = [ ]
99- var index = - 1
94+ let result = [ ]
95+ let index = - 1
10096
10197 if ( children ) {
10298 while ( ++ index < children . length ) {
@@ -108,8 +104,6 @@ function all(children) {
108104}
109105
110106function one ( node ) {
111- var copy
112-
113107 if (
114108 node . type === 'link' ||
115109 node . type === 'linkReference' ||
@@ -119,7 +113,7 @@ function one(node) {
119113 return all ( node . children )
120114 }
121115
122- copy = extend ( { } , node )
116+ let copy = extend ( { } , node )
123117
124118 delete copy . children
125119 delete copy . position
0 commit comments