<commit_before># tailored-keymapping
map objectKeys with given keyMap

## Examples
```JavaScript
import KeyMapping from 'tailored-keymapping'
const keyMapping = new KeyMapping({foo: 'bar'})

// basic flat keymap
let dataMapped = keyMapping.map({foo: 'foo_content'})
console.log(dataMapped) // => {bar: 'foo_content', foo: 'foo_content'}

// basic deep keymap
keyMapping.setKeymap({sub: {subsub: {foo: 'bar'}}})
dataMapped = keyMapping.map(
    {foo: 'foo_content'}, {
        keymapTree: ['sub', 'subsub']
    ,   onlyMappedVars: true
    }
)
console.log(dataMapped) // => {bar: 'foo_content'}

// custom functions
keyMapping.setKeymap({'newKey': (data)=>data.foo+'-'+data.bar})
dataMapped = keyMapping.map({foo: 'foo', bar: 'bar'}, {onlyMappedVars: true})
console.log(datMapped) // => {newKey: 'foo-bar'}

```

## Usage
```JavaScript
import TailoredKeymapping from 'tailored-keymapping';

// define keymap
const keymap = {
    'test': {
        'oldKey':   'newKey',
        'foo':      'bar',
        'abc':      'xyz'
        /**
         * custom mapping function
         *  called after mapping loop
         * @param  {object} data - mapped data object
         * @return {any} newValue - new value of the keyName
         * @return {array} [newKey,newValue] - new key/value pair
         */
        'keyName': function(data) {
            return ['newKey', newValue];
            // return newValue; // to use original keyname ('keyName')
        }
    }
};

// create instance
const keyMapping = new TailoredKeymapping(keymap);

// overwrite keymap after initialisation if needed
keyMapping.setKeymap(otherKeymap)

// process data with given options
let  mappedData = keyMapping.map(dataToMap, {
        'keymapTree': 'test', // key for subtree of keymap
        'onlyMappedVars': bool,
        /**
         * callback function
         *  mutate data afterwards
         * @param  {object} data - mapped data object (after custom functions)
         * @return {object} newData - mutated data object
         */
        callback: function(data) { // no arrowFn to prevent this-context
            data.dynamicVar = data.foo + data.abc;
            return data;
        }
     );

// you can also rely on default options and just pass a callback function
mappedData = keyMapping.map(payload, (data)=>newData);
```
__options__
```JavaScript
{// defaults
    onlyMappedVars: false, // bool - pass unmapped vars too?
    keymapTree: ['subtree', 'subsubtree'], // string || array
    callback: null // function
}
```

## TBD
* until v0.1.5
    * finish tests<commit_msg>no-semicolons + comma-first<commit_after># tailored-keymapping
map objectKeys with given keyMap

## Examples
```JavaScript
import KeyMapping from 'tailored-keymapping'
const keyMapping = new KeyMapping({foo: 'bar'})

// basic flat keymap
let dataMapped = keyMapping.map({foo: 'foo_content'})
console.log(dataMapped) // => {bar: 'foo_content', foo: 'foo_content'}

// basic deep keymap
keyMapping.setKeymap({sub: {subsub: {foo: 'bar'}}})
dataMapped = keyMapping.map(
    {foo: 'foo_content'}, {
        keymapTree: ['sub', 'subsub']
    ,   onlyMappedVars: true
    }
)
console.log(dataMapped) // => {bar: 'foo_content'}

// custom functions
keyMapping.setKeymap({'newKey': (data)=>data.foo+'-'+data.bar})
dataMapped = keyMapping.map({foo: 'foo', bar: 'bar'}, {onlyMappedVars: true})
console.log(datMapped) // => {newKey: 'foo-bar'}

```

## Usage
```JavaScript
import TailoredKeymapping from 'tailored-keymapping'

// define keymap
const keymap = {
    'test': {
        'oldKey':   'newKey'
    ,   'foo':      'bar'
    ,   'abc':      'xyz'
        /**
         * custom mapping function
         *  called after mapping loop
         * @param  {object} data - mapped data object
         * @return {any} newValue - new value of the keyName
         * @return {array} [newKey,newValue] - new key/value pair
         */
    ,   'keyName': function(data) {
            return ['newKey', newValue]
            // return newValue; // to use original keyname ('keyName')
        }
    }
}

// create instance
const keyMapping = new TailoredKeymapping(keymap)

// overwrite keymap after initialisation if needed
keyMapping.setKeymap(otherKeymap)

// process data with given options
let mappedData = keyMapping.map(dataToMap, {
       'keymapTree': 'test' // key for subtree of keymap
    ,  'onlyMappedVars': bool
        /**
         * callback function
         *  mutate data afterwards
         * @param  {object} data - mapped data object (after custom functions)
         * @return {object} newData - mutated data object
         */
    ,   callback: function(data) { // no arrowFn to prevent this-context
            data.dynamicVar = data.foo + data.abc;
            return data;
        }
     )

// you can also rely on default options and just pass a callback function
mappedData = keyMapping.map(payload, (data)=>newData)
```
__options__
```JavaScript
{// defaults
    onlyMappedVars: false, // bool - pass unmapped vars too?
    keymapTree: ['subtree', 'subsubtree'], // string || array
    callback: null // function
}
```

## TBD
* until v0.1.5
    * finish tests
{'fraction_non_alphanumeric': 0.13789085259273645, 'fraction_numerical': 0.0011652748106428432, 'mean_word_length': 2.783982365907421, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, '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': '691346', 'n_tokens_mistral': 1642, 'n_tokens_neox': 1613, 'n_words': 440}