| | |
| | | getFileExtensionWithDotRegex(filename) { |
| | | const match = filename.match(/\.[^.]+$/); |
| | | return match ? match[0] : ''; |
| | | }, |
| | | isEmpty(value) { |
| | | return ( |
| | | value === null || |
| | | value === undefined || |
| | | value === '' || |
| | | (Array.isArray(value) && value.length === 0) || |
| | | (typeof value === 'object' &&!Array.isArray(value) && Object.keys(value).length === 0) |
| | | ); |
| | | }, |
| | | |
| | | removeEmptyValuesRecursive(obj) { |
| | | const newObj = {}; |
| | | for (const key in obj) { |
| | | if (obj.hasOwnProperty(key)) { |
| | | const value = obj[key]; |
| | | if (!this.isEmpty(value)) { |
| | | if (typeof value === 'object' &&!Array.isArray(value)) { |
| | | newObj[key] = removeEmptyValuesRecursive(value); |
| | | } else { |
| | | newObj[key] = value; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return newObj; |
| | | } |
| | | } |