# @naveen-bharathi/recursive-object-key-filter

> Filter / Remove keys from object recursively.

Latest version **1.0.8** (published 2022-08-23) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @naveen-bharathi/recursive-object-key-filter
pnpm add @naveen-bharathi/recursive-object-key-filter
yarn add @naveen-bharathi/recursive-object-key-filter
bun add @naveen-bharathi/recursive-object-key-filter
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2022-08-23 |
| First published | 2020-05-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | naveen-bharathi |
| Keywords | recursive, object, key, filter, remover, object-key-filter, recursive-object-key-filter, object-key, object-filter, key-filter |

## Links

- npm: https://www.npmjs.com/package/@naveen-bharathi/recursive-object-key-filter
- npm.io page: https://npm.io/package/@naveen-bharathi/recursive-object-key-filter

## Recent versions

- 1.0.8 (latest) — 2022-08-23
- 1.0.7 — 2022-08-23
- 1.0.6 — 2022-08-23
- 1.0.5 — 2020-06-03
- 1.0.4 — 2020-06-03
- 1.0.3 — 2020-06-03
- 1.0.1 — 2020-06-03
- 1.0.0 — 2020-05-28
- 0.0.1 — 2020-05-28

## README

# ⚠️ This package has been deprecated in favour of [recursive-key-filter](https://www.npmjs.com/package/recursive-key-filter)


## recursive-object-key-filter

Filter / Remove keys from object recursively.

## Installation

if you are using npm, run
```
npm install --save @naveen-bharathi/recursive-object-key-filter
```

or

if you are using yarn package manager, run
```
yarn add @naveen-bharathi/recursive-object-key-filter
```

## Example

Remove the key **`__typename`** from an object.

```javascript
import filter from '@naveen-bharathi/recursive-object-key-filter'; // ES6
// or
const filter = require('@naveen-bharathi/recursive-object-key-filter'); // ES5

const dirtyObject = {
  'id': '12345',
  'name': 'javascript',
  '__typename': 'language'
};

console.log(dirtyObject);
// outputs ==> { 'id': '12345', 'name': 'javascript', '__typename': 'language' }

const cleanObject = filter(dirtyObject, ['__typename']);

console.log(cleanObject);
// outputs ==> { 'id': '12345', 'name': 'javascript'}
```

Remove any of the keys **`__typename`** , **`id`** from an object.

```javascript
import filter from '@naveen-bharathi/recursive-object-key-filter'; // ES6
// or
const filter = require('@naveen-bharathi/recursive-object-key-filter'); // ES5

const dirtyObject = {
  'id': '12345',
  'name': 'javascript',
  '__typename': 'language',
  'books': [
    {
      'name': 'Learn JS',
      'author': 'Naveen Bharathi',
      '__typename': 'book'
    },
    {
      'name': 'A guide to TS',
      'author': 'Naveen',
      '__typename': 'book'
    }
  ]
};

console.log(dirtyObject);
/* outputs ==>  
  {
    'id': '12345',
    'name': 'javascript',
    '__typename': 'language',
    'books': [
      {
        'name': 'Learn JS',
        'author': 'Naveen Bharathi',
        '__typename': 'book'
      },
      {
        'name': 'A guide to TS',
        'author': 'Naveen',
        '__typename': 'book'
      }
    ]
  }
*/

const cleanObject = filter(dirtyObject, ['__typename', 'id']);

console.log(cleanObject);
/* outputs ==>  
  {
    'name': 'javascript',
    'books': [
      {
        'name': 'Learn JS',
        'author': 'Naveen Bharathi',
      },
      {
        'name': 'A guide to TS',
        'author': 'Naveen',
      }
    ]
  }
*/
```

## Parameters

#### filter(object, keysToFilter)
- **object** **{Object | Array}** - object you want to filter the keys from.
- **keysToFilter** **{Array}** - Array of keys you want to filter / remove in the object passed.


## LICENSE

MIT License

Copyright (c) 2020 Naveen Bharathi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

---
_Source: https://npm.io/package/@naveen-bharathi/recursive-object-key-filter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
