docs: function replace() {
    var select      = null;
    var content     = void 0;
    var cardinality = null;
    var apply       = null;
  
    var argLen = arguments.length;
    for (var i=0; i < argLen; i++) {
      var arg = arguments[i];
      if (i === 0) {
        select = arg;
        continue;
      }
      if (arg === null && content === void 0) {
        content = arg;
        continue;
      }
      var isString = (typeof arg === 'string' || arg instanceof String);
      if (isString && cardinality === null && /^[?.*+]$/.test(arg)) {
        cardinality = arg;
        continue;
      }
      if (apply === null || apply === undefined) {
        apply = arg.apply;
        if (apply != null) {
          content = arg.content;
          continue;
        }
      }
      if (content === void 0) {
        content = arg;
        continue;
      }
      break;
    }
  
    if (select === null) {
      throw new Error(
          'replace takes a select path, content or an apply function, and optional cardinality'
          );
    }
  
    var operation = {
      select:  select,
      content: content
    };
    if (cardinality != null) {
      operation.cardinality = cardinality;
    }
    if (apply != null) {
      operation.apply = apply;
    }
  
    return {replace: operation};
  }