bootstrap-vue
Version:
BootstrapVue provides one of the most comprehensive implementations of Bootstrap 4 components and grid system for Vue.js and with extensive and automated WAI-ARIA accessibility markup.
28 lines (24 loc) • 610 B
JavaScript
import { isArray } from './array'
import { assign } from './object'
import identity from './identity'
/**
* @param {[]|{}} props
* @param {Function} transformFn
*/
export default function copyProps (props, transformFn = identity) {
if (isArray(props)) {
return props.map(transformFn)
}
// Props as an object.
const copied = {}
for (const prop in props) {
if (props.hasOwnProperty(prop)) {
if (typeof prop === 'object') {
copied[transformFn(prop)] = assign({}, props[prop])
} else {
copied[transformFn(prop)] = props[prop]
}
}
}
return copied
}