boa_engine/value/type.rs
1use super::JsValue;
2
3/// Possible types of values as defined at <https://tc39.es/ecma262/#sec-typeof-operator>.
4#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
5pub enum Type {
6 /// The "undefined" type.
7 Undefined,
8
9 /// The "null" type.
10 Null,
11
12 /// The "boolean" type.
13 Boolean,
14
15 /// The "number" type.
16 Number,
17
18 /// The "string" type.
19 String,
20
21 /// The "symbol" type.
22 Symbol,
23
24 /// The "bigint" type.
25 BigInt,
26
27 /// The "object" type.
28 Object,
29}
30
31impl JsValue {
32 /// Get the type of a value
33 ///
34 /// This is the abstract operation Type(v), as described in
35 /// <https://tc39.es/ecma262/multipage/ecmascript-data-types-and-values.html#sec-ecmascript-language-types>.
36 ///
37 /// Check [`JsValue::type_of`] if you need to call the `typeof` operator.
38 #[must_use]
39 #[inline]
40 pub fn get_type(&self) -> Type {
41 self.0.get_type()
42 }
43}