JSFiddle - React, Tailwind, and code Playground
JavaScript
/* Copyright (C) 2014 Kurt Milam - http://xioup.com | Source: https://gist.github.com/kurtmilam/7006dc1c2123787f9679
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**/
// This function takes an arbitrarily deeply nested object and returns a flat 'copy',
// an object with no nesting, just properties, where each property's identifier is a
// dot notation string representation of the path to the property on the original
// object of which it's a copy (see the working sample code at the end)
// Scroll to the bottom to see the working sample code
function slenderizeObject (fatObject) {
var _propertyIdentifiers = []
var _slenderObject = {}
function processNode (theNode, _propertyIdentifiers, _slenderObject) {
theNode = theNode || {}
_propertyIdentifiers = _propertyIdentifiers || []
var ret = _(theNode)
.map(
function (value, key) {
var myKeys = _.clone(_propertyIdentifiers),
ret = {}
myKeys.push(key)
...