Files
remark42/frontend/app/utils/parse-booleans-from-dictionary.ts
T
Yuriy KarpovandUmputun 4e0a4e52bd add the ability to configure the 'simple_view' parameter from the client,
the parameter is not required, but if set, it will overwrite the one that came from the backend
issues-916
2021-05-06 11:08:15 -05:00

16 lines
382 B
TypeScript

export function parseBooleansFromDictionary(input: Record<string, unknown>, ...args: string[]) {
const result: Record<string, boolean> = {};
for (let key of args) {
if (input[key] === undefined) {
continue;
}
if (input[key] === 'true') {
result[key] = true;
}
if (input[key] === 'false') {
result[key] = false;
}
}
return result;
}