mirror of
https://github.com/strapi/strapi.git
synced 2025-11-06 21:29:24 +00:00
21 lines
442 B
JavaScript
21 lines
442 B
JavaScript
'use strict';
|
|
|
|
const { typesArray } = require('./types');
|
|
|
|
/**
|
|
* return a map of default values
|
|
* @param {*} attributes
|
|
*/
|
|
function createDefaults(attributes) {
|
|
return Object.keys(attributes).reduce((acc, key) => {
|
|
const { type, default: defaultVal } = attributes[key];
|
|
if (typesArray.includes(type) && defaultVal !== undefined) {
|
|
acc[key] = defaultVal;
|
|
}
|
|
|
|
return acc;
|
|
}, {});
|
|
}
|
|
|
|
module.exports = createDefaults;
|