https://github.com/dy/obj-map-prop
Map object properties by a dict
https://github.com/dy/obj-map-prop
Last synced: about 1 year ago
JSON representation
Map object properties by a dict
- Host: GitHub
- URL: https://github.com/dy/obj-map-prop
- Owner: dy
- Created: 2017-09-20T00:42:05.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-04-02T22:27:51.000Z (about 7 years ago)
- Last Synced: 2024-10-30T01:37:19.627Z (over 1 year ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 3
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# obj-map-prop [](http://github.com/badges/stability-badges)
Map object properties by a dict of functions.
[](https://npmjs.org/package/obj-map-prop/)
```js
let map = require('obj-map-prop')
let obj = {propA: '0', propB: 1, propC: 'foo', propD: 'bar'}
let result = map(obj, {
propA: value => +value,
propB: value => value + 1,
propC: c => typeof c === 'function' ? c() : c
})
// {propA: 0, propB: 2, propC: 'foo'}
// keep rest of properties
let result = map(obj, {
propA: value => +value
}, true)
// {propA: 0, propB: 1, propC: 'foo', propD: 'bar'}
```
## Credits
© 2017 Dima Yv. MIT License