mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-16 02:00:51 +00:00
Define is_truthy in terms of is_falsy
This commit is contained in:
parent
e61f691e0b
commit
0ee7236698
@ -85,9 +85,6 @@ intrinsics! {
|
||||
#[symbol = "__wbindgen_is_string"]
|
||||
#[signature = fn(ref_anyref()) -> Boolean]
|
||||
IsString,
|
||||
#[symbol = "__wbindgen_is_truthy"]
|
||||
#[signature = fn(ref_anyref()) -> Boolean]
|
||||
IsTruthy,
|
||||
#[symbol = "__wbindgen_is_falsy"]
|
||||
#[signature = fn(ref_anyref()) -> Boolean]
|
||||
IsFalsy,
|
||||
|
@ -2299,11 +2299,6 @@ 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])
|
||||
|
@ -333,15 +333,15 @@ impl JsValue {
|
||||
}
|
||||
|
||||
/// Tests whether the value is ["truthy"].
|
||||
///
|
||||
///
|
||||
/// ["truthy"]: https://developer.mozilla.org/en-US/docs/Glossary/Truthy
|
||||
#[inline]
|
||||
pub fn is_truthy(&self) -> bool {
|
||||
unsafe { __wbindgen_is_truthy(self.idx) == 1 }
|
||||
!self.is_falsy()
|
||||
}
|
||||
|
||||
/// Tests whether the value is ["falsy"].
|
||||
///
|
||||
///
|
||||
/// ["falsy"]: https://developer.mozilla.org/en-US/docs/Glossary/Falsy
|
||||
#[inline]
|
||||
pub fn is_falsy(&self) -> bool {
|
||||
@ -518,7 +518,6 @@ externs! {
|
||||
fn __wbindgen_is_object(idx: u32) -> u32;
|
||||
fn __wbindgen_is_function(idx: u32) -> u32;
|
||||
fn __wbindgen_is_string(idx: u32) -> u32;
|
||||
fn __wbindgen_is_truthy(idx: u32) -> u32;
|
||||
fn __wbindgen_is_falsy(idx: u32) -> u32;
|
||||
|
||||
fn __wbindgen_number_get(idx: u32, invalid: *mut u8) -> f64;
|
||||
|
Loading…
x
Reference in New Issue
Block a user