bootstrap-vue
Version:
With more than 85 components, over 45 available plugins, several directives, and 1000+ icons, BootstrapVue provides one of the most comprehensive implementations of the Bootstrap v4 component and grid system available for Vue.js v2.6, complete with extens
16 lines (14 loc) • 421 B
JavaScript
import { isArray, isPlainObject } from './inspect'
import { keys } from './object'
export const cloneDeep = (obj, defaultValue = obj) => {
if (isArray(obj)) {
return obj.reduce((result, val) => [...result, cloneDeep(val, val)], [])
}
if (isPlainObject(obj)) {
return keys(obj).reduce(
(result, key) => ({ ...result, [key]: cloneDeep(obj[key], obj[key]) }),
{}
)
}
return defaultValue
}