first commit

This commit is contained in:
DanielRamirezGe
2020-01-14 20:43:08 -06:00
parent 3557894f7f
commit 5eecfbf6cd
26326 changed files with 2434803 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
import identity from './identity';
import { isArray, isObject } from './inspect';
import { clone } from './object';
/**
* Copies props from one array/object to a new array/object. Prop values
* are also cloned as new references to prevent possible mutation of original
* prop object values. Optionally accepts a function to transform the prop name.
*
* @param {[]|{}} props
* @param {Function} transformFn
*/
var copyProps = function copyProps(props) {
var transformFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : identity;
if (isArray(props)) {
return props.map(transformFn);
} // Props as an object.
var copied = {};
for (var prop in props) {
/* istanbul ignore else */
// eslint-disable-next-line no-prototype-builtins
if (props.hasOwnProperty(prop)) {
// If the prop value is an object, do a shallow clone to prevent
// potential mutations to the original object.
copied[transformFn(prop)] = isObject(props[prop]) ? clone(props[prop]) : props[prop];
}
}
return copied;
};
export default copyProps;