src/plugin.js
function replaceAll(source, name, oldStr, newStr) {
  const transformedSource = new ReplaceSource(source, name);
  const reTester = new RegExp(oldStr, 'g');
  let reResult = reTester.exec(source.source());

  if (reResult == null) {
    return source;
  }

  while (reResult != null) {
    transformedSource.replace(
      reResult.index,
      reTester.lastIndex - 1,
      newStr
    );

    reResult = reTester.exec(source.source());
  }

  return transformedSource;
}
function replaceAll(source, name, oldStr, newStr) {
  const transformedSource = new ReplaceSource(source, name);
  const reTester = new RegExp(oldStr, 'g');
  let reResult = reTester.exec(source.source());

  if (reResult == null) {
    return source;
  }

  while (reResult != null) {
    transformedSource.replace(
      reResult.index,
      reTester.lastIndex - 1,
      newStr
    );

    reResult = reTester.exec(source.source());
  }

  return transformedSource;
}
function replaceAll ( source , name , oldStr , newStr ) { const transformedSource = new ReplaceSource ( source , name ) ; const reTester = new RegExp ( oldStr , 'g' ) ; let reResult = reTester . exec ( source . source ( ) ) ; if ( reResult == null ) { return source ; } while ( reResult != null ) { transformedSource . replace ( reResult . index , reTester . lastIndex - 1 , newStr ) ; reResult = reTester . exec ( source . source ( ) ) ; } return transformedSource ; }
Takes a source, and a string to replace, and returns a ReplaceSource with
all the instances of that string replaced.
@param  {Source} source The original source
@param  {string} name   ReplaceSource has a `name` param in its constructor.
I don't actually know why.
@param  {string} oldStr The string to be replaced
@param  {string} newStr The string to replace it with
@return {ReplaceSource} A Source object with all of the replacements applied
Takes a source and a string to replace and returns a ReplaceSource with all the instances of that string replaced .