a looooot

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-02-22 21:50:30 +01:00
parent 1d800835b8
commit 9c92803c4c
61 changed files with 2689 additions and 681 deletions

View File

@@ -1,4 +1,4 @@
import { anyPass, isEmpty, isNil, reject } from 'ramda';
import { anyPass, assocPath, isEmpty, isNil, reject } from 'ramda';
export function toDots(
obj: Record<string, unknown>,
@@ -19,6 +19,16 @@ export function toDots(
}, {});
}
export function toObject(
obj: Record<string, string | undefined>
): Record<string, unknown> {
let result: Record<string, unknown> = {};
Object.entries(obj).forEach(([key, value]) => {
result = assocPath(key.split('.'), value, result);
});
return result;
}
export const strip = reject(anyPass([isEmpty, isNil]));
export function getSafeJson<T>(str: string): T | null {