bootstrap-vue
Version:
BootstrapVue, with more than 85 custom components, over 45 plugins, several custom directives, and over 300 icons, provides one of the most comprehensive implementations of Bootstrap v4 components and grid system for Vue.js. With extensive and automated W
22 lines (19 loc) • 680 B
JavaScript
import identity from './identity'
import { isArray } from './inspect'
import { keys } from './object'
/**
* Given an array of properties or an object of property keys,
* plucks all the values off the target object, returning a new object
* that has props that reference the original prop values
*
* @param {{}|string[]} keysToPluck
* @param {{}} objToPluck
* @param {Function} transformFn
* @return {{}}
*/
const pluckProps = (keysToPluck, objToPluck, transformFn = identity) =>
(isArray(keysToPluck) ? keysToPluck.slice() : keys(keysToPluck)).reduce((memo, prop) => {
memo[transformFn(prop)] = objToPluck[prop]
return memo
}, {})
export default pluckProps