|
|
|
@ -28,7 +28,7 @@ impl Value {
|
|
|
|
|
(Self::Null, Self::Null) => true, |
|
|
|
|
|
|
|
|
|
// 3. Return ! SameValueNonNumeric(x, y).
|
|
|
|
|
(_, _) => same_value_non_numeric(self, other), |
|
|
|
|
(_, _) => Self::same_value_non_numeric(self, other), |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -111,23 +111,6 @@ impl Value {
|
|
|
|
|
_ => false, |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// This function takes a string and conversts it to BigInt type.
|
|
|
|
|
///
|
|
|
|
|
/// If the result is `NaN` than `None` is returned.
|
|
|
|
|
///
|
|
|
|
|
/// More information:
|
|
|
|
|
/// - [ECMAScript reference][spec]
|
|
|
|
|
///
|
|
|
|
|
/// [spec]: https://tc39.es/ecma262/#sec-stringtobigint
|
|
|
|
|
pub fn string_to_bigint(string: &str) -> Option<BigInt> { |
|
|
|
|
if string.is_empty() { |
|
|
|
|
return Some(BigInt::from(0)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
BigInt::from_str(string) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// The internal comparison abstract operation SameValue(x, y),
|
|
|
|
|
/// where x and y are ECMAScript language values, produces true or false.
|
|
|
|
@ -152,7 +135,7 @@ pub fn same_value(x: &Value, y: &Value) -> bool {
|
|
|
|
|
(Value::Integer(x), Value::Integer(y)) => x == y, |
|
|
|
|
|
|
|
|
|
// 3. Return ! SameValueNonNumeric(x, y).
|
|
|
|
|
(_, _) => same_value_non_numeric(x, y), |
|
|
|
|
(_, _) => Self::same_value_non_numeric(x, y), |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -181,7 +164,7 @@ pub fn same_value_zero(x: &Value, y: &Value) -> bool {
|
|
|
|
|
(Value::Integer(x), Value::Integer(y)) => x == y, |
|
|
|
|
|
|
|
|
|
// 3. Return ! SameValueNonNumeric(x, y).
|
|
|
|
|
(_, _) => same_value_non_numeric(x, y), |
|
|
|
|
(_, _) => Self::same_value_non_numeric(x, y), |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -196,3 +179,20 @@ fn same_value_non_numeric(x: &Value, y: &Value) -> bool {
|
|
|
|
|
_ => false, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// This function takes a string and conversts it to BigInt type.
|
|
|
|
|
///
|
|
|
|
|
/// If the result is `NaN` than `None` is returned.
|
|
|
|
|
///
|
|
|
|
|
/// More information:
|
|
|
|
|
/// - [ECMAScript reference][spec]
|
|
|
|
|
///
|
|
|
|
|
/// [spec]: https://tc39.es/ecma262/#sec-stringtobigint
|
|
|
|
|
pub fn string_to_bigint(string: &str) -> Option<BigInt> { |
|
|
|
|
if string.is_empty() { |
|
|
|
|
return Some(BigInt::from(0)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
BigInt::from_str(string) |
|
|
|
|
} |
|
|
|
|