lib/log/format.js
/**
 * Split a string into shorter chunck
 *
 * @param {string} str The string to split
 * @param {number} maxLength The max length of each chunck
 * @return {Array} All the chuncks
 */
Split a string into shorter chunck
@param {string} str The string to split
@param {number} maxLength The max length of each chunck
@return {Array} All the chuncks
Split a string into shorter chunck @param { string } str The string to split @param { number } maxLength The max length of each chunck @return { Array } All the chuncks
function limitStringLength (str, maxLength) {
  const rgx = new RegExp(`.{0,${maxLength - 2}}(?:$|\\s|/)`, `g`)
  return str.split(`\n`).reduce((arr, s) => {
    const lns = s.match(rgx)
    return [...arr, ...(lns.length > 1 ? lns.slice(0, -1) : lns)]
  }, [])
}
function limitStringLength ( str , maxLength ) { const rgx = new RegExp ( ` ${ maxLength - 2 } \\ ` , ` ` ) return str . split ( ` \n ` ) . reduce ( ( arr , s ) => { const lns = s . match ( rgx ) return [ ... arr , ... ( lns . length > 1 ? lns . slice ( 0 , - 1 ) : lns ) ] } , [ ] ) }
Split a string into shorter chunck
 @param {string} str The string to split
 @param {number} maxLength The max length of each chunck
 @return {Array} All the chuncks
Split a string into shorter chunck @param { string } str The string to split @param { number } maxLength The max length of each chunck @return { Array } All the chuncks
// For some weird reason, match() add an extra empty string // at the end of the array. The only case it is relevant is // when the string is just `^\s*\n$` to preserve the line break. // In all other cases we need to get rid of it