Repository URL to install this package:
|
Version:
1.0.3-rc.0 ▾
|
@doodle/vault
/
mapData.js
|
|---|
/**
*
* @param {Object} mapping A mapping to use for reading secrets accessed by the vault data key
* @param {Object} dest A destination object, by default `{}`
* @returns {Object} the dest object assigned with values from secrets according to the mapping
* @example const { myKey } = mapSecrets({ secretKey: 'myKey' })(secrets);
*/
const mapData = (mapping, dest = {}) => ({
data
}) => Object.keys(data).reduce((result, key) => Object.assign(result, {
[mapping[key]]: data[key]
}), dest);
module.exports = mapData;