'use strict';
import isFn from 'is-fn';
import rework from 'rework';
import reworkUrl from 'rework-plugin-url';
import through from 'through2';

function modifyUrls(filePath, fileContents, options) {
  return rework(fileContents)
    .use(reworkUrl(url => {
      if (url.indexOf('data:') === 0) {
        return url;
      }

      if (isFn(options.modify)) {
        url = options.modify(url, filePath);
      }

      if (typeof options.prepend === 'string') {
        url = options.prepend + url;
      }

      if (typeof options.append === 'string') {
        url += options.append;
      }

      return url;
    })).toString();
}

module.exports = function (options = {}) {
  return through.obj(function (file, enc, cb) {
    const modifiedContents = modifyUrls(file.path, file.contents.toString(), options);

    file.contents = new Buffer(modifiedContents);

    this.push(file);

    cb();
  });
};

@@ -138,16 +138,539 @@
 ugh2';%0A%0A
+/**%0A * Transforms URLs in files%0A * @param %7BString%7D filePath - path of CSS file that may be used by options.modify%0A * @param %7BString%7D fileContents - contents of the file at filePath%0A * @param %7BObject%7D %5Boptions%5D - rules for modifying URLs%0A * @param %7BString%7D %5Boptions.append%5D - URLs are appended with this value%0A * @param %7BFunction%7D %5Boptions.modify%5D - This function is always called before append and prepend.%0A * @param %7BString%7D %5Boptions.prepend%5D - URLs are prepended with this value%0A * @return %7BString%7D - transformed URL%0A */%0A
 function
@@ -1155,16 +1155,188 @@
 g();%0A%7D%0A%0A
+/**%0A * Pushes along files with transformed URLs%0A * @param %7BObject%7D options - same as described for modifyUrls function%0A * @return %7BStream%7D - file with transformed URLs%0A */%0A
 module.e

add JSDoc for functions