1.0.1 • Published 7 years ago

rename-props-shallow v1.0.1

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

Rename Props Shallow

Rename js object fields and return a shallow copy.

Installation

npm i -S rename-props-shallow

Usage

const rename = require('rename-props-shallow')

const obj = {name: 'Bob', sex: 'male', age: 20}

const newObj = rename({'name': 'nickname', 'sex': 'gender'})(obj)
// newObj is {nickname: 'Bob', gender: 'male', age: 20}

const objs = [{name: 'Bob'}, {name: 'Alice'}]
const newObjs = objs.map(rename({'name': 'nickname'}))
// newObjs is [{nickname: 'Bob'}, {nickname: 'Alice'}]

License

MIT