debian-mirror-gitlab/app/assets/javascripts/pages/admin/application_settings/utils.js
2021-04-29 21:17:54 +05:30

21 lines
590 B
JavaScript

import { includes } from 'lodash';
import { parseBoolean } from '~/lib/utils/common_utils';
/**
* Returns a new dataset that has all the values of keys indicated in
* booleanAttributes transformed by the parseBoolean() helper function
*
* @param {Object}
* @returns {Object}
*/
export const getParsedDataset = ({ dataset = {}, booleanAttributes = [] } = {}) => {
const parsedDataset = {};
Object.keys(dataset).forEach((key) => {
parsedDataset[key] = includes(booleanAttributes, key)
? parseBoolean(dataset[key])
: dataset[key];
});
return parsedDataset;
};