keep-paths
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Keep paths

Small library that take an object and an array of paths and return a new object containing only those paths.

Importing library

import keepPaths from 'keep-paths'

Usage

import keepPaths from 'keep-paths'

const source = {
    foo: {
        bar: {
            key: 'value',
            key2: 'value2'
        }
    },
    other: {
        key1: 'value'
    }
};
const obj = keepPaths(source, ['foo.bar.key']);
console.log(obj);

Print:

 {
    foo: {
        bar: {
            key: 'value'
        }
    }
}

Readme

Keywords

Package Sidebar

Install

npm i keep-paths

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

9.66 kB

Total Files

10

Last publish

Collaborators

  • ydeshayes