datoit
Version:
An open source headless CMS solution to create and manage your own API. It provides a powerful dashboard and features to make your life easier. Databases supported: MongoDB, MySQL, MariaDB, PostgreSQL, SQLite
23 lines (17 loc) • 435 B
JavaScript
;
const { map, mapValues, isObject, isArray, toString } = require('lodash/fp');
/**
* Stringify all non object valutes before send them
* @param {object} obj
* @returns {object}
*/
const stringifyDeep = value => {
if (isArray(value)) {
return map(stringifyDeep, value);
}
if (isObject(value)) {
return mapValues(stringifyDeep, value);
}
return toString(value);
};
module.exports = stringifyDeep;