mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-01 18:01:06 +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"]
|
#[symbol = "__wbindgen_is_string"]
|
||||||
#[signature = fn(ref_anyref()) -> Boolean]
|
#[signature = fn(ref_anyref()) -> Boolean]
|
||||||
IsString,
|
IsString,
|
||||||
#[symbol = "__wbindgen_is_truthy"]
|
|
||||||
#[signature = fn(ref_anyref()) -> Boolean]
|
|
||||||
IsTruthy,
|
|
||||||
#[symbol = "__wbindgen_is_falsy"]
|
#[symbol = "__wbindgen_is_falsy"]
|
||||||
#[signature = fn(ref_anyref()) -> Boolean]
|
#[signature = fn(ref_anyref()) -> Boolean]
|
||||||
IsFalsy,
|
IsFalsy,
|
||||||
|
@ -2299,11 +2299,6 @@ impl<'a> Context<'a> {
|
|||||||
format!("typeof({}) === 'string'", args[0])
|
format!("typeof({}) === 'string'", args[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
Intrinsic::IsTruthy => {
|
|
||||||
assert_eq!(args.len(), 1);
|
|
||||||
format!("!!{}", args[0])
|
|
||||||
}
|
|
||||||
|
|
||||||
Intrinsic::IsFalsy => {
|
Intrinsic::IsFalsy => {
|
||||||
assert_eq!(args.len(), 1);
|
assert_eq!(args.len(), 1);
|
||||||
format!("!{}", args[0])
|
format!("!{}", args[0])
|
||||||
|
@ -333,15 +333,15 @@ impl JsValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Tests whether the value is ["truthy"].
|
/// Tests whether the value is ["truthy"].
|
||||||
///
|
///
|
||||||
/// ["truthy"]: https://developer.mozilla.org/en-US/docs/Glossary/Truthy
|
/// ["truthy"]: https://developer.mozilla.org/en-US/docs/Glossary/Truthy
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_truthy(&self) -> bool {
|
pub fn is_truthy(&self) -> bool {
|
||||||
unsafe { __wbindgen_is_truthy(self.idx) == 1 }
|
!self.is_falsy()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Tests whether the value is ["falsy"].
|
/// Tests whether the value is ["falsy"].
|
||||||
///
|
///
|
||||||
/// ["falsy"]: https://developer.mozilla.org/en-US/docs/Glossary/Falsy
|
/// ["falsy"]: https://developer.mozilla.org/en-US/docs/Glossary/Falsy
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_falsy(&self) -> bool {
|
pub fn is_falsy(&self) -> bool {
|
||||||
@ -518,7 +518,6 @@ externs! {
|
|||||||
fn __wbindgen_is_object(idx: u32) -> u32;
|
fn __wbindgen_is_object(idx: u32) -> u32;
|
||||||
fn __wbindgen_is_function(idx: u32) -> u32;
|
fn __wbindgen_is_function(idx: u32) -> u32;
|
||||||
fn __wbindgen_is_string(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_is_falsy(idx: u32) -> u32;
|
||||||
|
|
||||||
fn __wbindgen_number_get(idx: u32, invalid: *mut u8) -> f64;
|
fn __wbindgen_number_get(idx: u32, invalid: *mut u8) -> f64;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user