src/__mocks__/data.js
function padData(data) {
  let result = []
  for (let [ targetString, ...rest ] of data) {
    // We are testing for up to 3 spaces and for empty strings we’ll use this
    // condition to prevent duplicates.
    if (targetString === '') {
      result.push([ ' ', ...rest ])
      result.push([ '  ', ...rest ])
      result.push([ '   ', ...rest ])
      continue
    }
    // Other strings, add up to 3 spaces to the left and right.
    for (let i = 1; i <= 3; i++) {
      const LENGHT = targetString.length
      // Add spaces to the right.
      result.push([ pad(targetString, LENGHT + i), ...rest ])
      // Add spaces to the left.
      result.push([ pad(LENGHT + i, targetString), ...rest ])
    }
  }
  return result
}
function padData(data) {
  let result = []
  for (let [ targetString, ...rest ] of data) {
    // We are testing for up to 3 spaces and for empty strings we’ll use this
    // condition to prevent duplicates.
    if (targetString === '') {
      result.push([ ' ', ...rest ])
      result.push([ '  ', ...rest ])
      result.push([ '   ', ...rest ])
      continue
    }
    // Other strings, add up to 3 spaces to the left and right.
    for (let i = 1; i <= 3; i++) {
      const LENGHT = targetString.length
      // Add spaces to the right.
      result.push([ pad(targetString, LENGHT + i), ...rest ])
      // Add spaces to the left.
      result.push([ pad(LENGHT + i, targetString), ...rest ])
    }
  }
  return result
}
function padData ( data ) { let result = [ ] for ( let [ targetString , ... rest ] of data ) { // We are testing for up to 3 spaces and for empty strings we’ll use this // condition to prevent duplicates. if ( targetString === '' ) { result . push ( [ ' ' , ... rest ] ) result . push ( [ '  ' , ... rest ] ) result . push ( [ '   ' , ... rest ] ) continue } // Other strings, add up to 3 spaces to the left and right. for ( let i = 1 ; i <= 3 ; i ++ ) { const LENGHT = targetString . length // Add spaces to the right. result . push ( [ pad ( targetString , LENGHT + i ) , ... rest ] ) // Add spaces to the left. result . push ( [ pad ( LENGHT + i , targetString ) , ... rest ] ) } } return result }
Used to add spaces around the pattern.
Used to add spaces around the pattern .