<commit_before>parky [![Build Status][travis-badge]][travis-badge-url]
=====

Re-mapping object keys to new names

[![NPM][npm-badge]][npm-badge-url]

## Usage

Install with `npm install --save parky`.

```js
var parky = require('parky');
var user = {
  username: 'bob',
  email: '<EMAIL>'
};
var result = parky(user, {
  username: 'user_name'
});

console.log(result);
// { user_name: 'bob', email: '<EMAIL>' }
```

You can optionally pass a third parameter, a boolean, specifying
if you want it to throw an error if a mapping is invalid. Otherwise, the
default behavior is to ignore invalid key mappings.

```js
parky(user, { contactName: undefined }, true);
// Throws an error
```

## Test

```js
npm test
```

[travis-badge-url]: https://travis-ci.org/knownasilya/parky
[travis-badge]: https://travis-ci.org/knownasilya/parky.svg?branch=master
[npm-badge-url]: https://nodei.co/npm/parky/
[npm-badge]: https://nodei.co/npm/parky.png?downloads=true&stars=true<commit_msg>Add section on new constructor usage<commit_after>parky [![Build Status][travis-badge]][travis-badge-url]
=====

Re-mapping object keys to new names

[![NPM][npm-badge]][npm-badge-url]

## Usage

Install with `npm install --save parky`.

```js
var parky = require('parky');
var user = {
  username: 'bob',
  email: '<EMAIL>'
};
var result = parky(user, {
  username: 'user_name'
});

console.log(result);
// { user_name: 'bob', email: '<EMAIL>' }
```

You can optionally pass a third parameter, a boolean, specifying
if you want it to throw an error if a mapping is invalid. Otherwise, the
default behavior is to ignore invalid key mappings.

```js
parky(user, { contactName: undefined }, true);
// Throws an error
```

### Constructor Usage

```js
var user = { username: 'dragonx', email: '<EMAIL>' };
var parky = new Parky({
  keyMap: {
    username: 'user_name'
  },
  reuseObject: true,
  throwOnInvalid: true
});

var result = parky.map(user);
// { user_name: '..', email: '..' }

var alternate = parky.map(user, {
  email: 'user_email'
});
// { user_name: '..', user_email: '..' }
```

## Test

```js
npm test
```

[travis-badge-url]: https://travis-ci.org/knownasilya/parky
[travis-badge]: https://travis-ci.org/knownasilya/parky.svg?branch=master
[npm-badge-url]: https://nodei.co/npm/parky/
[npm-badge]: https://nodei.co/npm/parky.png?downloads=true&stars=true
{'fraction_non_alphanumeric': 0.18437900128040974, 'fraction_numerical': 0.0, 'mean_word_length': 4.339407744874715, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6551862', 'n_tokens_mistral': 898, 'n_tokens_neox': 862, 'n_words': 216}