Last active
January 15, 2017 16:19
-
-
Save roobie/4641d331144c61cdb2fdd0ea3bd957fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // see https://github.com/roobie/uniform-accessor | |
| import ua from 'uniform-accessor'; | |
| export default function uniformAccessTransform(object, extraProperties = {}) { | |
| console.assert(typeof object === 'object', 'Must pass a source object'); | |
| let freshObject = {}; | |
| // iterate over the properties of the object, and | |
| // create a uniform-accessor instance initialized | |
| // to the value of the property. | |
| Object.keys(object).forEach(k => { | |
| freshObject[k] = ua(object[k]); | |
| }); | |
| // assign any extra properties | |
| Object.keys(extraProperties).forEach(k => { | |
| freshObject[k] = extraProperties[k]; | |
| }); | |
| return freshObject; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment