@cookbook/dot-notation
Version:
Object readings and complex transformations using dot notation syntax.
20 lines • 448 B
JavaScript
import is from './is';
import typeOf from './type-of';
const shallowCopy = (value) => {
let copy;
if (is.array(value)) {
copy = [...value];
}
else if (is.object(value)) {
copy = Object.assign({}, value);
}
else if (typeOf(value) === 'date') {
copy = new Date(value);
}
else {
copy = value;
}
return copy;
};
export default shallowCopy;
//# sourceMappingURL=shallow-copy.js.map