1.0.0 • Published 11 months ago

keep-paths v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

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'
        }
    }
}
1.0.0

11 months ago