dist/functions.js
function stripEmptyFirstAndLast(string) {
  let strings = string.split(/\r?\n/);
  // construct a small resuable function for trimming all initial whitespace
  let trimL = s => s.replace(/^([ \t]*)/, '');
  let trimR = s => s.replace(/([ \t]*)($)/, '$1');

  // the first line is usually a misnomer, discount it if it is only
  // whitespace
  if (!trimL(strings[0]).length) {
    strings.splice(0, 1);
  }

  // the same goes for the last line
  if (
  strings.length &&
  strings[strings.length - 1] &&
  !trimL(strings[strings.length - 1]).length)
  {
    strings.splice(strings.length - 1, 1);
  }

  return strings.join('\n');
}
function stripEmptyFirstAndLast(string) {
  let strings = string.split(/\r?\n/);
  // construct a small resuable function for trimming all initial whitespace
  let trimL = s => s.replace(/^([ \t]*)/, '');
  let trimR = s => s.replace(/([ \t]*)($)/, '$1');

  // the first line is usually a misnomer, discount it if it is only
  // whitespace
  if (!trimL(strings[0]).length) {
    strings.splice(0, 1);
  }

  // the same goes for the last line
  if (
  strings.length &&
  strings[strings.length - 1] &&
  !trimL(strings[strings.length - 1]).length)
  {
    strings.splice(strings.length - 1, 1);
  }

  return strings.join('\n');
}
function stripEmptyFirstAndLast ( string ) { let strings = string . split ( / \r?\n / ) ; // construct a small resuable function for trimming all initial whitespace let trimL = s => s . replace ( / ^([ \t]*) / , '' ) ; let trimR = s => s . replace ( / ([ \t]*)($) / , '$1' ) ; // the first line is usually a misnomer, discount it if it is only // whitespace if ( ! trimL ( strings [ 0 ] ) . length ) { strings . splice ( 0 , 1 ) ; } // the same goes for the last line if ( strings . length && strings [ strings . length - 1 ] && ! trimL ( strings [ strings . length - 1 ] ) . length ) { strings . splice ( strings . length - 1 , 1 ) ; } return strings . join ( '\n' ) ; }
A `preWork` functor for use with `measureIndents` that strips the first and
last lines from a given string if that string has nothing but whitespace. A
commonly desired functionality when working with multiline template strings

@param  {string} string the string to parse
@return {string} a modified string missing bits that make up the first and/
or last lines **if** either of these lines are comprised of only whitespace
A preWork functor for use with measureIndents that strips the first and last lines from a given string if that string has nothing but whitespace . A commonly desired functionality when working with multiline template strings