rename-prop
Rename a property from an object
Install
$ npm install --save rename-prop
Usage
const renameProp = ; const obj = foo: bar: 'baz';;console;//=> {unicorn: {bar: 'baz'}} const obj = foo: bar: 'baz';;console;//=> {foo: {unicorn: 'baz'}}
API
renameProp(input, from, to)
input
Type: object
Object to rename the property.
from
Type: string
Path of the property in the object to rename, using .
to separate each nested key.
to
Type: string
Path of the property in the object to rename from
to, using .
to separate each nested key.
Related
- dot-prop - Get, set, or delete a property from a nested object using a dot path
License
MIT © Sam Verschueren