This file contains 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
export const compactFormData = obj => { | |
const objectFilteredKeys = Object.keys(obj).filter(k => !isNil(obj[k]) && !(isString(obj[k]) && isEmpty(obj[k]))) | |
const assignData = (newObj, k) => | |
isObject(obj[k]) ? Object.assign(newObj, { [k]: compactFormData(obj[k]) }) : Object.assign(newObj, { [k]: obj[k] }) | |
if (isArray(obj)) { | |
return objectFilteredKeys.reduce(assignData, []) | |
} else if (isObject(obj)) { | |
return objectFilteredKeys.reduce(assignData, {}) |
This file contains 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
import PropTypes from 'prop-types' | |
export const locationShape = PropTypes.shape({ | |
pathname: PropTypes.string.isRequired, | |
search: PropTypes.string.isRequired, | |
hash: PropTypes.string.isRequired, | |
state: PropTypes.object, | |
}); | |
export const historyShape = PropTypes.shape({ |
This file contains 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
/* | |
Given collection like: | |
``` | |
const fileData = { | |
dir : 'app', | |
files : [ | |
'index.html', | |
{ | |
dir : 'js', | |
files: [ |