uglifycss-lib.js
function collectComments(content, comments) {

    const table = []

    let from = 0
    let end

    while (true) {

        let start = content.indexOf('/*', from)

        if (start > -1) {

            end = content.indexOf('*/', start + 2)

            if (end > -1) {
                comments.push(content.slice(start + 2, end))
                table.push(content.slice(from, start))
                table.push('/*___PRESERVE_CANDIDATE_COMMENT_' + (comments.length - 1) + '___*/')
                from = end + 2

            } else {
                // unterminated comment
                end = -2
                break
            }

        } else {
            break
        }
    }

    table.push(content.slice(end + 2))

    return table.join('')
}
function collectComments(content, comments) {

    const table = []

    let from = 0
    let end

    while (true) {

        let start = content.indexOf('/*', from)

        if (start > -1) {

            end = content.indexOf('*/', start + 2)

            if (end > -1) {
                comments.push(content.slice(start + 2, end))
                table.push(content.slice(from, start))
                table.push('/*___PRESERVE_CANDIDATE_COMMENT_' + (comments.length - 1) + '___*/')
                from = end + 2

            } else {
                // unterminated comment
                end = -2
                break
            }

        } else {
            break
        }
    }

    table.push(content.slice(end + 2))

    return table.join('')
}
function collectComments ( content , comments ) { const table = [ ] let from = 0 let end while ( true ) { let start = content . indexOf ( '/*' , from ) if ( start > - 1 ) { end = content . indexOf ( '*/' , start + 2 ) if ( end > - 1 ) { comments . push ( content . slice ( start + 2 , end ) ) table . push ( content . slice ( from , start ) ) table . push ( '/*___PRESERVE_CANDIDATE_COMMENT_' + ( comments . length - 1 ) + '___*/' ) from = end + 2 } else { // unterminated comment end = - 2 break } } else { break } } table . push ( content . slice ( end + 2 ) ) return table . join ( '' ) }
collectComments collects all comment blocks and return new content with comment placeholders

@param {string} content - CSS content
@param {string[]} comments - Global array of extracted comments

@return {string} Processed CSS
collectComments collects all comment blocks and return new content with comment placeholders