10 lines
306 B
JavaScript
10 lines
306 B
JavaScript
|
export const booleanSelector = (obj, key, type) => {
|
||
|
if (!(key in obj))
|
||
|
return undefined;
|
||
|
if (obj[key] === "true")
|
||
|
return true;
|
||
|
if (obj[key] === "false")
|
||
|
return false;
|
||
|
throw new Error(`Cannot load ${type} "${key}". Expected "true" or "false", got ${obj[key]}.`);
|
||
|
};
|