index.js
function getMatchFn(valueFn) {
  return function () {
    var len = arguments.length
    // Create a RegExp match object.
    var match = Array.prototype.slice.call(arguments, 0, -2)
      .reduce(function (map, g, i) {
        map[i] = g
        return map
      }, {index: arguments[len - 2], input: arguments[len - 1]})
    // Call the original function.
    return valueFn(match)
  }
}
function getMatchFn(valueFn) {
  return function () {
    var len = arguments.length
    // Create a RegExp match object.
    var match = Array.prototype.slice.call(arguments, 0, -2)
      .reduce(function (map, g, i) {
        map[i] = g
        return map
      }, {index: arguments[len - 2], input: arguments[len - 1]})
    // Call the original function.
    return valueFn(match)
  }
}
function getMatchFn ( valueFn ) { return function ( ) { var len = arguments . length // Create a RegExp match object. var match = Array . prototype . slice . call ( arguments , 0 , - 2 ) . reduce ( function ( map , g , i ) { map [ i ] = g return map } , { index : arguments [ len - 2 ] , input : arguments [ len - 1 ] } ) // Call the original function. return valueFn ( match ) } }
Return a function for use with string.replace that converts that
function's arguments into a RegExpMatchArray and calls the
value function.

@param {(match: RegExpMatchArray) => string} valueFn
@returns {(m: string, ...args: string[], i: number, s: string) => string}
Return a function for use with string . replace that converts that function s arguments into a RegExpMatchArray and calls the value function .