RED-3988: add bool function
This commit is contained in:
parent
196f5424ab
commit
55fb40dd67
@ -113,3 +113,20 @@ export function deepDiffObj(base: Record<string, unknown>, object: Record<string
|
|||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function bool(value: unknown): boolean {
|
||||||
|
if (typeof value !== 'string') {
|
||||||
|
return Boolean(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
const _value = value.toLowerCase().trim();
|
||||||
|
if (_value === 'true') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_value === 'false') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Boolean(_value);
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user