Rewrite key in all targets (from index if necessary) to replace old with new
2838
def rewrite_refs( targets, old,new, index, key='refs', single_ref=False ):
    """"""
    for parent in targets:
        if not isinstance( parent, dict ):
            try:
                parent = index[parent]
            except KeyError, err:
                continue 
        rewrite_references( parent[key], old, new, single_ref=single_ref )
794874
def rename_key(d: Dict[str, Any], old: str, new: str) -> None:
    
    d[new] = d.pop(old)
1034093
def replace_keys(record: Mapping, key_map: Mapping) -> dict:
    """"""

    return {key_map[k]: v for k, v in record.items() if k in key_map}
1281014
def delete_from_index(self, key):
        ""
        old_value = self.data[key]
        keys = set(old_value.keys()).intersection(self.indexes.keys())
        for index_name in keys:
            if old_value[index_name] in self.indexes[index_name]:
                del self.indexes[index_name][old_value[index_name]]
479241
function replace(obj, prefix) {
    const retObj = {}
    const dot = prefix ? '.' : ''
    for (const key in obj) {
      if (key === 'description') {
        retObj[key] = obj[key]
      } else if (key === 'script') {
        retObj[key] = series(
          `cd ${relativeDir}`,
          `npm start ${prefix}`,
          `cd "${relativeReturn}"`,
        )
      } else if (typeof obj[key] === 'string') {
        retObj[key] = series(
          `cd ${relativeDir}`,
          `npm start ${prefix}${dot}${key}`,
        )
      } else {
        retObj[key] = Object.assign(
          {},
          replace(obj[key], `${prefix}${dot}${key}`, `cd "${startingDir}"`),
        )
      }
    }
    return retObj
  }
647385
def replace_keys(d, keymap, force_snake_case):
    
    return {
        to_snake(keymap.get(k, k)) if force_snake_case else keymap.get(k, k):
            v for k, v in d.items()
    }
74173
def reindex(self, new_index_name: str, identifier_key: str, **kwargs) -> 'ElasticIndex':
        
        if 'url' not in kwargs:
            kwargs['url'] = self.url
        if 'doc_type' not in kwargs:
            kwargs['doc_type'] = self.doc_type
        if 'mapping' not in kwargs:
            kwargs['mapping'] = self.mapping
        new_index = ElasticIndex(new_index_name, **kwargs)

        for results in self.scroll(size=500):
            new_index.bulk(results, identifier_key)
        return new_index
775314
function(key, replacements) {
        var message = messageMap[key];

        if (replacements) {
            message = util.replaceText(message, replacements);
        }

        return message;
    }
477203
function replaceLink(matched, index, original) {
    if (matched.includes('|')) {
        matched = matched.split('|');
        matched[0] = matched[0].replace(/[^\w\s]/gi, '').split(' ')[1].trim();
        matched[1] = matched[1].replace(/[^\w\s]/gi, '').trim();
        return `[${matched[1]}](${matched[0]})`;
    }
	const matchedString = matched.match(/\s.+\b/, matched)[0].trim();
    return `[${matchedString}](${matchedString.split(' ').join('-')})`;
}
20397
def pipe(self, target):
        
        return self._replace(recver=self.recver.pipe(target))
1022991
function(key) {
    if (!key.match(suffixRegex)) {
      return key + '2';
    }

    return key.replace(suffixRegex, function(suffix) {
      return Number(suffix) + 1;
    });
  }
1248417
def patch(attrs, updates):
    """"""
    orig = {}
    for attr, value in updates:
        orig[attr] = attrs[attr]
        attrs[attr] = value
    return orig
1174002
function replacer(key, value) {
  if (value instanceof Buffer)
    return value.toString('base64');
  // eslint-disable-next-line valid-typeof
  if (typeof value === 'bigint')
    return value.toString();
  return value;
}
223490
def rename_index(self, *args):
        '''
        '''
        if len(args) == 1:
            new_indices = args[0]
            old_indices =force_list(self.indices.keys())
        else:
            old_indices, new_indices = args
            old_indices, single = convert_index_to_keys(self.indices, old_indices)
            if single:
                old_indices, new_indices = [old_indices], [new_indices]

        if len(new_indices) != len(old_indices):
            raise ValueError('Length of update indices (%s) does not match '
                             'existing indices (%s)' %
                             (len(new_indices), len(old_indices)))

        map(MI_check_index_name, new_indices)

        if len(new_indices) != len(set(new_indices)):
            raise ValueError('New indices names are not unique: %s' % (new_indices,))

        od_replace_key(self.indices, old_indices, new_indices, multi=True)
1245850
def rename(self, old_key, new_key):
        
        return lib.zhash_rename(self._as_parameter_, old_key, new_key)
652314
def recursive_replace(list_, target, repl=-1):
    
    """
    repl_list = [
        recursive_replace(item, target, repl) if isinstance(item, (list, np.ndarray)) else
        (repl if item == target else item)
        for item in list_
    ]
    return repl_list
396981
def replace(self, target):
        
        if sys.version_info < (3, 3):
            raise NotImplementedError("replace() is only available "
                                      "with Python 3.3 and later")
        if self._closed:
            self._raise_closed()
        self._accessor.replace(self, target)