All Downloads are FREE. Search and download functionalities are using the official Maven repository.

utils.clearEmptyParams.ts Maven / Gradle / Ivy

The newest version!
import pickBy from 'lodash/pickBy'
import isObject from 'lodash/isObject'
import isEmpty from 'lodash/isEmpty'
import isNil from 'lodash/isNil'

/**
 * Удаляет все пустые значения в параметрах запроса
 * @param obj
 * @returns {*}
 */
export function clearEmptyParams(obj: T): Partial {
    return pickBy(obj, (value) => {
        if (isNil(value)) { return false }
        if (isObject(value)) { return !isEmpty(value) }

        return true
    })
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy