This commit is contained in:
Carl-Gerhard Lindesvärd
2024-02-04 13:23:21 +01:00
parent 30af9cab2f
commit ccd1a1456f
135 changed files with 5588 additions and 1758 deletions

View File

@@ -0,0 +1,22 @@
import { anyPass, isEmpty, isNil, reject } from 'ramda';
export function toDots(
obj: Record<string, unknown>,
path = ''
): Record<string, number | string | boolean> {
return Object.entries(obj).reduce((acc, [key, value]) => {
if (typeof value === 'object' && value !== null) {
return {
...acc,
...toDots(value as Record<string, unknown>, `${path}${key}.`),
};
}
return {
...acc,
[`${path}${key}`]: value,
};
}, {});
}
export const strip = reject(anyPass([isEmpty, isNil]));