src/parseImport.js
function findLeadingComments(comments, index, beginIndex, first) {
    const leadComments = [];
    if (first && ignoreComment.test(comments[index].raw)) {
        return leadComments;
    }
    let backIndex = index - 1;
    while (backIndex >= beginIndex &&
        (comments[backIndex].loc.end.line + 1 === comments[backIndex + 1].loc.start.line
            || comments[backIndex].loc.end.line === comments[backIndex + 1].loc.start.line)) {
        if (first && ignoreComment.test(comments[backIndex].raw)) {
            break;
        }
        backIndex -= 1;
    }
    for (let ind = backIndex + 1; ind <= index; ind += 1) {
        leadComments.push(comments[ind]);
    }
    return leadComments;
}
function findLeadingComments(comments, index, beginIndex, first) {
    const leadComments = [];
    if (first && ignoreComment.test(comments[index].raw)) {
        return leadComments;
    }
    let backIndex = index - 1;
    while (backIndex >= beginIndex &&
        (comments[backIndex].loc.end.line + 1 === comments[backIndex + 1].loc.start.line
            || comments[backIndex].loc.end.line === comments[backIndex + 1].loc.start.line)) {
        if (first && ignoreComment.test(comments[backIndex].raw)) {
            break;
        }
        backIndex -= 1;
    }
    for (let ind = backIndex + 1; ind <= index; ind += 1) {
        leadComments.push(comments[ind]);
    }
    return leadComments;
}
function findLeadingComments ( comments , index , beginIndex , first ) { const leadComments = [ ] ; if ( first && ignoreComment . test ( comments [ index ] . raw ) ) { return leadComments ; } let backIndex = index - 1 ; while ( backIndex >= beginIndex && ( comments [ backIndex ] . loc . end . line + 1 === comments [ backIndex + 1 ] . loc . start . line || comments [ backIndex ] . loc . end . line === comments [ backIndex + 1 ] . loc . start . line ) ) { if ( first && ignoreComment . test ( comments [ backIndex ] . raw ) ) { break ; } backIndex -= 1 ; } for ( let ind = backIndex + 1 ; ind <= index ; ind += 1 ) { leadComments . push ( comments [ ind ] ) ; } return leadComments ; }
return leading comment list
@param {*list<comment>} comments
@param {*} the last match leading comment of one import
@param {*} beginIndex the potential begin of the comment index of the import
@param {*} first whether first import
return leading comment list