<commit_before># d3fc-rebind

Utilities for copying methods from one d3 component to another in a configurable way

[Main d3fc package](https://github.com/ScottLogic/d3fc)

# Installation

```bash
npm install d3fc-rebind
```

# API

#### **rebind**(*source*, *target*, *...names*)

Provides the same functionality as `[d3.rebind](https://github.com/mbostock/d3/wiki/Internals#rebind)` -

> Copies the methods with the specified `names` from `source` to `target`, and returns `target`. Calling one of the named methods on the target object invokes the same-named method on the source object, passing any arguments passed to the target method, and using the source object as the this context. If the source method returns the source object, the target method returns the target object (“setter” method); otherwise, the target method returns the return value of the source method (“getter” mode). The rebind operator allows inherited methods (mix-ins) to be rebound to a subclass on a different object.

#### **rebindAll**(*source*, *target*, *[...transforms]*)

Provides the same functionality as [`rebind`](#rebind) but copies all properties found on `source` to `target`. Optionally, property name transforms can be specified. These receive a source property name and return either the target property name or a falsey value to indicate the property should not be copied.

As well as creating transforms manually, you can also make use of -

* `exclude(...names)` - exclude a set of property names or regexes
* `include(...names)` - include only the set of property names or regexes
* `map({ sourceName: targetName, ... })` - map the specified properties
* `prefix(str)` - prefix all property names with str<commit_msg>docs: break out transform methods and fix link<commit_after># d3fc-rebind

Utilities for copying methods from one d3 component to another in a configurable way

[Main d3fc package](https://github.com/ScottLogic/d3fc)

# Installation

```bash
npm install d3fc-rebind
```

# API

#### **rebind**(*source*, *target*, *...names*)

Provides the same functionality as [`d3.rebind`](https://github.com/mbostock/d3/wiki/Internals#rebind) -

> Copies the methods with the specified `names` from `source` to `target`, and returns `target`. Calling one of the named methods on the target object invokes the same-named method on the source object, passing any arguments passed to the target method, and using the source object as the this context. If the source method returns the source object, the target method returns the target object (“setter” method); otherwise, the target method returns the return value of the source method (“getter” mode). The rebind operator allows inherited methods (mix-ins) to be rebound to a subclass on a different object.

#### **rebindAll**(*source*, *target*, *[...transforms]*)

Provides the same functionality as `rebind` but copies **all** properties found on `source` to `target`. Optionally, property name transforms can be specified. These receive a source property name and return either the target property name or a falsey value to indicate the property should not be copied.

As well as creating transforms manually, the following may be useful (especially if you're not able to use ES2015 features) -

#### **exclude**(*...names*)

Exclude a set of property `names`. Names can be specified as a `string` or `RegExp`.

### **include**(*...names*)

Include only the set of property `names`. Names can be specified as a `string` or `RegExp`.

### **map**(*mappings*)

Map the keys of `mappings` using their corresponding values e.g. `{ 'targetName': 'sourceName' }`.

### **prefix**(*str*)

Prefix all property names with `str`.
{'fraction_non_alphanumeric': 0.10597826086956522, 'fraction_numerical': 0.004891304347826087, 'mean_word_length': 4.7515625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5261857', 'n_tokens_mistral': 990, 'n_tokens_neox': 962, 'n_words': 486}