Add is_truthy, is_falsy

This commit is contained in:
Thomas
2019-07-02 18:44:06 +02:00
parent bf631eda1b
commit e61f691e0b
4 changed files with 59 additions and 0 deletions

View File

@ -2299,6 +2299,16 @@ impl<'a> Context<'a> {
format!("typeof({}) === 'string'", args[0])
}
Intrinsic::IsTruthy => {
assert_eq!(args.len(), 1);
format!("!!{}", args[0])
}
Intrinsic::IsFalsy => {
assert_eq!(args.len(), 1);
format!("!{}", args[0])
}
Intrinsic::ObjectCloneRef => {
assert_eq!(args.len(), 1);
args[0].clone()