{"size": 733, "ext": "js", "max_stars_repo_path": "index.js", "max_stars_repo_name": "skylize/str-replace-loader", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "index.js", "max_issues_repo_name": "skylize/str-replace-loader", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "index.js", "max_forks_repo_name": "skylize/str-replace-loader", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.1923076923, "max_line_length": 104, "alphanum_fraction": 0.6466575716}

var querystring = require('querystring')

module.exports = function strReplaceLoader(source) {
  this.cacheable()

  var query = (typeof this.query === 'string')
    ? querystring.parse(this.query.substring(1))
    : this.query

  if ( !query.match
    || ( typeof query.match !== 'string'
      && !(query.match instanceof RegExp)
    )
  ) throw ('* str-replace-loader * missing or invalid option. `match` must be [String] or [RegExp]')

  if ( !query.replace
    || ( typeof query.replace !== 'string'
      && typeof query.replace !== 'function'
    )
  ) throw ('* str-replace-loader * missing or invalid option. `replace` must be [String] or [Function]')

  return source.toString()
    .replace(query.match, query.replace)
}
