strip-keys
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

Strip Keys

An utility for removing specific keys from an object.

Install

npm install --save strip-keys

Usage

import stripKeys from 'strip-keys';

const obj = {
  foo: true,
  secret: '1234',
  sub: {
    bar: true,
    secret: 'password'
  }
};

stripKeys ( obj, 'secret' ); // { foo: true, sub: { bar: true } }
stripKeys ( obj, 'secret', false ); // { foo: true, sub: { bar: true, secret: 'password' } }
stripKeys ( obj, ['secret', 'bar'] ); // { foo: true, sub: {} }

API

stripKeys ( obj, keys: string | string[], deep: boolean = true )

Removes a key, or an array of keys, deeply or not, from an object, without mutating the original object.

License

MIT © Fabio Spampinato

Dependencies (0)

    Dev Dependencies (3)

    Package Sidebar

    Install

    npm i strip-keys

    Weekly Downloads

    4

    Version

    2.0.0

    License

    none

    Unpacked Size

    6.64 kB

    Total Files

    12

    Last publish

    Collaborators

    • fabiospampinato