import * as R from 'ramda'; import { getClass } from '../_internal/getClass'; interface ObjectInterface { [propName: string]: any } export const trimParams = (object: any): unknown => { if (typeof object === 'string') { return R.trim(object) } if (getClass(object) === 'array' || getClass(object) === 'object') { if (Array.isArray(object)) { object.forEach((newParams: any) => { trimParams(newParams); }) } if (typeof object !== null) { Object.keys(object as ObjectInterface).map((key: string) => { const newValue = (object as ObjectInterface)[key]; if (typeof newValue === 'string') { object[key] = R.trim(newValue); } if (getClass(newValue) === 'object' || getClass(newValue) === 'array') { trimParams(newValue); } }); return object; } } return object; }