Skip to main content

js_sys/
lib.rs

1//! Bindings to JavaScript's standard, built-in objects, including their methods
2//! and properties.
3//!
4//! This does *not* include any Web, Node, or any other JS environment
5//! APIs. Only the things that are guaranteed to exist in the global scope by
6//! the ECMAScript standard.
7//!
8//! <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects>
9//!
10//! ## A Note About `camelCase`, `snake_case`, and Naming Conventions
11//!
12//! JavaScript's global objects use `camelCase` naming conventions for functions
13//! and methods, but Rust style is to use `snake_case`. These bindings expose
14//! the Rust style `snake_case` name. Additionally, acronyms within a method
15//! name are all lower case, where as in JavaScript they are all upper case. For
16//! example, `decodeURI` in JavaScript is exposed as `decode_uri` in these
17//! bindings.
18//!
19//! ## A Note About `toString` and `to_js_string`
20//!
21//! JavaScript's `toString()` method is exposed as `to_js_string()` in these
22//! bindings to avoid confusion with Rust's [`ToString`] trait and its
23//! `to_string()` method. This allows types to implement both the Rust
24//! [`Display`](core::fmt::Display) trait (which provides `to_string()` via
25//! [`ToString`]) and still expose the JavaScript `toString()` functionality.
26
27#![doc(html_root_url = "https://docs.rs/js-sys/0.2")]
28#![cfg_attr(not(feature = "std"), no_std)]
29#![cfg_attr(target_feature = "atomics", feature(thread_local))]
30#![cfg_attr(
31    all(feature = "futures", target_feature = "atomics"),
32    feature(stdarch_wasm_atomic_wait)
33)]
34
35extern crate alloc;
36
37use alloc::string::String;
38use alloc::vec::Vec;
39use core::cmp::Ordering;
40#[cfg(not(js_sys_unstable_apis))]
41use core::convert::Infallible;
42use core::convert::{self, TryFrom};
43use core::f64;
44use core::fmt;
45use core::iter::{self, Product, Sum};
46use core::marker::PhantomData;
47use core::mem::MaybeUninit;
48use core::ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Neg, Not, Rem, Shl, Shr, Sub};
49use core::str;
50use core::str::FromStr;
51pub use wasm_bindgen;
52use wasm_bindgen::closure::{ScopedClosure, WasmClosure};
53use wasm_bindgen::convert::{FromWasmAbi, IntoWasmAbi, Upcast, UpcastFrom};
54use wasm_bindgen::prelude::*;
55use wasm_bindgen::JsError;
56
57// Re-export sys types as js-sys types
58pub use wasm_bindgen::sys::{JsOption, Null, Promising, Undefined};
59pub use wasm_bindgen::JsGeneric;
60
61// When adding new imports:
62//
63// * Keep imports in alphabetical order.
64//
65// * Rename imports with `js_name = ...` according to the note about `camelCase`
66//   and `snake_case` in the module's documentation above.
67//
68// * Include the one sentence summary of the import from the MDN link in the
69//   module's documentation above, and the MDN link itself.
70//
71// * If a function or method can throw an exception, make it catchable by adding
72//   `#[wasm_bindgen(catch)]`.
73//
74// * Add a new `#[test]` into the appropriate file in the
75//   `crates/js-sys/tests/wasm/` directory. If the imported function or method
76//   can throw an exception, make sure to also add test coverage for that case.
77//
78// * Arguments that are `JsValue`s or imported JavaScript types should be taken
79//   by reference.
80//
81// * Name JavaScript's `toString()` method as `to_js_string()` to avoid conflict
82//   with Rust's `ToString` trait.
83
84macro_rules! forward_deref_unop {
85    (impl $imp:ident, $method:ident for $t:ty) => {
86        impl $imp for $t {
87            type Output = <&'static $t as $imp>::Output;
88
89            #[inline]
90            fn $method(self) -> Self::Output {
91                $imp::$method(&self)
92            }
93        }
94    };
95    (impl<$($gen:ident),+> $imp:ident, $method:ident for $t:ty) => {
96        impl<$($gen),+> $imp for $t {
97            type Output = <&'static $t as $imp>::Output;
98
99            #[inline]
100            fn $method(self) -> Self::Output {
101                $imp::$method(&self)
102            }
103        }
104    };
105}
106
107macro_rules! forward_deref_binop {
108    (impl $imp:ident, $method:ident for $t:ty) => {
109        impl<'a> $imp<$t> for &'a $t {
110            type Output = <&'static $t as $imp<&'static $t>>::Output;
111
112            #[inline]
113            fn $method(self, other: $t) -> Self::Output {
114                $imp::$method(self, &other)
115            }
116        }
117
118        impl $imp<&$t> for $t {
119            type Output = <&'static $t as $imp<&'static $t>>::Output;
120
121            #[inline]
122            fn $method(self, other: &$t) -> Self::Output {
123                $imp::$method(&self, other)
124            }
125        }
126
127        impl $imp<$t> for $t {
128            type Output = <&'static $t as $imp<&'static $t>>::Output;
129
130            #[inline]
131            fn $method(self, other: $t) -> Self::Output {
132                $imp::$method(&self, &other)
133            }
134        }
135    };
136    (impl<$($gen:ident),+> $imp:ident, $method:ident for $t:ty) => {
137        impl<'a, $($gen),+> $imp<$t> for &'a $t {
138            type Output = <&'static $t as $imp<&'static $t>>::Output;
139
140            #[inline]
141            fn $method(self, other: $t) -> Self::Output {
142                $imp::$method(self, &other)
143            }
144        }
145
146        impl<$($gen),+> $imp<&$t> for $t {
147            type Output = <&'static $t as $imp<&'static $t>>::Output;
148
149            #[inline]
150            fn $method(self, other: &$t) -> Self::Output {
151                $imp::$method(&self, other)
152            }
153        }
154
155        impl<$($gen),+> $imp<$t> for $t {
156            type Output = <&'static $t as $imp<&'static $t>>::Output;
157
158            #[inline]
159            fn $method(self, other: $t) -> Self::Output {
160                $imp::$method(&self, &other)
161            }
162        }
163    };
164}
165
166macro_rules! forward_js_unop {
167    (impl $imp:ident, $method:ident for $t:ty) => {
168        impl $imp for &$t {
169            type Output = $t;
170
171            #[inline]
172            fn $method(self) -> Self::Output {
173                $imp::$method(JsValue::as_ref(self)).unchecked_into()
174            }
175        }
176
177        forward_deref_unop!(impl $imp, $method for $t);
178    };
179    (impl<$($gen:ident),+> $imp:ident, $method:ident for $t:ty) => {
180        impl<$($gen),+> $imp for &$t {
181            type Output = $t;
182
183            #[inline]
184            fn $method(self) -> Self::Output {
185                $imp::$method(JsValue::as_ref(self)).unchecked_into()
186            }
187        }
188
189        forward_deref_unop!(impl<$($gen),+> $imp, $method for $t);
190    };
191}
192
193macro_rules! forward_js_binop {
194    (impl $imp:ident, $method:ident for $t:ty) => {
195        impl $imp<&$t> for &$t {
196            type Output = $t;
197
198            #[inline]
199            fn $method(self, other: &$t) -> Self::Output {
200                $imp::$method(JsValue::as_ref(self), JsValue::as_ref(other)).unchecked_into()
201            }
202        }
203
204        forward_deref_binop!(impl $imp, $method for $t);
205    };
206    (impl<$($gen:ident),+> $imp:ident, $method:ident for $t:ty) => {
207        impl<$($gen),+> $imp<&$t> for &$t {
208            type Output = $t;
209
210            #[inline]
211            fn $method(self, other: &$t) -> Self::Output {
212                $imp::$method(JsValue::as_ref(self), JsValue::as_ref(other)).unchecked_into()
213            }
214        }
215
216        forward_deref_binop!(impl<$($gen),+> $imp, $method for $t);
217    };
218}
219
220macro_rules! sum_product {
221    ($($a:ident)*) => ($(
222        impl Sum for $a {
223            #[inline]
224            fn sum<I: iter::Iterator<Item=Self>>(iter: I) -> Self {
225                iter.fold(
226                    $a::from(0),
227                    |a, b| a + b,
228                )
229            }
230        }
231
232        impl Product for $a {
233            #[inline]
234            fn product<I: iter::Iterator<Item=Self>>(iter: I) -> Self {
235                iter.fold(
236                    $a::from(1),
237                    |a, b| a * b,
238                )
239            }
240        }
241
242        impl<'a> Sum<&'a $a> for $a {
243            fn sum<I: iter::Iterator<Item=&'a Self>>(iter: I) -> Self {
244                iter.fold(
245                    $a::from(0),
246                    |a, b| a + b,
247                )
248            }
249        }
250
251        impl<'a> Product<&'a $a> for $a {
252            #[inline]
253            fn product<I: iter::Iterator<Item=&'a Self>>(iter: I) -> Self {
254                iter.fold(
255                    $a::from(1),
256                    |a, b| a * b,
257                )
258            }
259        }
260    )*);
261    // Generic variant: impl<T> for Type<T>
262    (impl<$gen:ident> $a:ident<$g2:ident>) => {
263        impl<$gen> Sum for $a<$g2>
264        where
265            $a<$g2>: From<$gen>,
266            $g2: From<u32>
267        {
268            #[inline]
269            fn sum<I: iter::Iterator<Item=Self>>(iter: I) -> Self {
270                iter.fold(
271                    $a::from($g2::from(0)),
272                    |a, b| a + b,
273                )
274            }
275        }
276
277        impl<$gen> Product for $a<$g2>
278        where
279            $a<$g2>: From<$gen>,
280            $g2: From<u32>
281        {
282            #[inline]
283            fn product<I: iter::Iterator<Item=Self>>(iter: I) -> Self {
284                iter.fold(
285                    $a::from($g2::from(1)),
286                    |a, b| a * b,
287                )
288            }
289        }
290
291        impl<'a, $gen> Sum<&'a $a<$g2>> for $a<$g2>
292        where
293            $a<$g2>: From<$gen>,
294            $g2: From<u32>
295        {
296            fn sum<I: iter::Iterator<Item=&'a Self>>(iter: I) -> Self {
297                iter.fold(
298                    $a::from($g2::from(0)),
299                    |a, b| a + b,
300                )
301            }
302        }
303
304        impl<'a, $gen> Product<&'a $a<$g2>> for $a<$g2>
305        where
306            $a<$g2>: From<$gen>,
307            $g2: From<u32>
308        {
309            #[inline]
310            fn product<I: iter::Iterator<Item=&'a Self>>(iter: I) -> Self {
311                iter.fold(
312                    $a::from($g2::from(1)),
313                    |a, b| a * b,
314                )
315            }
316        }
317    };
318}
319
320macro_rules! partialord_ord {
321    ($t:ident) => {
322        impl PartialOrd for $t {
323            #[inline]
324            fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
325                Some(self.cmp(other))
326            }
327
328            #[inline]
329            fn lt(&self, other: &Self) -> bool {
330                JsValue::as_ref(self).lt(JsValue::as_ref(other))
331            }
332
333            #[inline]
334            fn le(&self, other: &Self) -> bool {
335                JsValue::as_ref(self).le(JsValue::as_ref(other))
336            }
337
338            #[inline]
339            fn ge(&self, other: &Self) -> bool {
340                JsValue::as_ref(self).ge(JsValue::as_ref(other))
341            }
342
343            #[inline]
344            fn gt(&self, other: &Self) -> bool {
345                JsValue::as_ref(self).gt(JsValue::as_ref(other))
346            }
347        }
348
349        impl Ord for $t {
350            #[inline]
351            fn cmp(&self, other: &Self) -> Ordering {
352                if self == other {
353                    Ordering::Equal
354                } else if self.lt(other) {
355                    Ordering::Less
356                } else {
357                    Ordering::Greater
358                }
359            }
360        }
361    };
362}
363
364#[wasm_bindgen]
365extern "C" {
366    /// The `decodeURI()` function decodes a Uniform Resource Identifier (URI)
367    /// previously created by `encodeURI` or by a similar routine.
368    ///
369    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURI)
370    #[wasm_bindgen(catch, js_name = decodeURI)]
371    pub fn decode_uri(encoded: &str) -> Result<JsString, JsValue>;
372
373    /// The `decodeURIComponent()` function decodes a Uniform Resource Identifier (URI) component
374    /// previously created by `encodeURIComponent` or by a similar routine.
375    ///
376    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent)
377    #[wasm_bindgen(catch, js_name = decodeURIComponent)]
378    pub fn decode_uri_component(encoded: &str) -> Result<JsString, JsValue>;
379
380    /// The `encodeURI()` function encodes a Uniform Resource Identifier (URI)
381    /// by replacing each instance of certain characters by one, two, three, or
382    /// four escape sequences representing the UTF-8 encoding of the character
383    /// (will only be four escape sequences for characters composed of two
384    /// "surrogate" characters).
385    ///
386    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI)
387    #[wasm_bindgen(js_name = encodeURI)]
388    pub fn encode_uri(decoded: &str) -> JsString;
389
390    /// The `encodeURIComponent()` function encodes a Uniform Resource Identifier (URI) component
391    /// by replacing each instance of certain characters by one, two, three, or four escape sequences
392    /// representing the UTF-8 encoding of the character
393    /// (will only be four escape sequences for characters composed of two "surrogate" characters).
394    ///
395    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent)
396    #[wasm_bindgen(js_name = encodeURIComponent)]
397    pub fn encode_uri_component(decoded: &str) -> JsString;
398
399    /// The `eval()` function evaluates JavaScript code represented as a string.
400    ///
401    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval)
402    #[cfg(feature = "unsafe-eval")]
403    #[wasm_bindgen(catch)]
404    pub fn eval(js_source_text: &str) -> Result<JsValue, JsValue>;
405
406    /// The global `isFinite()` function determines whether the passed value is a finite number.
407    /// If needed, the parameter is first converted to a number.
408    ///
409    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isFinite)
410    #[wasm_bindgen(js_name = isFinite)]
411    pub fn is_finite(value: &JsValue) -> bool;
412
413    /// The `parseInt()` function parses a string argument and returns an integer
414    /// of the specified radix (the base in mathematical numeral systems), or NaN on error.
415    ///
416    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt)
417    #[wasm_bindgen(js_name = parseInt)]
418    pub fn parse_int(text: &str, radix: u8) -> f64;
419
420    /// The `parseFloat()` function parses an argument and returns a floating point number,
421    /// or NaN on error.
422    ///
423    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat)
424    #[wasm_bindgen(js_name = parseFloat)]
425    pub fn parse_float(text: &str) -> f64;
426
427    /// The `escape()` function computes a new string in which certain characters have been
428    /// replaced by a hexadecimal escape sequence.
429    ///
430    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/escape)
431    #[wasm_bindgen]
432    pub fn escape(string: &str) -> JsString;
433
434    /// The `unescape()` function computes a new string in which hexadecimal escape
435    /// sequences are replaced with the character that it represents. The escape sequences might
436    /// be introduced by a function like `escape`. Usually, `decodeURI` or `decodeURIComponent`
437    /// are preferred over `unescape`.
438    ///
439    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/unescape)
440    #[wasm_bindgen]
441    pub fn unescape(string: &str) -> JsString;
442}
443
444// Array
445#[wasm_bindgen]
446extern "C" {
447    #[wasm_bindgen(extends = Object, is_type_of = Array::is_array, typescript_type = "Array<any>")]
448    #[derive(Clone, Debug, PartialEq, Eq)]
449    pub type Array<T = JsValue>;
450
451    /// Creates a new empty array.
452    ///
453    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Array)
454    #[cfg(not(js_sys_unstable_apis))]
455    #[wasm_bindgen(constructor)]
456    pub fn new() -> Array;
457
458    /// Creates a new empty array.
459    ///
460    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Array)
461    #[cfg(js_sys_unstable_apis)]
462    #[wasm_bindgen(constructor)]
463    pub fn new<T>() -> Array<T>;
464
465    // Next major: deprecate
466    /// Creates a new empty array.
467    ///
468    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Array)
469    #[wasm_bindgen(constructor)]
470    pub fn new_typed<T>() -> Array<T>;
471
472    /// Creates a new array with the specified length (elements are initialized to `undefined`).
473    ///
474    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Array)
475    #[cfg(not(js_sys_unstable_apis))]
476    #[wasm_bindgen(constructor)]
477    pub fn new_with_length(len: u32) -> Array;
478
479    /// Creates a new array with the specified length (elements are initialized to `undefined`).
480    ///
481    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Array)
482    #[cfg(js_sys_unstable_apis)]
483    #[wasm_bindgen(constructor)]
484    pub fn new_with_length<T>(len: u32) -> Array<T>;
485
486    // Next major: deprecate
487    /// Creates a new array with the specified length (elements are initialized to `undefined`).
488    ///
489    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Array)
490    #[wasm_bindgen(constructor)]
491    pub fn new_with_length_typed<T>(len: u32) -> Array<T>;
492
493    /// Retrieves the element at the index, counting from the end if negative
494    /// (returns `undefined` if the index is out of range).
495    ///
496    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at)
497    #[cfg(not(js_sys_unstable_apis))]
498    #[wasm_bindgen(method)]
499    pub fn at<T>(this: &Array<T>, index: i32) -> T;
500
501    /// Retrieves the element at the index, counting from the end if negative
502    /// (returns `None` if the index is out of range).
503    ///
504    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at)
505    #[cfg(js_sys_unstable_apis)]
506    #[wasm_bindgen(method)]
507    pub fn at<T>(this: &Array<T>, index: i32) -> Option<T>;
508
509    /// Retrieves the element at the index (returns `undefined` if the index is out of range).
510    ///
511    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at)
512    #[cfg(not(js_sys_unstable_apis))]
513    #[wasm_bindgen(method, indexing_getter)]
514    pub fn get<T>(this: &Array<T>, index: u32) -> T;
515
516    /// Retrieves the element at the index (returns `None` if the index is out of range).
517    ///
518    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at)
519    #[cfg(js_sys_unstable_apis)]
520    #[wasm_bindgen(method, indexing_getter)]
521    pub fn get<T>(this: &Array<T>, index: u32) -> Option<T>;
522
523    /// Retrieves the element at the index (returns `undefined` if the index is out of range).
524    ///
525    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at)
526    #[wasm_bindgen(method, indexing_getter)]
527    pub fn get_unchecked<T>(this: &Array<T>, index: u32) -> T;
528
529    // Next major: deprecate
530    /// Retrieves the element at the index (returns `None` if the index is out of range,
531    /// or if the element is explicitly `undefined`).
532    #[wasm_bindgen(method, indexing_getter)]
533    pub fn get_checked<T>(this: &Array<T>, index: u32) -> Option<T>;
534
535    /// Sets the element at the index (auto-enlarges the array if the index is out of range).
536    #[cfg(not(js_sys_unstable_apis))]
537    #[wasm_bindgen(method, indexing_setter)]
538    pub fn set<T>(this: &Array<T>, index: u32, value: T);
539
540    /// Sets the element at the index (auto-enlarges the array if the index is out of range).
541    #[cfg(js_sys_unstable_apis)]
542    #[wasm_bindgen(method, indexing_setter)]
543    pub fn set<T>(this: &Array<T>, index: u32, value: &T);
544
545    // Next major: deprecate
546    /// Sets the element at the index (auto-enlarges the array if the index is out of range).
547    #[wasm_bindgen(method, indexing_setter)]
548    pub fn set_ref<T>(this: &Array<T>, index: u32, value: &T);
549
550    /// Deletes the element at the index (does nothing if the index is out of range).
551    ///
552    /// The element at the index is set to `undefined`.
553    ///
554    /// This does not resize the array, the array will still be the same length.
555    #[wasm_bindgen(method, indexing_deleter)]
556    pub fn delete<T>(this: &Array<T>, index: u32);
557
558    /// The `Array.from()` static method creates a new, shallow-copied `Array` instance
559    /// from an array-like or iterable object.
560    ///
561    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from)
562    #[cfg(not(js_sys_unstable_apis))]
563    #[wasm_bindgen(static_method_of = Array)]
564    pub fn from(val: &JsValue) -> Array;
565
566    /// The `Array.from()` static method creates a new, shallow-copied `Array` instance
567    /// from an array-like or iterable object.
568    ///
569    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from)
570    #[cfg(js_sys_unstable_apis)]
571    #[wasm_bindgen(static_method_of = Array, catch, js_name = from)]
572    pub fn from<I: Iterable>(val: &I) -> Result<Array<I::Item>, JsValue>;
573
574    // Next major: deprecate
575    /// The `Array.from()` static method creates a new, shallow-copied `Array` instance
576    /// from an array-like or iterable object.
577    ///
578    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from)
579    #[wasm_bindgen(static_method_of = Array, catch, js_name = from)]
580    pub fn from_iterable<I: Iterable>(val: &I) -> Result<Array<I::Item>, JsValue>;
581
582    /// The `Array.from()` static method with a map function creates a new, shallow-copied
583    /// `Array` instance from an array-like or iterable object, applying the map function
584    /// to each value.
585    ///
586    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from)
587    #[wasm_bindgen(static_method_of = Array, catch, js_name = from)]
588    pub fn from_iterable_map<I: Iterable, U>(
589        val: &I,
590        map: &mut dyn FnMut(I::Item, u32) -> Result<U, JsError>,
591    ) -> Result<Array<U>, JsValue>;
592
593    /// The `Array.fromAsync()` static method creates a new, shallow-copied `Array` instance
594    /// from an async iterable, iterable or array-like object.
595    ///
596    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fromAsync)
597    #[wasm_bindgen(static_method_of = Array, catch, js_name = fromAsync)]
598    pub fn from_async<I: AsyncIterable>(val: &I) -> Result<Promise<Array<I::Item>>, JsValue>;
599
600    /// The `Array.fromAsync()` static method with a map function creates a new, shallow-copied
601    /// `Array` instance from an async iterable, iterable or array-like object, applying the map
602    /// function to each value.
603    ///
604    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fromAsync)
605    #[wasm_bindgen(static_method_of = Array, catch, js_name = fromAsync)]
606    pub fn from_async_map<'a, I: AsyncIterable, R: Promising>(
607        val: &I,
608        map: &ScopedClosure<'a, dyn FnMut(I::Item, u32) -> Result<R, JsError>>,
609    ) -> Result<Promise<Array<R::Resolution>>, JsValue>;
610
611    /// The `copyWithin()` method shallow copies part of an array to another
612    /// location in the same array and returns it, without modifying its size.
613    ///
614    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin)
615    #[wasm_bindgen(method, js_name = copyWithin)]
616    pub fn copy_within<T>(this: &Array<T>, target: i32, start: i32, end: i32) -> Array<T>;
617
618    /// The `concat()` method is used to merge two or more arrays. This method
619    /// does not change the existing arrays, but instead returns a new array.
620    ///
621    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat)
622    #[wasm_bindgen(method)]
623    pub fn concat<T, U: Upcast<T>>(this: &Array<T>, array: &Array<U>) -> Array<T>;
624
625    /// The `concat()` method is used to merge two or more arrays. This method
626    /// does not change the existing arrays, but instead returns a new array.
627    ///
628    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat)
629    #[wasm_bindgen(method)]
630    pub fn concat_many<T, U: Upcast<T>>(this: &Array<T>, array: &[Array<U>]) -> Array<T>;
631
632    /// The `every()` method tests whether all elements in the array pass the test
633    /// implemented by the provided function.
634    ///
635    /// **Note:** Consider using [`Array::try_every`] if the predicate might throw an error.
636    ///
637    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every)
638    #[wasm_bindgen(method)]
639    pub fn every<T>(this: &Array<T>, predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool) -> bool;
640
641    /// The `every()` method tests whether all elements in the array pass the test
642    /// implemented by the provided function. _(Fallible variation)_
643    ///
644    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every)
645    #[wasm_bindgen(method, js_name = every, catch)]
646    pub fn try_every<T>(
647        this: &Array<T>,
648        predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
649    ) -> Result<bool, JsValue>;
650
651    /// The `fill()` method fills all the elements of an array from a start index
652    /// to an end index with a static value. The end index is not included.
653    ///
654    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill)
655    #[wasm_bindgen(method)]
656    pub fn fill<T>(this: &Array<T>, value: &T, start: u32, end: u32) -> Array<T>;
657
658    /// The `filter()` method creates a new array with all elements that pass the
659    /// test implemented by the provided function.
660    ///
661    /// **Note:** Consider using [`Array::try_filter`] if the predicate might throw an error.
662    ///
663    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
664    #[wasm_bindgen(method)]
665    pub fn filter<T>(
666        this: &Array<T>,
667        predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool,
668    ) -> Array<T>;
669
670    /// The `filter()` method creates a new array with all elements that pass the
671    /// test implemented by the provided function. _(Fallible variation)_
672    ///
673    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
674    #[wasm_bindgen(method, js_name = filter, catch)]
675    pub fn try_filter<T>(
676        this: &Array<T>,
677        predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
678    ) -> Result<Array<T>, JsValue>;
679
680    /// The `find()` method returns the value of the first element in the array that satisfies
681    /// the provided testing function. Otherwise `undefined` is returned.
682    ///
683    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)
684    #[cfg(not(js_sys_unstable_apis))]
685    #[wasm_bindgen(method)]
686    pub fn find<T>(this: &Array<T>, predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool) -> T;
687
688    /// The `find()` method returns the value of the first element in the array that satisfies
689    /// the provided testing function. Returns `None` if no element matches.
690    ///
691    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)
692    #[cfg(js_sys_unstable_apis)]
693    #[wasm_bindgen(method)]
694    pub fn find<T>(
695        this: &Array<T>,
696        predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool,
697    ) -> Option<T>;
698
699    /// The `find()` method returns the value of the first element in the array that satisfies
700    ///  the provided testing function. Otherwise `undefined` is returned. _(Fallible variation)_
701    ///
702    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)
703    #[wasm_bindgen(method, js_name = find, catch)]
704    pub fn try_find<T>(
705        this: &Array<T>,
706        predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
707    ) -> Result<Option<T>, JsValue>;
708
709    /// The `findIndex()` method returns the index of the first element in the array that
710    /// satisfies the provided testing function. Otherwise -1 is returned.
711    ///
712    /// **Note:** Consider using [`Array::try_find_index`] if the predicate might throw an error.
713    ///
714    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex)
715    #[wasm_bindgen(method, js_name = findIndex)]
716    pub fn find_index<T>(
717        this: &Array<T>,
718        predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool,
719    ) -> i32;
720
721    /// The `findIndex()` method returns the index of the first element in the array that
722    /// satisfies the provided testing function. Otherwise -1 is returned. _(Fallible variation)_
723    ///
724    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex)
725    #[wasm_bindgen(method, js_name = findIndex, catch)]
726    pub fn try_find_index<T>(
727        this: &Array<T>,
728        predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
729    ) -> Result<i32, JsValue>;
730
731    /// The `findLast()` method of Array instances iterates the array in reverse order
732    /// and returns the value of the first element that satisfies the provided testing function.
733    /// If no elements satisfy the testing function, undefined is returned.
734    ///
735    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast)
736    #[cfg(not(js_sys_unstable_apis))]
737    #[wasm_bindgen(method, js_name = findLast)]
738    pub fn find_last<T>(this: &Array<T>, predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool) -> T;
739
740    /// The `findLast()` method of Array instances iterates the array in reverse order
741    /// and returns the value of the first element that satisfies the provided testing function.
742    /// Returns `None` if no element matches.
743    ///
744    /// **Note:** Consider using [`Array::try_find_last`] if the predicate might throw an error.
745    ///
746    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast)
747    #[cfg(js_sys_unstable_apis)]
748    #[wasm_bindgen(method, js_name = findLast)]
749    pub fn find_last<T>(this: &Array<T>, predicate: &mut dyn FnMut(T, u32) -> bool) -> Option<T>;
750
751    /// The `findLast()` method of Array instances iterates the array in reverse order
752    /// and returns the value of the first element that satisfies the provided testing function.
753    /// If no elements satisfy the testing function, undefined is returned. _(Fallible variation)_
754    ///
755    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast)
756    #[wasm_bindgen(method, js_name = findLast, catch)]
757    pub fn try_find_last<T>(
758        this: &Array<T>,
759        predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
760    ) -> Result<Option<T>, JsValue>;
761
762    /// The `findLastIndex()` method of Array instances iterates the array in reverse order
763    /// and returns the index of the first element that satisfies the provided testing function.
764    /// If no elements satisfy the testing function, -1 is returned.
765    ///
766    /// **Note:** Consider using [`Array::try_find_last_index`] if the predicate might throw an error.
767    ///
768    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex)
769    #[wasm_bindgen(method, js_name = findLastIndex)]
770    pub fn find_last_index<T>(
771        this: &Array<T>,
772        predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool,
773    ) -> i32;
774
775    /// The `findLastIndex()` method of Array instances iterates the array in reverse order
776    /// and returns the index of the first element that satisfies the provided testing function.
777    /// If no elements satisfy the testing function, -1 is returned. _(Fallible variation)_
778    ///
779    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex)
780    #[wasm_bindgen(method, js_name = findLastIndex, catch)]
781    pub fn try_find_last_index<T>(
782        this: &Array<T>,
783        predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
784    ) -> Result<i32, JsValue>;
785
786    /// The `flat()` method creates a new array with all sub-array elements concatenated into it
787    /// recursively up to the specified depth.
788    ///
789    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat)
790    #[wasm_bindgen(method)]
791    pub fn flat<T>(this: &Array<T>, depth: i32) -> Array<JsValue>;
792
793    /// The `flatMap()` method first maps each element using a mapping function, then flattens
794    /// the result into a new array.
795    ///
796    /// **Note:** Consider using [`Array::try_flat_map`] for safer fallible handling.
797    ///
798    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap)
799    #[wasm_bindgen(method, js_name = flatMap)]
800    pub fn flat_map<T, U>(
801        this: &Array<T>,
802        callback: &mut dyn FnMut(T, u32, Array<T>) -> Vec<U>,
803    ) -> Array<U>;
804
805    /// The `flatMap()` method first maps each element using a mapping function, then flattens
806    /// the result into a new array.
807    ///
808    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap)
809    #[wasm_bindgen(method, js_name = flatMap, catch)]
810    pub fn try_flat_map<T, U>(
811        this: &Array<T>,
812        callback: &mut dyn FnMut(T, u32) -> Vec<U>,
813    ) -> Result<Array<U>, JsValue>;
814
815    /// The `forEach()` method executes a provided function once for each array element.
816    ///
817    /// **Note:** Consider using [`Array::try_for_each`] if the callback might throw an error.
818    ///
819    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)
820    #[wasm_bindgen(method, js_name = forEach)]
821    pub fn for_each<T: JsGeneric>(this: &Array<T>, callback: &mut dyn FnMut(T, u32, Array<T>));
822
823    /// The `forEach()` method executes a provided function once for each array element. _(Fallible variation)_
824    ///
825    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)
826    #[wasm_bindgen(method, js_name = forEach, catch)]
827    pub fn try_for_each<T>(
828        this: &Array<T>,
829        callback: &mut dyn FnMut(T, u32) -> Result<(), JsError>,
830    ) -> Result<(), JsValue>;
831
832    /// The `includes()` method determines whether an array includes a certain
833    /// element, returning true or false as appropriate.
834    ///
835    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes)
836    #[wasm_bindgen(method)]
837    pub fn includes<T>(this: &Array<T>, value: &T, from_index: i32) -> bool;
838
839    /// The `indexOf()` method returns the first index at which a given element
840    /// can be found in the array, or -1 if it is not present.
841    ///
842    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf)
843    #[wasm_bindgen(method, js_name = indexOf)]
844    pub fn index_of<T>(this: &Array<T>, value: &T, from_index: i32) -> i32;
845
846    /// The `Array.isArray()` method determines whether the passed value is an Array.
847    ///
848    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray)
849    #[wasm_bindgen(static_method_of = Array, js_name = isArray)]
850    pub fn is_array(value: &JsValue) -> bool;
851
852    /// The `join()` method joins all elements of an array (or an array-like object)
853    /// into a string and returns this string.
854    ///
855    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join)
856    #[wasm_bindgen(method)]
857    pub fn join<T>(this: &Array<T>, delimiter: &str) -> JsString;
858
859    /// The `lastIndexOf()` method returns the last index at which a given element
860    /// can be found in the array, or -1 if it is not present. The array is
861    /// searched backwards, starting at fromIndex.
862    ///
863    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf)
864    #[wasm_bindgen(method, js_name = lastIndexOf)]
865    pub fn last_index_of<T>(this: &Array<T>, value: &T, from_index: i32) -> i32;
866
867    /// The length property of an object which is an instance of type Array
868    /// sets or returns the number of elements in that array. The value is an
869    /// unsigned, 32-bit integer that is always numerically greater than the
870    /// highest index in the array.
871    ///
872    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length)
873    #[wasm_bindgen(method, getter)]
874    pub fn length<T>(this: &Array<T>) -> u32;
875
876    /// Sets the length of the array.
877    ///
878    /// If it is set to less than the current length of the array, it will
879    /// shrink the array.
880    ///
881    /// If it is set to more than the current length of the array, it will
882    /// increase the length of the array, filling the new space with empty
883    /// slots.
884    ///
885    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length)
886    #[wasm_bindgen(method, setter)]
887    pub fn set_length<T>(this: &Array<T>, value: u32);
888
889    /// `map()` calls a provided callback function once for each element in an array,
890    /// in order, and constructs a new array from the results. callback is invoked
891    /// only for indexes of the array which have assigned values, including undefined.
892    /// It is not called for missing elements of the array (that is, indexes that have
893    /// never been set, which have been deleted or which have never been assigned a value).
894    ///
895    /// **Note:** Consider using [`Array::try_map`] for safer fallible handling.
896    ///
897    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
898    #[wasm_bindgen(method)]
899    pub fn map<T, U>(this: &Array<T>, predicate: &mut dyn FnMut(T, u32, Array<T>) -> U)
900        -> Array<U>;
901
902    /// `map()` calls a provided callback function once for each element in an array,
903    /// in order, and constructs a new array from the results. callback is invoked
904    /// only for indexes of the array which have assigned values, including undefined.
905    /// It is not called for missing elements of the array (that is, indexes that have
906    /// never been set, which have been deleted or which have never been assigned a value).
907    /// _(Fallible variation)_
908    ///
909    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
910    #[wasm_bindgen(method, js_name = map, catch)]
911    pub fn try_map<T, U>(
912        this: &Array<T>,
913        predicate: &mut dyn FnMut(T, u32) -> Result<U, JsError>,
914    ) -> Result<Array<U>, JsValue>;
915
916    /// The `Array.of()` method creates a new Array instance with a variable
917    /// number of arguments, regardless of number or type of the arguments.
918    ///
919    /// Note: For type inference use `Array::<T>::of(&[T])`.
920    ///
921    /// The difference between `Array.of()` and the `Array` constructor is in the
922    /// handling of integer arguments: `Array.of(7)` creates an array with a single
923    /// element, `7`, whereas `Array(7)` creates an empty array with a `length`
924    /// property of `7` (Note: this implies an array of 7 empty slots, not slots
925    /// with actual undefined values).
926    ///
927    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
928    #[wasm_bindgen(static_method_of = Array, js_name = of, variadic)]
929    pub fn of<T>(values: &[T]) -> Array<T>;
930
931    // Next major: deprecate these
932    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
933    #[wasm_bindgen(static_method_of = Array, js_name = of)]
934    pub fn of1(a: &JsValue) -> Array;
935
936    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
937    #[wasm_bindgen(static_method_of = Array, js_name = of)]
938    pub fn of2(a: &JsValue, b: &JsValue) -> Array;
939
940    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
941    #[wasm_bindgen(static_method_of = Array, js_name = of)]
942    pub fn of3(a: &JsValue, b: &JsValue, c: &JsValue) -> Array;
943
944    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
945    #[wasm_bindgen(static_method_of = Array, js_name = of)]
946    pub fn of4(a: &JsValue, b: &JsValue, c: &JsValue, d: &JsValue) -> Array;
947
948    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
949    #[wasm_bindgen(static_method_of = Array, js_name = of)]
950    pub fn of5(a: &JsValue, b: &JsValue, c: &JsValue, d: &JsValue, e: &JsValue) -> Array;
951
952    /// The `pop()` method removes the last element from an array and returns that
953    /// element. This method changes the length of the array.
954    ///
955    /// **Note:** Consider using [`Array::pop_checked`] for handling empty arrays.
956    ///
957    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop)
958    #[cfg(not(js_sys_unstable_apis))]
959    #[wasm_bindgen(method)]
960    pub fn pop<T>(this: &Array<T>) -> T;
961
962    /// The `pop()` method removes the last element from an array and returns that
963    /// element. This method changes the length of the array.
964    /// Returns `None` if the array is empty.
965    ///
966    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop)
967    #[cfg(js_sys_unstable_apis)]
968    #[wasm_bindgen(method)]
969    pub fn pop<T>(this: &Array<T>) -> Option<T>;
970
971    // Next major: deprecate
972    /// The `pop()` method removes the last element from an array and returns that
973    /// element. This method changes the length of the array.
974    ///
975    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop)
976    #[wasm_bindgen(method, js_name = pop)]
977    pub fn pop_checked<T>(this: &Array<T>) -> Option<T>;
978
979    /// The `push()` method adds one element to the end of an array and
980    /// returns the new length of the array.
981    ///
982    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push)
983    #[wasm_bindgen(method)]
984    pub fn push<T>(this: &Array<T>, value: &T) -> u32;
985
986    /// The `push()` method adds one or more elements to the end of an array and
987    /// returns the new length of the array.
988    ///
989    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push)
990    #[wasm_bindgen(method, js_name = push, variadic)]
991    pub fn push_many<T>(this: &Array<T>, values: &[T]) -> u32;
992
993    /// The `reduce()` method applies a function against an accumulator and each element in
994    /// the array (from left to right) to reduce it to a single value.
995    ///
996    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce)
997    #[cfg(not(js_sys_unstable_apis))]
998    #[wasm_bindgen(method)]
999    pub fn reduce<T>(
1000        this: &Array<T>,
1001        predicate: &mut dyn FnMut(JsValue, T, u32, Array<T>) -> JsValue,
1002        initial_value: &JsValue,
1003    ) -> JsValue;
1004
1005    /// The `reduce()` method applies a function against an accumulator and each element in
1006    /// the array (from left to right) to reduce it to a single value.
1007    ///
1008    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce)
1009    #[cfg(js_sys_unstable_apis)]
1010    #[wasm_bindgen(method)]
1011    pub fn reduce<T, A>(
1012        this: &Array<T>,
1013        predicate: &mut dyn FnMut(A, T, u32, Array<T>) -> A,
1014        initial_value: &A,
1015    ) -> A;
1016
1017    /// The `reduce()` method applies a function against an accumulator and each element in
1018    /// the array (from left to right) to reduce it to a single value. _(Fallible variation)_
1019    ///
1020    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce)
1021    #[wasm_bindgen(method, js_name = reduce, catch)]
1022    pub fn try_reduce<T, A>(
1023        this: &Array<T>,
1024        predicate: &mut dyn FnMut(A, T, u32) -> Result<A, JsError>,
1025        initial_value: &A,
1026    ) -> Result<A, JsValue>;
1027
1028    /// The `reduceRight()` method applies a function against an accumulator and each value
1029    /// of the array (from right-to-left) to reduce it to a single value.
1030    ///
1031    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/ReduceRight)
1032    #[cfg(not(js_sys_unstable_apis))]
1033    #[wasm_bindgen(method, js_name = reduceRight)]
1034    pub fn reduce_right<T>(
1035        this: &Array<T>,
1036        predicate: &mut dyn FnMut(JsValue, T, u32, Array<T>) -> JsValue,
1037        initial_value: &JsValue,
1038    ) -> JsValue;
1039
1040    /// The `reduceRight()` method applies a function against an accumulator and each value
1041    /// of the array (from right-to-left) to reduce it to a single value.
1042    ///
1043    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/ReduceRight)
1044    #[cfg(js_sys_unstable_apis)]
1045    #[wasm_bindgen(method, js_name = reduceRight)]
1046    pub fn reduce_right<T, A>(
1047        this: &Array<T>,
1048        predicate: &mut dyn FnMut(A, T, u32, Array<T>) -> A,
1049        initial_value: &A,
1050    ) -> A;
1051
1052    /// The `reduceRight()` method applies a function against an accumulator and each value
1053    /// of the array (from right-to-left) to reduce it to a single value. _(Fallible variation)_
1054    ///
1055    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/ReduceRight)
1056    #[wasm_bindgen(method, js_name = reduceRight, catch)]
1057    pub fn try_reduce_right<T, A>(
1058        this: &Array<T>,
1059        predicate: &mut dyn FnMut(JsValue, T, u32) -> Result<A, JsError>,
1060        initial_value: &A,
1061    ) -> Result<A, JsValue>;
1062
1063    /// The `reverse()` method reverses an array in place. The first array
1064    /// element becomes the last, and the last array element becomes the first.
1065    ///
1066    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse)
1067    #[wasm_bindgen(method)]
1068    pub fn reverse<T>(this: &Array<T>) -> Array<T>;
1069
1070    /// The `shift()` method removes the first element from an array and returns
1071    /// that removed element. This method changes the length of the array.
1072    ///
1073    /// **Note:** Consider using [`Array::shift_checked`] for handling empty arrays.
1074    ///
1075    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift)
1076    #[cfg(not(js_sys_unstable_apis))]
1077    #[wasm_bindgen(method)]
1078    pub fn shift<T>(this: &Array<T>) -> T;
1079
1080    /// The `shift()` method removes the first element from an array and returns
1081    /// that removed element. This method changes the length of the array.
1082    /// Returns `None` if the array is empty.
1083    ///
1084    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift)
1085    #[cfg(js_sys_unstable_apis)]
1086    #[wasm_bindgen(method)]
1087    pub fn shift<T>(this: &Array<T>) -> Option<T>;
1088
1089    // Next major: deprecate
1090    /// The `shift()` method removes the first element from an array and returns
1091    /// that removed element. This method changes the length of the array.
1092    ///
1093    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift)
1094    #[wasm_bindgen(method, js_name = shift)]
1095    pub fn shift_checked<T>(this: &Array<T>) -> Option<T>;
1096
1097    /// The `slice()` method returns a shallow copy of a portion of an array into
1098    /// a new array object selected from begin to end (end not included).
1099    /// The original array will not be modified.
1100    ///
1101    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)
1102    #[cfg(not(js_sys_unstable_apis))]
1103    #[wasm_bindgen(method)]
1104    pub fn slice<T>(this: &Array<T>, start: u32, end: u32) -> Array<T>;
1105
1106    /// The `slice()` method returns a shallow copy of a portion of an array into
1107    /// a new array object selected from begin to end (end not included).
1108    /// The original array will not be modified. Negative indices count from the end.
1109    ///
1110    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)
1111    #[cfg(js_sys_unstable_apis)]
1112    #[wasm_bindgen(method)]
1113    pub fn slice<T>(this: &Array<T>, start: i32, end: i32) -> Array<T>;
1114
1115    /// The `slice()` method returns a shallow copy of a portion of an array into
1116    /// a new array object selected from the given index to the end.
1117    /// The original array will not be modified.
1118    ///
1119    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)
1120    #[cfg(not(js_sys_unstable_apis))]
1121    #[wasm_bindgen(method, js_name = slice)]
1122    pub fn slice_from<T>(this: &Array<T>, start: u32) -> Array<T>;
1123
1124    /// The `slice()` method returns a shallow copy of a portion of an array into
1125    /// a new array object selected from the given index to the end.
1126    /// The original array will not be modified. Negative indices count from the end.
1127    ///
1128    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)
1129    #[cfg(js_sys_unstable_apis)]
1130    #[wasm_bindgen(method, js_name = slice)]
1131    pub fn slice_from<T>(this: &Array<T>, start: i32) -> Array<T>;
1132
1133    /// The `some()` method tests whether at least one element in the array passes the test implemented
1134    /// by the provided function.
1135    /// Note: This method returns false for any condition put on an empty array.
1136    ///
1137    /// **Note:** Consider using [`Array::try_some`] if the predicate might throw an error.
1138    ///
1139    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some)
1140    #[wasm_bindgen(method)]
1141    pub fn some<T>(this: &Array<T>, predicate: &mut dyn FnMut(T) -> bool) -> bool;
1142
1143    /// The `some()` method tests whether at least one element in the array passes the test implemented
1144    /// by the provided function. _(Fallible variation)_
1145    /// Note: This method returns false for any condition put on an empty array.
1146    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some)
1147    #[wasm_bindgen(method, js_name = some, catch)]
1148    pub fn try_some<T>(
1149        this: &Array<T>,
1150        predicate: &mut dyn FnMut(T) -> Result<bool, JsError>,
1151    ) -> Result<bool, JsValue>;
1152
1153    /// The `sort()` method sorts the elements of an array in place and returns
1154    /// the array. The sort is not necessarily stable. The default sort
1155    /// order is according to string Unicode code points.
1156    ///
1157    /// The time and space complexity of the sort cannot be guaranteed as it
1158    /// is implementation dependent.
1159    ///
1160    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)
1161    #[wasm_bindgen(method)]
1162    pub fn sort<T>(this: &Array<T>) -> Array<T>;
1163
1164    /// The `sort()` method with a custom compare function.
1165    ///
1166    /// **Note:** Consider using [`Array::try_sort_by`] if the predicate might throw an error.
1167    ///
1168    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)
1169    #[wasm_bindgen(method, js_name = sort)]
1170    pub fn sort_by<T>(this: &Array<T>, compare_fn: &mut dyn FnMut(T, T) -> i32) -> Array<T>;
1171
1172    /// The `sort()` method with a custom compare function. _(Fallible variation)_
1173    ///
1174    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)
1175    #[wasm_bindgen(method, js_name = sort, catch)]
1176    pub fn try_sort_by<T>(
1177        this: &Array<T>,
1178        compare_fn: &mut dyn FnMut(T, T) -> Result<i32, JsError>,
1179    ) -> Result<Array<T>, JsValue>;
1180
1181    /// The `splice()` method changes the contents of an array by removing existing elements and/or
1182    /// adding new elements.
1183    ///
1184    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice)
1185    #[wasm_bindgen(method)]
1186    pub fn splice<T>(this: &Array<T>, start: u32, delete_count: u32, item: &T) -> Array<T>;
1187
1188    /// The `splice()` method changes the contents of an array by removing existing elements and/or
1189    /// adding new elements.
1190    ///
1191    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice)
1192    #[wasm_bindgen(method, js_name = splice, variadic)]
1193    pub fn splice_many<T>(this: &Array<T>, start: u32, delete_count: u32, items: &[T]) -> Array<T>;
1194
1195    /// The `toLocaleString()` method returns a string representing the elements of the array.
1196    /// The elements are converted to Strings using their toLocaleString methods and these
1197    /// Strings are separated by a locale-specific String (such as a comma ",").
1198    ///
1199    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString)
1200    #[cfg(not(js_sys_unstable_apis))]
1201    #[wasm_bindgen(method, js_name = toLocaleString)]
1202    pub fn to_locale_string<T>(this: &Array<T>, locales: &JsValue, options: &JsValue) -> JsString;
1203
1204    /// The `toLocaleString()` method returns a string representing the elements of the array.
1205    /// The elements are converted to Strings using their toLocaleString methods and these
1206    /// Strings are separated by a locale-specific String (such as a comma ",").
1207    ///
1208    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString)
1209    #[cfg(js_sys_unstable_apis)]
1210    #[wasm_bindgen(method, js_name = toLocaleString)]
1211    pub fn to_locale_string<T>(
1212        this: &Array<T>,
1213        locales: &[JsString],
1214        options: &Intl::NumberFormatOptions,
1215    ) -> JsString;
1216
1217    /// The `toReversed()` method returns a new array with the elements in reversed order,
1218    /// without modifying the original array.
1219    ///
1220    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toReversed)
1221    #[wasm_bindgen(method, js_name = toReversed)]
1222    pub fn to_reversed<T>(this: &Array<T>) -> Array<T>;
1223
1224    /// The `toSorted()` method returns a new array with the elements sorted in ascending order,
1225    /// without modifying the original array.
1226    ///
1227    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSorted)
1228    #[wasm_bindgen(method, js_name = toSorted)]
1229    pub fn to_sorted<T>(this: &Array<T>) -> Array<T>;
1230
1231    /// The `toSorted()` method with a custom compare function.
1232    ///
1233    /// **Note:** Consider using [`Array::try_to_sorted_by`] if the predicate might throw an error.
1234    ///
1235    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSorted)
1236    #[wasm_bindgen(method, js_name = toSorted)]
1237    pub fn to_sorted_by<T>(this: &Array<T>, compare_fn: &mut dyn FnMut(T, T) -> i32) -> Array<T>;
1238
1239    /// The `toSorted()` method with a custom compare function. _(Fallible variation)_
1240    ///
1241    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSorted)
1242    #[wasm_bindgen(method, js_name = toSorted, catch)]
1243    pub fn try_to_sorted_by<T>(
1244        this: &Array<T>,
1245        compare_fn: &mut dyn FnMut(T, T) -> Result<i32, JsError>,
1246    ) -> Result<Array<T>, JsValue>;
1247
1248    /// The `toSpliced()` method returns a new array with some elements removed and/or
1249    /// replaced at a given index, without modifying the original array.
1250    ///
1251    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSpliced)
1252    #[wasm_bindgen(method, js_name = toSpliced, variadic)]
1253    pub fn to_spliced<T>(this: &Array<T>, start: u32, delete_count: u32, items: &[T]) -> Array<T>;
1254
1255    /// The `toString()` method returns a string representing the specified array
1256    /// and its elements.
1257    ///
1258    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString)
1259    #[cfg(not(js_sys_unstable_apis))]
1260    #[wasm_bindgen(method, js_name = toString)]
1261    pub fn to_string<T>(this: &Array<T>) -> JsString;
1262
1263    /// Converts the Array into a Vector.
1264    #[wasm_bindgen(method, js_name = slice)]
1265    pub fn to_vec<T>(this: &Array<T>) -> Vec<T>;
1266
1267    /// The `unshift()` method adds one element to the beginning of an
1268    /// array and returns the new length of the array.
1269    ///
1270    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift)
1271    #[wasm_bindgen(method)]
1272    pub fn unshift<T>(this: &Array<T>, value: &T) -> u32;
1273
1274    /// The `unshift()` method adds one or more elements to the beginning of an
1275    /// array and returns the new length of the array.
1276    ///
1277    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift)
1278    #[wasm_bindgen(method, js_name = unshift, variadic)]
1279    pub fn unshift_many<T>(this: &Array<T>, values: &[T]) -> u32;
1280
1281    /// The `with()` method returns a new array with the element at the given index
1282    /// replaced with the given value, without modifying the original array.
1283    ///
1284    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/with)
1285    #[wasm_bindgen(method, js_name = with)]
1286    pub fn with<T>(this: &Array<T>, index: u32, value: &T) -> Array<T>;
1287}
1288
1289// Tuples as a typed array variant
1290#[wasm_bindgen]
1291extern "C" {
1292    #[wasm_bindgen(extends = Object, js_name = Array, is_type_of = Array::is_array, no_upcast, typescript_type = "Array<any>")]
1293    #[derive(Clone, Debug)]
1294    pub type ArrayTuple<T: JsTuple = (JsValue,)>;
1295
1296    /// Creates a new JS array typed as a 1-tuple.
1297    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1298    pub fn new1<T1>(t1: &T1) -> ArrayTuple<(T1,)>;
1299
1300    /// Creates a new JS array typed as a 2-tuple.
1301    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1302    pub fn new2<T1, T2>(t1: &T1, t2: &T2) -> ArrayTuple<(T1, T2)>;
1303
1304    /// Creates a new JS array typed as a 3-tuple.
1305    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1306    pub fn new3<T1, T2, T3>(t1: &T1, t2: &T2, t3: &T3) -> ArrayTuple<(T1, T2, T3)>;
1307
1308    /// Creates a new JS array typed as a 4-tuple.
1309    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1310    pub fn new4<T1, T2, T3, T4>(t1: &T1, t2: &T2, t3: &T3, t4: &T4)
1311        -> ArrayTuple<(T1, T2, T3, T4)>;
1312
1313    /// Creates a new JS array typed as a 5-tuple.
1314    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1315    pub fn new5<T1, T2, T3, T4, T5>(
1316        t1: &T1,
1317        t2: &T2,
1318        t3: &T3,
1319        t4: &T4,
1320        t5: &T5,
1321    ) -> ArrayTuple<(T1, T2, T3, T4, T5)>;
1322
1323    /// Creates a new JS array typed as a 6-tuple.
1324    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1325    pub fn new6<T1, T2, T3, T4, T5, T6>(
1326        t1: &T1,
1327        t2: &T2,
1328        t3: &T3,
1329        t4: &T4,
1330        t5: &T5,
1331        t6: &T6,
1332    ) -> ArrayTuple<(T1, T2, T3, T4, T5, T6)>;
1333
1334    /// Creates a new JS array typed as a 7-tuple.
1335    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1336    pub fn new7<T1, T2, T3, T4, T5, T6, T7>(
1337        t1: &T1,
1338        t2: &T2,
1339        t3: &T3,
1340        t4: &T4,
1341        t5: &T5,
1342        t6: &T6,
1343        t7: &T7,
1344    ) -> ArrayTuple<(T1, T2, T3, T4, T5, T6, T7)>;
1345
1346    /// Creates a new JS array typed as a 8-tuple.
1347    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1348    pub fn new8<T1, T2, T3, T4, T5, T6, T7, T8>(
1349        t1: &T1,
1350        t2: &T2,
1351        t3: &T3,
1352        t4: &T4,
1353        t5: &T5,
1354        t6: &T6,
1355        t7: &T7,
1356        t8: &T8,
1357    ) -> ArrayTuple<(T1, T2, T3, T4, T5, T6, T7, T8)>;
1358
1359    /// Gets the 1st item
1360    #[wasm_bindgen(
1361        method,
1362        js_class = Array,
1363        getter,
1364        js_name = "0"
1365    )]
1366    pub fn get0<T: JsTuple1 = (JsValue,)>(this: &ArrayTuple<T>) -> <T as JsTuple1>::T1;
1367
1368    /// Gets the 2nd item
1369    #[wasm_bindgen(
1370        method,
1371        js_class = Array,
1372        getter,
1373        js_name = "1"
1374    )]
1375    pub fn get1<T: JsTuple2 = (JsValue, JsValue)>(this: &ArrayTuple<T>) -> <T as JsTuple2>::T2;
1376
1377    /// Gets the 3rd item
1378    #[wasm_bindgen(
1379        method,
1380        js_class = Array,
1381        getter,
1382        js_name = "2"
1383    )]
1384    pub fn get2<T: JsTuple3 = (JsValue, JsValue, JsValue)>(
1385        this: &ArrayTuple<T>,
1386    ) -> <T as JsTuple3>::T3;
1387
1388    /// Gets the 4th item
1389    #[wasm_bindgen(
1390        method,
1391        js_class = Array,
1392        getter,
1393        js_name = "3"
1394    )]
1395    pub fn get3<T: JsTuple4 = (JsValue, JsValue, JsValue, JsValue)>(
1396        this: &ArrayTuple<T>,
1397    ) -> <T as JsTuple4>::T4;
1398
1399    /// Gets the 5th item
1400    #[wasm_bindgen(
1401        method,
1402        js_class = Array,
1403        getter,
1404        js_name = "4"
1405    )]
1406    pub fn get4<T: JsTuple5 = (JsValue, JsValue, JsValue, JsValue, JsValue)>(
1407        this: &ArrayTuple<T>,
1408    ) -> <T as JsTuple5>::T5;
1409
1410    /// Gets the 6th item
1411    #[wasm_bindgen(
1412        method,
1413        js_class = Array,
1414        getter,
1415        js_name = "5"
1416    )]
1417    pub fn get5<T: JsTuple6 = (JsValue, JsValue, JsValue, JsValue, JsValue, JsValue)>(
1418        this: &ArrayTuple<T>,
1419    ) -> <T as JsTuple6>::T6;
1420
1421    /// Gets the 7th item
1422    #[wasm_bindgen(
1423        method,
1424        js_class = Array,
1425        getter,
1426        js_name = "6"
1427    )]
1428    pub fn get6<
1429        T: JsTuple7 = (
1430            JsValue,
1431            JsValue,
1432            JsValue,
1433            JsValue,
1434            JsValue,
1435            JsValue,
1436            JsValue,
1437        ),
1438    >(
1439        this: &ArrayTuple<T>,
1440    ) -> <T as JsTuple7>::T7;
1441
1442    /// Gets the 8th item
1443    #[wasm_bindgen(
1444        method,
1445        js_class = Array,
1446        getter,
1447        js_name = "7"
1448    )]
1449    pub fn get7<
1450        T: JsTuple8 = (
1451            JsValue,
1452            JsValue,
1453            JsValue,
1454            JsValue,
1455            JsValue,
1456            JsValue,
1457            JsValue,
1458            JsValue,
1459        ),
1460    >(
1461        this: &ArrayTuple<T>,
1462    ) -> <T as JsTuple8>::T8;
1463
1464    /// Sets the 1st item
1465    #[wasm_bindgen(
1466        method,
1467        js_class = Array,
1468        setter,
1469        js_name = "0"
1470    )]
1471    pub fn set0<T: JsTuple1 = (JsValue,)>(this: &ArrayTuple<T>, value: &<T as JsTuple1>::T1);
1472
1473    /// Sets the 2nd item
1474    #[wasm_bindgen(
1475        method,
1476        js_class = Array,
1477        setter,
1478        js_name = "1"
1479    )]
1480    pub fn set1<T: JsTuple2 = (JsValue, JsValue)>(
1481        this: &ArrayTuple<T>,
1482        value: &<T as JsTuple2>::T2,
1483    );
1484
1485    /// Sets the 3rd item
1486    #[wasm_bindgen(
1487        method,
1488        js_class = Array,
1489        setter,
1490        js_name = "2"
1491    )]
1492    pub fn set2<T: JsTuple3 = (JsValue, JsValue, JsValue)>(
1493        this: &ArrayTuple<T>,
1494        value: &<T as JsTuple3>::T3,
1495    );
1496
1497    /// Sets the 4th item
1498    #[wasm_bindgen(
1499        method,
1500        js_class = Array,
1501        setter,
1502        js_name = "3"
1503    )]
1504    pub fn set3<T: JsTuple4 = (JsValue, JsValue, JsValue, JsValue)>(
1505        this: &ArrayTuple<T>,
1506        value: &<T as JsTuple4>::T4,
1507    );
1508
1509    /// Sets the 5th item
1510    #[wasm_bindgen(
1511        method,
1512        js_class = Array,
1513        setter,
1514        js_name = "4"
1515    )]
1516    pub fn set4<T: JsTuple5 = (JsValue, JsValue, JsValue, JsValue, JsValue)>(
1517        this: &ArrayTuple<T>,
1518        value: &<T as JsTuple5>::T5,
1519    );
1520
1521    /// Sets the 6th item
1522    #[wasm_bindgen(
1523        method,
1524        js_class = Array,
1525        setter,
1526        js_name = "5"
1527    )]
1528    pub fn set5<T: JsTuple6 = (JsValue, JsValue, JsValue, JsValue, JsValue, JsValue)>(
1529        this: &ArrayTuple<T>,
1530        value: &<T as JsTuple6>::T6,
1531    );
1532
1533    /// Sets the 7th item
1534    #[wasm_bindgen(
1535        method,
1536        js_class = Array,
1537        setter,
1538        js_name = "6"
1539    )]
1540    pub fn set6<
1541        T: JsTuple7 = (
1542            JsValue,
1543            JsValue,
1544            JsValue,
1545            JsValue,
1546            JsValue,
1547            JsValue,
1548            JsValue,
1549        ),
1550    >(
1551        this: &ArrayTuple<T>,
1552        value: &<T as JsTuple7>::T7,
1553    );
1554
1555    /// Sets the 8th item
1556    #[wasm_bindgen(
1557        method,
1558        js_class = Array,
1559        setter,
1560        js_name = "7"
1561    )]
1562    pub fn set7<
1563        T: JsTuple8 = (
1564            JsValue,
1565            JsValue,
1566            JsValue,
1567            JsValue,
1568            JsValue,
1569            JsValue,
1570            JsValue,
1571            JsValue,
1572        ),
1573    >(
1574        this: &ArrayTuple<T>,
1575        value: &<T as JsTuple8>::T8,
1576    );
1577}
1578
1579/// Base trait for tuple types.
1580pub trait JsTuple {
1581    const ARITY: usize;
1582}
1583
1584macro_rules! impl_tuple_traits {
1585    // Base case: first trait has no parent (besides JsTuple)
1586    ($name:ident $ty:tt) => {
1587        pub trait $name: JsTuple {
1588            type $ty;
1589        }
1590    };
1591
1592    // Recursive case: define trait with parent, then recurse
1593    ($name:ident $ty:tt $($rest_name:ident $rest_ty:tt)+) => {
1594        pub trait $name: JsTuple {
1595            type $ty;
1596        }
1597
1598        impl_tuple_traits!(@with_parent $name $($rest_name $rest_ty)+);
1599    };
1600
1601    // Internal: traits that have a parent
1602    (@with_parent $trait:ident $name:ident $ty:tt) => {
1603        pub trait $name: $trait {
1604            type $ty;
1605        }
1606    };
1607
1608    (@with_parent $trait:ident $name:ident $ty:tt $($rest_name:ident $rest_ty:tt)+) => {
1609        pub trait $name: $trait {
1610            type $ty;
1611        }
1612
1613        impl_tuple_traits!(@with_parent $name $($rest_name $rest_ty)+);
1614    };
1615}
1616
1617macro_rules! impl_parent_traits {
1618    ([$($types:tt),+] [] []) => {};
1619
1620    ([$($types:tt),+] [$trait:ident $($rest_traits:ident)*] [$ty:tt $($rest_tys:tt)*]) => {
1621        impl<$($types),+> $trait for ($($types),+,) {
1622            type $ty = $ty;
1623        }
1624
1625        impl_parent_traits!([$($types),+] [$($rest_traits)*] [$($rest_tys)*]);
1626    };
1627}
1628
1629// Define the trait hierarchy once
1630impl_tuple_traits!(
1631    JsTuple1 T1
1632    JsTuple2 T2
1633    JsTuple3 T3
1634    JsTuple4 T4
1635    JsTuple5 T5
1636    JsTuple6 T6
1637    JsTuple7 T7
1638    JsTuple8 T8
1639);
1640
1641impl<T: JsTuple> ArrayTuple<T> {
1642    /// Get the static arity of the ArrayTuple type.
1643    #[allow(clippy::len_without_is_empty)]
1644    pub fn len(&self) -> usize {
1645        <T as JsTuple>::ARITY
1646    }
1647}
1648
1649macro_rules! impl_tuple {
1650    ($arity:literal [$($traits:ident)*] [$($T:tt)+] [$($vars:tt)+] $new:ident $last:ident $last_ty:tt) => {
1651        impl<$($T),+> JsTuple for ($($T),+,) {
1652            const ARITY: usize = $arity;
1653        }
1654
1655        impl_parent_traits!([$($T),+] [$($traits)*] [$($T)*]);
1656
1657        impl<$($T: JsGeneric),+> From<($($T,)+)> for ArrayTuple<($($T),+,)> {
1658            fn from(($($vars,)+): ($($T,)+)) -> Self {
1659                $(let $vars: JsValue = $vars.upcast_into();)+
1660                Array::of(&[$($vars),+]).unchecked_into()
1661            }
1662        }
1663
1664        impl<$($T: JsGeneric + Default),+> Default for ArrayTuple<($($T),+,)> {
1665            fn default() -> Self {
1666                (
1667                    $($T::default(),)+
1668                ).into()
1669            }
1670        }
1671
1672        impl<$($T: JsGeneric),+> ArrayTuple<($($T),+,)> {
1673            /// Get the first element of the ArrayTuple
1674            pub fn first(&self) -> T1 {
1675                self.get0()
1676            }
1677
1678            /// Get the last element of the ArrayTuple
1679            pub fn last(&self) -> $last_ty {
1680                self.$last()
1681            }
1682
1683            /// Convert the ArrayTuple into its corresponding Rust tuple
1684            pub fn into_parts(self) -> ($($T,)+) {
1685                ($(self.$vars(),)+)
1686            }
1687
1688            /// Create a new ArrayTuple from the corresponding parts.
1689            ///
1690            /// # Example
1691            ///
1692            /// ```
1693            /// use js_sys::{ArrayTuple, JsString};
1694            ///
1695            /// let tuple = ArrayTuple::<JsString, JsString>::new(&"a".into(), &"b".into());
1696            /// ```
1697            ///
1698            /// Note: You must specify the T using `::<...>` syntax on `ArrayTuple`.
1699            /// Alternatively, use `new1`, `new2`, etc. for type inference from the left-hand side.
1700            pub fn new($($vars: &$T),+) -> ArrayTuple<($($T),+,)> {
1701                ArrayTuple::$new($($vars),+)
1702            }
1703        }
1704    };
1705}
1706
1707// Implement for each tuple size
1708impl_tuple!(1 [JsTuple1] [T1] [get0] new1 get0 T1);
1709impl_tuple!(2 [JsTuple1 JsTuple2] [T1 T2] [get0 get1] new2 get1 T2);
1710impl_tuple!(3 [JsTuple1 JsTuple2 JsTuple3] [T1 T2 T3] [get0 get1 get2] new3 get2 T3);
1711impl_tuple!(4 [JsTuple1 JsTuple2 JsTuple3 JsTuple4] [T1 T2 T3 T4] [get0 get1 get2 get3] new4 get3 T4);
1712impl_tuple!(5 [JsTuple1 JsTuple2 JsTuple3 JsTuple4 JsTuple5] [T1 T2 T3 T4 T5] [get0 get1 get2 get3 get4] new5 get4 T5);
1713impl_tuple!(6 [JsTuple1 JsTuple2 JsTuple3 JsTuple4 JsTuple5 JsTuple6] [T1 T2 T3 T4 T5 T6] [get0 get1 get2 get3 get4 get5] new6 get5 T6);
1714impl_tuple!(7 [JsTuple1 JsTuple2 JsTuple3 JsTuple4 JsTuple5 JsTuple6 JsTuple7] [T1 T2 T3 T4 T5 T6 T7] [get0 get1 get2 get3 get4 get5 get6] new7 get6 T7);
1715impl_tuple!(8 [JsTuple1 JsTuple2 JsTuple3 JsTuple4 JsTuple5 JsTuple6 JsTuple7 JsTuple8] [T1 T2 T3 T4 T5 T6 T7 T8] [get0 get1 get2 get3 get4 get5 get6 get7] new8 get7 T8);
1716
1717// Macro to generate structural covariance impls for each arity
1718macro_rules! impl_tuple_covariance {
1719    ([$($T:ident)+] [$($Target:ident)+] [$($Ts:ident)+]) => {
1720        // ArrayTuple -> Array
1721        // Allows (T1, T2, ...) to be used where (Target) is expected
1722        // when all T1, T2, ... are covariant to Target
1723        impl<$($T,)+ Target> UpcastFrom<ArrayTuple<($($T,)+)>> for Array<Target>
1724        where
1725            $(Target: UpcastFrom<$T>,)+
1726        {
1727        }
1728        impl<$($T,)+ Target> UpcastFrom<ArrayTuple<($($T,)+)>> for JsOption<Array<Target>>
1729        where
1730            $(Target: UpcastFrom<$T>,)+
1731        {}
1732        // Array<T> -> ArrayTuple<T, ...>
1733        impl<T> UpcastFrom<Array<T>> for ArrayTuple<($($Ts,)+)> {}
1734        impl<T: JsGeneric> UpcastFrom<Array<T>> for ArrayTuple<($(JsOption<$Ts>,)+)> {}
1735    };
1736}
1737
1738impl_tuple_covariance!([T1][Target1][T]);
1739impl_tuple_covariance!([T1 T2] [Target1 Target2] [T T]);
1740impl_tuple_covariance!([T1 T2 T3] [Target1 Target2 Target3] [T T T]);
1741impl_tuple_covariance!([T1 T2 T3 T4] [Target1 Target2 Target3 Target4] [T T T T]);
1742impl_tuple_covariance!([T1 T2 T3 T4 T5] [Target1 Target2 Target3 Target4 Target5] [T T T T T]);
1743impl_tuple_covariance!([T1 T2 T3 T4 T5 T6] [Target1 Target2 Target3 Target4 Target5 Target6] [T T T T T T]);
1744impl_tuple_covariance!([T1 T2 T3 T4 T5 T6 T7] [Target1 Target2 Target3 Target4 Target5 Target6 Target7] [T T T T T T T]);
1745impl_tuple_covariance!([T1 T2 T3 T4 T5 T6 T7 T8] [Target1 Target2 Target3 Target4 Target5 Target6 Target7 Target8] [T T T T T T T T]);
1746
1747// Tuple casting is implemented in core
1748impl<T: JsTuple, U: JsTuple> UpcastFrom<ArrayTuple<T>> for ArrayTuple<U> where U: UpcastFrom<T> {}
1749impl<T: JsTuple> UpcastFrom<ArrayTuple<T>> for JsValue {}
1750impl<T: JsTuple> UpcastFrom<ArrayTuple<T>> for JsOption<JsValue> {}
1751
1752/// Iterator returned by `Array::into_iter`
1753#[derive(Debug, Clone)]
1754pub struct ArrayIntoIter<T: JsGeneric = JsValue> {
1755    range: core::ops::Range<u32>,
1756    array: Array<T>,
1757}
1758
1759#[cfg(not(js_sys_unstable_apis))]
1760impl<T: JsGeneric> core::iter::Iterator for ArrayIntoIter<T> {
1761    type Item = T;
1762
1763    fn next(&mut self) -> Option<Self::Item> {
1764        let index = self.range.next()?;
1765        Some(self.array.get(index))
1766    }
1767
1768    #[inline]
1769    fn size_hint(&self) -> (usize, Option<usize>) {
1770        self.range.size_hint()
1771    }
1772
1773    #[inline]
1774    fn count(self) -> usize
1775    where
1776        Self: Sized,
1777    {
1778        self.range.count()
1779    }
1780
1781    #[inline]
1782    fn last(self) -> Option<Self::Item>
1783    where
1784        Self: Sized,
1785    {
1786        let Self { range, array } = self;
1787        range.last().map(|index| array.get(index))
1788    }
1789
1790    #[inline]
1791    fn nth(&mut self, n: usize) -> Option<Self::Item> {
1792        self.range.nth(n).map(|index| self.array.get(index))
1793    }
1794}
1795
1796#[cfg(js_sys_unstable_apis)]
1797impl<T: JsGeneric> core::iter::Iterator for ArrayIntoIter<T> {
1798    type Item = T;
1799
1800    fn next(&mut self) -> Option<Self::Item> {
1801        let index = self.range.next()?;
1802        self.array.get(index)
1803    }
1804
1805    #[inline]
1806    fn size_hint(&self) -> (usize, Option<usize>) {
1807        self.range.size_hint()
1808    }
1809
1810    #[inline]
1811    fn count(self) -> usize
1812    where
1813        Self: Sized,
1814    {
1815        self.range.count()
1816    }
1817
1818    #[inline]
1819    fn last(self) -> Option<Self::Item>
1820    where
1821        Self: Sized,
1822    {
1823        let Self { range, array } = self;
1824        range.last().and_then(|index| array.get(index))
1825    }
1826
1827    #[inline]
1828    fn nth(&mut self, n: usize) -> Option<Self::Item> {
1829        self.range.nth(n).and_then(|index| self.array.get(index))
1830    }
1831}
1832
1833#[cfg(not(js_sys_unstable_apis))]
1834impl<T: JsGeneric> core::iter::DoubleEndedIterator for ArrayIntoIter<T> {
1835    fn next_back(&mut self) -> Option<Self::Item> {
1836        let index = self.range.next_back()?;
1837        Some(self.array.get(index))
1838    }
1839
1840    fn nth_back(&mut self, n: usize) -> Option<Self::Item> {
1841        self.range.nth_back(n).map(|index| self.array.get(index))
1842    }
1843}
1844
1845#[cfg(js_sys_unstable_apis)]
1846impl<T: JsGeneric> core::iter::DoubleEndedIterator for ArrayIntoIter<T> {
1847    fn next_back(&mut self) -> Option<Self::Item> {
1848        let index = self.range.next_back()?;
1849        self.array.get(index)
1850    }
1851
1852    fn nth_back(&mut self, n: usize) -> Option<Self::Item> {
1853        self.range
1854            .nth_back(n)
1855            .and_then(|index| self.array.get(index))
1856    }
1857}
1858
1859impl<T: JsGeneric> core::iter::FusedIterator for ArrayIntoIter<T> {}
1860
1861impl<T: JsGeneric> core::iter::ExactSizeIterator for ArrayIntoIter<T> {}
1862
1863/// Iterator returned by `Array::iter`
1864#[derive(Debug, Clone)]
1865pub struct ArrayIter<'a, T: JsGeneric = JsValue> {
1866    range: core::ops::Range<u32>,
1867    array: &'a Array<T>,
1868}
1869
1870impl<T: JsGeneric> core::iter::Iterator for ArrayIter<'_, T> {
1871    type Item = T;
1872
1873    fn next(&mut self) -> Option<Self::Item> {
1874        let index = self.range.next()?;
1875        Some(self.array.get_unchecked(index))
1876    }
1877
1878    #[inline]
1879    fn size_hint(&self) -> (usize, Option<usize>) {
1880        self.range.size_hint()
1881    }
1882
1883    #[inline]
1884    fn count(self) -> usize
1885    where
1886        Self: Sized,
1887    {
1888        self.range.count()
1889    }
1890
1891    #[inline]
1892    fn last(self) -> Option<Self::Item>
1893    where
1894        Self: Sized,
1895    {
1896        let Self { range, array } = self;
1897        range.last().map(|index| array.get_unchecked(index))
1898    }
1899
1900    #[inline]
1901    fn nth(&mut self, n: usize) -> Option<Self::Item> {
1902        self.range
1903            .nth(n)
1904            .map(|index| self.array.get_unchecked(index))
1905    }
1906}
1907
1908impl<T: JsGeneric> core::iter::DoubleEndedIterator for ArrayIter<'_, T> {
1909    fn next_back(&mut self) -> Option<Self::Item> {
1910        let index = self.range.next_back()?;
1911        Some(self.array.get_unchecked(index))
1912    }
1913
1914    fn nth_back(&mut self, n: usize) -> Option<Self::Item> {
1915        self.range
1916            .nth_back(n)
1917            .map(|index| self.array.get_unchecked(index))
1918    }
1919}
1920
1921impl<T: JsGeneric> core::iter::FusedIterator for ArrayIter<'_, T> {}
1922
1923impl<T: JsGeneric> core::iter::ExactSizeIterator for ArrayIter<'_, T> {}
1924
1925impl<T: JsGeneric> Array<T> {
1926    /// Returns an iterator over the values of the JS array.
1927    pub fn iter(&self) -> ArrayIter<'_, T> {
1928        ArrayIter {
1929            range: 0..self.length(),
1930            array: self,
1931        }
1932    }
1933}
1934
1935impl<T: JsGeneric> core::iter::IntoIterator for Array<T> {
1936    type Item = T;
1937    type IntoIter = ArrayIntoIter<T>;
1938
1939    fn into_iter(self) -> Self::IntoIter {
1940        ArrayIntoIter {
1941            range: 0..self.length(),
1942            array: self,
1943        }
1944    }
1945}
1946
1947#[cfg(not(js_sys_unstable_apis))]
1948impl<A> core::iter::FromIterator<A> for Array
1949where
1950    A: AsRef<JsValue>,
1951{
1952    fn from_iter<I>(iter: I) -> Array
1953    where
1954        I: IntoIterator<Item = A>,
1955    {
1956        let mut out = Array::new();
1957        out.extend(iter);
1958        out
1959    }
1960}
1961
1962#[cfg(js_sys_unstable_apis)]
1963impl<A, T: JsGeneric> core::iter::FromIterator<A> for Array<T>
1964where
1965    A: AsRef<T>,
1966{
1967    fn from_iter<I>(iter: I) -> Array<T>
1968    where
1969        I: IntoIterator<Item = A>,
1970    {
1971        let iter = iter.into_iter();
1972        let (lower, upper) = iter.size_hint();
1973        let capacity = upper.unwrap_or(lower);
1974        let out = Array::new_with_length_typed(capacity as u32);
1975        let mut i = 0;
1976        for value in iter {
1977            out.set(i, value.as_ref());
1978            i += 1;
1979        }
1980        // Trim to the actual number of items written, in case size_hint over-estimated.
1981        if i < capacity as u32 {
1982            out.set_length(i);
1983        }
1984        out
1985    }
1986}
1987
1988#[cfg(not(js_sys_unstable_apis))]
1989impl<A> core::iter::Extend<A> for Array
1990where
1991    A: AsRef<JsValue>,
1992{
1993    fn extend<I>(&mut self, iter: I)
1994    where
1995        I: IntoIterator<Item = A>,
1996    {
1997        for value in iter {
1998            self.push(value.as_ref());
1999        }
2000    }
2001}
2002
2003#[cfg(js_sys_unstable_apis)]
2004impl<A, T: JsGeneric> core::iter::Extend<A> for Array<T>
2005where
2006    A: AsRef<T>,
2007{
2008    fn extend<I>(&mut self, iter: I)
2009    where
2010        I: IntoIterator<Item = A>,
2011    {
2012        for value in iter {
2013            self.push(value.as_ref());
2014        }
2015    }
2016}
2017
2018impl Default for Array<JsValue> {
2019    fn default() -> Self {
2020        Self::new()
2021    }
2022}
2023
2024impl<T> Iterable for Array<T> {
2025    type Item = T;
2026}
2027
2028impl<T: JsTuple> Iterable for ArrayTuple<T> {
2029    type Item = JsValue;
2030}
2031
2032// ArrayBufferOptions
2033#[wasm_bindgen]
2034extern "C" {
2035    #[wasm_bindgen(extends = Object, typescript_type = "ArrayBufferOptions")]
2036    #[derive(Clone, Debug, PartialEq, Eq)]
2037    pub type ArrayBufferOptions;
2038
2039    /// The maximum size, in bytes, that the array buffer can be resized to.
2040    #[wasm_bindgen(method, setter, js_name = maxByteLength)]
2041    pub fn set_max_byte_length(this: &ArrayBufferOptions, max_byte_length: usize);
2042
2043    /// The maximum size, in bytes, that the array buffer can be resized to.
2044    #[wasm_bindgen(method, getter, js_name = maxByteLength)]
2045    pub fn get_max_byte_length(this: &ArrayBufferOptions) -> usize;
2046}
2047
2048impl ArrayBufferOptions {
2049    #[cfg(not(js_sys_unstable_apis))]
2050    pub fn new(max_byte_length: usize) -> ArrayBufferOptions {
2051        let options = JsCast::unchecked_into::<ArrayBufferOptions>(Object::new());
2052        options.set_max_byte_length(max_byte_length);
2053        options
2054    }
2055
2056    #[cfg(js_sys_unstable_apis)]
2057    pub fn new(max_byte_length: usize) -> ArrayBufferOptions {
2058        let options = JsCast::unchecked_into::<ArrayBufferOptions>(Object::<JsValue>::new());
2059        options.set_max_byte_length(max_byte_length);
2060        options
2061    }
2062}
2063
2064// ArrayBuffer
2065#[wasm_bindgen]
2066extern "C" {
2067    #[wasm_bindgen(extends = Object, typescript_type = "ArrayBuffer")]
2068    #[derive(Clone, Debug, PartialEq, Eq)]
2069    pub type ArrayBuffer;
2070
2071    /// The `ArrayBuffer` object is used to represent a generic,
2072    /// fixed-length raw binary data buffer. You cannot directly
2073    /// manipulate the contents of an `ArrayBuffer`; instead, you
2074    /// create one of the typed array objects or a `DataView` object
2075    /// which represents the buffer in a specific format, and use that
2076    /// to read and write the contents of the buffer.
2077    ///
2078    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)
2079    #[cfg(not(js_sys_unstable_apis))]
2080    #[wasm_bindgen(constructor)]
2081    pub fn new(length: u32) -> ArrayBuffer;
2082
2083    /// The `ArrayBuffer` object is used to represent a generic,
2084    /// fixed-length raw binary data buffer. You cannot directly
2085    /// manipulate the contents of an `ArrayBuffer`; instead, you
2086    /// create one of the typed array objects or a `DataView` object
2087    /// which represents the buffer in a specific format, and use that
2088    /// to read and write the contents of the buffer.
2089    ///
2090    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)
2091    #[cfg(js_sys_unstable_apis)]
2092    #[wasm_bindgen(constructor)]
2093    pub fn new(length: usize) -> ArrayBuffer;
2094
2095    /// The `ArrayBuffer` object is used to represent a generic,
2096    /// fixed-length raw binary data buffer. You cannot directly
2097    /// manipulate the contents of an `ArrayBuffer`; instead, you
2098    /// create one of the typed array objects or a `DataView` object
2099    /// which represents the buffer in a specific format, and use that
2100    /// to read and write the contents of the buffer.
2101    ///
2102    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)
2103    #[wasm_bindgen(constructor)]
2104    pub fn new_with_options(length: usize, options: &ArrayBufferOptions) -> ArrayBuffer;
2105
2106    /// The `byteLength` property of an object which is an instance of type ArrayBuffer
2107    /// it's an accessor property whose set accessor function is undefined,
2108    /// meaning that you can only read this property.
2109    /// The value is established when the array is constructed and cannot be changed.
2110    /// This property returns 0 if this ArrayBuffer has been detached.
2111    ///
2112    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/byteLength)
2113    #[cfg(not(js_sys_unstable_apis))]
2114    #[wasm_bindgen(method, getter, js_name = byteLength)]
2115    pub fn byte_length(this: &ArrayBuffer) -> u32;
2116
2117    /// The `byteLength` property of an object which is an instance of type ArrayBuffer
2118    /// it's an accessor property whose set accessor function is undefined,
2119    /// meaning that you can only read this property.
2120    /// The value is established when the array is constructed and cannot be changed.
2121    /// This property returns 0 if this ArrayBuffer has been detached.
2122    ///
2123    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/byteLength)
2124    #[cfg(js_sys_unstable_apis)]
2125    #[wasm_bindgen(method, getter, js_name = byteLength)]
2126    pub fn byte_length(this: &ArrayBuffer) -> usize;
2127
2128    /// The `detached` accessor property of `ArrayBuffer` instances returns a boolean indicating
2129    /// whether or not this buffer has been detached (transferred).
2130    ///
2131    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/detached)
2132    #[wasm_bindgen(method, getter)]
2133    pub fn detached(this: &ArrayBuffer) -> bool;
2134
2135    /// The `isView()` method returns true if arg is one of the `ArrayBuffer`
2136    /// views, such as typed array objects or a DataView; false otherwise.
2137    ///
2138    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView)
2139    #[wasm_bindgen(static_method_of = ArrayBuffer, js_name = isView)]
2140    pub fn is_view(value: &JsValue) -> bool;
2141
2142    /// The `maxByteLength` accessor property of ArrayBuffer instances returns the maximum
2143    /// length (in bytes) that this array buffer can be resized to.
2144    ///
2145    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/maxByteLength)
2146    #[wasm_bindgen(method, getter, js_name = maxByteLength)]
2147    pub fn max_byte_length(this: &ArrayBuffer) -> usize;
2148
2149    /// The `resizable` accessor property of `ArrayBuffer` instances returns whether this array buffer
2150    /// can be resized or not.
2151    ///
2152    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/resizable)
2153    #[wasm_bindgen(method, getter)]
2154    pub fn resizable(this: &ArrayBuffer) -> bool;
2155
2156    /// The `resize()` method of ArrayBuffer instances resizes the ArrayBuffer to the
2157    /// specified size, in bytes.
2158    ///
2159    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/resize)
2160    #[wasm_bindgen(method, catch)]
2161    pub fn resize(this: &ArrayBuffer, new_len: usize) -> Result<(), JsValue>;
2162
2163    /// The `slice()` method returns a new `ArrayBuffer` whose contents
2164    /// are a copy of this `ArrayBuffer`'s bytes from begin, inclusive,
2165    /// up to end, exclusive.
2166    ///
2167    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice)
2168    #[cfg(not(js_sys_unstable_apis))]
2169    #[wasm_bindgen(method)]
2170    pub fn slice(this: &ArrayBuffer, begin: u32) -> ArrayBuffer;
2171
2172    /// The `slice()` method returns a new `ArrayBuffer` whose contents
2173    /// are a copy of this `ArrayBuffer`'s bytes from begin, inclusive,
2174    /// up to end, exclusive. Negative indices count from the end.
2175    ///
2176    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice)
2177    #[cfg(js_sys_unstable_apis)]
2178    #[wasm_bindgen(method)]
2179    pub fn slice(this: &ArrayBuffer, begin: isize, end: isize) -> ArrayBuffer;
2180
2181    /// The `slice()` method returns a new `ArrayBuffer` whose contents
2182    /// are a copy of this `ArrayBuffer`'s bytes from begin, inclusive,
2183    /// up to end, exclusive.
2184    ///
2185    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice)
2186    #[cfg(not(js_sys_unstable_apis))]
2187    #[wasm_bindgen(method, js_name = slice)]
2188    pub fn slice_from(this: &ArrayBuffer, begin: isize) -> ArrayBuffer;
2189
2190    /// The `slice()` method returns a new `ArrayBuffer` whose contents
2191    /// are a copy of this `ArrayBuffer`'s bytes from begin to the end.
2192    /// Negative indices count from the end.
2193    ///
2194    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice)
2195    #[cfg(js_sys_unstable_apis)]
2196    #[wasm_bindgen(method, js_name = slice)]
2197    pub fn slice_from(this: &ArrayBuffer, begin: isize) -> ArrayBuffer;
2198
2199    // Next major: deprecate
2200    /// Like `slice()` but with the `end` argument.
2201    ///
2202    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice)
2203    #[wasm_bindgen(method, js_name = slice)]
2204    pub fn slice_with_end(this: &ArrayBuffer, begin: u32, end: u32) -> ArrayBuffer;
2205
2206    /// The `transfer()` method of ArrayBuffer instances creates a new `ArrayBuffer`
2207    /// with the same byte content as this buffer, then detaches this buffer.
2208    ///
2209    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/transfer)
2210    #[wasm_bindgen(method, catch)]
2211    pub fn transfer(this: &ArrayBuffer) -> Result<ArrayBuffer, JsValue>;
2212
2213    /// The `transfer()` method of `ArrayBuffer` instances creates a new `ArrayBuffer`
2214    /// with the same byte content as this buffer, then detaches this buffer.
2215    ///
2216    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/transfer)
2217    #[wasm_bindgen(method, catch, js_name = transfer)]
2218    pub fn transfer_with_length(
2219        this: &ArrayBuffer,
2220        new_byte_length: usize,
2221    ) -> Result<ArrayBuffer, JsValue>;
2222
2223    /// The `transferToFixedLength()` method of `ArrayBuffer` instances creates a new non-resizable
2224    /// ArrayBuffer with the same byte content as this buffer, then detaches this buffer.
2225    ///
2226    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/transferToFixedLength)
2227    #[wasm_bindgen(method, catch, js_name = transferToFixedLength)]
2228    pub fn transfer_to_fixed_length(this: &ArrayBuffer) -> Result<ArrayBuffer, JsValue>;
2229
2230    /// The `transferToFixedLength()` method of `ArrayBuffer` instances creates a new non-resizable
2231    /// `ArrayBuffer` with the same byte content as this buffer, then detaches this buffer.
2232    ///
2233    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/transferToFixedLength)
2234    #[wasm_bindgen(method, catch, js_name = transferToFixedLength)]
2235    pub fn transfer_to_fixed_length_with_length(
2236        this: &ArrayBuffer,
2237        new_byte_length: usize,
2238    ) -> Result<ArrayBuffer, JsValue>;
2239}
2240
2241impl UpcastFrom<&[u8]> for ArrayBuffer {}
2242
2243// SharedArrayBuffer
2244#[wasm_bindgen]
2245extern "C" {
2246    #[wasm_bindgen(extends = Object, typescript_type = "SharedArrayBuffer")]
2247    #[derive(Clone, Debug)]
2248    pub type SharedArrayBuffer;
2249
2250    /// The `SharedArrayBuffer` object is used to represent a generic,
2251    /// fixed-length raw binary data buffer, similar to the `ArrayBuffer`
2252    /// object, but in a way that they can be used to create views
2253    /// on shared memory. Unlike an `ArrayBuffer`, a `SharedArrayBuffer`
2254    /// cannot become detached.
2255    ///
2256    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer)
2257    #[cfg(not(js_sys_unstable_apis))]
2258    #[wasm_bindgen(constructor)]
2259    pub fn new(length: u32) -> SharedArrayBuffer;
2260
2261    /// The `SharedArrayBuffer` object is used to represent a generic,
2262    /// fixed-length raw binary data buffer, similar to the `ArrayBuffer`
2263    /// object, but in a way that they can be used to create views
2264    /// on shared memory. Unlike an `ArrayBuffer`, a `SharedArrayBuffer`
2265    /// cannot become detached.
2266    ///
2267    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer)
2268    #[cfg(js_sys_unstable_apis)]
2269    #[wasm_bindgen(constructor)]
2270    pub fn new(length: usize) -> SharedArrayBuffer;
2271
2272    /// The `SharedArrayBuffer` object is used to represent a generic,
2273    /// fixed-length raw binary data buffer, similar to the `ArrayBuffer`
2274    /// object, but in a way that they can be used to create views
2275    /// on shared memory. Unlike an `ArrayBuffer`, a `SharedArrayBuffer`
2276    /// cannot become detached.
2277    ///
2278    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer)
2279    #[wasm_bindgen(constructor)]
2280    pub fn new_with_options(length: usize, options: &ArrayBufferOptions) -> SharedArrayBuffer;
2281
2282    /// The `byteLength` accessor property represents the length of
2283    /// an `SharedArrayBuffer` in bytes. This is established when
2284    /// the `SharedArrayBuffer` is constructed and cannot be changed.
2285    ///
2286    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/byteLength)
2287    #[cfg(not(js_sys_unstable_apis))]
2288    #[wasm_bindgen(method, getter, js_name = byteLength)]
2289    pub fn byte_length(this: &SharedArrayBuffer) -> u32;
2290
2291    /// The `byteLength` accessor property represents the length of
2292    /// an `SharedArrayBuffer` in bytes. This is established when
2293    /// the `SharedArrayBuffer` is constructed and cannot be changed.
2294    ///
2295    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/byteLength)
2296    #[cfg(js_sys_unstable_apis)]
2297    #[wasm_bindgen(method, getter, js_name = byteLength)]
2298    pub fn byte_length(this: &SharedArrayBuffer) -> usize;
2299
2300    /// The `growable` accessor property of `SharedArrayBuffer` instances returns whether
2301    /// this `SharedArrayBuffer` can be grown or not.
2302    ///
2303    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/growable)
2304    #[wasm_bindgen(method, getter)]
2305    pub fn growable(this: &SharedArrayBuffer) -> bool;
2306
2307    /// The `grow()` method of `SharedArrayBuffer` instances grows the
2308    /// `SharedArrayBuffer` to the specified size, in bytes.
2309    ///
2310    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/grow)
2311    #[wasm_bindgen(method, catch)]
2312    pub fn grow(this: &SharedArrayBuffer, new_byte_length: usize) -> Result<(), JsValue>;
2313
2314    /// The `maxByteLength` accessor property of `SharedArrayBuffer` instances returns the maximum
2315    /// length (in bytes) that this `SharedArrayBuffer` can be resized to.
2316    ///
2317    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/maxByteLength)
2318    #[wasm_bindgen(method, getter, js_name = maxByteLength)]
2319    pub fn max_byte_length(this: &SharedArrayBuffer) -> usize;
2320
2321    /// The `slice()` method returns a new `SharedArrayBuffer` whose contents
2322    /// are a copy of this `SharedArrayBuffer`'s bytes from begin, inclusive,
2323    /// up to end, exclusive.
2324    ///
2325    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice)
2326    #[cfg(not(js_sys_unstable_apis))]
2327    #[wasm_bindgen(method)]
2328    pub fn slice(this: &SharedArrayBuffer, begin: u32) -> SharedArrayBuffer;
2329
2330    /// The `slice()` method returns a new `SharedArrayBuffer` whose contents
2331    /// are a copy of this `SharedArrayBuffer`'s bytes from begin, inclusive,
2332    /// up to end, exclusive. Negative indices count from the end.
2333    ///
2334    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice)
2335    #[cfg(js_sys_unstable_apis)]
2336    #[wasm_bindgen(method)]
2337    pub fn slice(this: &SharedArrayBuffer, begin: isize, end: isize) -> SharedArrayBuffer;
2338
2339    /// The `slice()` method returns a new `SharedArrayBuffer` whose contents
2340    /// are a copy of this `SharedArrayBuffer`'s bytes from begin, inclusive,
2341    /// up to end, exclusive.
2342    ///
2343    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice)
2344    #[cfg(not(js_sys_unstable_apis))]
2345    #[wasm_bindgen(method)]
2346    pub fn slice_from(this: &SharedArrayBuffer, begin: isize) -> SharedArrayBuffer;
2347
2348    /// The `slice()` method returns a new `SharedArrayBuffer` whose contents
2349    /// are a copy of this `SharedArrayBuffer`'s bytes from begin to end.
2350    /// Negative indices count from the end.
2351    ///
2352    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice)
2353    #[cfg(js_sys_unstable_apis)]
2354    #[wasm_bindgen(method)]
2355    pub fn slice_from(this: &SharedArrayBuffer, begin: isize) -> SharedArrayBuffer;
2356
2357    // Next major: deprecate
2358    /// Like `slice()` but with the `end` argument.
2359    ///
2360    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice)
2361    #[wasm_bindgen(method, js_name = slice)]
2362    pub fn slice_with_end(this: &SharedArrayBuffer, begin: u32, end: u32) -> SharedArrayBuffer;
2363}
2364
2365// Array Iterator
2366#[wasm_bindgen]
2367extern "C" {
2368    /// The `keys()` method returns a new Array Iterator object that contains the
2369    /// keys for each index in the array.
2370    ///
2371    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/keys)
2372    #[wasm_bindgen(method)]
2373    pub fn keys<T>(this: &Array<T>) -> Iterator<T>;
2374
2375    /// The `entries()` method returns a new Array Iterator object that contains
2376    /// the key/value pairs for each index in the array.
2377    ///
2378    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries)
2379    #[cfg(not(js_sys_unstable_apis))]
2380    #[wasm_bindgen(method)]
2381    #[deprecated(note = "recommended to use `Array::entries_typed` instead for typing")]
2382    #[allow(deprecated)]
2383    pub fn entries<T>(this: &Array<T>) -> Iterator<T>;
2384
2385    /// The `entries()` method returns a new Array Iterator object that contains
2386    /// the key/value pairs for each index in the array.
2387    ///
2388    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries)
2389    #[cfg(js_sys_unstable_apis)]
2390    #[wasm_bindgen(method)]
2391    pub fn entries<T: JsGeneric>(this: &Array<T>) -> Iterator<ArrayTuple<(Number, T)>>;
2392
2393    // Next major: deprecate
2394    /// The `entries()` method returns a new Array Iterator object that contains
2395    /// the key/value pairs for each index in the array.
2396    ///
2397    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries)
2398    #[wasm_bindgen(method, js_name = entries)]
2399    pub fn entries_typed<T: JsGeneric>(this: &Array<T>) -> Iterator<ArrayTuple<(Number, T)>>;
2400
2401    /// The `values()` method returns a new Array Iterator object that
2402    /// contains the values for each index in the array.
2403    ///
2404    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/values)
2405    #[wasm_bindgen(method)]
2406    pub fn values<T>(this: &Array<T>) -> Iterator<T>;
2407}
2408
2409pub trait TypedArray: JsGeneric {}
2410
2411// Next major: use usize/isize for indices
2412/// The `Atomics` object provides atomic operations as static methods.
2413/// They are used with `SharedArrayBuffer` objects.
2414///
2415/// The Atomic operations are installed on an `Atomics` module. Unlike
2416/// the other global objects, `Atomics` is not a constructor. You cannot
2417/// use it with a new operator or invoke the `Atomics` object as a
2418/// function. All properties and methods of `Atomics` are static
2419/// (as is the case with the Math object, for example).
2420/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics)
2421#[allow(non_snake_case)]
2422pub mod Atomics {
2423    use super::*;
2424
2425    #[wasm_bindgen]
2426    extern "C" {
2427        /// The static `Atomics.add()` method adds a given value at a given
2428        /// position in the array and returns the old value at that position.
2429        /// This atomic operation guarantees that no other write happens
2430        /// until the modified value is written back.
2431        ///
2432        /// You should use `add_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2433        ///
2434        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/add)
2435        #[wasm_bindgen(js_namespace = Atomics, catch)]
2436        pub fn add<T: TypedArray = Int32Array>(
2437            typed_array: &T,
2438            index: u32,
2439            value: i32,
2440        ) -> Result<i32, JsValue>;
2441
2442        /// The static `Atomics.add()` method adds a given value at a given
2443        /// position in the array and returns the old value at that position.
2444        /// This atomic operation guarantees that no other write happens
2445        /// until the modified value is written back.
2446        ///
2447        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2448        ///
2449        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/add)
2450        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = add)]
2451        pub fn add_bigint<T: TypedArray = Int32Array>(
2452            typed_array: &T,
2453            index: u32,
2454            value: i64,
2455        ) -> Result<i64, JsValue>;
2456
2457        /// The static `Atomics.and()` method computes a bitwise AND with a given
2458        /// value at a given position in the array, and returns the old value
2459        /// at that position.
2460        /// This atomic operation guarantees that no other write happens
2461        /// until the modified value is written back.
2462        ///
2463        /// You should use `and_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2464        ///
2465        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/and)
2466        #[wasm_bindgen(js_namespace = Atomics, catch)]
2467        pub fn and<T: TypedArray = Int32Array>(
2468            typed_array: &T,
2469            index: u32,
2470            value: i32,
2471        ) -> Result<i32, JsValue>;
2472
2473        /// The static `Atomics.and()` method computes a bitwise AND with a given
2474        /// value at a given position in the array, and returns the old value
2475        /// at that position.
2476        /// This atomic operation guarantees that no other write happens
2477        /// until the modified value is written back.
2478        ///
2479        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2480        ///
2481        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/and)
2482        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = and)]
2483        pub fn and_bigint<T: TypedArray = Int32Array>(
2484            typed_array: &T,
2485            index: u32,
2486            value: i64,
2487        ) -> Result<i64, JsValue>;
2488
2489        /// The static `Atomics.compareExchange()` method exchanges a given
2490        /// replacement value at a given position in the array, if a given expected
2491        /// value equals the old value. It returns the old value at that position
2492        /// whether it was equal to the expected value or not.
2493        /// This atomic operation guarantees that no other write happens
2494        /// until the modified value is written back.
2495        ///
2496        /// You should use `compare_exchange_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2497        ///
2498        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/compareExchange)
2499        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = compareExchange)]
2500        pub fn compare_exchange<T: TypedArray = Int32Array>(
2501            typed_array: &T,
2502            index: u32,
2503            expected_value: i32,
2504            replacement_value: i32,
2505        ) -> Result<i32, JsValue>;
2506
2507        /// The static `Atomics.compareExchange()` method exchanges a given
2508        /// replacement value at a given position in the array, if a given expected
2509        /// value equals the old value. It returns the old value at that position
2510        /// whether it was equal to the expected value or not.
2511        /// This atomic operation guarantees that no other write happens
2512        /// until the modified value is written back.
2513        ///
2514        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2515        ///
2516        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/compareExchange)
2517        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = compareExchange)]
2518        pub fn compare_exchange_bigint<T: TypedArray = Int32Array>(
2519            typed_array: &T,
2520            index: u32,
2521            expected_value: i64,
2522            replacement_value: i64,
2523        ) -> Result<i64, JsValue>;
2524
2525        /// The static `Atomics.exchange()` method stores a given value at a given
2526        /// position in the array and returns the old value at that position.
2527        /// This atomic operation guarantees that no other write happens
2528        /// until the modified value is written back.
2529        ///
2530        /// You should use `exchange_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2531        ///
2532        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/exchange)
2533        #[wasm_bindgen(js_namespace = Atomics, catch)]
2534        pub fn exchange<T: TypedArray = Int32Array>(
2535            typed_array: &T,
2536            index: u32,
2537            value: i32,
2538        ) -> Result<i32, JsValue>;
2539
2540        /// The static `Atomics.exchange()` method stores a given value at a given
2541        /// position in the array and returns the old value at that position.
2542        /// This atomic operation guarantees that no other write happens
2543        /// until the modified value is written back.
2544        ///
2545        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2546        ///
2547        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/exchange)
2548        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = exchange)]
2549        pub fn exchange_bigint<T: TypedArray = Int32Array>(
2550            typed_array: &T,
2551            index: u32,
2552            value: i64,
2553        ) -> Result<i64, JsValue>;
2554
2555        /// The static `Atomics.isLockFree()` method is used to determine
2556        /// whether to use locks or atomic operations. It returns true,
2557        /// if the given size is one of the `BYTES_PER_ELEMENT` property
2558        /// of integer `TypedArray` types.
2559        ///
2560        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/isLockFree)
2561        #[wasm_bindgen(js_namespace = Atomics, js_name = isLockFree)]
2562        pub fn is_lock_free(size: u32) -> bool;
2563
2564        /// The static `Atomics.load()` method returns a value at a given
2565        /// position in the array.
2566        ///
2567        /// You should use `load_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2568        ///
2569        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/load)
2570        #[wasm_bindgen(js_namespace = Atomics, catch)]
2571        pub fn load<T: TypedArray = Int32Array>(
2572            typed_array: &T,
2573            index: u32,
2574        ) -> Result<i32, JsValue>;
2575
2576        /// The static `Atomics.load()` method returns a value at a given
2577        /// position in the array.
2578        ///
2579        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2580        ///
2581        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/load)
2582        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = load)]
2583        pub fn load_bigint<T: TypedArray = Int32Array>(
2584            typed_array: &T,
2585            index: i64,
2586        ) -> Result<i64, JsValue>;
2587
2588        /// The static `Atomics.notify()` method notifies up some agents that
2589        /// are sleeping in the wait queue.
2590        /// Note: This operation works with a shared `Int32Array` only.
2591        /// If `count` is not provided, notifies all the agents in the queue.
2592        ///
2593        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/notify)
2594        #[wasm_bindgen(js_namespace = Atomics, catch)]
2595        pub fn notify(typed_array: &Int32Array, index: u32) -> Result<u32, JsValue>;
2596
2597        /// The static `Atomics.notify()` method notifies up some agents that
2598        /// are sleeping in the wait queue.
2599        /// Note: This operation works with a shared `Int32Array` only.
2600        /// If `count` is not provided, notifies all the agents in the queue.
2601        ///
2602        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/notify)
2603        #[wasm_bindgen(js_namespace = Atomics, catch)]
2604        pub fn notify_bigint(typed_array: &BigInt64Array, index: u32) -> Result<u32, JsValue>;
2605
2606        /// Notifies up to `count` agents in the wait queue.
2607        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = notify)]
2608        pub fn notify_with_count(
2609            typed_array: &Int32Array,
2610            index: u32,
2611            count: u32,
2612        ) -> Result<u32, JsValue>;
2613
2614        /// Notifies up to `count` agents in the wait queue.
2615        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = notify)]
2616        pub fn notify_bigint_with_count(
2617            typed_array: &BigInt64Array,
2618            index: u32,
2619            count: u32,
2620        ) -> Result<u32, JsValue>;
2621
2622        /// The static `Atomics.or()` method computes a bitwise OR with a given value
2623        /// at a given position in the array, and returns the old value at that position.
2624        /// This atomic operation guarantees that no other write happens
2625        /// until the modified value is written back.
2626        ///
2627        /// You should use `or_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2628        ///
2629        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/or)
2630        #[wasm_bindgen(js_namespace = Atomics, catch)]
2631        pub fn or<T: TypedArray = Int32Array>(
2632            typed_array: &T,
2633            index: u32,
2634            value: i32,
2635        ) -> Result<i32, JsValue>;
2636
2637        /// The static `Atomics.or()` method computes a bitwise OR with a given value
2638        /// at a given position in the array, and returns the old value at that position.
2639        /// This atomic operation guarantees that no other write happens
2640        /// until the modified value is written back.
2641        ///
2642        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2643        ///
2644        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/or)
2645        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = or)]
2646        pub fn or_bigint<T: TypedArray = Int32Array>(
2647            typed_array: &T,
2648            index: u32,
2649            value: i64,
2650        ) -> Result<i64, JsValue>;
2651
2652        /// The static `Atomics.pause()` static method provides a micro-wait primitive that hints to the CPU
2653        /// that the caller is spinning while waiting on access to a shared resource. This allows the system
2654        /// to reduce the resources allocated to the core (such as power) or thread, without yielding the
2655        /// current thread.
2656        ///
2657        /// `pause()` has no observable behavior other than timing. The exact behavior is dependent on the CPU
2658        /// architecture and the operating system. For example, in Intel x86, it may be a pause instruction as
2659        /// per Intel's optimization manual. It could be a no-op in certain platforms.
2660        ///
2661        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2662        ///
2663        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/xor)
2664        #[wasm_bindgen(js_namespace = Atomics)]
2665        pub fn pause();
2666
2667        /// The static `Atomics.pause()` static method provides a micro-wait primitive that hints to the CPU
2668        /// that the caller is spinning while waiting on access to a shared resource. This allows the system
2669        /// to reduce the resources allocated to the core (such as power) or thread, without yielding the
2670        /// current thread.
2671        ///
2672        /// `pause()` has no observable behavior other than timing. The exact behavior is dependent on the CPU
2673        /// architecture and the operating system. For example, in Intel x86, it may be a pause instruction as
2674        /// per Intel's optimization manual. It could be a no-op in certain platforms.
2675        ///
2676        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2677        ///
2678        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/xor)
2679        #[wasm_bindgen(js_namespace = Atomics)]
2680        pub fn pause_with_hint(duration_hint: u32);
2681
2682        /// The static `Atomics.store()` method stores a given value at the given
2683        /// position in the array and returns that value.
2684        ///
2685        /// You should use `store_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2686        ///
2687        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/store)
2688        #[wasm_bindgen(js_namespace = Atomics, catch)]
2689        pub fn store<T: TypedArray = Int32Array>(
2690            typed_array: &T,
2691            index: u32,
2692            value: i32,
2693        ) -> Result<i32, JsValue>;
2694
2695        /// The static `Atomics.store()` method stores a given value at the given
2696        /// position in the array and returns that value.
2697        ///
2698        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2699        ///
2700        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/store)
2701        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = store)]
2702        pub fn store_bigint<T: TypedArray = Int32Array>(
2703            typed_array: &T,
2704            index: u32,
2705            value: i64,
2706        ) -> Result<i64, JsValue>;
2707
2708        /// The static `Atomics.sub()` method subtracts a given value at a
2709        /// given position in the array and returns the old value at that position.
2710        /// This atomic operation guarantees that no other write happens
2711        /// until the modified value is written back.
2712        ///
2713        /// You should use `sub_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2714        ///
2715        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/sub)
2716        #[wasm_bindgen(js_namespace = Atomics, catch)]
2717        pub fn sub<T: TypedArray = Int32Array>(
2718            typed_array: &T,
2719            index: u32,
2720            value: i32,
2721        ) -> Result<i32, JsValue>;
2722
2723        /// The static `Atomics.sub()` method subtracts a given value at a
2724        /// given position in the array and returns the old value at that position.
2725        /// This atomic operation guarantees that no other write happens
2726        /// until the modified value is written back.
2727        ///
2728        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2729        ///
2730        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/sub)
2731        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = sub)]
2732        pub fn sub_bigint<T: TypedArray = Int32Array>(
2733            typed_array: &T,
2734            index: u32,
2735            value: i64,
2736        ) -> Result<i64, JsValue>;
2737
2738        /// The static `Atomics.wait()` method verifies that a given
2739        /// position in an `Int32Array` still contains a given value
2740        /// and if so sleeps, awaiting a wakeup or a timeout.
2741        /// It returns a string which is either "ok", "not-equal", or "timed-out".
2742        /// Note: This operation only works with a shared `Int32Array`
2743        /// and may not be allowed on the main thread.
2744        ///
2745        /// You should use `wait_bigint` to operate on a `BigInt64Array`.
2746        ///
2747        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait)
2748        #[wasm_bindgen(js_namespace = Atomics, catch)]
2749        pub fn wait(typed_array: &Int32Array, index: u32, value: i32) -> Result<JsString, JsValue>;
2750
2751        /// The static `Atomics.wait()` method verifies that a given
2752        /// position in an `BigInt64Array` still contains a given value
2753        /// and if so sleeps, awaiting a wakeup or a timeout.
2754        /// It returns a string which is either "ok", "not-equal", or "timed-out".
2755        /// Note: This operation only works with a shared `BigInt64Array`
2756        /// and may not be allowed on the main thread.
2757        ///
2758        /// You should use `wait` to operate on a `Int32Array`.
2759        ///
2760        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait)
2761        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = wait)]
2762        pub fn wait_bigint(
2763            typed_array: &BigInt64Array,
2764            index: u32,
2765            value: i64,
2766        ) -> Result<JsString, JsValue>;
2767
2768        /// Like `wait()`, but with timeout
2769        ///
2770        /// You should use `wait_with_timeout_bigint` to operate on a `BigInt64Array`.
2771        ///
2772        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait)
2773        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = wait)]
2774        pub fn wait_with_timeout(
2775            typed_array: &Int32Array,
2776            index: u32,
2777            value: i32,
2778            timeout: f64,
2779        ) -> Result<JsString, JsValue>;
2780
2781        /// Like `wait()`, but with timeout
2782        ///
2783        /// You should use `wait_with_timeout` to operate on a `Int32Array`.
2784        ///
2785        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait)
2786        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = wait)]
2787        pub fn wait_with_timeout_bigint(
2788            typed_array: &BigInt64Array,
2789            index: u32,
2790            value: i64,
2791            timeout: f64,
2792        ) -> Result<JsString, JsValue>;
2793
2794        /// The static `Atomics.waitAsync()` method verifies that a given position in an
2795        /// `Int32Array` still contains a given value and if so sleeps, awaiting a
2796        /// wakeup or a timeout. It returns an object with two properties. The first
2797        /// property `async` is a boolean which if true indicates that the second
2798        /// property `value` is a promise. If `async` is false then value is a string
2799        /// whether equal to either "not-equal" or "timed-out".
2800        /// Note: This operation only works with a shared `Int32Array` and may be used
2801        /// on the main thread.
2802        ///
2803        /// You should use `wait_async_bigint` to operate on a `BigInt64Array`.
2804        ///
2805        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/waitAsync)
2806        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = waitAsync)]
2807        pub fn wait_async(
2808            typed_array: &Int32Array,
2809            index: u32,
2810            value: i32,
2811        ) -> Result<Object, JsValue>;
2812
2813        /// The static `Atomics.waitAsync()` method verifies that a given position in an
2814        /// `Int32Array` still contains a given value and if so sleeps, awaiting a
2815        /// wakeup or a timeout. It returns an object with two properties. The first
2816        /// property `async` is a boolean which if true indicates that the second
2817        /// property `value` is a promise. If `async` is false then value is a string
2818        /// whether equal to either "not-equal" or "timed-out".
2819        /// Note: This operation only works with a shared `BigInt64Array` and may be used
2820        /// on the main thread.
2821        ///
2822        /// You should use `wait_async` to operate on a `Int32Array`.
2823        ///
2824        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/waitAsync)
2825        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = waitAsync)]
2826        pub fn wait_async_bigint(
2827            typed_array: &BigInt64Array,
2828            index: u32,
2829            value: i64,
2830        ) -> Result<Object, JsValue>;
2831
2832        /// Like `waitAsync()`, but with timeout
2833        ///
2834        /// You should use `wait_async_with_timeout_bigint` to operate on a `BigInt64Array`.
2835        ///
2836        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/waitAsync)
2837        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = waitAsync)]
2838        pub fn wait_async_with_timeout(
2839            typed_array: &Int32Array,
2840            index: u32,
2841            value: i32,
2842            timeout: f64,
2843        ) -> Result<Object, JsValue>;
2844
2845        /// Like `waitAsync()`, but with timeout
2846        ///
2847        /// You should use `wait_async_with_timeout` to operate on a `Int32Array`.
2848        ///
2849        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/waitAsync)
2850        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = waitAsync)]
2851        pub fn wait_async_with_timeout_bigint(
2852            typed_array: &BigInt64Array,
2853            index: u32,
2854            value: i64,
2855            timeout: f64,
2856        ) -> Result<Object, JsValue>;
2857
2858        /// The static `Atomics.xor()` method computes a bitwise XOR
2859        /// with a given value at a given position in the array,
2860        /// and returns the old value at that position.
2861        /// This atomic operation guarantees that no other write happens
2862        /// until the modified value is written back.
2863        ///
2864        /// You should use `xor_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2865        ///
2866        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/xor)
2867        #[wasm_bindgen(js_namespace = Atomics, catch)]
2868        pub fn xor<T: TypedArray = Int32Array>(
2869            typed_array: &T,
2870            index: u32,
2871            value: i32,
2872        ) -> Result<i32, JsValue>;
2873
2874        /// The static `Atomics.xor()` method computes a bitwise XOR
2875        /// with a given value at a given position in the array,
2876        /// and returns the old value at that position.
2877        /// This atomic operation guarantees that no other write happens
2878        /// until the modified value is written back.
2879        ///
2880        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2881        ///
2882        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/xor)
2883        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = xor)]
2884        pub fn xor_bigint<T: TypedArray = Int32Array>(
2885            typed_array: &T,
2886            index: u32,
2887            value: i64,
2888        ) -> Result<i64, JsValue>;
2889    }
2890}
2891
2892// BigInt
2893#[wasm_bindgen]
2894extern "C" {
2895    #[wasm_bindgen(extends = Object, is_type_of = |v| v.is_bigint(), typescript_type = "bigint")]
2896    #[derive(Clone, PartialEq, Eq)]
2897    pub type BigInt;
2898
2899    #[wasm_bindgen(catch, js_name = BigInt)]
2900    fn new_bigint(value: &JsValue) -> Result<BigInt, Error>;
2901
2902    #[wasm_bindgen(js_name = BigInt)]
2903    fn new_bigint_unchecked(value: &JsValue) -> BigInt;
2904
2905    /// Clamps a BigInt value to a signed integer value, and returns that value.
2906    ///
2907    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/asIntN)
2908    #[wasm_bindgen(static_method_of = BigInt, js_name = asIntN)]
2909    pub fn as_int_n(bits: f64, bigint: &BigInt) -> BigInt;
2910
2911    /// Clamps a BigInt value to an unsigned integer value, and returns that value.
2912    ///
2913    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/asUintN)
2914    #[wasm_bindgen(static_method_of = BigInt, js_name = asUintN)]
2915    pub fn as_uint_n(bits: f64, bigint: &BigInt) -> BigInt;
2916
2917    /// Returns a string with a language-sensitive representation of this BigInt value. Overrides the [`Object.prototype.toLocaleString()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/toLocaleString) method.
2918    ///
2919    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/toLocaleString)
2920    #[cfg(not(js_sys_unstable_apis))]
2921    #[wasm_bindgen(method, js_name = toLocaleString)]
2922    pub fn to_locale_string(this: &BigInt, locales: &JsValue, options: &JsValue) -> JsString;
2923
2924    /// Returns a string with a language-sensitive representation of this BigInt value. Overrides the [`Object.prototype.toLocaleString()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/toLocaleString) method.
2925    ///
2926    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/toLocaleString)
2927    #[cfg(js_sys_unstable_apis)]
2928    #[wasm_bindgen(method, js_name = toLocaleString)]
2929    pub fn to_locale_string(
2930        this: &BigInt,
2931        locales: &[JsString],
2932        options: &Intl::NumberFormatOptions,
2933    ) -> JsString;
2934
2935    // Next major: deprecate
2936    /// Returns a string representing this BigInt value in the specified radix (base). Overrides the [`Object.prototype.toString()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString) method.
2937    ///
2938    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/toString)
2939    #[wasm_bindgen(catch, method, js_name = toString)]
2940    pub fn to_string(this: &BigInt, radix: u8) -> Result<JsString, RangeError>;
2941
2942    /// Returns a string representing this BigInt value in the specified radix (base).
2943    ///
2944    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/toString)
2945    #[cfg(js_sys_unstable_apis)]
2946    #[wasm_bindgen(catch, method, js_name = toString)]
2947    pub fn to_string_with_radix(this: &BigInt, radix: u8) -> Result<JsString, RangeError>;
2948
2949    #[wasm_bindgen(method, js_name = toString)]
2950    fn to_string_unchecked(this: &BigInt, radix: u8) -> String;
2951
2952    /// Returns this BigInt value. Overrides the [`Object.prototype.valueOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf) method.
2953    ///
2954    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/valueOf)
2955    #[wasm_bindgen(method, js_name = valueOf)]
2956    pub fn value_of(this: &BigInt, radix: u8) -> BigInt;
2957}
2958
2959impl BigInt {
2960    /// Creates a new BigInt value.
2961    ///
2962    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/BigInt)
2963    #[inline]
2964    pub fn new(value: &JsValue) -> Result<BigInt, Error> {
2965        new_bigint(value)
2966    }
2967
2968    /// Applies the binary `/` JS operator on two `BigInt`s, catching and returning any `RangeError` thrown.
2969    ///
2970    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Division)
2971    pub fn checked_div(&self, rhs: &Self) -> Result<Self, RangeError> {
2972        let result = JsValue::as_ref(self).checked_div(JsValue::as_ref(rhs));
2973
2974        if result.is_instance_of::<RangeError>() {
2975            Err(result.unchecked_into())
2976        } else {
2977            Ok(result.unchecked_into())
2978        }
2979    }
2980
2981    /// Applies the binary `**` JS operator on the two `BigInt`s.
2982    ///
2983    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Exponentiation)
2984    #[inline]
2985    pub fn pow(&self, rhs: &Self) -> Self {
2986        JsValue::as_ref(self)
2987            .pow(JsValue::as_ref(rhs))
2988            .unchecked_into()
2989    }
2990
2991    /// Returns a tuple of this [`BigInt`]'s absolute value along with a
2992    /// [`bool`] indicating whether the [`BigInt`] was negative.
2993    fn abs(&self) -> (Self, bool) {
2994        if self < &BigInt::from(0) {
2995            (-self, true)
2996        } else {
2997            (self.clone(), false)
2998        }
2999    }
3000}
3001
3002macro_rules! bigint_from {
3003    ($($x:ident)*) => ($(
3004        impl From<$x> for BigInt {
3005            #[inline]
3006            fn from(x: $x) -> BigInt {
3007                new_bigint_unchecked(&JsValue::from(x))
3008            }
3009        }
3010
3011        impl PartialEq<$x> for BigInt {
3012            #[inline]
3013            fn eq(&self, other: &$x) -> bool {
3014                JsValue::from(self) == JsValue::from(BigInt::from(*other))
3015            }
3016        }
3017    )*)
3018}
3019bigint_from!(i8 u8 i16 u16 i32 u32 isize usize);
3020
3021macro_rules! bigint_from_big {
3022    ($($x:ident)*) => ($(
3023        impl From<$x> for BigInt {
3024            #[inline]
3025            fn from(x: $x) -> BigInt {
3026                JsValue::from(x).unchecked_into()
3027            }
3028        }
3029
3030        impl PartialEq<$x> for BigInt {
3031            #[inline]
3032            fn eq(&self, other: &$x) -> bool {
3033                self == &BigInt::from(*other)
3034            }
3035        }
3036
3037        impl TryFrom<BigInt> for $x {
3038            type Error = BigInt;
3039
3040            #[inline]
3041            fn try_from(x: BigInt) -> Result<Self, BigInt> {
3042                Self::try_from(JsValue::from(x)).map_err(JsCast::unchecked_into)
3043            }
3044        }
3045    )*)
3046}
3047bigint_from_big!(i64 u64 i128 u128);
3048
3049impl PartialEq<Number> for BigInt {
3050    #[inline]
3051    fn eq(&self, other: &Number) -> bool {
3052        JsValue::as_ref(self).loose_eq(JsValue::as_ref(other))
3053    }
3054}
3055
3056impl Not for &BigInt {
3057    type Output = BigInt;
3058
3059    #[inline]
3060    fn not(self) -> Self::Output {
3061        JsValue::as_ref(self).bit_not().unchecked_into()
3062    }
3063}
3064
3065forward_deref_unop!(impl Not, not for BigInt);
3066forward_js_unop!(impl Neg, neg for BigInt);
3067forward_js_binop!(impl BitAnd, bitand for BigInt);
3068forward_js_binop!(impl BitOr, bitor for BigInt);
3069forward_js_binop!(impl BitXor, bitxor for BigInt);
3070forward_js_binop!(impl Shl, shl for BigInt);
3071forward_js_binop!(impl Shr, shr for BigInt);
3072forward_js_binop!(impl Add, add for BigInt);
3073forward_js_binop!(impl Sub, sub for BigInt);
3074forward_js_binop!(impl Div, div for BigInt);
3075forward_js_binop!(impl Mul, mul for BigInt);
3076forward_js_binop!(impl Rem, rem for BigInt);
3077sum_product!(BigInt);
3078
3079partialord_ord!(BigInt);
3080
3081impl Default for BigInt {
3082    fn default() -> Self {
3083        BigInt::from(i32::default())
3084    }
3085}
3086
3087impl FromStr for BigInt {
3088    type Err = Error;
3089
3090    #[inline]
3091    fn from_str(s: &str) -> Result<Self, Self::Err> {
3092        BigInt::new(&s.into())
3093    }
3094}
3095
3096impl fmt::Debug for BigInt {
3097    #[inline]
3098    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3099        fmt::Display::fmt(self, f)
3100    }
3101}
3102
3103impl fmt::Display for BigInt {
3104    #[inline]
3105    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3106        let (abs, is_neg) = self.abs();
3107        f.pad_integral(!is_neg, "", &abs.to_string_unchecked(10))
3108    }
3109}
3110
3111impl fmt::Binary for BigInt {
3112    #[inline]
3113    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3114        let (abs, is_neg) = self.abs();
3115        f.pad_integral(!is_neg, "0b", &abs.to_string_unchecked(2))
3116    }
3117}
3118
3119impl fmt::Octal for BigInt {
3120    #[inline]
3121    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3122        let (abs, is_neg) = self.abs();
3123        f.pad_integral(!is_neg, "0o", &abs.to_string_unchecked(8))
3124    }
3125}
3126
3127impl fmt::LowerHex for BigInt {
3128    #[inline]
3129    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3130        let (abs, is_neg) = self.abs();
3131        f.pad_integral(!is_neg, "0x", &abs.to_string_unchecked(16))
3132    }
3133}
3134
3135impl fmt::UpperHex for BigInt {
3136    #[inline]
3137    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3138        let (abs, is_neg) = self.abs();
3139        let mut s: String = abs.to_string_unchecked(16);
3140        s.make_ascii_uppercase();
3141        f.pad_integral(!is_neg, "0x", &s)
3142    }
3143}
3144
3145// Boolean
3146#[wasm_bindgen]
3147extern "C" {
3148    #[wasm_bindgen(extends = Object, is_type_of = |v| v.as_bool().is_some(), typescript_type = "boolean")]
3149    #[derive(Clone, PartialEq, Eq)]
3150    pub type Boolean;
3151
3152    /// The `Boolean()` constructor creates an object wrapper for a boolean value.
3153    ///
3154    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
3155    #[cfg(not(js_sys_unstable_apis))]
3156    #[wasm_bindgen(constructor)]
3157    #[deprecated(note = "recommended to use `Boolean::from` instead")]
3158    #[allow(deprecated)]
3159    pub fn new(value: &JsValue) -> Boolean;
3160
3161    /// The `valueOf()` method returns the primitive value of a `Boolean` object.
3162    ///
3163    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/valueOf)
3164    #[wasm_bindgen(method, js_name = valueOf)]
3165    pub fn value_of(this: &Boolean) -> bool;
3166}
3167
3168impl UpcastFrom<bool> for Boolean {}
3169impl UpcastFrom<Boolean> for bool {}
3170
3171impl Boolean {
3172    /// Typed Boolean true constant.
3173    pub const TRUE: Boolean = Self {
3174        obj: Object {
3175            obj: JsValue::TRUE,
3176            generics: PhantomData,
3177        },
3178    };
3179
3180    /// Typed Boolean false constant.
3181    pub const FALSE: Boolean = Self {
3182        obj: Object {
3183            obj: JsValue::FALSE,
3184            generics: PhantomData,
3185        },
3186    };
3187}
3188
3189impl From<bool> for Boolean {
3190    #[inline]
3191    fn from(b: bool) -> Boolean {
3192        Boolean::unchecked_from_js(JsValue::from(b))
3193    }
3194}
3195
3196impl From<Boolean> for bool {
3197    #[inline]
3198    fn from(b: Boolean) -> bool {
3199        b.value_of()
3200    }
3201}
3202
3203impl PartialEq<bool> for Boolean {
3204    #[inline]
3205    fn eq(&self, other: &bool) -> bool {
3206        self.value_of() == *other
3207    }
3208}
3209
3210impl fmt::Debug for Boolean {
3211    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
3212        fmt::Debug::fmt(&self.value_of(), f)
3213    }
3214}
3215
3216impl fmt::Display for Boolean {
3217    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
3218        fmt::Display::fmt(&self.value_of(), f)
3219    }
3220}
3221
3222impl Default for Boolean {
3223    fn default() -> Self {
3224        Self::from(bool::default())
3225    }
3226}
3227
3228impl Not for &Boolean {
3229    type Output = Boolean;
3230
3231    #[inline]
3232    fn not(self) -> Self::Output {
3233        (!JsValue::as_ref(self)).into()
3234    }
3235}
3236
3237forward_deref_unop!(impl Not, not for Boolean);
3238
3239partialord_ord!(Boolean);
3240
3241// DataView
3242#[wasm_bindgen]
3243extern "C" {
3244    #[wasm_bindgen(extends = Object, typescript_type = "DataView")]
3245    #[derive(Clone, Debug, PartialEq, Eq)]
3246    pub type DataView;
3247
3248    /// The `DataView` view provides a low-level interface for reading and
3249    /// writing multiple number types in an `ArrayBuffer` irrespective of the
3250    /// platform's endianness.
3251    ///
3252    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView)
3253    #[wasm_bindgen(constructor)]
3254    pub fn new(buffer: &ArrayBuffer, byteOffset: usize, byteLength: usize) -> DataView;
3255
3256    /// The `DataView` view provides a low-level interface for reading and
3257    /// writing multiple number types in an `ArrayBuffer` irrespective of the
3258    /// platform's endianness.
3259    ///
3260    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView)
3261    #[wasm_bindgen(constructor)]
3262    pub fn new_with_shared_array_buffer(
3263        buffer: &SharedArrayBuffer,
3264        byteOffset: usize,
3265        byteLength: usize,
3266    ) -> DataView;
3267
3268    /// The ArrayBuffer referenced by this view. Fixed at construction time and thus read only.
3269    ///
3270    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/buffer)
3271    #[wasm_bindgen(method, getter)]
3272    pub fn buffer(this: &DataView) -> ArrayBuffer;
3273
3274    /// The length (in bytes) of this view from the start of its ArrayBuffer.
3275    /// Fixed at construction time and thus read only.
3276    ///
3277    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteLength)
3278    #[wasm_bindgen(method, getter, js_name = byteLength)]
3279    pub fn byte_length(this: &DataView) -> usize;
3280
3281    /// The offset (in bytes) of this view from the start of its ArrayBuffer.
3282    /// Fixed at construction time and thus read only.
3283    ///
3284    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteOffset)
3285    #[wasm_bindgen(method, getter, js_name = byteOffset)]
3286    pub fn byte_offset(this: &DataView) -> usize;
3287
3288    /// The `getInt8()` method gets a signed 8-bit integer (byte) at the
3289    /// specified byte offset from the start of the DataView.
3290    ///
3291    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt8)
3292    #[wasm_bindgen(method, js_name = getInt8)]
3293    pub fn get_int8(this: &DataView, byte_offset: usize) -> i8;
3294
3295    /// The `getUint8()` method gets a unsigned 8-bit integer (byte) at the specified
3296    /// byte offset from the start of the DataView.
3297    ///
3298    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint8)
3299    #[wasm_bindgen(method, js_name = getUint8)]
3300    pub fn get_uint8(this: &DataView, byte_offset: usize) -> u8;
3301
3302    /// The `getInt16()` method gets a signed 16-bit integer (short) at the specified
3303    /// byte offset from the start of the DataView.
3304    ///
3305    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt16)
3306    #[wasm_bindgen(method, js_name = getInt16)]
3307    pub fn get_int16(this: &DataView, byte_offset: usize) -> i16;
3308
3309    /// The `getInt16()` method gets a signed 16-bit integer (short) at the specified
3310    /// byte offset from the start of the DataView.
3311    ///
3312    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt16)
3313    #[wasm_bindgen(method, js_name = getInt16)]
3314    pub fn get_int16_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> i16;
3315
3316    /// The `getUint16()` method gets an unsigned 16-bit integer (unsigned short) at the specified
3317    /// byte offset from the start of the view.
3318    ///
3319    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint16)
3320    #[wasm_bindgen(method, js_name = getUint16)]
3321    pub fn get_uint16(this: &DataView, byte_offset: usize) -> u16;
3322
3323    /// The `getUint16()` method gets an unsigned 16-bit integer (unsigned short) at the specified
3324    /// byte offset from the start of the view.
3325    ///
3326    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint16)
3327    #[wasm_bindgen(method, js_name = getUint16)]
3328    pub fn get_uint16_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> u16;
3329
3330    /// The `getInt32()` method gets a signed 32-bit integer (long) at the specified
3331    /// byte offset from the start of the DataView.
3332    ///
3333    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt32)
3334    #[wasm_bindgen(method, js_name = getInt32)]
3335    pub fn get_int32(this: &DataView, byte_offset: usize) -> i32;
3336
3337    /// The `getInt32()` method gets a signed 32-bit integer (long) at the specified
3338    /// byte offset from the start of the DataView.
3339    ///
3340    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt32)
3341    #[wasm_bindgen(method, js_name = getInt32)]
3342    pub fn get_int32_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> i32;
3343
3344    /// The `getUint32()` method gets an unsigned 32-bit integer (unsigned long) at the specified
3345    /// byte offset from the start of the view.
3346    ///
3347    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint32)
3348    #[wasm_bindgen(method, js_name = getUint32)]
3349    pub fn get_uint32(this: &DataView, byte_offset: usize) -> u32;
3350
3351    /// The `getUint32()` method gets an unsigned 32-bit integer (unsigned long) at the specified
3352    /// byte offset from the start of the view.
3353    ///
3354    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint32)
3355    #[wasm_bindgen(method, js_name = getUint32)]
3356    pub fn get_uint32_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> u32;
3357
3358    /// The `getFloat32()` method gets a signed 32-bit float (float) at the specified
3359    /// byte offset from the start of the DataView.
3360    ///
3361    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat32)
3362    #[wasm_bindgen(method, js_name = getFloat32)]
3363    pub fn get_float32(this: &DataView, byte_offset: usize) -> f32;
3364
3365    /// The `getFloat32()` method gets a signed 32-bit float (float) at the specified
3366    /// byte offset from the start of the DataView.
3367    ///
3368    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat32)
3369    #[wasm_bindgen(method, js_name = getFloat32)]
3370    pub fn get_float32_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> f32;
3371
3372    /// The `getFloat16()` method gets a signed 16-bit float at the specified
3373    /// byte offset from the start of the DataView as an `f32`.
3374    ///
3375    /// The unsuffixed `get_float16` name is reserved for a future native
3376    /// `f16` binding once Rust stabilizes the type.
3377    ///
3378    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat16)
3379    #[wasm_bindgen(method, js_name = getFloat16)]
3380    pub fn get_float16_as_f32(this: &DataView, byte_offset: usize) -> f32;
3381
3382    /// The `getFloat16()` method gets a signed 16-bit float at the specified
3383    /// byte offset from the start of the DataView as an `f32`.
3384    ///
3385    /// The unsuffixed `get_float16_endian` name is reserved for a future
3386    /// native `f16` binding once Rust stabilizes the type.
3387    ///
3388    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat16)
3389    #[wasm_bindgen(method, js_name = getFloat16)]
3390    pub fn get_float16_endian_as_f32(
3391        this: &DataView,
3392        byte_offset: usize,
3393        little_endian: bool,
3394    ) -> f32;
3395
3396    /// The `getFloat64()` method gets a signed 64-bit float (double) at the specified
3397    /// byte offset from the start of the DataView.
3398    ///
3399    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat64)
3400    #[wasm_bindgen(method, js_name = getFloat64)]
3401    pub fn get_float64(this: &DataView, byte_offset: usize) -> f64;
3402
3403    /// The `getFloat64()` method gets a signed 64-bit float (double) at the specified
3404    /// byte offset from the start of the DataView.
3405    ///
3406    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat64)
3407    #[wasm_bindgen(method, js_name = getFloat64)]
3408    pub fn get_float64_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> f64;
3409
3410    /// The `setInt8()` method stores a signed 8-bit integer (byte) value at the
3411    /// specified byte offset from the start of the DataView.
3412    ///
3413    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt8)
3414    #[wasm_bindgen(method, js_name = setInt8)]
3415    pub fn set_int8(this: &DataView, byte_offset: usize, value: i8);
3416
3417    /// The `setUint8()` method stores an unsigned 8-bit integer (byte) value at the
3418    /// specified byte offset from the start of the DataView.
3419    ///
3420    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint8)
3421    #[wasm_bindgen(method, js_name = setUint8)]
3422    pub fn set_uint8(this: &DataView, byte_offset: usize, value: u8);
3423
3424    /// The `setInt16()` method stores a signed 16-bit integer (short) value at the
3425    /// specified byte offset from the start of the DataView.
3426    ///
3427    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt16)
3428    #[wasm_bindgen(method, js_name = setInt16)]
3429    pub fn set_int16(this: &DataView, byte_offset: usize, value: i16);
3430
3431    /// The `setInt16()` method stores a signed 16-bit integer (short) value at the
3432    /// specified byte offset from the start of the DataView.
3433    ///
3434    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt16)
3435    #[wasm_bindgen(method, js_name = setInt16)]
3436    pub fn set_int16_endian(this: &DataView, byte_offset: usize, value: i16, little_endian: bool);
3437
3438    /// The `setUint16()` method stores an unsigned 16-bit integer (unsigned short) value at the
3439    /// specified byte offset from the start of the DataView.
3440    ///
3441    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint16)
3442    #[wasm_bindgen(method, js_name = setUint16)]
3443    pub fn set_uint16(this: &DataView, byte_offset: usize, value: u16);
3444
3445    /// The `setUint16()` method stores an unsigned 16-bit integer (unsigned short) value at the
3446    /// specified byte offset from the start of the DataView.
3447    ///
3448    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint16)
3449    #[wasm_bindgen(method, js_name = setUint16)]
3450    pub fn set_uint16_endian(this: &DataView, byte_offset: usize, value: u16, little_endian: bool);
3451
3452    /// The `setInt32()` method stores a signed 32-bit integer (long) value at the
3453    /// specified byte offset from the start of the DataView.
3454    ///
3455    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt32)
3456    #[wasm_bindgen(method, js_name = setInt32)]
3457    pub fn set_int32(this: &DataView, byte_offset: usize, value: i32);
3458
3459    /// The `setInt32()` method stores a signed 32-bit integer (long) value at the
3460    /// specified byte offset from the start of the DataView.
3461    ///
3462    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt32)
3463    #[wasm_bindgen(method, js_name = setInt32)]
3464    pub fn set_int32_endian(this: &DataView, byte_offset: usize, value: i32, little_endian: bool);
3465
3466    /// The `setUint32()` method stores an unsigned 32-bit integer (unsigned long) value at the
3467    /// specified byte offset from the start of the DataView.
3468    ///
3469    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint32)
3470    #[wasm_bindgen(method, js_name = setUint32)]
3471    pub fn set_uint32(this: &DataView, byte_offset: usize, value: u32);
3472
3473    /// The `setUint32()` method stores an unsigned 32-bit integer (unsigned long) value at the
3474    /// specified byte offset from the start of the DataView.
3475    ///
3476    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint32)
3477    #[wasm_bindgen(method, js_name = setUint32)]
3478    pub fn set_uint32_endian(this: &DataView, byte_offset: usize, value: u32, little_endian: bool);
3479
3480    /// The `setFloat32()` method stores a signed 32-bit float (float) value at the
3481    /// specified byte offset from the start of the DataView.
3482    ///
3483    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat32)
3484    #[wasm_bindgen(method, js_name = setFloat32)]
3485    pub fn set_float32(this: &DataView, byte_offset: usize, value: f32);
3486
3487    /// The `setFloat32()` method stores a signed 32-bit float (float) value at the
3488    /// specified byte offset from the start of the DataView.
3489    ///
3490    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat32)
3491    #[wasm_bindgen(method, js_name = setFloat32)]
3492    pub fn set_float32_endian(this: &DataView, byte_offset: usize, value: f32, little_endian: bool);
3493
3494    /// The `setFloat16()` method stores a signed 16-bit float value from an
3495    /// `f32` at the specified byte offset from the start of the DataView.
3496    ///
3497    /// The unsuffixed `set_float16` name is reserved for a future native
3498    /// `f16` binding once Rust stabilizes the type.
3499    ///
3500    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat16)
3501    #[wasm_bindgen(method, js_name = setFloat16)]
3502    pub fn set_float16_from_f32(this: &DataView, byte_offset: usize, value: f32);
3503
3504    /// The `setFloat16()` method stores a signed 16-bit float value from an
3505    /// `f32` at the specified byte offset from the start of the DataView.
3506    ///
3507    /// The unsuffixed `set_float16_endian` name is reserved for a future
3508    /// native `f16` binding once Rust stabilizes the type.
3509    ///
3510    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat16)
3511    #[wasm_bindgen(method, js_name = setFloat16)]
3512    pub fn set_float16_endian_from_f32(
3513        this: &DataView,
3514        byte_offset: usize,
3515        value: f32,
3516        little_endian: bool,
3517    );
3518
3519    /// The `setFloat64()` method stores a signed 64-bit float (double) value at the
3520    /// specified byte offset from the start of the DataView.
3521    ///
3522    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat64)
3523    #[wasm_bindgen(method, js_name = setFloat64)]
3524    pub fn set_float64(this: &DataView, byte_offset: usize, value: f64);
3525
3526    /// The `setFloat64()` method stores a signed 64-bit float (double) value at the
3527    /// specified byte offset from the start of the DataView.
3528    ///
3529    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat64)
3530    #[wasm_bindgen(method, js_name = setFloat64)]
3531    pub fn set_float64_endian(this: &DataView, byte_offset: usize, value: f64, little_endian: bool);
3532}
3533
3534// Error
3535#[wasm_bindgen]
3536extern "C" {
3537    #[wasm_bindgen(extends = Object, typescript_type = "Error")]
3538    #[derive(Clone, Debug, PartialEq, Eq)]
3539    pub type Error;
3540
3541    /// The Error constructor creates an error object.
3542    /// Instances of Error objects are thrown when runtime errors occur.
3543    /// The Error object can also be used as a base object for user-defined exceptions.
3544    /// See below for standard built-in error types.
3545    ///
3546    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)
3547    #[wasm_bindgen(constructor)]
3548    pub fn new(message: &str) -> Error;
3549    #[wasm_bindgen(constructor)]
3550    pub fn new_with_options(message: &str, options: &Object) -> Error;
3551
3552    /// The cause property is the underlying cause of the error.
3553    /// Usually this is used to add context to re-thrown errors.
3554    ///
3555    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#differentiate_between_similar_errors)
3556    #[wasm_bindgen(method, getter)]
3557    pub fn cause(this: &Error) -> JsValue;
3558    #[wasm_bindgen(method, setter)]
3559    pub fn set_cause(this: &Error, cause: &JsValue);
3560
3561    /// The message property is a human-readable description of the error.
3562    ///
3563    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/message)
3564    #[wasm_bindgen(method, getter)]
3565    pub fn message(this: &Error) -> JsString;
3566    #[wasm_bindgen(method, setter)]
3567    pub fn set_message(this: &Error, message: &str);
3568
3569    /// The name property represents a name for the type of error. The initial value is "Error".
3570    ///
3571    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name)
3572    #[wasm_bindgen(method, getter)]
3573    pub fn name(this: &Error) -> JsString;
3574    #[wasm_bindgen(method, setter)]
3575    pub fn set_name(this: &Error, name: &str);
3576
3577    /// The `toString()` method returns a string representing the specified Error object
3578    ///
3579    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/toString)
3580    #[cfg(not(js_sys_unstable_apis))]
3581    #[wasm_bindgen(method, js_name = toString)]
3582    pub fn to_string(this: &Error) -> JsString;
3583
3584    /// The `Error.stackTraceLimit` property controls the number of stack
3585    /// frames collected by a stack trace.
3586    ///
3587    /// This is a non-standard V8/Node.js API.
3588    ///
3589    /// [V8 documentation](https://v8.dev/docs/stack-trace-api#stack-trace-collection-for-custom-exceptions)
3590    #[wasm_bindgen(static_method_of = Error, getter, js_name = stackTraceLimit)]
3591    pub fn stack_trace_limit() -> JsValue;
3592
3593    /// Set `Error.stackTraceLimit` to control the number of stack frames
3594    /// collected by a stack trace.
3595    ///
3596    /// This is a non-standard V8/Node.js API.
3597    ///
3598    /// [V8 documentation](https://v8.dev/docs/stack-trace-api#stack-trace-collection-for-custom-exceptions)
3599    #[wasm_bindgen(static_method_of = Error, setter, js_name = stackTraceLimit)]
3600    pub fn set_stack_trace_limit(value: &JsValue);
3601}
3602
3603partialord_ord!(JsString);
3604
3605// EvalError
3606#[wasm_bindgen]
3607extern "C" {
3608    #[wasm_bindgen(extends = Object, extends = Error, typescript_type = "EvalError")]
3609    #[derive(Clone, Debug, PartialEq, Eq)]
3610    pub type EvalError;
3611
3612    /// The `EvalError` object indicates an error regarding the global eval() function. This
3613    /// exception is not thrown by JavaScript anymore, however the EvalError object remains for
3614    /// compatibility.
3615    ///
3616    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError)
3617    #[wasm_bindgen(constructor)]
3618    pub fn new(message: &str) -> EvalError;
3619}
3620
3621#[wasm_bindgen]
3622extern "C" {
3623    #[wasm_bindgen(extends = Object, is_type_of = JsValue::is_function, no_upcast, typescript_type = "Function")]
3624    #[derive(Clone, Debug, PartialEq, Eq)]
3625    /// `Function` represents any generic Function in JS, by treating all arguments as `JsValue`.
3626    ///
3627    /// It takes a generic parameter of phantom type `fn (Arg1, ..., Argn) -> Ret` which
3628    /// is used to type the JS function. For example, `Function<fn () -> Number>` represents
3629    /// a function taking no arguments that returns a number.
3630    ///
3631    /// The 8 generic argument parameters (`Arg1` through `Arg8`) are the argument
3632    /// types. Arguments not provided enable strict arity checking at compile time.
3633    ///
3634    /// A void function is represented by `fn (Arg) -> Undefined`, and **not** the `()` unit
3635    /// type. This is because generics must be based on JS values in the JS generic type system.
3636    ///
3637    /// _The default without any parameters is as a void function - no arguments, `Undefined` return._
3638    ///
3639    /// _The default generic for `Function` is `fn (JsValue, JsValue, ...) -> JsValue`,
3640    /// representing any function, since all functions safely upcast into this function._
3641    ///
3642    /// ### Arity Enforcement
3643    ///
3644    /// It is not possible to use `call4` or `bind4` on a function that does not have
3645    /// at least 4 arguments — the compiler will reject this because only arguments that
3646    /// are not `None` support the trait bound for `ErasableGeneric`.
3647    ///
3648    /// ### Examples
3649    ///
3650    /// ```ignore
3651    /// // A function taking no args, returning Number
3652    /// let f: Function<Number> = get_some_fn();
3653    ///
3654    /// // A function taking (String, Number) and returning Boolean
3655    /// let f: Function<Boolean, String, Number> = get_some_fn();
3656    ///
3657    /// ### Upcasting
3658    ///
3659    /// To pass a typed `Function` where a different generic Function is expected, `upcast()` may be used
3660    /// to convert into any generic `Function` at zero cost with type-safety.
3661    ///
3662    /// MDN documentation (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
3663    pub type Function<
3664        T: JsFunction = fn(
3665            JsValue,
3666            JsValue,
3667            JsValue,
3668            JsValue,
3669            JsValue,
3670            JsValue,
3671            JsValue,
3672            JsValue,
3673        ) -> JsValue,
3674    >;
3675}
3676
3677#[wasm_bindgen]
3678extern "C" {
3679    /// The `Function` constructor creates a new `Function` object. Calling the
3680    /// constructor directly can create functions dynamically, but suffers from
3681    /// security and similar (but far less significant) performance issues
3682    /// similar to `eval`. However, unlike `eval`, the `Function` constructor
3683    /// allows executing code in the global scope, prompting better programming
3684    /// habits and allowing for more efficient code minification.
3685    ///
3686    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
3687    #[cfg(all(feature = "unsafe-eval", not(js_sys_unstable_apis)))]
3688    #[wasm_bindgen(constructor)]
3689    pub fn new_with_args(args: &str, body: &str) -> Function;
3690
3691    /// The `Function` constructor creates a new `Function` object. Calling the
3692    /// constructor directly can create functions dynamically, but suffers from
3693    /// security and similar (but far less significant) performance issues
3694    /// similar to `eval`. However, unlike `eval`, the `Function` constructor
3695    /// allows executing code in the global scope, prompting better programming
3696    /// habits and allowing for more efficient code minification.
3697    ///
3698    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
3699    #[cfg(all(feature = "unsafe-eval", js_sys_unstable_apis))]
3700    #[wasm_bindgen(constructor)]
3701    pub fn new_with_args<T: JsFunction = fn() -> JsValue>(args: &str, body: &str) -> Function<T>;
3702
3703    // Next major: deprecate
3704    /// The `Function` constructor creates a new `Function` object. Calling the
3705    /// constructor directly can create functions dynamically, but suffers from
3706    /// security and similar (but far less significant) performance issues
3707    /// similar to `eval`. However, unlike `eval`, the `Function` constructor
3708    /// allows executing code in the global scope, prompting better programming
3709    /// habits and allowing for more efficient code minification.
3710    ///
3711    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
3712    #[cfg(feature = "unsafe-eval")]
3713    #[wasm_bindgen(constructor)]
3714    pub fn new_with_args_typed<T: JsFunction = fn() -> JsValue>(
3715        args: &str,
3716        body: &str,
3717    ) -> Function<T>;
3718
3719    /// The `Function` constructor creates a new `Function` object. Calling the
3720    /// constructor directly can create functions dynamically, but suffers from
3721    /// security and similar (but far less significant) performance issues
3722    /// similar to `eval`. However, unlike `eval`, the `Function` constructor
3723    /// allows executing code in the global scope, prompting better programming
3724    /// habits and allowing for more efficient code minification.
3725    ///
3726    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
3727    #[cfg(all(feature = "unsafe-eval", not(js_sys_unstable_apis)))]
3728    #[wasm_bindgen(constructor)]
3729    pub fn new_no_args(body: &str) -> Function;
3730
3731    /// The `Function` constructor creates a new `Function` object. Calling the
3732    /// constructor directly can create functions dynamically, but suffers from
3733    /// security and similar (but far less significant) performance issues
3734    /// similar to `eval`. However, unlike `eval`, the `Function` constructor
3735    /// allows executing code in the global scope, prompting better programming
3736    /// habits and allowing for more efficient code minification.
3737    ///
3738    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
3739    #[cfg(all(feature = "unsafe-eval", js_sys_unstable_apis))]
3740    #[wasm_bindgen(constructor)]
3741    pub fn new_no_args<T: JsFunction = fn() -> JsValue>(body: &str) -> Function<T>;
3742
3743    // Next major: deprecate
3744    /// The `Function` constructor creates a new `Function` object.
3745    ///
3746    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
3747    #[cfg(feature = "unsafe-eval")]
3748    #[wasm_bindgen(constructor)]
3749    pub fn new_no_args_typed<T: JsFunction = fn() -> JsValue>(body: &str) -> Function<T>;
3750
3751    /// The `apply()` method calls a function with a given this value, and arguments provided as an array
3752    /// (or an array-like object).
3753    ///
3754    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply)
3755    #[wasm_bindgen(method, catch)]
3756    pub fn apply<T: JsFunction = fn() -> JsValue>(
3757        this: &Function<T>,
3758        context: &JsValue,
3759        args: &Array,
3760    ) -> Result<<T as JsFunction>::Ret, JsValue>;
3761
3762    // Next major: Deprecate, and separately provide provide impl
3763    /// The `call()` method calls a function with a given this value and
3764    /// arguments provided individually.
3765    ///
3766    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
3767    ///
3768    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
3769    #[wasm_bindgen(method, catch, js_name = call)]
3770    pub fn call0<Ret: JsGeneric, F: JsFunction<Ret = Ret> = fn() -> JsValue>(
3771        this: &Function<F>,
3772        context: &JsValue,
3773    ) -> Result<Ret, JsValue>;
3774
3775    // Next major: Deprecate, and separately provide provide impl
3776    /// The `call()` method calls a function with a given this value and
3777    /// arguments provided individually.
3778    ///
3779    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
3780    ///
3781    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
3782    #[wasm_bindgen(method, catch, js_name = call)]
3783    pub fn call1<
3784        Ret: JsGeneric,
3785        Arg1: JsGeneric,
3786        F: JsFunction<Ret = Ret> + JsFunction1<Arg1 = Arg1> = fn(JsValue) -> JsValue,
3787    >(
3788        this: &Function<F>,
3789        context: &JsValue,
3790        arg1: &Arg1,
3791    ) -> Result<Ret, JsValue>;
3792
3793    // Next major: Deprecate, and separately provide provide impl
3794    /// The `call()` method calls a function with a given this value and
3795    /// arguments provided individually.
3796    ///
3797    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
3798    ///
3799    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
3800    #[wasm_bindgen(method, catch, js_name = call)]
3801    pub fn call2<
3802        Ret: JsGeneric,
3803        Arg1: JsGeneric,
3804        Arg2: JsGeneric,
3805        F: JsFunction<Ret = Ret> + JsFunction1<Arg1 = Arg1> + JsFunction2<Arg2 = Arg2> = fn(
3806            JsValue,
3807            JsValue,
3808        ) -> JsValue,
3809    >(
3810        this: &Function<F>,
3811        context: &JsValue,
3812        arg1: &Arg1,
3813        arg2: &Arg2,
3814    ) -> Result<Ret, JsValue>;
3815
3816    // Next major: Deprecate, and separately provide provide impl
3817    /// The `call()` method calls a function with a given this value and
3818    /// arguments provided individually.
3819    ///
3820    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
3821    ///
3822    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
3823    #[wasm_bindgen(method, catch, js_name = call)]
3824    pub fn call3<
3825        Ret: JsGeneric,
3826        Arg1: JsGeneric,
3827        Arg2: JsGeneric,
3828        Arg3: JsGeneric,
3829        F: JsFunction<Ret = Ret> + JsFunction3<Arg1 = Arg1, Arg2 = Arg2, Arg3 = Arg3> = fn(
3830            JsValue,
3831            JsValue,
3832            JsValue,
3833        ) -> JsValue,
3834    >(
3835        this: &Function<F>,
3836        context: &JsValue,
3837        arg1: &Arg1,
3838        arg2: &Arg2,
3839        arg3: &Arg3,
3840    ) -> Result<Ret, JsValue>;
3841
3842    // Next major: Deprecate, and separately provide provide impl
3843    /// The `call()` method calls a function with a given this value and
3844    /// arguments provided individually.
3845    ///
3846    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
3847    ///
3848    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
3849    #[wasm_bindgen(method, catch, js_name = call)]
3850    pub fn call4<
3851        Ret: JsGeneric,
3852        Arg1: JsGeneric,
3853        Arg2: JsGeneric,
3854        Arg3: JsGeneric,
3855        Arg4: JsGeneric,
3856        F: JsFunction<Ret = Ret> + JsFunction4<Arg1 = Arg1, Arg2 = Arg2, Arg3 = Arg3, Arg4 = Arg4> = fn(
3857            JsValue,
3858            JsValue,
3859            JsValue,
3860            JsValue,
3861        ) -> JsValue,
3862    >(
3863        this: &Function<F>,
3864        context: &JsValue,
3865        arg1: &Arg1,
3866        arg2: &Arg2,
3867        arg3: &Arg3,
3868        arg4: &Arg4,
3869    ) -> Result<Ret, JsValue>;
3870
3871    // Next major: Deprecate, and separately provide provide impl
3872    /// The `call()` method calls a function with a given this value and
3873    /// arguments provided individually.
3874    ///
3875    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
3876    ///
3877    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
3878    #[wasm_bindgen(method, catch, js_name = call)]
3879    pub fn call5<
3880        Ret: JsGeneric,
3881        Arg1: JsGeneric,
3882        Arg2: JsGeneric,
3883        Arg3: JsGeneric,
3884        Arg4: JsGeneric,
3885        Arg5: JsGeneric,
3886        F: JsFunction<Ret = Ret>
3887            + JsFunction5<Arg1 = Arg1, Arg2 = Arg2, Arg3 = Arg3, Arg4 = Arg4, Arg5 = Arg5> = fn(
3888            JsValue,
3889            JsValue,
3890            JsValue,
3891            JsValue,
3892            JsValue,
3893        ) -> JsValue,
3894    >(
3895        this: &Function<F>,
3896        context: &JsValue,
3897        arg1: &Arg1,
3898        arg2: &Arg2,
3899        arg3: &Arg3,
3900        arg4: &Arg4,
3901        arg5: &Arg5,
3902    ) -> Result<Ret, JsValue>;
3903
3904    // Next major: Deprecate, and separately provide provide impl
3905    /// The `call()` method calls a function with a given this value and
3906    /// arguments provided individually.
3907    ///
3908    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
3909    ///
3910    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
3911    #[wasm_bindgen(method, catch, js_name = call)]
3912    pub fn call6<
3913        Ret: JsGeneric,
3914        Arg1: JsGeneric,
3915        Arg2: JsGeneric,
3916        Arg3: JsGeneric,
3917        Arg4: JsGeneric,
3918        Arg5: JsGeneric,
3919        Arg6: JsGeneric,
3920        F: JsFunction<Ret = Ret>
3921            + JsFunction6<
3922                Arg1 = Arg1,
3923                Arg2 = Arg2,
3924                Arg3 = Arg3,
3925                Arg4 = Arg4,
3926                Arg5 = Arg5,
3927                Arg6 = Arg6,
3928            > = fn(JsValue, JsValue, JsValue, JsValue, JsValue, JsValue) -> JsValue,
3929    >(
3930        this: &Function<F>,
3931        context: &JsValue,
3932        arg1: &Arg1,
3933        arg2: &Arg2,
3934        arg3: &Arg3,
3935        arg4: &Arg4,
3936        arg5: &Arg5,
3937        arg6: &Arg6,
3938    ) -> Result<Ret, JsValue>;
3939
3940    // Next major: Deprecate, and separately provide provide impl
3941    /// The `call()` method calls a function with a given this value and
3942    /// arguments provided individually.
3943    ///
3944    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
3945    ///
3946    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
3947    #[wasm_bindgen(method, catch, js_name = call)]
3948    pub fn call7<
3949        Ret: JsGeneric,
3950        Arg1: JsGeneric,
3951        Arg2: JsGeneric,
3952        Arg3: JsGeneric,
3953        Arg4: JsGeneric,
3954        Arg5: JsGeneric,
3955        Arg6: JsGeneric,
3956        Arg7: JsGeneric,
3957        F: JsFunction<Ret = Ret>
3958            + JsFunction7<
3959                Arg1 = Arg1,
3960                Arg2 = Arg2,
3961                Arg3 = Arg3,
3962                Arg4 = Arg4,
3963                Arg5 = Arg5,
3964                Arg6 = Arg6,
3965                Arg7 = Arg7,
3966            > = fn(
3967            JsValue,
3968            JsValue,
3969            JsValue,
3970            JsValue,
3971            JsValue,
3972            JsValue,
3973            JsValue,
3974        ) -> JsValue,
3975    >(
3976        this: &Function<F>,
3977        context: &JsValue,
3978        arg1: &Arg1,
3979        arg2: &Arg2,
3980        arg3: &Arg3,
3981        arg4: &Arg4,
3982        arg5: &Arg5,
3983        arg6: &Arg6,
3984        arg7: &Arg7,
3985    ) -> Result<Ret, JsValue>;
3986
3987    // Next major: Deprecate, and separately provide provide impl
3988    /// The `call()` method calls a function with a given this value and
3989    /// arguments provided individually.
3990    ///
3991    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
3992    ///
3993    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
3994    #[wasm_bindgen(method, catch, js_name = call)]
3995    pub fn call8<
3996        Ret: JsGeneric,
3997        Arg1: JsGeneric,
3998        Arg2: JsGeneric,
3999        Arg3: JsGeneric,
4000        Arg4: JsGeneric,
4001        Arg5: JsGeneric,
4002        Arg6: JsGeneric,
4003        Arg7: JsGeneric,
4004        Arg8: JsGeneric,
4005        F: JsFunction8<
4006            Ret = Ret,
4007            Arg1 = Arg1,
4008            Arg2 = Arg2,
4009            Arg3 = Arg3,
4010            Arg4 = Arg4,
4011            Arg5 = Arg5,
4012            Arg6 = Arg6,
4013            Arg7 = Arg7,
4014            Arg8 = Arg8,
4015        > = fn(
4016            JsValue,
4017            JsValue,
4018            JsValue,
4019            JsValue,
4020            JsValue,
4021            JsValue,
4022            JsValue,
4023            JsValue,
4024        ) -> JsValue,
4025    >(
4026        this: &Function<F>,
4027        context: &JsValue,
4028        arg1: &Arg1,
4029        arg2: &Arg2,
4030        arg3: &Arg3,
4031        arg4: &Arg4,
4032        arg5: &Arg5,
4033        arg6: &Arg6,
4034        arg7: &Arg7,
4035        arg8: &Arg8,
4036    ) -> Result<Ret, JsValue>;
4037
4038    /// The `call()` method calls a function with a given this value and
4039    /// arguments provided individually.
4040    ///
4041    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
4042    ///
4043    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
4044    #[deprecated]
4045    #[allow(deprecated)]
4046    #[wasm_bindgen(method, catch, js_name = call)]
4047    pub fn call9<
4048        Ret: JsGeneric,
4049        Arg1: JsGeneric,
4050        Arg2: JsGeneric,
4051        Arg3: JsGeneric,
4052        Arg4: JsGeneric,
4053        Arg5: JsGeneric,
4054        Arg6: JsGeneric,
4055        Arg7: JsGeneric,
4056        Arg8: JsGeneric,
4057        F: JsFunction8<
4058            Ret = Ret,
4059            Arg1 = Arg1,
4060            Arg2 = Arg2,
4061            Arg3 = Arg3,
4062            Arg4 = Arg4,
4063            Arg5 = Arg5,
4064            Arg6 = Arg6,
4065            Arg7 = Arg7,
4066            Arg8 = Arg8,
4067        > = fn(
4068            JsValue,
4069            JsValue,
4070            JsValue,
4071            JsValue,
4072            JsValue,
4073            JsValue,
4074            JsValue,
4075            JsValue,
4076        ) -> JsValue,
4077    >(
4078        this: &Function<F>,
4079        context: &JsValue,
4080        arg1: &Arg1,
4081        arg2: &Arg2,
4082        arg3: &Arg3,
4083        arg4: &Arg4,
4084        arg5: &Arg5,
4085        arg6: &Arg6,
4086        arg7: &Arg7,
4087        arg8: &Arg8,
4088        arg9: &JsValue,
4089    ) -> Result<Ret, JsValue>;
4090
4091    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4092    /// with a given sequence of arguments preceding any provided when the new function is called.
4093    ///
4094    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4095    #[cfg(not(js_sys_unstable_apis))]
4096    #[deprecated(note = "Use `Function::bind0` instead.")]
4097    #[allow(deprecated)]
4098    #[wasm_bindgen(method, js_name = bind)]
4099    pub fn bind<T: JsFunction = fn() -> JsValue>(
4100        this: &Function<T>,
4101        context: &JsValue,
4102    ) -> Function<T>;
4103
4104    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4105    /// with a given sequence of arguments preceding any provided when the new function is called.
4106    ///
4107    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4108    ///
4109    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4110    #[wasm_bindgen(method, js_name = bind)]
4111    pub fn bind0<T: JsFunction = fn() -> JsValue>(
4112        this: &Function<T>,
4113        context: &JsValue,
4114    ) -> Function<T>;
4115
4116    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4117    /// with a given sequence of arguments preceding any provided when the new function is called.
4118    ///
4119    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4120    ///
4121    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4122    #[wasm_bindgen(method, js_name = bind)]
4123    pub fn bind1<
4124        Ret: JsGeneric,
4125        Arg1: JsGeneric,
4126        F: JsFunction1<Ret = Ret, Arg1 = Arg1> = fn(JsValue) -> JsValue,
4127    >(
4128        this: &Function<F>,
4129        context: &JsValue,
4130        arg1: &Arg1,
4131    ) -> Function<<F as JsFunction1>::Bind1>;
4132
4133    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4134    /// with a given sequence of arguments preceding any provided when the new function is called.
4135    ///
4136    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4137    ///
4138    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4139    #[wasm_bindgen(method, js_name = bind)]
4140    pub fn bind2<
4141        Ret: JsGeneric,
4142        Arg1: JsGeneric,
4143        Arg2: JsGeneric,
4144        F: JsFunction2<Ret = Ret, Arg1 = Arg1, Arg2 = Arg2> = fn(JsValue, JsValue) -> JsValue,
4145    >(
4146        this: &Function<F>,
4147        context: &JsValue,
4148        arg1: &Arg1,
4149        arg2: &Arg2,
4150    ) -> Function<<F as JsFunction2>::Bind2>;
4151
4152    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4153    /// with a given sequence of arguments preceding any provided when the new function is called.
4154    ///
4155    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4156    ///
4157    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4158    #[wasm_bindgen(method, js_name = bind)]
4159    pub fn bind3<
4160        Ret: JsGeneric,
4161        Arg1: JsGeneric,
4162        Arg2: JsGeneric,
4163        Arg3: JsGeneric,
4164        F: JsFunction3<Ret = Ret, Arg1 = Arg1, Arg2 = Arg2, Arg3 = Arg3> = fn(
4165            JsValue,
4166            JsValue,
4167            JsValue,
4168        ) -> JsValue,
4169    >(
4170        this: &Function<F>,
4171        context: &JsValue,
4172        arg1: &Arg1,
4173        arg2: &Arg2,
4174        arg3: &Arg3,
4175    ) -> Function<<F as JsFunction3>::Bind3>;
4176
4177    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4178    /// with a given sequence of arguments preceding any provided when the new function is called.
4179    ///
4180    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4181    ///
4182    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4183    #[wasm_bindgen(method, js_name = bind)]
4184    pub fn bind4<
4185        Ret: JsGeneric,
4186        Arg1: JsGeneric,
4187        Arg2: JsGeneric,
4188        Arg3: JsGeneric,
4189        Arg4: JsGeneric,
4190        F: JsFunction4<Ret = Ret, Arg1 = Arg1, Arg2 = Arg2, Arg3 = Arg3, Arg4 = Arg4> = fn(
4191            JsValue,
4192            JsValue,
4193            JsValue,
4194            JsValue,
4195        ) -> JsValue,
4196    >(
4197        this: &Function<F>,
4198        context: &JsValue,
4199        arg1: &Arg1,
4200        arg2: &Arg2,
4201        arg3: &Arg3,
4202        arg4: &Arg4,
4203    ) -> Function<<F as JsFunction4>::Bind4>;
4204
4205    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4206    /// with a given sequence of arguments preceding any provided when the new function is called.
4207    ///
4208    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4209    ///
4210    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4211    #[wasm_bindgen(method, js_name = bind)]
4212    pub fn bind5<
4213        Ret: JsGeneric,
4214        Arg1: JsGeneric,
4215        Arg2: JsGeneric,
4216        Arg3: JsGeneric,
4217        Arg4: JsGeneric,
4218        Arg5: JsGeneric,
4219        F: JsFunction5<Ret = Ret, Arg1 = Arg1, Arg2 = Arg2, Arg3 = Arg3, Arg4 = Arg4, Arg5 = Arg5> = fn(
4220            JsValue,
4221            JsValue,
4222            JsValue,
4223            JsValue,
4224            JsValue,
4225        ) -> JsValue,
4226    >(
4227        this: &Function<F>,
4228        context: &JsValue,
4229        arg1: &Arg1,
4230        arg2: &Arg2,
4231        arg3: &Arg3,
4232        arg4: &Arg4,
4233        arg5: &Arg5,
4234    ) -> Function<<F as JsFunction5>::Bind5>;
4235
4236    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4237    /// with a given sequence of arguments preceding any provided when the new function is called.
4238    ///
4239    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4240    ///
4241    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4242    #[wasm_bindgen(method, js_name = bind)]
4243    pub fn bind6<
4244        Ret: JsGeneric,
4245        Arg1: JsGeneric,
4246        Arg2: JsGeneric,
4247        Arg3: JsGeneric,
4248        Arg4: JsGeneric,
4249        Arg5: JsGeneric,
4250        Arg6: JsGeneric,
4251        F: JsFunction6<
4252            Ret = Ret,
4253            Arg1 = Arg1,
4254            Arg2 = Arg2,
4255            Arg3 = Arg3,
4256            Arg4 = Arg4,
4257            Arg5 = Arg5,
4258            Arg6 = Arg6,
4259        > = fn(JsValue, JsValue, JsValue, JsValue, JsValue, JsValue) -> JsValue,
4260    >(
4261        this: &Function<F>,
4262        context: &JsValue,
4263        arg1: &Arg1,
4264        arg2: &Arg2,
4265        arg3: &Arg3,
4266        arg4: &Arg4,
4267        arg5: &Arg5,
4268        arg6: &Arg6,
4269    ) -> Function<<F as JsFunction6>::Bind6>;
4270
4271    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4272    /// with a given sequence of arguments preceding any provided when the new function is called.
4273    ///
4274    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4275    ///
4276    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4277    #[wasm_bindgen(method, js_name = bind)]
4278    pub fn bind7<
4279        Ret: JsGeneric,
4280        Arg1: JsGeneric,
4281        Arg2: JsGeneric,
4282        Arg3: JsGeneric,
4283        Arg4: JsGeneric,
4284        Arg5: JsGeneric,
4285        Arg6: JsGeneric,
4286        Arg7: JsGeneric,
4287        F: JsFunction7<
4288            Ret = Ret,
4289            Arg1 = Arg1,
4290            Arg2 = Arg2,
4291            Arg3 = Arg3,
4292            Arg4 = Arg4,
4293            Arg5 = Arg5,
4294            Arg6 = Arg6,
4295            Arg7 = Arg7,
4296        > = fn(
4297            JsValue,
4298            JsValue,
4299            JsValue,
4300            JsValue,
4301            JsValue,
4302            JsValue,
4303            JsValue,
4304        ) -> JsValue,
4305    >(
4306        this: &Function<F>,
4307        context: &JsValue,
4308        arg1: &Arg1,
4309        arg2: &Arg2,
4310        arg3: &Arg3,
4311        arg4: &Arg4,
4312        arg5: &Arg5,
4313        arg6: &Arg6,
4314        arg7: &Arg7,
4315    ) -> Function<<F as JsFunction7>::Bind7>;
4316
4317    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4318    /// with a given sequence of arguments preceding any provided when the new function is called.
4319    ///
4320    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4321    ///
4322    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4323    #[wasm_bindgen(method, js_name = bind)]
4324    pub fn bind8<
4325        Ret: JsGeneric,
4326        Arg1: JsGeneric,
4327        Arg2: JsGeneric,
4328        Arg3: JsGeneric,
4329        Arg4: JsGeneric,
4330        Arg5: JsGeneric,
4331        Arg6: JsGeneric,
4332        Arg7: JsGeneric,
4333        Arg8: JsGeneric,
4334        F: JsFunction8<
4335            Ret = Ret,
4336            Arg1 = Arg1,
4337            Arg2 = Arg2,
4338            Arg3 = Arg3,
4339            Arg4 = Arg4,
4340            Arg5 = Arg5,
4341            Arg6 = Arg6,
4342            Arg7 = Arg7,
4343            Arg8 = Arg8,
4344        > = fn(
4345            JsValue,
4346            JsValue,
4347            JsValue,
4348            JsValue,
4349            JsValue,
4350            JsValue,
4351            JsValue,
4352            JsValue,
4353        ) -> JsValue,
4354    >(
4355        this: &Function<F>,
4356        context: &JsValue,
4357        arg1: &Arg1,
4358        arg2: &Arg2,
4359        arg3: &Arg3,
4360        arg4: &Arg4,
4361        arg5: &Arg5,
4362        arg6: &Arg6,
4363        arg7: &Arg7,
4364        arg8: &Arg8,
4365    ) -> Function<<F as JsFunction8>::Bind8>;
4366
4367    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4368    /// with a given sequence of arguments preceding any provided when the new function is called.
4369    ///
4370    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4371    ///
4372    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4373    #[deprecated]
4374    #[allow(deprecated)]
4375    #[wasm_bindgen(method, js_name = bind)]
4376    pub fn bind9<
4377        Ret: JsGeneric,
4378        Arg1: JsGeneric,
4379        Arg2: JsGeneric,
4380        Arg3: JsGeneric,
4381        Arg4: JsGeneric,
4382        Arg5: JsGeneric,
4383        Arg6: JsGeneric,
4384        Arg7: JsGeneric,
4385        Arg8: JsGeneric,
4386        F: JsFunction8<
4387            Ret = Ret,
4388            Arg1 = Arg1,
4389            Arg2 = Arg2,
4390            Arg3 = Arg3,
4391            Arg4 = Arg4,
4392            Arg5 = Arg5,
4393            Arg6 = Arg6,
4394            Arg7 = Arg7,
4395            Arg8 = Arg8,
4396        > = fn(
4397            JsValue,
4398            JsValue,
4399            JsValue,
4400            JsValue,
4401            JsValue,
4402            JsValue,
4403            JsValue,
4404            JsValue,
4405        ) -> JsValue,
4406    >(
4407        this: &Function<F>,
4408        context: &JsValue,
4409        arg1: &Arg1,
4410        arg2: &Arg2,
4411        arg3: &Arg3,
4412        arg4: &Arg4,
4413        arg5: &Arg5,
4414        arg6: &Arg6,
4415        arg7: &Arg7,
4416        arg8: &Arg8,
4417        arg9: &JsValue,
4418    ) -> Function<fn() -> Ret>;
4419
4420    /// The length property indicates the number of arguments expected by the function.
4421    ///
4422    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length)
4423    #[wasm_bindgen(method, getter)]
4424    pub fn length<T: JsFunction = fn() -> JsValue>(this: &Function<T>) -> u32;
4425
4426    /// A Function object's read-only name property indicates the function's
4427    /// name as specified when it was created or "anonymous" for functions
4428    /// created anonymously.
4429    ///
4430    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name)
4431    #[wasm_bindgen(method, getter)]
4432    pub fn name<T: JsFunction = fn() -> JsValue>(this: &Function<T>) -> JsString;
4433
4434    /// The `toString()` method returns a string representing the source code of the function.
4435    ///
4436    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toString)
4437    #[cfg(not(js_sys_unstable_apis))]
4438    #[wasm_bindgen(method, js_name = toString)]
4439    pub fn to_string<T: JsFunction = fn() -> JsValue>(this: &Function<T>) -> JsString;
4440}
4441
4442// Basic UpcastFrom impls for Function<T>
4443impl<T: JsFunction> UpcastFrom<Function<T>> for JsValue {}
4444impl<T: JsFunction> UpcastFrom<Function<T>> for JsOption<JsValue> {}
4445impl<T: JsFunction> UpcastFrom<Function<T>> for Object {}
4446impl<T: JsFunction> UpcastFrom<Function<T>> for JsOption<Object> {}
4447
4448// Blanket trait for Function upcast
4449// Function<T> upcasts to Function<U> when the underlying fn type T upcasts to U.
4450// The fn signature UpcastFrom impls already encode correct variance (covariant return, contravariant args).
4451impl<T: JsFunction, U: JsFunction> UpcastFrom<Function<T>> for Function<U> where U: UpcastFrom<T> {}
4452
4453// len() method for Function<T> using JsFunction::ARITY
4454impl<T: JsFunction> Function<T> {
4455    /// Get the static arity of this function type.
4456    #[allow(clippy::len_without_is_empty)]
4457    pub fn len(&self) -> usize {
4458        T::ARITY
4459    }
4460
4461    /// Returns true if this is a zero-argument function.
4462    pub fn is_empty(&self) -> bool {
4463        T::ARITY == 0
4464    }
4465}
4466
4467// Base traits for function signature types.
4468pub trait JsFunction {
4469    type Ret: JsGeneric;
4470    const ARITY: usize;
4471}
4472
4473pub trait JsFunction1: JsFunction {
4474    type Arg1: JsGeneric;
4475    type Bind1: JsFunction;
4476}
4477pub trait JsFunction2: JsFunction1 {
4478    type Arg2: JsGeneric;
4479    type Bind2: JsFunction;
4480}
4481pub trait JsFunction3: JsFunction2 {
4482    type Arg3: JsGeneric;
4483    type Bind3: JsFunction;
4484}
4485pub trait JsFunction4: JsFunction3 {
4486    type Arg4: JsGeneric;
4487    type Bind4: JsFunction;
4488}
4489pub trait JsFunction5: JsFunction4 {
4490    type Arg5: JsGeneric;
4491    type Bind5: JsFunction;
4492}
4493pub trait JsFunction6: JsFunction5 {
4494    type Arg6: JsGeneric;
4495    type Bind6: JsFunction;
4496}
4497pub trait JsFunction7: JsFunction6 {
4498    type Arg7: JsGeneric;
4499    type Bind7: JsFunction;
4500}
4501pub trait JsFunction8: JsFunction7 {
4502    type Arg8: JsGeneric;
4503    type Bind8: JsFunction;
4504}
4505
4506// Manual impl for fn() -> R
4507impl<Ret: JsGeneric> JsFunction for fn() -> Ret {
4508    type Ret = Ret;
4509    const ARITY: usize = 0;
4510}
4511
4512macro_rules! impl_fn {
4513    () => {
4514        impl_fn!(@impl 1 [Arg1] [
4515            JsFunction1 Arg1 Bind1 {fn() -> Ret}
4516        ]);
4517        impl_fn!(@impl 2 [Arg1 Arg2] [
4518            JsFunction1 Arg1 Bind1 {fn(Arg2) -> Ret}
4519            JsFunction2 Arg2 Bind2 {fn() -> Ret}
4520        ]);
4521        impl_fn!(@impl 3 [Arg1 Arg2 Arg3] [
4522            JsFunction1 Arg1 Bind1 {fn(Arg2, Arg3) -> Ret}
4523            JsFunction2 Arg2 Bind2 {fn(Arg3) -> Ret}
4524            JsFunction3 Arg3 Bind3 {fn() -> Ret}
4525        ]);
4526        impl_fn!(@impl 4 [Arg1 Arg2 Arg3 Arg4] [
4527            JsFunction1 Arg1 Bind1 {fn(Arg2, Arg3, Arg4) -> Ret}
4528            JsFunction2 Arg2 Bind2 {fn(Arg3, Arg4) -> Ret}
4529            JsFunction3 Arg3 Bind3 {fn(Arg4) -> Ret}
4530            JsFunction4 Arg4 Bind4 {fn() -> Ret}
4531        ]);
4532        impl_fn!(@impl 5 [Arg1 Arg2 Arg3 Arg4 Arg5] [
4533            JsFunction1 Arg1 Bind1 {fn(Arg2, Arg3, Arg4, Arg5) -> Ret}
4534            JsFunction2 Arg2 Bind2 {fn(Arg3, Arg4, Arg5) -> Ret}
4535            JsFunction3 Arg3 Bind3 {fn(Arg4, Arg5) -> Ret}
4536            JsFunction4 Arg4 Bind4 {fn(Arg5) -> Ret}
4537            JsFunction5 Arg5 Bind5 {fn() -> Ret}
4538        ]);
4539        impl_fn!(@impl 6 [Arg1 Arg2 Arg3 Arg4 Arg5 Arg6] [
4540            JsFunction1 Arg1 Bind1 {fn(Arg2, Arg3, Arg4, Arg5, Arg6) -> Ret}
4541            JsFunction2 Arg2 Bind2 {fn(Arg3, Arg4, Arg5, Arg6) -> Ret}
4542            JsFunction3 Arg3 Bind3 {fn(Arg4, Arg5, Arg6) -> Ret}
4543            JsFunction4 Arg4 Bind4 {fn(Arg5, Arg6) -> Ret}
4544            JsFunction5 Arg5 Bind5 {fn(Arg6) -> Ret}
4545            JsFunction6 Arg6 Bind6 {fn() -> Ret}
4546        ]);
4547        impl_fn!(@impl 7 [Arg1 Arg2 Arg3 Arg4 Arg5 Arg6 Arg7] [
4548            JsFunction1 Arg1 Bind1 {fn(Arg2, Arg3, Arg4, Arg5, Arg6, Arg7) -> Ret}
4549            JsFunction2 Arg2 Bind2 {fn(Arg3, Arg4, Arg5, Arg6, Arg7) -> Ret}
4550            JsFunction3 Arg3 Bind3 {fn(Arg4, Arg5, Arg6, Arg7) -> Ret}
4551            JsFunction4 Arg4 Bind4 {fn(Arg5, Arg6, Arg7) -> Ret}
4552            JsFunction5 Arg5 Bind5 {fn(Arg6, Arg7) -> Ret}
4553            JsFunction6 Arg6 Bind6 {fn(Arg7) -> Ret}
4554            JsFunction7 Arg7 Bind7 {fn() -> Ret}
4555        ]);
4556        impl_fn!(@impl 8 [Arg1 Arg2 Arg3 Arg4 Arg5 Arg6 Arg7 Arg8] [
4557            JsFunction1 Arg1 Bind1 {fn(Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8) -> Ret}
4558            JsFunction2 Arg2 Bind2 {fn(Arg3, Arg4, Arg5, Arg6, Arg7, Arg8) -> Ret}
4559            JsFunction3 Arg3 Bind3 {fn(Arg4, Arg5, Arg6, Arg7, Arg8) -> Ret}
4560            JsFunction4 Arg4 Bind4 {fn(Arg5, Arg6, Arg7, Arg8) -> Ret}
4561            JsFunction5 Arg5 Bind5 {fn(Arg6, Arg7, Arg8) -> Ret}
4562            JsFunction6 Arg6 Bind6 {fn(Arg7, Arg8) -> Ret}
4563            JsFunction7 Arg7 Bind7 {fn(Arg8) -> Ret}
4564            JsFunction8 Arg8 Bind8 {fn() -> Ret}
4565        ]);
4566    };
4567
4568    (@impl $arity:literal [$($A:ident)+] [$($trait:ident $arg:ident $bind:ident {$bind_ty:ty})+]) => {
4569        impl<Ret: JsGeneric $(, $A: JsGeneric)+> JsFunction for fn($($A),+) -> Ret {
4570            type Ret = Ret;
4571            const ARITY: usize = $arity;
4572        }
4573
4574        impl_fn!(@traits [$($A)+] [$($trait $arg $bind {$bind_ty})+]);
4575    };
4576
4577    (@traits [$($A:ident)+] []) => {};
4578
4579    (@traits [$($A:ident)+] [$trait:ident $arg:ident $bind:ident {$bind_ty:ty} $($rest:tt)*]) => {
4580        impl<Ret: JsGeneric $(, $A: JsGeneric)+> $trait for fn($($A),+) -> Ret {
4581            type $arg = $arg;
4582            type $bind = $bind_ty;
4583        }
4584
4585        impl_fn!(@traits [$($A)+] [$($rest)*]);
4586    };
4587}
4588
4589impl_fn!();
4590
4591/// Trait for argument tuples that can call or bind a `Function<T>`.
4592pub trait JsArgs<T: JsFunction> {
4593    type BindOutput;
4594    fn apply_call(self, func: &Function<T>, context: &JsValue) -> Result<T::Ret, JsValue>;
4595    fn apply_bind(self, func: &Function<T>, context: &JsValue) -> Self::BindOutput;
4596}
4597
4598// Manual impl for 0-arg
4599impl<Ret: JsGeneric, F: JsFunction<Ret = Ret>> JsArgs<F> for () {
4600    type BindOutput = Function<F>;
4601
4602    #[inline]
4603    fn apply_call(self, func: &Function<F>, context: &JsValue) -> Result<Ret, JsValue> {
4604        func.call0(context)
4605    }
4606
4607    #[inline]
4608    fn apply_bind(self, func: &Function<F>, context: &JsValue) -> Self::BindOutput {
4609        func.bind0(context)
4610    }
4611}
4612
4613macro_rules! impl_js_args {
4614    ($arity:literal $trait:ident $bind_output:ident [$($A:ident)+] [$($idx:tt)+] $call:ident $bind:ident) => {
4615        impl<Ret: JsGeneric, $($A: JsGeneric,)+ F: $trait<Ret = Ret, $($A = $A,)*>> JsArgs<F> for ($(&$A,)+)
4616        {
4617            type BindOutput = Function<<F as $trait>::$bind_output>;
4618
4619            #[inline]
4620            fn apply_call(self, func: &Function<F>, context: &JsValue) -> Result<Ret, JsValue> {
4621                func.$call(context, $(self.$idx),+)
4622            }
4623
4624            #[inline]
4625            fn apply_bind(self, func: &Function<F>, context: &JsValue) -> Self::BindOutput {
4626                func.$bind(context, $(self.$idx),+)
4627            }
4628        }
4629    };
4630}
4631
4632impl_js_args!(1 JsFunction1 Bind1 [Arg1] [0] call1 bind1);
4633impl_js_args!(2 JsFunction2 Bind2 [Arg1 Arg2] [0 1] call2 bind2);
4634impl_js_args!(3 JsFunction3 Bind3 [Arg1 Arg2 Arg3] [0 1 2] call3 bind3);
4635impl_js_args!(4 JsFunction4 Bind4 [Arg1 Arg2 Arg3 Arg4] [0 1 2 3] call4 bind4);
4636impl_js_args!(5 JsFunction5 Bind5 [Arg1 Arg2 Arg3 Arg4 Arg5] [0 1 2 3 4] call5 bind5);
4637impl_js_args!(6 JsFunction6 Bind6 [Arg1 Arg2 Arg3 Arg4 Arg5 Arg6] [0 1 2 3 4 5] call6 bind6);
4638impl_js_args!(7 JsFunction7 Bind7 [Arg1 Arg2 Arg3 Arg4 Arg5 Arg6 Arg7] [0 1 2 3 4 5 6] call7 bind7);
4639impl_js_args!(8 JsFunction8 Bind8 [Arg1 Arg2 Arg3 Arg4 Arg5 Arg6 Arg7 Arg8] [0 1 2 3 4 5 6 7] call8 bind8);
4640
4641impl<T: JsFunction> Function<T> {
4642    /// The `call()` method calls a function with a given `this` value and
4643    /// arguments provided as a tuple.
4644    ///
4645    /// This method accepts a tuple of references matching the function's
4646    /// argument types.
4647    ///
4648    /// # Example
4649    ///
4650    /// ```ignore
4651    /// // 0-arg function
4652    /// let f: Function<fn() -> Number> = get_fn();
4653    /// let result = f.call(&JsValue::NULL, ())?;
4654    ///
4655    /// // 1-arg function (note trailing comma for 1-tuple)
4656    /// let f: Function<fn(JsString) -> Number> = get_fn();
4657    /// let result = f.call(&JsValue::NULL, (&name,))?;
4658    ///
4659    /// // 2-arg function
4660    /// let f: Function<fn(JsString, Boolean) -> Number> = get_fn();
4661    /// let result = f.call(&JsValue::NULL, (&name, &flag))?;
4662    /// ```
4663    ///
4664    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
4665    #[inline]
4666    pub fn call<Args: JsArgs<T>>(&self, context: &JsValue, args: Args) -> Result<T::Ret, JsValue> {
4667        args.apply_call(self, context)
4668    }
4669
4670    /// The `bind()` method creates a new function that, when called, has its
4671    /// `this` keyword set to the provided value, with a given sequence of
4672    /// arguments preceding any provided when the new function is called.
4673    ///
4674    /// This method accepts a tuple of references to bind.
4675    ///
4676    /// # Example
4677    ///
4678    /// ```ignore
4679    /// let f: Function<fn(JsString, Boolean) -> Number> = get_fn();
4680    ///
4681    /// // Bind no args - same signature
4682    /// let bound: Function<fn(JsString, Boolean) -> Number> = f.bind(&ctx, ());
4683    ///
4684    /// // Bind one arg (use 1-tuple of references)
4685    /// let bound: Function<fn(Boolean) -> Number> = f.bind(&ctx, (&my_string,));
4686    ///
4687    /// // Bind two args - becomes 0-arg function
4688    /// let bound: Function<fn() -> Number> = f.bind(&ctx, (&my_string, &my_bool));
4689    /// ```
4690    ///
4691    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4692    #[inline]
4693    pub fn bindn<Args: JsArgs<T>>(&self, context: &JsValue, args: Args) -> Args::BindOutput {
4694        args.apply_bind(self, context)
4695    }
4696
4697    /// The `bind()` method creates a new function that, when called, has its
4698    /// `this` keyword set to the provided value, with a given sequence of
4699    /// arguments preceding any provided when the new function is called.
4700    ///
4701    /// This method accepts a tuple of references to bind.
4702    ///
4703    /// # Example
4704    ///
4705    /// ```ignore
4706    /// let f: Function<fn(JsString, Boolean) -> Number> = get_fn();
4707    ///
4708    /// // Bind no args - same signature
4709    /// let bound: Function<fn(JsString, Boolean) -> Number> = f.bind(&ctx, ());
4710    ///
4711    /// // Bind one arg (use 1-tuple of references)
4712    /// let bound: Function<fn(Boolean) -> Number> = f.bind(&ctx, (&my_string,));
4713    ///
4714    /// // Bind two args - becomes 0-arg function
4715    /// let bound: Function<fn() -> Number> = f.bind(&ctx, (&my_string, &my_bool));
4716    /// ```
4717    ///
4718    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4719    #[cfg(js_sys_unstable_apis)]
4720    #[inline]
4721    pub fn bind<Args: JsArgs<T>>(&self, context: &JsValue, args: Args) -> Args::BindOutput {
4722        args.apply_bind(self, context)
4723    }
4724}
4725
4726pub trait FunctionIntoClosure: JsFunction {
4727    type ClosureTypeMut: WasmClosure + ?Sized;
4728}
4729
4730macro_rules! impl_function_into_closure {
4731    ( $(($($var:ident)*))* ) => {$(
4732        impl<$($var: FromWasmAbi + JsGeneric,)* R: IntoWasmAbi + JsGeneric> FunctionIntoClosure for fn($($var),*) -> R {
4733            type ClosureTypeMut = dyn FnMut($($var),*) -> R;
4734        }
4735    )*};
4736}
4737
4738impl_function_into_closure! {
4739    ()
4740    (A)
4741    (A B)
4742    (A B C)
4743    (A B C D)
4744    (A B C D E)
4745    (A B C D E F)
4746    (A B C D E F G)
4747    (A B C D E F G H)
4748}
4749
4750impl<F: JsFunction> Function<F> {
4751    /// Convert a borrowed `ScopedClosure` into a typed JavaScript Function reference.
4752    ///
4753    /// The conversion is a direct type-safe conversion and upcast of a
4754    /// closure into its corresponding typed JavaScript Function,
4755    /// based on covariance and contravariance [`Upcast`] trait hierarchy.
4756    ///
4757    /// For transferring ownership to JS, use [`Function::from_closure`].
4758    #[inline]
4759    pub fn closure_ref<'a, C>(closure: &'a ScopedClosure<'_, C>) -> &'a Self
4760    where
4761        F: FunctionIntoClosure,
4762        C: WasmClosure + ?Sized,
4763        <F as FunctionIntoClosure>::ClosureTypeMut: UpcastFrom<<C as WasmClosure>::AsMut>,
4764    {
4765        closure.as_js_value().unchecked_ref()
4766    }
4767
4768    /// Convert a Rust closure into a typed JavaScript Function.
4769    ///
4770    /// This function releases ownership of the closure to JS, and provides
4771    /// an owned function handle for the same closure.
4772    ///
4773    /// The conversion is a direct type-safe conversion and upcast of a
4774    /// closure into its corresponding typed JavaScript Function,
4775    /// based on covariance and contravariance [`Upcast`] trait hierarchy.
4776    ///
4777    /// This method is only supported for static closures which do not have
4778    /// borrowed lifetime data, and thus can be released into JS.
4779    ///
4780    /// For borrowed closures, which cannot cede ownership to JS,
4781    /// instead use [`Function::closure_ref`].
4782    #[inline]
4783    pub fn from_closure<C>(closure: ScopedClosure<'static, C>) -> Self
4784    where
4785        F: FunctionIntoClosure,
4786        C: WasmClosure + ?Sized,
4787        <F as FunctionIntoClosure>::ClosureTypeMut: UpcastFrom<<C as WasmClosure>::AsMut>,
4788    {
4789        closure.into_js_value().unchecked_into()
4790    }
4791}
4792
4793#[cfg(not(js_sys_unstable_apis))]
4794impl Function {
4795    /// Returns the `Function` value of this JS value if it's an instance of a
4796    /// function.
4797    ///
4798    /// If this JS value is not an instance of a function then this returns
4799    /// `None`.
4800    #[deprecated(note = "recommended to use dyn_ref instead which is now equivalent")]
4801    pub fn try_from(val: &JsValue) -> Option<&Function> {
4802        val.dyn_ref()
4803    }
4804}
4805
4806#[cfg(feature = "unsafe-eval")]
4807impl Default for Function {
4808    fn default() -> Self {
4809        Self::new_no_args("")
4810    }
4811}
4812
4813// Generator
4814#[wasm_bindgen]
4815extern "C" {
4816    #[wasm_bindgen(extends = Object, typescript_type = "Generator<any, any, any>")]
4817    #[derive(Clone, Debug, PartialEq, Eq)]
4818    pub type Generator<T = JsValue>;
4819
4820    /// The `next()` method returns an object with two properties done and value.
4821    /// You can also provide a parameter to the next method to send a value to the generator.
4822    ///
4823    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/next)
4824    #[cfg(not(js_sys_unstable_apis))]
4825    #[wasm_bindgen(method, catch)]
4826    pub fn next<T>(this: &Generator<T>, value: &T) -> Result<JsValue, JsValue>;
4827
4828    /// The `next()` method returns an object with two properties done and value.
4829    /// You can also provide a parameter to the next method to send a value to the generator.
4830    ///
4831    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/next)
4832    #[cfg(js_sys_unstable_apis)]
4833    #[wasm_bindgen(method, catch, js_name = next)]
4834    pub fn next<T: FromWasmAbi>(this: &Generator<T>, value: &T)
4835        -> Result<IteratorNext<T>, JsValue>;
4836
4837    // Next major: deprecate
4838    /// The `next()` method returns an object with two properties done and value.
4839    /// You can also provide a parameter to the next method to send a value to the generator.
4840    ///
4841    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/next)
4842    #[wasm_bindgen(method, catch)]
4843    pub fn next_iterator<T: FromWasmAbi>(
4844        this: &Generator<T>,
4845        value: &T,
4846    ) -> Result<IteratorNext<T>, JsValue>;
4847
4848    /// The `return()` method returns the given value and finishes the generator.
4849    ///
4850    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/return)
4851    #[cfg(not(js_sys_unstable_apis))]
4852    #[wasm_bindgen(method, js_name = "return")]
4853    pub fn return_<T>(this: &Generator<T>, value: &T) -> JsValue;
4854
4855    /// The `return()` method returns the given value and finishes the generator.
4856    ///
4857    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/return)
4858    #[cfg(js_sys_unstable_apis)]
4859    #[wasm_bindgen(method, catch, js_name = "return")]
4860    pub fn return_<T: FromWasmAbi>(
4861        this: &Generator<T>,
4862        value: &T,
4863    ) -> Result<IteratorNext<T>, JsValue>;
4864
4865    // Next major: deprecate
4866    /// The `return()` method returns the given value and finishes the generator.
4867    ///
4868    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/return)
4869    #[wasm_bindgen(method, catch, js_name = "return")]
4870    pub fn try_return<T: FromWasmAbi>(
4871        this: &Generator<T>,
4872        value: &T,
4873    ) -> Result<IteratorNext<T>, JsValue>;
4874
4875    /// The `throw()` method resumes the execution of a generator by throwing an error into it
4876    /// and returns an object with two properties done and value.
4877    ///
4878    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/throw)
4879    #[cfg(not(js_sys_unstable_apis))]
4880    #[wasm_bindgen(method, catch)]
4881    pub fn throw<T>(this: &Generator<T>, error: &Error) -> Result<JsValue, JsValue>;
4882
4883    /// The `throw()` method resumes the execution of a generator by throwing an error into it
4884    /// and returns an object with two properties done and value.
4885    ///
4886    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/throw)
4887    #[cfg(js_sys_unstable_apis)]
4888    #[wasm_bindgen(method, catch, js_name = throw)]
4889    pub fn throw<T: FromWasmAbi>(
4890        this: &Generator<T>,
4891        error: &JsValue,
4892    ) -> Result<IteratorNext<T>, JsValue>;
4893
4894    // Next major: deprecate
4895    /// The `throw()` method resumes the execution of a generator by throwing an error into it
4896    /// and returns an object with two properties done and value.
4897    ///
4898    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/throw)
4899    #[wasm_bindgen(method, catch, js_name = throw)]
4900    pub fn throw_value<T: FromWasmAbi>(
4901        this: &Generator<T>,
4902        error: &JsValue,
4903    ) -> Result<IteratorNext<T>, JsValue>;
4904}
4905
4906impl<T: FromWasmAbi> Iterable for Generator<T> {
4907    type Item = T;
4908}
4909
4910// AsyncGenerator
4911#[wasm_bindgen]
4912extern "C" {
4913    #[wasm_bindgen(extends = Object, typescript_type = "AsyncGenerator<any, any, any>")]
4914    #[derive(Clone, Debug, PartialEq, Eq)]
4915    pub type AsyncGenerator<T = JsValue>;
4916
4917    /// The `next()` method returns an object with two properties done and value.
4918    /// You can also provide a parameter to the next method to send a value to the generator.
4919    ///
4920    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncGenerator/next)
4921    #[wasm_bindgen(method, catch)]
4922    pub fn next<T>(
4923        this: &AsyncGenerator<T>,
4924        value: &T,
4925    ) -> Result<Promise<IteratorNext<T>>, JsValue>;
4926
4927    /// The `return()` method returns the given value and finishes the generator.
4928    ///
4929    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncGenerator/return)
4930    #[wasm_bindgen(method, js_name = "return", catch)]
4931    pub fn return_<T>(
4932        this: &AsyncGenerator<T>,
4933        value: &T,
4934    ) -> Result<Promise<IteratorNext<T>>, JsValue>;
4935
4936    /// The `throw()` method resumes the execution of a generator by throwing an error into it
4937    /// and returns an object with two properties done and value.
4938    ///
4939    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncGenerator/throw)
4940    #[wasm_bindgen(method, catch)]
4941    pub fn throw<T>(
4942        this: &AsyncGenerator<T>,
4943        error: &JsValue,
4944    ) -> Result<Promise<IteratorNext<T>>, JsValue>;
4945}
4946
4947impl<T: FromWasmAbi> AsyncIterable for AsyncGenerator<T> {
4948    type Item = T;
4949}
4950
4951// Map
4952#[wasm_bindgen]
4953extern "C" {
4954    #[wasm_bindgen(extends = Object, typescript_type = "Map<any, any>")]
4955    #[derive(Clone, Debug, PartialEq, Eq)]
4956    pub type Map<K = JsValue, V = JsValue>;
4957
4958    /// The Map object holds key-value pairs. Any value (both objects and
4959    /// primitive values) maybe used as either a key or a value.
4960    ///
4961    /// **Note:** Consider using [`Map::new_typed`] for typing support.
4962    ///
4963    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
4964    #[cfg(not(js_sys_unstable_apis))]
4965    #[wasm_bindgen(constructor)]
4966    pub fn new() -> Map;
4967
4968    /// The Map object holds key-value pairs. Any value (both objects and
4969    /// primitive values) maybe used as either a key or a value.
4970    ///
4971    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
4972    #[cfg(js_sys_unstable_apis)]
4973    #[wasm_bindgen(constructor)]
4974    pub fn new<K, V>() -> Map<K, V>;
4975
4976    // Next major: deprecate
4977    /// The Map object holds key-value pairs. Any value (both objects and
4978    /// primitive values) maybe used as either a key or a value.
4979    ///
4980    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
4981    #[wasm_bindgen(constructor)]
4982    pub fn new_typed<K, V>() -> Map<K, V>;
4983
4984    /// The Map object holds key-value pairs. Any value (both objects and
4985    /// primitive values) maybe used as either a key or a value.
4986    ///
4987    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
4988    #[wasm_bindgen(constructor, js_name = new)]
4989    pub fn new_from_entries<K, V, I: Iterable<Item = ArrayTuple<(K, V)>>>(entries: &I)
4990        -> Map<K, V>;
4991
4992    /// The `clear()` method removes all elements from a Map object.
4993    ///
4994    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/clear)
4995    #[wasm_bindgen(method)]
4996    pub fn clear<K, V>(this: &Map<K, V>);
4997
4998    /// The `delete()` method removes the specified element from a Map object.
4999    ///
5000    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/delete)
5001    #[wasm_bindgen(method)]
5002    pub fn delete<K, V>(this: &Map<K, V>, key: &K) -> bool;
5003
5004    /// The `forEach()` method executes a provided function once per each
5005    /// key/value pair in the Map object, in insertion order.
5006    /// Note that in Javascript land the `Key` and `Value` are reversed compared to normal expectations:
5007    /// # Examples
5008    /// ```
5009    /// let js_map = Map::new();
5010    /// js_map.for_each(&mut |value, key| {
5011    ///     // Do something here...
5012    /// })
5013    /// ```
5014    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach)
5015    #[wasm_bindgen(method, js_name = forEach)]
5016    pub fn for_each<K, V>(this: &Map<K, V>, callback: &mut dyn FnMut(V, K));
5017
5018    /// The `forEach()` method executes a provided function once per each
5019    /// key/value pair in the Map object, in insertion order. _(Fallible variation)_
5020    /// Note that in Javascript land the `Key` and `Value` are reversed compared to normal expectations:
5021    /// # Examples
5022    /// ```
5023    /// let js_map = Map::new();
5024    /// js_map.for_each(&mut |value, key| {
5025    ///     // Do something here...
5026    /// })
5027    /// ```
5028    ///
5029    /// **Note:** Consider using [`Map::try_for_each`] if the callback might throw an error.
5030    ///
5031    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach)
5032    #[wasm_bindgen(method, js_name = forEach, catch)]
5033    pub fn try_for_each<K, V>(
5034        this: &Map<K, V>,
5035        callback: &mut dyn FnMut(V, K) -> Result<(), JsError>,
5036    ) -> Result<(), JsValue>;
5037
5038    /// The `get()` method returns a specified element from a Map object.
5039    /// Returns `undefined` if the key is not found.
5040    ///
5041    /// **Note:** Consider using [`Map::get_checked`] to get an `Option<V>` instead.
5042    ///
5043    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get)
5044    #[cfg(not(js_sys_unstable_apis))]
5045    #[wasm_bindgen(method)]
5046    pub fn get<K, V>(this: &Map<K, V>, key: &K) -> V;
5047
5048    /// The `get()` method returns a specified element from a Map object.
5049    /// Returns `None` if the key is not found.
5050    ///
5051    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get)
5052    #[cfg(js_sys_unstable_apis)]
5053    #[wasm_bindgen(method)]
5054    pub fn get<K, V>(this: &Map<K, V>, key: &K) -> Option<V>;
5055
5056    /// The `get()` method returns a specified element from a Map object.
5057    /// Returns `None` if the key is not found.
5058    ///
5059    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get)
5060    #[wasm_bindgen(method, js_name = get)]
5061    pub fn get_checked<K, V>(this: &Map<K, V>, key: &K) -> Option<V>;
5062
5063    /// The `has()` method returns a boolean indicating whether an element with
5064    /// the specified key exists or not.
5065    ///
5066    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has)
5067    #[wasm_bindgen(method)]
5068    pub fn has<K, V>(this: &Map<K, V>, key: &K) -> bool;
5069
5070    /// The `set()` method adds or updates an element with a specified key
5071    /// and value to a Map object.
5072    ///
5073    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/set)
5074    #[wasm_bindgen(method)]
5075    pub fn set<K, V>(this: &Map<K, V>, key: &K, value: &V) -> Map<K, V>;
5076
5077    /// The value of size is an integer representing how many entries
5078    /// the Map object has. A set accessor function for size is undefined;
5079    /// you can not change this property.
5080    ///
5081    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/size)
5082    #[wasm_bindgen(method, getter)]
5083    pub fn size<K, V>(this: &Map<K, V>) -> u32;
5084}
5085
5086impl Default for Map<JsValue, JsValue> {
5087    fn default() -> Self {
5088        Self::new()
5089    }
5090}
5091
5092// Map Iterator
5093#[wasm_bindgen]
5094extern "C" {
5095    /// The `entries()` method returns a new Iterator object that contains
5096    /// the [key, value] pairs for each element in the Map object in
5097    /// insertion order.
5098    ///
5099    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/entries)
5100    #[cfg(not(js_sys_unstable_apis))]
5101    #[wasm_bindgen(method)]
5102    pub fn entries<K, V: FromWasmAbi>(this: &Map<K, V>) -> Iterator;
5103
5104    /// The `entries()` method returns a new Iterator object that contains
5105    /// the [key, value] pairs for each element in the Map object in
5106    /// insertion order.
5107    ///
5108    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/entries)
5109    #[cfg(js_sys_unstable_apis)]
5110    #[wasm_bindgen(method, js_name = entries)]
5111    pub fn entries<K: JsGeneric, V: FromWasmAbi + JsGeneric>(
5112        this: &Map<K, V>,
5113    ) -> Iterator<ArrayTuple<(K, V)>>;
5114
5115    // Next major: deprecate
5116    /// The `entries()` method returns a new Iterator object that contains
5117    /// the [key, value] pairs for each element in the Map object in
5118    /// insertion order.
5119    ///
5120    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/entries)
5121    #[wasm_bindgen(method, js_name = entries)]
5122    pub fn entries_typed<K: JsGeneric, V: FromWasmAbi + JsGeneric>(
5123        this: &Map<K, V>,
5124    ) -> Iterator<ArrayTuple<(K, V)>>;
5125
5126    /// The `keys()` method returns a new Iterator object that contains the
5127    /// keys for each element in the Map object in insertion order.
5128    ///
5129    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/keys)
5130    #[wasm_bindgen(method)]
5131    pub fn keys<K: FromWasmAbi, V: FromWasmAbi>(this: &Map<K, V>) -> Iterator<K>;
5132
5133    /// The `values()` method returns a new Iterator object that contains the
5134    /// values for each element in the Map object in insertion order.
5135    ///
5136    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/values)
5137    #[wasm_bindgen(method)]
5138    pub fn values<K, V: FromWasmAbi>(this: &Map<K, V>) -> Iterator<V>;
5139}
5140
5141impl<K, V> Iterable for Map<K, V> {
5142    type Item = ArrayTuple<(K, V)>;
5143}
5144
5145// Iterator
5146#[wasm_bindgen]
5147extern "C" {
5148    /// Any object that conforms to the JS iterator protocol. For example,
5149    /// something returned by `myArray[Symbol.iterator]()`.
5150    ///
5151    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols)
5152    #[derive(Clone, Debug)]
5153    #[wasm_bindgen(is_type_of = Iterator::looks_like_iterator, typescript_type = "Iterator<any>")]
5154    pub type Iterator<T = JsValue>;
5155
5156    /// The `next()` method always has to return an object with appropriate
5157    /// properties including done and value. If a non-object value gets returned
5158    /// (such as false or undefined), a TypeError ("iterator.next() returned a
5159    /// non-object value") will be thrown.
5160    #[wasm_bindgen(catch, method)]
5161    pub fn next<T: FromWasmAbi>(this: &Iterator<T>) -> Result<IteratorNext<T>, JsValue>;
5162}
5163
5164impl<T> UpcastFrom<Iterator<T>> for Object {}
5165
5166impl Iterator {
5167    fn looks_like_iterator(it: &JsValue) -> bool {
5168        #[wasm_bindgen]
5169        extern "C" {
5170            type MaybeIterator;
5171
5172            #[wasm_bindgen(method, getter)]
5173            fn next(this: &MaybeIterator) -> JsValue;
5174        }
5175
5176        if !it.is_object() {
5177            return false;
5178        }
5179
5180        let it = it.unchecked_ref::<MaybeIterator>();
5181
5182        it.next().is_function()
5183    }
5184}
5185
5186// iterators in JS are themselves iterable
5187impl<T> Iterable for Iterator<T> {
5188    type Item = T;
5189}
5190
5191// Async Iterator
5192#[wasm_bindgen]
5193extern "C" {
5194    /// Any object that conforms to the JS async iterator protocol. For example,
5195    /// something returned by `myObject[Symbol.asyncIterator]()`.
5196    ///
5197    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of)
5198    #[derive(Clone, Debug)]
5199    #[wasm_bindgen(is_type_of = Iterator::looks_like_iterator, typescript_type = "AsyncIterator<any>")]
5200    pub type AsyncIterator<T = JsValue>;
5201
5202    /// The `next()` method always has to return a Promise which resolves to an object
5203    /// with appropriate properties including done and value. If a non-object value
5204    /// gets returned (such as false or undefined), a TypeError ("iterator.next()
5205    /// returned a non-object value") will be thrown.
5206    #[cfg(not(js_sys_unstable_apis))]
5207    #[wasm_bindgen(catch, method)]
5208    pub fn next<T>(this: &AsyncIterator<T>) -> Result<Promise, JsValue>;
5209
5210    /// The `next()` method always has to return a Promise which resolves to an object
5211    /// with appropriate properties including done and value. If a non-object value
5212    /// gets returned (such as false or undefined), a TypeError ("iterator.next()
5213    /// returned a non-object value") will be thrown.
5214    #[cfg(js_sys_unstable_apis)]
5215    #[wasm_bindgen(catch, method, js_name = next)]
5216    pub fn next<T: FromWasmAbi>(
5217        this: &AsyncIterator<T>,
5218    ) -> Result<Promise<IteratorNext<T>>, JsValue>;
5219
5220    // Next major: deprecate
5221    /// The `next()` method always has to return a Promise which resolves to an object
5222    /// with appropriate properties including done and value. If a non-object value
5223    /// gets returned (such as false or undefined), a TypeError ("iterator.next()
5224    /// returned a non-object value") will be thrown.
5225    #[wasm_bindgen(catch, method, js_name = next)]
5226    pub fn next_iterator<T: FromWasmAbi>(
5227        this: &AsyncIterator<T>,
5228    ) -> Result<Promise<IteratorNext<T>>, JsValue>;
5229}
5230
5231impl<T> UpcastFrom<AsyncIterator<T>> for Object {}
5232
5233// iterators in JS are themselves iterable
5234impl<T> AsyncIterable for AsyncIterator<T> {
5235    type Item = T;
5236}
5237
5238/// An iterator over the JS `Symbol.iterator` iteration protocol.
5239///
5240/// Use the `IntoIterator for &js_sys::Iterator` implementation to create this.
5241pub struct Iter<'a, T = JsValue> {
5242    js: &'a Iterator<T>,
5243    state: IterState,
5244}
5245
5246/// An iterator over the JS `Symbol.iterator` iteration protocol.
5247///
5248/// Use the `IntoIterator for js_sys::Iterator` implementation to create this.
5249pub struct IntoIter<T = JsValue> {
5250    js: Iterator<T>,
5251    state: IterState,
5252}
5253
5254struct IterState {
5255    done: bool,
5256}
5257
5258impl<'a, T: FromWasmAbi + JsGeneric> IntoIterator for &'a Iterator<T> {
5259    type Item = Result<T, JsValue>;
5260    type IntoIter = Iter<'a, T>;
5261
5262    fn into_iter(self) -> Iter<'a, T> {
5263        Iter {
5264            js: self,
5265            state: IterState::new(),
5266        }
5267    }
5268}
5269
5270impl<T: FromWasmAbi + JsGeneric> core::iter::Iterator for Iter<'_, T> {
5271    type Item = Result<T, JsValue>;
5272
5273    fn next(&mut self) -> Option<Self::Item> {
5274        self.state.next(self.js)
5275    }
5276}
5277
5278impl<T: FromWasmAbi + JsGeneric> IntoIterator for Iterator<T> {
5279    type Item = Result<T, JsValue>;
5280    type IntoIter = IntoIter<T>;
5281
5282    fn into_iter(self) -> IntoIter<T> {
5283        IntoIter {
5284            js: self,
5285            state: IterState::new(),
5286        }
5287    }
5288}
5289
5290impl<T: FromWasmAbi + JsGeneric> core::iter::Iterator for IntoIter<T> {
5291    type Item = Result<T, JsValue>;
5292
5293    fn next(&mut self) -> Option<Self::Item> {
5294        self.state.next(&self.js)
5295    }
5296}
5297
5298impl IterState {
5299    fn new() -> IterState {
5300        IterState { done: false }
5301    }
5302
5303    fn next<T: FromWasmAbi + JsGeneric>(&mut self, js: &Iterator<T>) -> Option<Result<T, JsValue>> {
5304        if self.done {
5305            return None;
5306        }
5307        let next = match js.next() {
5308            Ok(val) => val,
5309            Err(e) => {
5310                self.done = true;
5311                return Some(Err(e));
5312            }
5313        };
5314        if next.done() {
5315            self.done = true;
5316            None
5317        } else {
5318            Some(Ok(next.value()))
5319        }
5320    }
5321}
5322
5323/// Create an iterator over `val` using the JS iteration protocol and
5324/// `Symbol.iterator`.
5325// #[cfg(not(js_sys_unstable_apis))]
5326pub fn try_iter(val: &JsValue) -> Result<Option<IntoIter<JsValue>>, JsValue> {
5327    let iter_sym = Symbol::iterator();
5328
5329    let iter_fn = Reflect::get_symbol::<Object>(val.unchecked_ref(), iter_sym.as_ref())?;
5330    let iter_fn: Function = match iter_fn.dyn_into() {
5331        Ok(iter_fn) => iter_fn,
5332        Err(_) => return Ok(None),
5333    };
5334
5335    let it: Iterator = match iter_fn.call0(val)?.dyn_into() {
5336        Ok(it) => it,
5337        Err(_) => return Ok(None),
5338    };
5339
5340    Ok(Some(it.into_iter()))
5341}
5342
5343/// Trait for JavaScript types that implement the iterable protocol via `Symbol.iterator`.
5344///
5345/// Types implementing this trait can be iterated over using JavaScript's iteration
5346/// protocol. The `Item` associated type specifies the type of values yielded.
5347///
5348/// ## Built-in Iterables
5349///
5350/// Many `js-sys` collection types implement `Iterable` out of the box:
5351///
5352/// ```ignore
5353/// use js_sys::{Array, Map, Set};
5354///
5355/// // Array<T> yields T
5356/// let arr: Array<Number> = get_numbers();
5357/// for value in arr.iter() {
5358///     let num: Number = value?;
5359/// }
5360///
5361/// // Map<K, V> yields Array (key-value pairs)
5362/// let map: Map<JsString, Number> = get_map();
5363/// for entry in map.iter() {
5364///     let pair: Array = entry?;
5365/// }
5366///
5367/// // Set<T> yields T
5368/// let set: Set<JsString> = get_set();
5369/// for value in set.iter() {
5370///     let s: JsString = value?;
5371/// }
5372/// ```
5373///
5374/// ## Typing Foreign Iterators
5375///
5376/// If you have a JavaScript value that implements the iterator protocol (has a `next()`
5377/// method) but isn't a built-in type, you can use [`JsCast`] to cast it to [`Iterator<T>`]:
5378///
5379/// ```ignore
5380/// use js_sys::Iterator;
5381/// use wasm_bindgen::JsCast;
5382///
5383/// // For a value you know implements the iterator protocol
5384/// fn process_iterator(js_iter: JsValue) {
5385///     // Checked cast - returns None if not an iterator
5386///     if let Some(iter) = js_iter.dyn_ref::<Iterator<Number>>() {
5387///         for value in iter.into_iter() {
5388///             let num: Number = value.unwrap();
5389///             // ...
5390///         }
5391///     }
5392/// }
5393///
5394/// // Or with unchecked cast when you're certain of the type
5395/// fn process_known_iterator(js_iter: JsValue) {
5396///     let iter: &Iterator<JsString> = js_iter.unchecked_ref();
5397///     for value in iter.into_iter() {
5398///         let s: JsString = value.unwrap();
5399///         // ...
5400///     }
5401/// }
5402/// ```
5403///
5404/// ## Using with `JsValue`
5405///
5406/// For dynamic or unknown iterables, use [`try_iter`] which returns an untyped iterator:
5407///
5408/// ```ignore
5409/// fn iterate_unknown(val: &JsValue) -> Result<(), JsValue> {
5410///     if let Some(iter) = js_sys::try_iter(val)? {
5411///         for item in iter {
5412///             let value: JsValue = item?;
5413///             // Handle dynamically...
5414///         }
5415///     }
5416///     Ok(())
5417/// }
5418/// ```
5419///
5420/// [`JsCast`]: wasm_bindgen::JsCast
5421/// [`Iterator<T>`]: Iterator
5422/// [`try_iter`]: crate::try_iter
5423pub trait Iterable {
5424    /// The type of values yielded by this iterable.
5425    type Item;
5426}
5427
5428impl<T: Iterable> Iterable for &T {
5429    type Item = T::Item;
5430}
5431
5432/// Trait for types known to implement the iterator protocol on Symbol.asyncIterator
5433pub trait AsyncIterable {
5434    type Item;
5435}
5436
5437impl<T: AsyncIterable> AsyncIterable for &T {
5438    type Item = T::Item;
5439}
5440
5441impl AsyncIterable for JsValue {
5442    type Item = JsValue;
5443}
5444
5445// IteratorNext
5446#[wasm_bindgen]
5447extern "C" {
5448    /// The result of calling `next()` on a JS iterator.
5449    ///
5450    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols)
5451    #[wasm_bindgen(extends = Object, typescript_type = "IteratorResult<any>")]
5452    #[derive(Clone, Debug, PartialEq, Eq)]
5453    pub type IteratorNext<T = JsValue>;
5454
5455    /// Has the value `true` if the iterator is past the end of the iterated
5456    /// sequence. In this case value optionally specifies the return value of
5457    /// the iterator.
5458    ///
5459    /// Has the value `false` if the iterator was able to produce the next value
5460    /// in the sequence. This is equivalent of not specifying the done property
5461    /// altogether.
5462    #[wasm_bindgen(method, getter)]
5463    pub fn done<T>(this: &IteratorNext<T>) -> bool;
5464
5465    /// Any JavaScript value returned by the iterator. Can be omitted when done
5466    /// is true.
5467    #[wasm_bindgen(method, getter)]
5468    pub fn value<T>(this: &IteratorNext<T>) -> T;
5469}
5470
5471#[allow(non_snake_case)]
5472pub mod Math {
5473    use super::*;
5474
5475    // Math
5476    #[wasm_bindgen]
5477    extern "C" {
5478        /// The `Math.abs()` function returns the absolute value of a number, that is
5479        /// Math.abs(x) = |x|
5480        ///
5481        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs)
5482        #[wasm_bindgen(js_namespace = Math)]
5483        pub fn abs(x: f64) -> f64;
5484
5485        /// The `Math.acos()` function returns the arccosine (in radians) of a
5486        /// number, that is ∀x∊[-1;1]
5487        /// Math.acos(x) = arccos(x) = the unique y∊[0;π] such that cos(y)=x
5488        ///
5489        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acos)
5490        #[wasm_bindgen(js_namespace = Math)]
5491        pub fn acos(x: f64) -> f64;
5492
5493        /// The `Math.acosh()` function returns the hyperbolic arc-cosine of a
5494        /// number, that is ∀x ≥ 1
5495        /// Math.acosh(x) = arcosh(x) = the unique y ≥ 0 such that cosh(y) = x
5496        ///
5497        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acosh)
5498        #[wasm_bindgen(js_namespace = Math)]
5499        pub fn acosh(x: f64) -> f64;
5500
5501        /// The `Math.asin()` function returns the arcsine (in radians) of a
5502        /// number, that is ∀x ∊ [-1;1]
5503        /// Math.asin(x) = arcsin(x) = the unique y∊[-π2;π2] such that sin(y) = x
5504        ///
5505        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asin)
5506        #[wasm_bindgen(js_namespace = Math)]
5507        pub fn asin(x: f64) -> f64;
5508
5509        /// The `Math.asinh()` function returns the hyperbolic arcsine of a
5510        /// number, that is Math.asinh(x) = arsinh(x) = the unique y such that sinh(y) = x
5511        ///
5512        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asinh)
5513        #[wasm_bindgen(js_namespace = Math)]
5514        pub fn asinh(x: f64) -> f64;
5515
5516        /// The `Math.atan()` function returns the arctangent (in radians) of a
5517        /// number, that is Math.atan(x) = arctan(x) = the unique y ∊ [-π2;π2]such that
5518        /// tan(y) = x
5519        #[wasm_bindgen(js_namespace = Math)]
5520        pub fn atan(x: f64) -> f64;
5521
5522        /// The `Math.atan2()` function returns the arctangent of the quotient of
5523        /// its arguments.
5524        ///
5525        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan2)
5526        #[wasm_bindgen(js_namespace = Math)]
5527        pub fn atan2(y: f64, x: f64) -> f64;
5528
5529        /// The `Math.atanh()` function returns the hyperbolic arctangent of a number,
5530        /// that is ∀x ∊ (-1,1), Math.atanh(x) = arctanh(x) = the unique y such that
5531        /// tanh(y) = x
5532        ///
5533        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atanh)
5534        #[wasm_bindgen(js_namespace = Math)]
5535        pub fn atanh(x: f64) -> f64;
5536
5537        /// The `Math.cbrt() `function returns the cube root of a number, that is
5538        /// Math.cbrt(x) = ∛x = the unique y such that y^3 = x
5539        ///
5540        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt)
5541        #[wasm_bindgen(js_namespace = Math)]
5542        pub fn cbrt(x: f64) -> f64;
5543
5544        /// The `Math.ceil()` function returns the smallest integer greater than
5545        /// or equal to a given number.
5546        ///
5547        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil)
5548        #[wasm_bindgen(js_namespace = Math)]
5549        pub fn ceil(x: f64) -> f64;
5550
5551        /// The `Math.clz32()` function returns the number of leading zero bits in
5552        /// the 32-bit binary representation of a number.
5553        ///
5554        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32)
5555        #[wasm_bindgen(js_namespace = Math)]
5556        pub fn clz32(x: i32) -> u32;
5557
5558        /// The `Math.cos()` static function returns the cosine of the specified angle,
5559        /// which must be specified in radians. This value is length(adjacent)/length(hypotenuse).
5560        ///
5561        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cos)
5562        #[wasm_bindgen(js_namespace = Math)]
5563        pub fn cos(x: f64) -> f64;
5564
5565        /// The `Math.cosh()` function returns the hyperbolic cosine of a number,
5566        /// that can be expressed using the constant e.
5567        ///
5568        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cosh)
5569        #[wasm_bindgen(js_namespace = Math)]
5570        pub fn cosh(x: f64) -> f64;
5571
5572        /// The `Math.exp()` function returns e^x, where x is the argument, and e is Euler's number
5573        /// (also known as Napier's constant), the base of the natural logarithms.
5574        ///
5575        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/exp)
5576        #[wasm_bindgen(js_namespace = Math)]
5577        pub fn exp(x: f64) -> f64;
5578
5579        /// The `Math.expm1()` function returns e^x - 1, where x is the argument, and e the base of the
5580        /// natural logarithms.
5581        ///
5582        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/expm1)
5583        #[wasm_bindgen(js_namespace = Math)]
5584        pub fn expm1(x: f64) -> f64;
5585
5586        /// The `Math.floor()` function returns the largest integer less than or
5587        /// equal to a given number.
5588        ///
5589        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor)
5590        #[wasm_bindgen(js_namespace = Math)]
5591        pub fn floor(x: f64) -> f64;
5592
5593        /// The `Math.fround()` function returns the nearest 32-bit single precision float representation
5594        /// of a Number.
5595        ///
5596        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround)
5597        #[wasm_bindgen(js_namespace = Math)]
5598        pub fn fround(x: f64) -> f32;
5599
5600        /// The `Math.hypot()` function returns the square root of the sum of squares of its arguments.
5601        ///
5602        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot)
5603        #[wasm_bindgen(js_namespace = Math)]
5604        pub fn hypot(x: f64, y: f64) -> f64;
5605
5606        /// The `Math.imul()` function returns the result of the C-like 32-bit multiplication of the
5607        /// two parameters.
5608        ///
5609        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul)
5610        #[wasm_bindgen(js_namespace = Math)]
5611        pub fn imul(x: i32, y: i32) -> i32;
5612
5613        /// The `Math.log()` function returns the natural logarithm (base e) of a number.
5614        /// The JavaScript `Math.log()` function is equivalent to ln(x) in mathematics.
5615        ///
5616        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log)
5617        #[wasm_bindgen(js_namespace = Math)]
5618        pub fn log(x: f64) -> f64;
5619
5620        /// The `Math.log10()` function returns the base 10 logarithm of a number.
5621        ///
5622        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log10)
5623        #[wasm_bindgen(js_namespace = Math)]
5624        pub fn log10(x: f64) -> f64;
5625
5626        /// The `Math.log1p()` function returns the natural logarithm (base e) of 1 + a number.
5627        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log1p)
5628        #[wasm_bindgen(js_namespace = Math)]
5629        pub fn log1p(x: f64) -> f64;
5630
5631        /// The `Math.log2()` function returns the base 2 logarithm of a number.
5632        ///
5633        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log2)
5634        #[wasm_bindgen(js_namespace = Math)]
5635        pub fn log2(x: f64) -> f64;
5636
5637        /// The `Math.max()` function returns the largest of two numbers.
5638        ///
5639        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max)
5640        #[wasm_bindgen(js_namespace = Math)]
5641        pub fn max(x: f64, y: f64) -> f64;
5642
5643        /// The static function `Math.min()` returns the lowest-valued number passed into it.
5644        ///
5645        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min)
5646        #[wasm_bindgen(js_namespace = Math)]
5647        pub fn min(x: f64, y: f64) -> f64;
5648
5649        /// The `Math.pow()` function returns the base to the exponent power, that is, base^exponent.
5650        ///
5651        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow)
5652        #[wasm_bindgen(js_namespace = Math)]
5653        pub fn pow(base: f64, exponent: f64) -> f64;
5654
5655        /// The `Math.random()` function returns a floating-point, pseudo-random number
5656        /// in the range 0–1 (inclusive of 0, but not 1) with approximately uniform distribution
5657        /// over that range — which you can then scale to your desired range.
5658        /// The implementation selects the initial seed to the random number generation algorithm;
5659        /// it cannot be chosen or reset by the user.
5660        ///
5661        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random)
5662        #[wasm_bindgen(js_namespace = Math)]
5663        pub fn random() -> f64;
5664
5665        /// The `Math.round()` function returns the value of a number rounded to the nearest integer.
5666        ///
5667        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round)
5668        #[wasm_bindgen(js_namespace = Math)]
5669        pub fn round(x: f64) -> f64;
5670
5671        /// The `Math.sign()` function returns the sign of a number, indicating whether the number is
5672        /// positive, negative or zero.
5673        ///
5674        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign)
5675        #[wasm_bindgen(js_namespace = Math)]
5676        pub fn sign(x: f64) -> f64;
5677
5678        /// The `Math.sin()` function returns the sine of a number.
5679        ///
5680        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sin)
5681        #[wasm_bindgen(js_namespace = Math)]
5682        pub fn sin(x: f64) -> f64;
5683
5684        /// The `Math.sinh()` function returns the hyperbolic sine of a number, that can be expressed
5685        /// using the constant e: Math.sinh(x) = (e^x - e^-x)/2
5686        ///
5687        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sinh)
5688        #[wasm_bindgen(js_namespace = Math)]
5689        pub fn sinh(x: f64) -> f64;
5690
5691        /// The `Math.sqrt()` function returns the square root of a number, that is
5692        /// ∀x ≥ 0, Math.sqrt(x) = √x = the unique y ≥ 0 such that y^2 = x
5693        ///
5694        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sqrt)
5695        #[wasm_bindgen(js_namespace = Math)]
5696        pub fn sqrt(x: f64) -> f64;
5697
5698        /// The `Math.tan()` function returns the tangent of a number.
5699        ///
5700        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tan)
5701        #[wasm_bindgen(js_namespace = Math)]
5702        pub fn tan(x: f64) -> f64;
5703
5704        /// The `Math.tanh()` function returns the hyperbolic tangent of a number, that is
5705        /// tanh x = sinh x / cosh x = (e^x - e^-x)/(e^x + e^-x) = (e^2x - 1)/(e^2x + 1)
5706        ///
5707        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tanh)
5708        #[wasm_bindgen(js_namespace = Math)]
5709        pub fn tanh(x: f64) -> f64;
5710
5711        /// The `Math.trunc()` function returns the integer part of a number by removing any fractional
5712        /// digits.
5713        ///
5714        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc)
5715        #[wasm_bindgen(js_namespace = Math)]
5716        pub fn trunc(x: f64) -> f64;
5717
5718        /// The `Math.PI` property represents the ratio of the circumference of a circle to its diameter,
5719        /// approximately 3.14159.
5720        ///
5721        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/PI)
5722        #[wasm_bindgen(thread_local_v2, js_namespace = Math)]
5723        pub static PI: f64;
5724    }
5725}
5726
5727// Number.
5728#[wasm_bindgen]
5729extern "C" {
5730    #[wasm_bindgen(extends = Object, is_type_of = |v| v.as_f64().is_some(), typescript_type = "number")]
5731    #[derive(Clone, PartialEq)]
5732    pub type Number;
5733
5734    /// The `Number.isFinite()` method determines whether the passed value is a finite number.
5735    ///
5736    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite)
5737    #[wasm_bindgen(static_method_of = Number, js_name = isFinite)]
5738    pub fn is_finite(value: &JsValue) -> bool;
5739
5740    /// The `Number.isInteger()` method determines whether the passed value is an integer.
5741    ///
5742    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger)
5743    #[wasm_bindgen(static_method_of = Number, js_name = isInteger)]
5744    pub fn is_integer(value: &JsValue) -> bool;
5745
5746    /// The `Number.isNaN()` method determines whether the passed value is `NaN` and its type is Number.
5747    /// It is a more robust version of the original, global isNaN().
5748    ///
5749    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN)
5750    #[wasm_bindgen(static_method_of = Number, js_name = isNaN)]
5751    pub fn is_nan(value: &JsValue) -> bool;
5752
5753    /// The `Number.isSafeInteger()` method determines whether the provided value is a number
5754    /// that is a safe integer.
5755    ///
5756    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger)
5757    #[wasm_bindgen(static_method_of = Number, js_name = isSafeInteger)]
5758    pub fn is_safe_integer(value: &JsValue) -> bool;
5759
5760    /// The `Number` JavaScript object is a wrapper object allowing
5761    /// you to work with numerical values. A `Number` object is
5762    /// created using the `Number()` constructor.
5763    ///
5764    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)
5765    #[cfg(not(js_sys_unstable_apis))]
5766    #[wasm_bindgen(constructor)]
5767    #[deprecated(note = "recommended to use `Number::from` instead")]
5768    #[allow(deprecated)]
5769    pub fn new(value: &JsValue) -> Number;
5770
5771    #[wasm_bindgen(constructor)]
5772    fn new_from_str(value: &str) -> Number;
5773
5774    /// The `Number.parseInt()` method parses a string argument and returns an
5775    /// integer of the specified radix or base.
5776    ///
5777    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseInt)
5778    #[wasm_bindgen(static_method_of = Number, js_name = parseInt)]
5779    pub fn parse_int(text: &str, radix: u8) -> f64;
5780
5781    /// The `Number.parseFloat()` method parses a string argument and returns a
5782    /// floating point number.
5783    ///
5784    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseFloat)
5785    #[wasm_bindgen(static_method_of = Number, js_name = parseFloat)]
5786    pub fn parse_float(text: &str) -> f64;
5787
5788    /// The `toLocaleString()` method returns a string with a language sensitive
5789    /// representation of this number.
5790    ///
5791    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString)
5792    #[cfg(not(js_sys_unstable_apis))]
5793    #[wasm_bindgen(method, js_name = toLocaleString)]
5794    pub fn to_locale_string(this: &Number, locale: &str) -> JsString;
5795
5796    /// The `toLocaleString()` method returns a string with a language sensitive
5797    /// representation of this number.
5798    ///
5799    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString)
5800    #[cfg(js_sys_unstable_apis)]
5801    #[wasm_bindgen(method, js_name = toLocaleString)]
5802    pub fn to_locale_string(
5803        this: &Number,
5804        locales: &[JsString],
5805        options: &Intl::NumberFormatOptions,
5806    ) -> JsString;
5807
5808    /// The `toPrecision()` method returns a string representing the Number
5809    /// object to the specified precision.
5810    ///
5811    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision)
5812    #[wasm_bindgen(catch, method, js_name = toPrecision)]
5813    pub fn to_precision(this: &Number, precision: u8) -> Result<JsString, JsValue>;
5814
5815    /// The `toFixed()` method returns a string representing the Number
5816    /// object using fixed-point notation.
5817    ///
5818    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed)
5819    #[wasm_bindgen(catch, method, js_name = toFixed)]
5820    pub fn to_fixed(this: &Number, digits: u8) -> Result<JsString, JsValue>;
5821
5822    /// The `toExponential()` method returns a string representing the Number
5823    /// object in exponential notation.
5824    ///
5825    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential)
5826    #[wasm_bindgen(catch, method, js_name = toExponential)]
5827    pub fn to_exponential(this: &Number, fraction_digits: u8) -> Result<JsString, JsValue>;
5828
5829    /// The `toString()` method returns a string representing the
5830    /// specified Number object.
5831    ///
5832    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString)
5833    #[cfg(not(js_sys_unstable_apis))]
5834    #[deprecated(note = "Use `Number::to_string_with_radix` instead.")]
5835    #[allow(deprecated)]
5836    #[wasm_bindgen(catch, method, js_name = toString)]
5837    pub fn to_string(this: &Number, radix: u8) -> Result<JsString, JsValue>;
5838
5839    /// The `toString()` method returns a string representing the
5840    /// specified Number object.
5841    ///
5842    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString)
5843    #[wasm_bindgen(catch, method, js_name = toString)]
5844    pub fn to_string_with_radix(this: &Number, radix: u8) -> Result<JsString, JsValue>;
5845
5846    /// The `valueOf()` method returns the wrapped primitive value of
5847    /// a Number object.
5848    ///
5849    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/valueOf)
5850    #[wasm_bindgen(method, js_name = valueOf)]
5851    pub fn value_of(this: &Number) -> f64;
5852}
5853
5854impl Number {
5855    /// The smallest interval between two representable numbers.
5856    ///
5857    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON)
5858    pub const EPSILON: f64 = f64::EPSILON;
5859    /// The maximum safe integer in JavaScript (2^53 - 1).
5860    ///
5861    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)
5862    pub const MAX_SAFE_INTEGER: f64 = 9007199254740991.0;
5863    /// The largest positive representable number.
5864    ///
5865    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE)
5866    pub const MAX_VALUE: f64 = f64::MAX;
5867    /// The minimum safe integer in JavaScript (-(2^53 - 1)).
5868    ///
5869    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER)
5870    pub const MIN_SAFE_INTEGER: f64 = -9007199254740991.0;
5871    /// The smallest positive representable number—that is, the positive number closest to zero
5872    /// (without actually being zero).
5873    ///
5874    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_VALUE)
5875    // Cannot use f64::MIN_POSITIVE since that is the smallest **normal** positive number.
5876    pub const MIN_VALUE: f64 = 5E-324;
5877    /// Special "Not a Number" value.
5878    ///
5879    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NaN)
5880    pub const NAN: f64 = f64::NAN;
5881    /// Special value representing negative infinity. Returned on overflow.
5882    ///
5883    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY)
5884    pub const NEGATIVE_INFINITY: f64 = f64::NEG_INFINITY;
5885    /// Special value representing infinity. Returned on overflow.
5886    ///
5887    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY)
5888    pub const POSITIVE_INFINITY: f64 = f64::INFINITY;
5889
5890    /// Applies the binary `**` JS operator on the two `Number`s.
5891    ///
5892    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Exponentiation)
5893    #[inline]
5894    pub fn pow(&self, rhs: &Self) -> Self {
5895        JsValue::as_ref(self)
5896            .pow(JsValue::as_ref(rhs))
5897            .unchecked_into()
5898    }
5899
5900    /// Applies the binary `>>>` JS operator on the two `Number`s.
5901    ///
5902    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Unsigned_right_shift)
5903    #[inline]
5904    pub fn unsigned_shr(&self, rhs: &Self) -> Self {
5905        Number::from(JsValue::as_ref(self).unsigned_shr(JsValue::as_ref(rhs)))
5906    }
5907}
5908
5909macro_rules! number_from {
5910    ($($x:ident)*) => ($(
5911        impl From<$x> for Number {
5912            #[inline]
5913            fn from(x: $x) -> Number {
5914                Number::unchecked_from_js(JsValue::from(x))
5915            }
5916        }
5917
5918        impl PartialEq<$x> for Number {
5919            #[inline]
5920            fn eq(&self, other: &$x) -> bool {
5921                self.value_of() == f64::from(*other)
5922            }
5923        }
5924
5925        impl UpcastFrom<$x> for Number {}
5926    )*)
5927}
5928number_from!(i8 u8 i16 u16 i32 u32 f32 f64);
5929
5930// The only guarantee for a JS number
5931impl UpcastFrom<Number> for f64 {}
5932
5933/// The error type returned when a checked integral type conversion fails.
5934#[derive(Debug, Copy, Clone, PartialEq, Eq)]
5935pub struct TryFromIntError(());
5936
5937impl fmt::Display for TryFromIntError {
5938    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
5939        fmt.write_str("out of range integral type conversion attempted")
5940    }
5941}
5942
5943#[cfg(feature = "std")]
5944impl std::error::Error for TryFromIntError {}
5945
5946macro_rules! number_try_from {
5947    ($($x:ident)*) => ($(
5948        impl TryFrom<$x> for Number {
5949            type Error = TryFromIntError;
5950
5951            #[inline]
5952            fn try_from(x: $x) -> Result<Number, Self::Error> {
5953                let x_f64 = x as f64;
5954                if (Number::MIN_SAFE_INTEGER..=Number::MAX_SAFE_INTEGER).contains(&x_f64) {
5955                    Ok(Number::from(x_f64))
5956                } else {
5957                    Err(TryFromIntError(()))
5958                }
5959            }
5960        }
5961    )*)
5962}
5963number_try_from!(i64 u64 i128 u128);
5964
5965impl From<&Number> for f64 {
5966    #[inline]
5967    fn from(n: &Number) -> f64 {
5968        n.value_of()
5969    }
5970}
5971
5972impl From<Number> for f64 {
5973    #[inline]
5974    fn from(n: Number) -> f64 {
5975        <f64 as From<&'_ Number>>::from(&n)
5976    }
5977}
5978
5979impl fmt::Debug for Number {
5980    #[inline]
5981    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
5982        fmt::Debug::fmt(&self.value_of(), f)
5983    }
5984}
5985
5986impl fmt::Display for Number {
5987    #[inline]
5988    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
5989        fmt::Display::fmt(&self.value_of(), f)
5990    }
5991}
5992
5993impl Default for Number {
5994    fn default() -> Self {
5995        Self::from(f64::default())
5996    }
5997}
5998
5999impl PartialEq<BigInt> for Number {
6000    #[inline]
6001    fn eq(&self, other: &BigInt) -> bool {
6002        JsValue::as_ref(self).loose_eq(JsValue::as_ref(other))
6003    }
6004}
6005
6006impl Not for &Number {
6007    type Output = BigInt;
6008
6009    #[inline]
6010    fn not(self) -> Self::Output {
6011        JsValue::as_ref(self).bit_not().unchecked_into()
6012    }
6013}
6014
6015forward_deref_unop!(impl Not, not for Number);
6016forward_js_unop!(impl Neg, neg for Number);
6017forward_js_binop!(impl BitAnd, bitand for Number);
6018forward_js_binop!(impl BitOr, bitor for Number);
6019forward_js_binop!(impl BitXor, bitxor for Number);
6020forward_js_binop!(impl Shl, shl for Number);
6021forward_js_binop!(impl Shr, shr for Number);
6022forward_js_binop!(impl Add, add for Number);
6023forward_js_binop!(impl Sub, sub for Number);
6024forward_js_binop!(impl Div, div for Number);
6025forward_js_binop!(impl Mul, mul for Number);
6026forward_js_binop!(impl Rem, rem for Number);
6027
6028sum_product!(Number);
6029
6030impl PartialOrd for Number {
6031    #[inline]
6032    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
6033        if Number::is_nan(self) || Number::is_nan(other) {
6034            None
6035        } else if self == other {
6036            Some(Ordering::Equal)
6037        } else if self.lt(other) {
6038            Some(Ordering::Less)
6039        } else {
6040            Some(Ordering::Greater)
6041        }
6042    }
6043
6044    #[inline]
6045    fn lt(&self, other: &Self) -> bool {
6046        JsValue::as_ref(self).lt(JsValue::as_ref(other))
6047    }
6048
6049    #[inline]
6050    fn le(&self, other: &Self) -> bool {
6051        JsValue::as_ref(self).le(JsValue::as_ref(other))
6052    }
6053
6054    #[inline]
6055    fn ge(&self, other: &Self) -> bool {
6056        JsValue::as_ref(self).ge(JsValue::as_ref(other))
6057    }
6058
6059    #[inline]
6060    fn gt(&self, other: &Self) -> bool {
6061        JsValue::as_ref(self).gt(JsValue::as_ref(other))
6062    }
6063}
6064
6065#[cfg(not(js_sys_unstable_apis))]
6066impl FromStr for Number {
6067    type Err = Infallible;
6068
6069    #[allow(deprecated)]
6070    #[inline]
6071    fn from_str(s: &str) -> Result<Self, Self::Err> {
6072        Ok(Number::new_from_str(s))
6073    }
6074}
6075
6076// Date.
6077#[wasm_bindgen]
6078extern "C" {
6079    #[wasm_bindgen(extends = Object, typescript_type = "Date")]
6080    #[derive(Clone, Debug, PartialEq, Eq)]
6081    pub type Date;
6082
6083    /// The `getDate()` method returns the day of the month for the
6084    /// specified date according to local time.
6085    ///
6086    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDate)
6087    #[wasm_bindgen(method, js_name = getDate)]
6088    pub fn get_date(this: &Date) -> u32;
6089
6090    /// The `getDay()` method returns the day of the week for the specified date according to local time,
6091    /// where 0 represents Sunday. For the day of the month see getDate().
6092    ///
6093    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay)
6094    #[wasm_bindgen(method, js_name = getDay)]
6095    pub fn get_day(this: &Date) -> u32;
6096
6097    /// The `getFullYear()` method returns the year of the specified date according to local time.
6098    ///
6099    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getFullYear)
6100    #[wasm_bindgen(method, js_name = getFullYear)]
6101    pub fn get_full_year(this: &Date) -> u32;
6102
6103    /// The `getHours()` method returns the hour for the specified date, according to local time.
6104    ///
6105    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getHours)
6106    #[wasm_bindgen(method, js_name = getHours)]
6107    pub fn get_hours(this: &Date) -> u32;
6108
6109    /// The `getMilliseconds()` method returns the milliseconds in the specified date according to local time.
6110    ///
6111    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMilliseconds)
6112    #[wasm_bindgen(method, js_name = getMilliseconds)]
6113    pub fn get_milliseconds(this: &Date) -> u32;
6114
6115    /// The `getMinutes()` method returns the minutes in the specified date according to local time.
6116    ///
6117    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMinutes)
6118    #[wasm_bindgen(method, js_name = getMinutes)]
6119    pub fn get_minutes(this: &Date) -> u32;
6120
6121    /// The `getMonth()` method returns the month in the specified date according to local time,
6122    /// as a zero-based value (where zero indicates the first month of the year).
6123    ///
6124    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMonth)
6125    #[wasm_bindgen(method, js_name = getMonth)]
6126    pub fn get_month(this: &Date) -> u32;
6127
6128    /// The `getSeconds()` method returns the seconds in the specified date according to local time.
6129    ///
6130    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getSeconds)
6131    #[wasm_bindgen(method, js_name = getSeconds)]
6132    pub fn get_seconds(this: &Date) -> u32;
6133
6134    /// The `getTime()` method returns the numeric value corresponding to the time for the specified date
6135    /// according to universal time.
6136    ///
6137    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime)
6138    #[wasm_bindgen(method, js_name = getTime)]
6139    pub fn get_time(this: &Date) -> f64;
6140
6141    /// The `getTimezoneOffset()` method returns the time zone difference, in minutes,
6142    /// from current locale (host system settings) to UTC.
6143    ///
6144    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset)
6145    #[wasm_bindgen(method, js_name = getTimezoneOffset)]
6146    pub fn get_timezone_offset(this: &Date) -> f64;
6147
6148    /// The `getUTCDate()` method returns the day (date) of the month in the specified date
6149    /// according to universal time.
6150    ///
6151    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDate)
6152    #[wasm_bindgen(method, js_name = getUTCDate)]
6153    pub fn get_utc_date(this: &Date) -> u32;
6154
6155    /// The `getUTCDay()` method returns the day of the week in the specified date according to universal time,
6156    /// where 0 represents Sunday.
6157    ///
6158    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDay)
6159    #[wasm_bindgen(method, js_name = getUTCDay)]
6160    pub fn get_utc_day(this: &Date) -> u32;
6161
6162    /// The `getUTCFullYear()` method returns the year in the specified date according to universal time.
6163    ///
6164    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCFullYear)
6165    #[wasm_bindgen(method, js_name = getUTCFullYear)]
6166    pub fn get_utc_full_year(this: &Date) -> u32;
6167
6168    /// The `getUTCHours()` method returns the hours in the specified date according to universal time.
6169    ///
6170    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCHours)
6171    #[wasm_bindgen(method, js_name = getUTCHours)]
6172    pub fn get_utc_hours(this: &Date) -> u32;
6173
6174    /// The `getUTCMilliseconds()` method returns the milliseconds in the specified date
6175    /// according to universal time.
6176    ///
6177    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMilliseconds)
6178    #[wasm_bindgen(method, js_name = getUTCMilliseconds)]
6179    pub fn get_utc_milliseconds(this: &Date) -> u32;
6180
6181    /// The `getUTCMinutes()` method returns the minutes in the specified date according to universal time.
6182    ///
6183    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMinutes)
6184    #[wasm_bindgen(method, js_name = getUTCMinutes)]
6185    pub fn get_utc_minutes(this: &Date) -> u32;
6186
6187    /// The `getUTCMonth()` returns the month of the specified date according to universal time,
6188    /// as a zero-based value (where zero indicates the first month of the year).
6189    ///
6190    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMonth)
6191    #[wasm_bindgen(method, js_name = getUTCMonth)]
6192    pub fn get_utc_month(this: &Date) -> u32;
6193
6194    /// The `getUTCSeconds()` method returns the seconds in the specified date according to universal time.
6195    ///
6196    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCSeconds)
6197    #[wasm_bindgen(method, js_name = getUTCSeconds)]
6198    pub fn get_utc_seconds(this: &Date) -> u32;
6199
6200    /// Creates a JavaScript `Date` instance that represents
6201    /// a single moment in time. `Date` objects are based on a time value that is
6202    /// the number of milliseconds since 1 January 1970 UTC.
6203    ///
6204    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6205    #[wasm_bindgen(constructor)]
6206    pub fn new(init: &JsValue) -> Date;
6207
6208    /// Creates a JavaScript `Date` instance that represents the current moment in
6209    /// time.
6210    ///
6211    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6212    #[wasm_bindgen(constructor)]
6213    pub fn new_0() -> Date;
6214
6215    /// Creates a JavaScript `Date` instance that represents
6216    /// a single moment in time. `Date` objects are based on a time value that is
6217    /// the number of milliseconds since 1 January 1970 UTC.
6218    ///
6219    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6220    #[wasm_bindgen(constructor)]
6221    pub fn new_with_year_month(year: u32, month: i32) -> Date;
6222
6223    /// Creates a JavaScript `Date` instance that represents
6224    /// a single moment in time. `Date` objects are based on a time value that is
6225    /// the number of milliseconds since 1 January 1970 UTC.
6226    ///
6227    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6228    #[wasm_bindgen(constructor)]
6229    pub fn new_with_year_month_day(year: u32, month: i32, day: i32) -> Date;
6230
6231    /// Creates a JavaScript `Date` instance that represents
6232    /// a single moment in time. `Date` objects are based on a time value that is
6233    /// the number of milliseconds since 1 January 1970 UTC.
6234    ///
6235    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6236    #[wasm_bindgen(constructor)]
6237    pub fn new_with_year_month_day_hr(year: u32, month: i32, day: i32, hr: i32) -> Date;
6238
6239    /// Creates a JavaScript `Date` instance that represents
6240    /// a single moment in time. `Date` objects are based on a time value that is
6241    /// the number of milliseconds since 1 January 1970 UTC.
6242    ///
6243    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6244    #[wasm_bindgen(constructor)]
6245    pub fn new_with_year_month_day_hr_min(
6246        year: u32,
6247        month: i32,
6248        day: i32,
6249        hr: i32,
6250        min: i32,
6251    ) -> Date;
6252
6253    /// Creates a JavaScript `Date` instance that represents
6254    /// a single moment in time. `Date` objects are based on a time value that is
6255    /// the number of milliseconds since 1 January 1970 UTC.
6256    ///
6257    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6258    #[wasm_bindgen(constructor)]
6259    pub fn new_with_year_month_day_hr_min_sec(
6260        year: u32,
6261        month: i32,
6262        day: i32,
6263        hr: i32,
6264        min: i32,
6265        sec: i32,
6266    ) -> Date;
6267
6268    /// Creates a JavaScript `Date` instance that represents
6269    /// a single moment in time. `Date` objects are based on a time value that is
6270    /// the number of milliseconds since 1 January 1970 UTC.
6271    ///
6272    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6273    #[wasm_bindgen(constructor)]
6274    pub fn new_with_year_month_day_hr_min_sec_milli(
6275        year: u32,
6276        month: i32,
6277        day: i32,
6278        hr: i32,
6279        min: i32,
6280        sec: i32,
6281        milli: i32,
6282    ) -> Date;
6283
6284    /// The `Date.now()` method returns the number of milliseconds
6285    /// elapsed since January 1, 1970 00:00:00 UTC.
6286    ///
6287    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now)
6288    #[wasm_bindgen(static_method_of = Date)]
6289    pub fn now() -> f64;
6290
6291    /// The `Date.parse()` method parses a string representation of a date, and returns the number of milliseconds
6292    /// since January 1, 1970, 00:00:00 UTC or `NaN` if the string is unrecognized or, in some cases,
6293    /// contains illegal date values (e.g. 2015-02-31).
6294    ///
6295    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse)
6296    #[wasm_bindgen(static_method_of = Date)]
6297    pub fn parse(date: &str) -> f64;
6298
6299    /// The `setDate()` method sets the day of the Date object relative to the beginning of the currently set month.
6300    ///
6301    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setDate)
6302    #[wasm_bindgen(method, js_name = setDate)]
6303    pub fn set_date(this: &Date, day: u32) -> f64;
6304
6305    /// The `setFullYear()` method sets the full year for a specified date according to local time.
6306    /// Returns new timestamp.
6307    ///
6308    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear)
6309    #[wasm_bindgen(method, js_name = setFullYear)]
6310    pub fn set_full_year(this: &Date, year: u32) -> f64;
6311
6312    /// The `setFullYear()` method sets the full year for a specified date according to local time.
6313    /// Returns new timestamp.
6314    ///
6315    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear)
6316    #[wasm_bindgen(method, js_name = setFullYear)]
6317    pub fn set_full_year_with_month(this: &Date, year: u32, month: i32) -> f64;
6318
6319    /// The `setFullYear()` method sets the full year for a specified date according to local time.
6320    /// Returns new timestamp.
6321    ///
6322    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear)
6323    #[wasm_bindgen(method, js_name = setFullYear)]
6324    pub fn set_full_year_with_month_date(this: &Date, year: u32, month: i32, date: i32) -> f64;
6325
6326    /// The `setHours()` method sets the hours for a specified date according to local time,
6327    /// and returns the number of milliseconds since January 1, 1970 00:00:00 UTC until the time represented
6328    /// by the updated Date instance.
6329    ///
6330    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setHours)
6331    #[wasm_bindgen(method, js_name = setHours)]
6332    pub fn set_hours(this: &Date, hours: u32) -> f64;
6333
6334    /// The `setMilliseconds()` method sets the milliseconds for a specified date according to local time.
6335    ///
6336    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMilliseconds)
6337    #[wasm_bindgen(method, js_name = setMilliseconds)]
6338    pub fn set_milliseconds(this: &Date, milliseconds: u32) -> f64;
6339
6340    /// The `setMinutes()` method sets the minutes for a specified date according to local time.
6341    ///
6342    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMinutes)
6343    #[wasm_bindgen(method, js_name = setMinutes)]
6344    pub fn set_minutes(this: &Date, minutes: u32) -> f64;
6345
6346    /// The `setMonth()` method sets the month for a specified date according to the currently set year.
6347    ///
6348    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMonth)
6349    #[wasm_bindgen(method, js_name = setMonth)]
6350    pub fn set_month(this: &Date, month: u32) -> f64;
6351
6352    /// The `setSeconds()` method sets the seconds for a specified date according to local time.
6353    ///
6354    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setSeconds)
6355    #[wasm_bindgen(method, js_name = setSeconds)]
6356    pub fn set_seconds(this: &Date, seconds: u32) -> f64;
6357
6358    /// The `setTime()` method sets the Date object to the time represented by a number of milliseconds
6359    /// since January 1, 1970, 00:00:00 UTC.
6360    ///
6361    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setTime)
6362    #[wasm_bindgen(method, js_name = setTime)]
6363    pub fn set_time(this: &Date, time: f64) -> f64;
6364
6365    /// The `setUTCDate()` method sets the day of the month for a specified date
6366    /// according to universal time.
6367    ///
6368    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCDate)
6369    #[wasm_bindgen(method, js_name = setUTCDate)]
6370    pub fn set_utc_date(this: &Date, day: u32) -> f64;
6371
6372    /// The `setUTCFullYear()` method sets the full year for a specified date according to universal time.
6373    ///
6374    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear)
6375    #[wasm_bindgen(method, js_name = setUTCFullYear)]
6376    pub fn set_utc_full_year(this: &Date, year: u32) -> f64;
6377
6378    /// The `setUTCFullYear()` method sets the full year for a specified date according to universal time.
6379    ///
6380    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear)
6381    #[wasm_bindgen(method, js_name = setUTCFullYear)]
6382    pub fn set_utc_full_year_with_month(this: &Date, year: u32, month: i32) -> f64;
6383
6384    /// The `setUTCFullYear()` method sets the full year for a specified date according to universal time.
6385    ///
6386    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear)
6387    #[wasm_bindgen(method, js_name = setUTCFullYear)]
6388    pub fn set_utc_full_year_with_month_date(this: &Date, year: u32, month: i32, date: i32) -> f64;
6389
6390    /// The `setUTCHours()` method sets the hour for a specified date according to universal time,
6391    /// and returns the number of milliseconds since  January 1, 1970 00:00:00 UTC until the time
6392    /// represented by the updated Date instance.
6393    ///
6394    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCHours)
6395    #[wasm_bindgen(method, js_name = setUTCHours)]
6396    pub fn set_utc_hours(this: &Date, hours: u32) -> f64;
6397
6398    /// The `setUTCMilliseconds()` method sets the milliseconds for a specified date
6399    /// according to universal time.
6400    ///
6401    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMilliseconds)
6402    #[wasm_bindgen(method, js_name = setUTCMilliseconds)]
6403    pub fn set_utc_milliseconds(this: &Date, milliseconds: u32) -> f64;
6404
6405    /// The `setUTCMinutes()` method sets the minutes for a specified date according to universal time.
6406    ///
6407    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMinutes)
6408    #[wasm_bindgen(method, js_name = setUTCMinutes)]
6409    pub fn set_utc_minutes(this: &Date, minutes: u32) -> f64;
6410
6411    /// The `setUTCMonth()` method sets the month for a specified date according to universal time.
6412    ///
6413    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMonth)
6414    #[wasm_bindgen(method, js_name = setUTCMonth)]
6415    pub fn set_utc_month(this: &Date, month: u32) -> f64;
6416
6417    /// The `setUTCSeconds()` method sets the seconds for a specified date according to universal time.
6418    ///
6419    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCSeconds)
6420    #[wasm_bindgen(method, js_name = setUTCSeconds)]
6421    pub fn set_utc_seconds(this: &Date, seconds: u32) -> f64;
6422
6423    /// The `toDateString()` method returns the date portion of a Date object
6424    /// in human readable form in American English.
6425    ///
6426    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toDateString)
6427    #[wasm_bindgen(method, js_name = toDateString)]
6428    pub fn to_date_string(this: &Date) -> JsString;
6429
6430    /// The `toISOString()` method returns a string in simplified extended ISO format (ISO
6431    /// 8601), which is always 24 or 27 characters long (YYYY-MM-DDTHH:mm:ss.sssZ or
6432    /// ±YYYYYY-MM-DDTHH:mm:ss.sssZ, respectively). The timezone is always zero UTC offset,
6433    /// as denoted by the suffix "Z"
6434    ///
6435    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
6436    #[wasm_bindgen(method, js_name = toISOString)]
6437    pub fn to_iso_string(this: &Date) -> JsString;
6438
6439    /// The `toJSON()` method returns a string representation of the Date object.
6440    ///
6441    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toJSON)
6442    #[wasm_bindgen(method, js_name = toJSON)]
6443    pub fn to_json(this: &Date) -> JsString;
6444
6445    /// The `toLocaleDateString()` method returns a string with a language sensitive
6446    /// representation of the date portion of this date. The new locales and options
6447    /// arguments let applications specify the language whose formatting conventions
6448    /// should be used and allow to customize the behavior of the function.
6449    /// In older implementations, which ignore the locales and options arguments,
6450    /// the locale used and the form of the string
6451    /// returned are entirely implementation dependent.
6452    ///
6453    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString)
6454    #[cfg(not(js_sys_unstable_apis))]
6455    #[wasm_bindgen(method, js_name = toLocaleDateString)]
6456    pub fn to_locale_date_string(this: &Date, locale: &str, options: &JsValue) -> JsString;
6457
6458    /// The `toLocaleDateString()` method returns a string with a language sensitive
6459    /// representation of the date portion of this date.
6460    ///
6461    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString)
6462    #[cfg(js_sys_unstable_apis)]
6463    #[wasm_bindgen(method, js_name = toLocaleDateString)]
6464    pub fn to_locale_date_string(
6465        this: &Date,
6466        locales: &[JsString],
6467        options: &Intl::DateTimeFormatOptions,
6468    ) -> JsString;
6469
6470    /// The `toLocaleString()` method returns a string with a language sensitive
6471    /// representation of this date. The new locales and options arguments
6472    /// let applications specify the language whose formatting conventions
6473    /// should be used and customize the behavior of the function.
6474    /// In older implementations, which ignore the locales
6475    /// and options arguments, the locale used and the form of the string
6476    /// returned are entirely implementation dependent.
6477    ///
6478    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString)
6479    #[cfg(not(js_sys_unstable_apis))]
6480    #[wasm_bindgen(method, js_name = toLocaleString)]
6481    pub fn to_locale_string(this: &Date, locale: &str, options: &JsValue) -> JsString;
6482
6483    /// The `toLocaleString()` method returns a string with a language sensitive
6484    /// representation of this date.
6485    ///
6486    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString)
6487    #[cfg(js_sys_unstable_apis)]
6488    #[wasm_bindgen(method, js_name = toLocaleString)]
6489    pub fn to_locale_string(
6490        this: &Date,
6491        locales: &[JsString],
6492        options: &Intl::DateTimeFormatOptions,
6493    ) -> JsString;
6494
6495    /// The `toLocaleTimeString()` method returns a string with a language sensitive
6496    /// representation of the time portion of this date. The new locales and options
6497    /// arguments let applications specify the language whose formatting conventions should be
6498    /// used and customize the behavior of the function. In older implementations, which ignore
6499    /// the locales and options arguments, the locale used and the form of the string
6500    /// returned are entirely implementation dependent.
6501    ///
6502    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString)
6503    #[cfg(not(js_sys_unstable_apis))]
6504    #[wasm_bindgen(method, js_name = toLocaleTimeString)]
6505    pub fn to_locale_time_string(this: &Date, locale: &str) -> JsString;
6506
6507    /// The `toLocaleTimeString()` method returns a string with a language sensitive
6508    /// representation of the time portion of this date.
6509    ///
6510    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString)
6511    #[cfg(js_sys_unstable_apis)]
6512    #[wasm_bindgen(method, js_name = toLocaleTimeString)]
6513    pub fn to_locale_time_string(
6514        this: &Date,
6515        locales: &[JsString],
6516        options: &Intl::DateTimeFormatOptions,
6517    ) -> JsString;
6518
6519    #[cfg(not(js_sys_unstable_apis))]
6520    #[wasm_bindgen(method, js_name = toLocaleTimeString)]
6521    pub fn to_locale_time_string_with_options(
6522        this: &Date,
6523        locale: &str,
6524        options: &JsValue,
6525    ) -> JsString;
6526
6527    /// The `toString()` method returns a string representing
6528    /// the specified Date object.
6529    ///
6530    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toString)
6531    #[cfg(not(js_sys_unstable_apis))]
6532    #[wasm_bindgen(method, js_name = toString)]
6533    pub fn to_string(this: &Date) -> JsString;
6534
6535    /// The `toTimeString()` method returns the time portion of a Date object in human
6536    /// readable form in American English.
6537    ///
6538    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toTimeString)
6539    #[wasm_bindgen(method, js_name = toTimeString)]
6540    pub fn to_time_string(this: &Date) -> JsString;
6541
6542    /// The `toUTCString()` method converts a date to a string,
6543    /// using the UTC time zone.
6544    ///
6545    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString)
6546    #[wasm_bindgen(method, js_name = toUTCString)]
6547    pub fn to_utc_string(this: &Date) -> JsString;
6548
6549    /// The `Date.UTC()` method accepts the same parameters as the
6550    /// longest form of the constructor, and returns the number of
6551    /// milliseconds in a `Date` object since January 1, 1970,
6552    /// 00:00:00, universal time.
6553    ///
6554    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC)
6555    #[wasm_bindgen(static_method_of = Date, js_name = UTC)]
6556    pub fn utc(year: f64, month: f64) -> f64;
6557
6558    /// The `valueOf()` method  returns the primitive value of
6559    /// a Date object.
6560    ///
6561    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/valueOf)
6562    #[wasm_bindgen(method, js_name = valueOf)]
6563    pub fn value_of(this: &Date) -> f64;
6564
6565    /// The `toTemporalInstant()` method converts a legacy `Date` object to a
6566    /// `Temporal.Instant` object representing the same moment in time.
6567    ///
6568    /// This method is added by the Temporal proposal to facilitate migration
6569    /// from legacy `Date` to the new Temporal API.
6570    ///
6571    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toTemporalInstant)
6572    #[cfg(js_sys_unstable_apis)]
6573    #[wasm_bindgen(method, js_name = toTemporalInstant)]
6574    pub fn to_temporal_instant(this: &Date) -> Temporal::Instant;
6575}
6576
6577// Property Descriptor.
6578#[wasm_bindgen]
6579extern "C" {
6580    #[wasm_bindgen(extends = Object)]
6581    #[derive(Clone, Debug)]
6582    pub type PropertyDescriptor<T = JsValue>;
6583
6584    #[wasm_bindgen(method, getter = writable)]
6585    pub fn get_writable<T>(this: &PropertyDescriptor<T>) -> Option<bool>;
6586
6587    #[wasm_bindgen(method, setter = writable)]
6588    pub fn set_writable<T>(this: &PropertyDescriptor<T>, writable: bool);
6589
6590    #[wasm_bindgen(method, getter = enumerable)]
6591    pub fn get_enumerable<T>(this: &PropertyDescriptor<T>) -> Option<bool>;
6592
6593    #[wasm_bindgen(method, setter = enumerable)]
6594    pub fn set_enumerable<T>(this: &PropertyDescriptor<T>, enumerable: bool);
6595
6596    #[wasm_bindgen(method, getter = configurable)]
6597    pub fn get_configurable<T>(this: &PropertyDescriptor<T>) -> Option<bool>;
6598
6599    #[wasm_bindgen(method, setter = configurable)]
6600    pub fn set_configurable<T>(this: &PropertyDescriptor<T>, configurable: bool);
6601
6602    #[wasm_bindgen(method, getter = get)]
6603    pub fn get_get<T: JsGeneric>(this: &PropertyDescriptor<T>) -> Option<Function<fn() -> T>>;
6604
6605    #[wasm_bindgen(method, setter = get)]
6606    pub fn set_get<T: JsGeneric>(this: &PropertyDescriptor<T>, get: Function<fn() -> T>);
6607
6608    #[wasm_bindgen(method, getter = set)]
6609    pub fn get_set<T: JsGeneric>(
6610        this: &PropertyDescriptor<T>,
6611    ) -> Option<Function<fn(T) -> JsValue>>;
6612
6613    #[wasm_bindgen(method, setter = set)]
6614    pub fn set_set<T: JsGeneric>(this: &PropertyDescriptor<T>, set: Function<fn(T) -> JsValue>);
6615
6616    #[wasm_bindgen(method, getter = value)]
6617    pub fn get_value<T>(this: &PropertyDescriptor<T>) -> Option<T>;
6618
6619    #[wasm_bindgen(method, setter = value)]
6620    pub fn set_value<T>(this: &PropertyDescriptor<T>, value: &T);
6621}
6622
6623impl PropertyDescriptor {
6624    #[cfg(not(js_sys_unstable_apis))]
6625    pub fn new<T>() -> PropertyDescriptor<T> {
6626        JsCast::unchecked_into(Object::new())
6627    }
6628
6629    #[cfg(js_sys_unstable_apis)]
6630    pub fn new<T>() -> PropertyDescriptor<T> {
6631        JsCast::unchecked_into(Object::<JsValue>::new())
6632    }
6633
6634    #[cfg(not(js_sys_unstable_apis))]
6635    pub fn new_value<T: JsGeneric>(value: &T) -> PropertyDescriptor<T> {
6636        let desc: PropertyDescriptor<T> = JsCast::unchecked_into(Object::new());
6637        desc.set_value(value);
6638        desc
6639    }
6640
6641    #[cfg(js_sys_unstable_apis)]
6642    pub fn new_value<T: JsGeneric>(value: &T) -> PropertyDescriptor<T> {
6643        let desc: PropertyDescriptor<T> = JsCast::unchecked_into(Object::<JsValue>::new());
6644        desc.set_value(value);
6645        desc
6646    }
6647}
6648
6649impl Default for PropertyDescriptor {
6650    fn default() -> Self {
6651        PropertyDescriptor::new()
6652    }
6653}
6654
6655// Object.
6656#[wasm_bindgen]
6657extern "C" {
6658    #[wasm_bindgen(typescript_type = "object")]
6659    #[derive(Clone, Debug)]
6660    pub type Object<T = JsValue>;
6661
6662    // Next major: deprecate
6663    /// The `Object.assign()` method is used to copy the values of all enumerable
6664    /// own properties from one or more source objects to a target object. It
6665    /// will return the target object.
6666    ///
6667    /// **Note:** Consider using [`Object::try_assign`] to support error handling.
6668    ///
6669    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
6670    #[wasm_bindgen(static_method_of = Object)]
6671    pub fn assign<T>(target: &Object<T>, source: &Object<T>) -> Object<T>;
6672
6673    // Next major: deprecate
6674    /// The `Object.assign()` method is used to copy the values of all enumerable
6675    /// own properties from one or more source objects to a target object. It
6676    /// will return the target object.
6677    ///
6678    /// **Note:** Consider using [`Object::try_assign`] to support error handling.
6679    ///
6680    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
6681    #[wasm_bindgen(static_method_of = Object, js_name = assign, catch)]
6682    pub fn try_assign<T>(target: &Object<T>, source: &Object<T>) -> Result<Object<T>, JsValue>;
6683
6684    /// The `Object.assign()` method is used to copy the values of all enumerable
6685    /// own properties from one or more source objects to a target object. It
6686    /// will return the target object.
6687    ///
6688    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
6689    #[cfg(not(js_sys_unstable_apis))]
6690    #[wasm_bindgen(static_method_of = Object, js_name = assign)]
6691    #[deprecated(note = "use `assign_many` for arbitrary assign arguments instead")]
6692    #[allow(deprecated)]
6693    pub fn assign2<T>(target: &Object<T>, source1: &Object<T>, source2: &Object<T>) -> Object<T>;
6694
6695    /// The `Object.assign()` method is used to copy the values of all enumerable
6696    /// own properties from one or more source objects to a target object. It
6697    /// will return the target object.
6698    ///
6699    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
6700    #[cfg(not(js_sys_unstable_apis))]
6701    #[wasm_bindgen(static_method_of = Object, js_name = assign)]
6702    #[deprecated(note = "use `assign_many` for arbitrary assign arguments instead")]
6703    #[allow(deprecated)]
6704    pub fn assign3<T>(
6705        target: &Object<T>,
6706        source1: &Object<T>,
6707        source2: &Object<T>,
6708        source3: &Object<T>,
6709    ) -> Object<T>;
6710
6711    /// The `Object.assign()` method is used to copy the values of all enumerable
6712    /// own properties from one or more source objects to a target object. It
6713    /// will return the target object.
6714    ///
6715    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
6716    #[wasm_bindgen(static_method_of = Object, js_name = assign, catch, variadic)]
6717    pub fn assign_many<T>(target: &Object<T>, sources: &[Object<T>]) -> Result<Object<T>, JsValue>;
6718
6719    /// The constructor property returns a reference to the `Object` constructor
6720    /// function that created the instance object.
6721    ///
6722    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor)
6723    #[wasm_bindgen(method, getter)]
6724    pub fn constructor<T>(this: &Object<T>) -> Function;
6725
6726    /// The `Object.create()` method creates a new object, using an existing
6727    /// object to provide the newly created object's prototype.
6728    ///
6729    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create)
6730    #[wasm_bindgen(static_method_of = Object)]
6731    pub fn create<T>(prototype: &Object<T>) -> Object<T>;
6732
6733    /// The static method `Object.defineProperty()` defines a new
6734    /// property directly on an object, or modifies an existing
6735    /// property on an object, and returns the object.
6736    ///
6737    /// **Note:** Consider using [`Object::define_property_str`] to support typing and error handling.
6738    ///
6739    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty)
6740    #[cfg(not(js_sys_unstable_apis))]
6741    #[wasm_bindgen(static_method_of = Object, js_name = defineProperty)]
6742    pub fn define_property<T>(obj: &Object<T>, prop: &JsValue, descriptor: &Object) -> Object<T>;
6743
6744    /// The static method `Object.defineProperty()` defines a new
6745    /// property directly on an object, or modifies an existing
6746    /// property on an object, and returns the object.
6747    ///
6748    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty)
6749    #[cfg(js_sys_unstable_apis)]
6750    #[wasm_bindgen(static_method_of = Object, js_name = defineProperty, catch)]
6751    pub fn define_property<T>(
6752        obj: &Object<T>,
6753        prop: &JsString,
6754        descriptor: &PropertyDescriptor<T>,
6755    ) -> Result<Object<T>, JsValue>;
6756
6757    // Next major: deprecate
6758    /// The static method `Object.defineProperty()` defines a new
6759    /// property directly on an object, or modifies an existing
6760    /// property on an object, and returns the object.
6761    ///
6762    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty)
6763    #[wasm_bindgen(static_method_of = Object, js_name = defineProperty, catch)]
6764    pub fn define_property_str<T>(
6765        obj: &Object<T>,
6766        prop: &JsString,
6767        descriptor: &PropertyDescriptor<T>,
6768    ) -> Result<Object<T>, JsValue>;
6769
6770    /// The static method `Object.defineProperty()` defines a new
6771    /// property directly on an object, or modifies an existing
6772    /// property on an object, and returns the object.
6773    ///
6774    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty)
6775    #[wasm_bindgen(static_method_of = Object, js_name = defineProperty, catch)]
6776    pub fn define_property_symbol<T>(
6777        obj: &Object<T>,
6778        prop: &Symbol,
6779        descriptor: &PropertyDescriptor<JsValue>,
6780    ) -> Result<Object<T>, JsValue>;
6781
6782    /// The `Object.defineProperties()` method defines new or modifies
6783    /// existing properties directly on an object, returning the
6784    /// object.
6785    ///
6786    /// **Note:** Consider using [`Object::try_define_properties`] to support typing and error handling.
6787    ///
6788    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties)
6789    #[wasm_bindgen(static_method_of = Object, js_name = defineProperties)]
6790    pub fn define_properties<T>(obj: &Object<T>, props: &Object) -> Object<T>;
6791
6792    /// The `Object.defineProperties()` method defines new or modifies
6793    /// existing properties directly on an object, returning the
6794    /// object.
6795    ///
6796    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties)
6797    #[cfg(js_sys_unstable_apis)]
6798    #[wasm_bindgen(static_method_of = Object, js_name = defineProperties, catch)]
6799    pub fn try_define_properties<T>(
6800        obj: &Object<T>,
6801        props: &Object<PropertyDescriptor<T>>,
6802    ) -> Result<Object<T>, JsValue>;
6803
6804    /// The `Object.entries()` method returns an array of a given
6805    /// object's own enumerable property [key, value] pairs, in the
6806    /// same order as that provided by a for...in loop (the difference
6807    /// being that a for-in loop enumerates properties in the
6808    /// prototype chain as well).
6809    ///
6810    /// **Note:** Consider using [`Object::entries_typed`] to support typing and error handling.
6811    ///
6812    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries)
6813    #[cfg(not(js_sys_unstable_apis))]
6814    #[wasm_bindgen(static_method_of = Object)]
6815    pub fn entries(object: &Object) -> Array;
6816
6817    /// The `Object.entries()` method returns an array of a given
6818    /// object's own enumerable property [key, value] pairs, in the
6819    /// same order as that provided by a for...in loop (the difference
6820    /// being that a for-in loop enumerates properties in the
6821    /// prototype chain as well).
6822    ///
6823    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries)
6824    #[cfg(js_sys_unstable_apis)]
6825    #[wasm_bindgen(static_method_of = Object, js_name = entries, catch)]
6826    pub fn entries<T: JsGeneric>(
6827        object: &Object<T>,
6828    ) -> Result<Array<ArrayTuple<(JsString, T)>>, JsValue>;
6829
6830    // Next major: deprecate
6831    /// The `Object.entries()` method returns an array of a given
6832    /// object's own enumerable property [key, value] pairs, in the
6833    /// same order as that provided by a for...in loop (the difference
6834    /// being that a for-in loop enumerates properties in the
6835    /// prototype chain as well).
6836    ///
6837    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries)
6838    #[wasm_bindgen(static_method_of = Object, js_name = entries, catch)]
6839    pub fn entries_typed<T: JsGeneric>(
6840        object: &Object<T>,
6841    ) -> Result<Array<ArrayTuple<(JsString, T)>>, JsValue>;
6842
6843    /// The `Object.freeze()` method freezes an object: that is, prevents new
6844    /// properties from being added to it; prevents existing properties from
6845    /// being removed; and prevents existing properties, or their enumerability,
6846    /// configurability, or writability, from being changed, it also prevents
6847    /// the prototype from being changed. The method returns the passed object.
6848    ///
6849    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze)
6850    #[wasm_bindgen(static_method_of = Object)]
6851    pub fn freeze<T>(value: &Object<T>) -> Object<T>;
6852
6853    /// The `Object.fromEntries()` method transforms a list of key-value pairs
6854    /// into an object.
6855    ///
6856    /// **Note:** Consider using [`Object::from_entries_typed`] to support typing and error handling.
6857    ///
6858    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries)
6859    #[cfg(not(js_sys_unstable_apis))]
6860    #[wasm_bindgen(static_method_of = Object, catch, js_name = fromEntries)]
6861    pub fn from_entries(entries: &JsValue) -> Result<Object, JsValue>;
6862
6863    /// The `Object.fromEntries()` method transforms a list of key-value pairs
6864    /// into an object.
6865    ///
6866    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries)
6867    #[cfg(js_sys_unstable_apis)]
6868    #[wasm_bindgen(static_method_of = Object, catch, js_name = fromEntries)]
6869    pub fn from_entries<T: JsGeneric, I: Iterable<Item = ArrayTuple<(JsString, T)>>>(
6870        entries: &I,
6871    ) -> Result<Object<T>, JsValue>;
6872
6873    // Next major: deprecate
6874    /// The `Object.fromEntries()` method transforms a list of key-value pairs
6875    /// into an object.
6876    ///
6877    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries)
6878    #[wasm_bindgen(static_method_of = Object, catch, js_name = fromEntries)]
6879    pub fn from_entries_typed<T: JsGeneric, I: Iterable<Item = ArrayTuple<(JsString, T)>>>(
6880        entries: &I,
6881    ) -> Result<Object<T>, JsValue>;
6882
6883    /// The `Object.getOwnPropertyDescriptor()` method returns a
6884    /// property descriptor for an own property (that is, one directly
6885    /// present on an object and not in the object's prototype chain)
6886    /// of a given object.
6887    ///
6888    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor)
6889    #[cfg(not(js_sys_unstable_apis))]
6890    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptor)]
6891    pub fn get_own_property_descriptor<T>(obj: &Object<T>, prop: &JsValue) -> JsValue;
6892
6893    /// The `Object.getOwnPropertyDescriptor()` method returns a
6894    /// property descriptor for an own property (that is, one directly
6895    /// present on an object and not in the object's prototype chain)
6896    /// of a given object.
6897    ///
6898    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor)
6899    #[cfg(js_sys_unstable_apis)]
6900    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptor, catch)]
6901    pub fn get_own_property_descriptor<T>(
6902        obj: &Object<T>,
6903        prop: &JsString,
6904    ) -> Result<PropertyDescriptor<T>, JsValue>;
6905
6906    // Next major: deprecate
6907    /// The `Object.getOwnPropertyDescriptor()` method returns a
6908    /// property descriptor for an own property (that is, one directly
6909    /// present on an object and not in the object's prototype chain)
6910    /// of a given object.
6911    ///
6912    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor)
6913    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptor, catch)]
6914    pub fn get_own_property_descriptor_str<T>(
6915        obj: &Object<T>,
6916        prop: &JsString,
6917    ) -> Result<PropertyDescriptor<T>, JsValue>;
6918
6919    /// The `Object.getOwnPropertyDescriptor()` method returns a
6920    /// property descriptor for an own property (that is, one directly
6921    /// present on an object and not in the object's prototype chain)
6922    /// of a given object.
6923    ///
6924    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor)
6925    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptor, catch)]
6926    pub fn get_own_property_descriptor_symbol<T>(
6927        obj: &Object<T>,
6928        prop: &Symbol,
6929    ) -> Result<PropertyDescriptor<JsValue>, JsValue>;
6930
6931    /// The `Object.getOwnPropertyDescriptors()` method returns all own
6932    /// property descriptors of a given object.
6933    ///
6934    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors)
6935    #[cfg(not(js_sys_unstable_apis))]
6936    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptors)]
6937    pub fn get_own_property_descriptors<T>(obj: &Object<T>) -> JsValue;
6938
6939    /// The `Object.getOwnPropertyDescriptors()` method returns all own
6940    /// property descriptors of a given object.
6941    ///
6942    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors)
6943    #[cfg(js_sys_unstable_apis)]
6944    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptors, catch)]
6945    pub fn get_own_property_descriptors<T>(
6946        obj: &Object<T>,
6947    ) -> Result<Object<PropertyDescriptor<T>>, JsValue>;
6948
6949    /// The `Object.getOwnPropertyNames()` method returns an array of
6950    /// all properties (including non-enumerable properties except for
6951    /// those which use Symbol) found directly upon a given object.
6952    ///
6953    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames)
6954    #[cfg(not(js_sys_unstable_apis))]
6955    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyNames)]
6956    pub fn get_own_property_names<T>(obj: &Object<T>) -> Array;
6957
6958    /// The `Object.getOwnPropertyNames()` method returns an array of
6959    /// all properties (including non-enumerable properties except for
6960    /// those which use Symbol) found directly upon a given object.
6961    ///
6962    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames)
6963    #[cfg(js_sys_unstable_apis)]
6964    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyNames, catch)]
6965    pub fn get_own_property_names<T>(obj: &Object<T>) -> Result<Array<JsString>, JsValue>;
6966
6967    /// The `Object.getOwnPropertySymbols()` method returns an array of
6968    /// all symbol properties found directly upon a given object.
6969    ///
6970    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols)
6971    #[cfg(not(js_sys_unstable_apis))]
6972    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertySymbols)]
6973    pub fn get_own_property_symbols<T>(obj: &Object<T>) -> Array;
6974
6975    /// The `Object.getOwnPropertySymbols()` method returns an array of
6976    /// all symbol properties found directly upon a given object.
6977    ///
6978    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols)
6979    #[cfg(js_sys_unstable_apis)]
6980    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertySymbols, catch)]
6981    pub fn get_own_property_symbols<T>(obj: &Object<T>) -> Result<Array<Symbol>, JsValue>;
6982
6983    /// The `Object.getPrototypeOf()` method returns the prototype
6984    /// (i.e. the value of the internal [[Prototype]] property) of the
6985    /// specified object.
6986    ///
6987    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf)
6988    #[wasm_bindgen(static_method_of = Object, js_name = getPrototypeOf)]
6989    pub fn get_prototype_of(obj: &JsValue) -> Object;
6990
6991    /// The `hasOwnProperty()` method returns a boolean indicating whether the
6992    /// object has the specified property as its own property (as opposed to
6993    /// inheriting it).
6994    ///
6995    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty)
6996    #[deprecated(note = "Use `Object::hasOwn` instead.")]
6997    #[allow(deprecated)]
6998    #[wasm_bindgen(method, js_name = hasOwnProperty)]
6999    pub fn has_own_property<T>(this: &Object<T>, property: &JsValue) -> bool;
7000
7001    /// The `Object.hasOwn()` method returns a boolean indicating whether the
7002    /// object passed in has the specified property as its own property (as
7003    /// opposed to inheriting it).
7004    ///
7005    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn)
7006    #[cfg(not(js_sys_unstable_apis))]
7007    #[wasm_bindgen(static_method_of = Object, js_name = hasOwn)]
7008    pub fn has_own<T>(instance: &Object<T>, property: &JsValue) -> bool;
7009
7010    /// The `Object.hasOwn()` method returns a boolean indicating whether the
7011    /// object passed in has the specified property as its own property (as
7012    /// opposed to inheriting it).
7013    ///
7014    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn)
7015    #[cfg(js_sys_unstable_apis)]
7016    #[wasm_bindgen(static_method_of = Object, js_name = hasOwn, catch)]
7017    pub fn has_own<T>(instance: &Object<T>, property: &JsString) -> Result<bool, JsValue>;
7018
7019    // Next major: deprecate
7020    /// The `Object.hasOwn()` method returns a boolean indicating whether the
7021    /// object passed in has the specified property as its own property (as
7022    /// opposed to inheriting it).
7023    ///
7024    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn)
7025    #[wasm_bindgen(static_method_of = Object, js_name = hasOwn, catch)]
7026    pub fn has_own_str<T>(instance: &Object<T>, property: &JsString) -> Result<bool, JsValue>;
7027
7028    /// The `Object.hasOwn()` method returns a boolean indicating whether the
7029    /// object passed in has the specified property as its own property (as
7030    /// opposed to inheriting it).
7031    ///
7032    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn)
7033    #[wasm_bindgen(static_method_of = Object, js_name = hasOwn, catch)]
7034    pub fn has_own_symbol<T>(instance: &Object<T>, property: &Symbol) -> Result<bool, JsValue>;
7035
7036    /// The `Object.is()` method determines whether two values are the same value.
7037    ///
7038    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is)
7039    #[wasm_bindgen(static_method_of = Object)]
7040    pub fn is(value1: &JsValue, value_2: &JsValue) -> bool;
7041
7042    /// The `Object.isExtensible()` method determines if an object is extensible
7043    /// (whether it can have new properties added to it).
7044    ///
7045    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible)
7046    #[wasm_bindgen(static_method_of = Object, js_name = isExtensible)]
7047    pub fn is_extensible<T>(object: &Object<T>) -> bool;
7048
7049    /// The `Object.isFrozen()` determines if an object is frozen.
7050    ///
7051    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen)
7052    #[wasm_bindgen(static_method_of = Object, js_name = isFrozen)]
7053    pub fn is_frozen<T>(object: &Object<T>) -> bool;
7054
7055    /// The `Object.isSealed()` method determines if an object is sealed.
7056    ///
7057    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isSealed)
7058    #[wasm_bindgen(static_method_of = Object, js_name = isSealed)]
7059    pub fn is_sealed<T>(object: &Object<T>) -> bool;
7060
7061    /// The `isPrototypeOf()` method checks if an object exists in another
7062    /// object's prototype chain.
7063    ///
7064    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf)
7065    #[wasm_bindgen(method, js_name = isPrototypeOf)]
7066    pub fn is_prototype_of<T>(this: &Object<T>, value: &JsValue) -> bool;
7067
7068    /// The `Object.keys()` method returns an array of a given object's property
7069    /// names, in the same order as we get with a normal loop.
7070    ///
7071    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys)
7072    #[cfg(not(js_sys_unstable_apis))]
7073    #[wasm_bindgen(static_method_of = Object)]
7074    pub fn keys<T>(object: &Object<T>) -> Array;
7075
7076    /// The `Object.keys()` method returns an array of a given object's property
7077    /// names, in the same order as we get with a normal loop.
7078    ///
7079    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys)
7080    #[cfg(js_sys_unstable_apis)]
7081    #[wasm_bindgen(static_method_of = Object)]
7082    pub fn keys<T>(object: &Object<T>) -> Array<JsString>;
7083
7084    /// The [`Object`] constructor creates an object wrapper.
7085    ///
7086    /// **Note:** Consider using [`Object::new_typed`] for typed object records.
7087    ///
7088    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
7089    #[wasm_bindgen(constructor)]
7090    pub fn new() -> Object;
7091
7092    // Next major: deprecate
7093    /// The [`Object`] constructor creates an object wrapper.
7094    ///
7095    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
7096    #[wasm_bindgen(constructor)]
7097    pub fn new_typed<T>() -> Object<T>;
7098
7099    /// The `Object.preventExtensions()` method prevents new properties from
7100    /// ever being added to an object (i.e. prevents future extensions to the
7101    /// object).
7102    ///
7103    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions)
7104    #[wasm_bindgen(static_method_of = Object, js_name = preventExtensions)]
7105    pub fn prevent_extensions<T>(object: &Object<T>);
7106
7107    /// The `propertyIsEnumerable()` method returns a Boolean indicating
7108    /// whether the specified property is enumerable.
7109    ///
7110    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable)
7111    #[wasm_bindgen(method, js_name = propertyIsEnumerable)]
7112    pub fn property_is_enumerable<T>(this: &Object<T>, property: &JsValue) -> bool;
7113
7114    /// The `Object.seal()` method seals an object, preventing new properties
7115    /// from being added to it and marking all existing properties as
7116    /// non-configurable.  Values of present properties can still be changed as
7117    /// long as they are writable.
7118    ///
7119    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal)
7120    #[wasm_bindgen(static_method_of = Object)]
7121    pub fn seal<T>(value: &Object<T>) -> Object<T>;
7122
7123    /// The `Object.setPrototypeOf()` method sets the prototype (i.e., the
7124    /// internal `[[Prototype]]` property) of a specified object to another
7125    /// object or `null`.
7126    ///
7127    /// **Note:** Consider using [`Object::try_set_prototype_of`] to support errors.
7128    ///
7129    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf)
7130    #[wasm_bindgen(static_method_of = Object, js_name = setPrototypeOf)]
7131    pub fn set_prototype_of<T>(object: &Object<T>, prototype: &Object) -> Object<T>;
7132
7133    /// The `Object.setPrototypeOf()` method sets the prototype (i.e., the
7134    /// internal `[[Prototype]]` property) of a specified object to another
7135    /// object or `null`.
7136    ///
7137    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf)
7138    #[wasm_bindgen(static_method_of = Object, js_name = setPrototypeOf, catch)]
7139    pub fn try_set_prototype_of<T>(
7140        object: &Object<T>,
7141        prototype: &Object,
7142    ) -> Result<Object<T>, JsValue>;
7143
7144    /// The `toLocaleString()` method returns a string representing the object.
7145    /// This method is meant to be overridden by derived objects for
7146    /// locale-specific purposes.
7147    ///
7148    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toLocaleString)
7149    #[wasm_bindgen(method, js_name = toLocaleString)]
7150    pub fn to_locale_string<T>(this: &Object<T>) -> JsString;
7151
7152    // Next major: deprecate
7153    /// The `toString()` method returns a string representing the object.
7154    ///
7155    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString)
7156    #[wasm_bindgen(method, js_name = toString)]
7157    pub fn to_string<T>(this: &Object<T>) -> JsString;
7158
7159    /// The `toString()` method returns a string representing the object.
7160    ///
7161    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString)
7162    #[wasm_bindgen(method, js_name = toString)]
7163    pub fn to_js_string<T>(this: &Object<T>) -> JsString;
7164
7165    /// The `valueOf()` method returns the primitive value of the
7166    /// specified object.
7167    ///
7168    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf)
7169    #[wasm_bindgen(method, js_name = valueOf)]
7170    pub fn value_of<T>(this: &Object<T>) -> Object;
7171
7172    /// The `Object.values()` method returns an array of a given object's own
7173    /// enumerable property values, in the same order as that provided by a
7174    /// `for...in` loop (the difference being that a for-in loop enumerates
7175    /// properties in the prototype chain as well).
7176    ///
7177    /// **Note:** Consider using [`Object::try_values`] to support errors.
7178    ///
7179    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values)
7180    #[cfg(not(js_sys_unstable_apis))]
7181    #[wasm_bindgen(static_method_of = Object)]
7182    pub fn values<T>(object: &Object<T>) -> Array<T>;
7183
7184    /// The `Object.values()` method returns an array of a given object's own
7185    /// enumerable property values, in the same order as that provided by a
7186    /// `for...in` loop (the difference being that a for-in loop enumerates
7187    /// properties in the prototype chain as well).
7188    ///
7189    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values)
7190    #[cfg(js_sys_unstable_apis)]
7191    #[wasm_bindgen(static_method_of = Object, catch, js_name = values)]
7192    pub fn values<T>(object: &Object<T>) -> Result<Array<T>, JsValue>;
7193
7194    // Next major: deprecate
7195    /// The `Object.values()` method returns an array of a given object's own
7196    /// enumerable property values, in the same order as that provided by a
7197    /// `for...in` loop (the difference being that a for-in loop enumerates
7198    /// properties in the prototype chain as well).
7199    ///
7200    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values)
7201    #[cfg(not(js_sys_unstable_apis))]
7202    #[wasm_bindgen(static_method_of = Object, catch, js_name = values)]
7203    pub fn try_values<T>(object: &Object<T>) -> Result<Array<T>, JsValue>;
7204}
7205
7206impl Object {
7207    /// Returns the `Object` value of this JS value if it's an instance of an
7208    /// object.
7209    ///
7210    /// If this JS value is not an instance of an object then this returns
7211    /// `None`.
7212    pub fn try_from(val: &JsValue) -> Option<&Object> {
7213        if val.is_object() {
7214            Some(val.unchecked_ref())
7215        } else {
7216            None
7217        }
7218    }
7219}
7220
7221impl PartialEq for Object {
7222    #[inline]
7223    fn eq(&self, other: &Object) -> bool {
7224        Object::is(self.as_ref(), other.as_ref())
7225    }
7226}
7227
7228impl Eq for Object {}
7229
7230impl Default for Object<JsValue> {
7231    fn default() -> Self {
7232        Self::new()
7233    }
7234}
7235
7236// Proxy
7237#[wasm_bindgen]
7238extern "C" {
7239    #[wasm_bindgen(typescript_type = "ProxyConstructor")]
7240    #[derive(Clone, Debug)]
7241    pub type Proxy;
7242
7243    /// The [`Proxy`] object is used to define custom behavior for fundamental
7244    /// operations (e.g. property lookup, assignment, enumeration, function
7245    /// invocation, etc).
7246    ///
7247    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy)
7248    #[wasm_bindgen(constructor)]
7249    pub fn new(target: &JsValue, handler: &Object) -> Proxy;
7250
7251    /// The `Proxy.revocable()` method is used to create a revocable [`Proxy`]
7252    /// object.
7253    ///
7254    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/revocable)
7255    #[wasm_bindgen(static_method_of = Proxy)]
7256    pub fn revocable(target: &JsValue, handler: &Object) -> Object;
7257}
7258
7259// RangeError
7260#[wasm_bindgen]
7261extern "C" {
7262    /// The `RangeError` object indicates an error when a value is not in the set
7263    /// or range of allowed values.
7264    ///
7265    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError)
7266    #[wasm_bindgen(extends = Error, extends = Object, typescript_type = "RangeError")]
7267    #[derive(Clone, Debug, PartialEq, Eq)]
7268    pub type RangeError;
7269
7270    /// The `RangeError` object indicates an error when a value is not in the set
7271    /// or range of allowed values.
7272    ///
7273    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError)
7274    #[wasm_bindgen(constructor)]
7275    pub fn new(message: &str) -> RangeError;
7276}
7277
7278// ReferenceError
7279#[wasm_bindgen]
7280extern "C" {
7281    /// The `ReferenceError` object represents an error when a non-existent
7282    /// variable is referenced.
7283    ///
7284    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError)
7285    #[wasm_bindgen(extends = Error, extends = Object, typescript_type = "ReferenceError")]
7286    #[derive(Clone, Debug, PartialEq, Eq)]
7287    pub type ReferenceError;
7288
7289    /// The `ReferenceError` object represents an error when a non-existent
7290    /// variable is referenced.
7291    ///
7292    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError)
7293    #[wasm_bindgen(constructor)]
7294    pub fn new(message: &str) -> ReferenceError;
7295}
7296
7297#[allow(non_snake_case)]
7298pub mod Reflect {
7299    use super::*;
7300
7301    // Reflect
7302    #[wasm_bindgen]
7303    extern "C" {
7304        /// The static `Reflect.apply()` method calls a target function with
7305        /// arguments as specified.
7306        ///
7307        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/apply)
7308        #[wasm_bindgen(js_namespace = Reflect, catch)]
7309        pub fn apply<T: JsFunction = fn() -> JsValue>(
7310            target: &Function<T>,
7311            this_argument: &JsValue,
7312            arguments_list: &Array,
7313        ) -> Result<<T as JsFunction>::Ret, JsValue>;
7314
7315        /// The static `Reflect.construct()` method acts like the new operator, but
7316        /// as a function.  It is equivalent to calling `new target(...args)`. It
7317        /// gives also the added option to specify a different prototype.
7318        ///
7319        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct)
7320        #[cfg(not(js_sys_unstable_apis))]
7321        #[wasm_bindgen(js_namespace = Reflect, catch)]
7322        pub fn construct<T: JsFunction = fn() -> JsValue>(
7323            target: &Function<T>,
7324            arguments_list: &Array,
7325        ) -> Result<JsValue, JsValue>;
7326
7327        /// The static `Reflect.construct()` method acts like the new operator, but
7328        /// as a function.  It is equivalent to calling `new target(...args)`. It
7329        /// gives also the added option to specify a different prototype.
7330        ///
7331        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct)
7332        #[cfg(js_sys_unstable_apis)]
7333        #[wasm_bindgen(js_namespace = Reflect, catch)]
7334        pub fn construct<T: JsFunction = fn() -> JsValue>(
7335            target: &Function<T>,
7336            arguments_list: &ArrayTuple, // DOTO: <A1, A2, A3, A4, A5, A6, A7, A8>,
7337        ) -> Result<JsValue, JsValue>;
7338
7339        /// The static `Reflect.construct()` method acts like the new operator, but
7340        /// as a function.  It is equivalent to calling `new target(...args)`. It
7341        /// gives also the added option to specify a different prototype.
7342        ///
7343        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct)
7344        #[wasm_bindgen(js_namespace = Reflect, js_name = construct, catch)]
7345        pub fn construct_with_new_target(
7346            target: &Function,
7347            arguments_list: &Array,
7348            new_target: &Function,
7349        ) -> Result<JsValue, JsValue>;
7350
7351        /// The static `Reflect.defineProperty()` method is like
7352        /// `Object.defineProperty()` but returns a `Boolean`.
7353        ///
7354        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty)
7355        #[cfg(not(js_sys_unstable_apis))]
7356        #[wasm_bindgen(js_namespace = Reflect, js_name = defineProperty, catch)]
7357        pub fn define_property<T>(
7358            target: &Object<T>,
7359            property_key: &JsValue,
7360            attributes: &Object,
7361        ) -> Result<bool, JsValue>;
7362
7363        /// The static `Reflect.defineProperty()` method is like
7364        /// `Object.defineProperty()` but returns a `Boolean`.
7365        ///
7366        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty)
7367        #[cfg(js_sys_unstable_apis)]
7368        #[wasm_bindgen(js_namespace = Reflect, js_name = defineProperty, catch)]
7369        pub fn define_property<T>(
7370            target: &Object<T>,
7371            property_key: &JsValue,
7372            attributes: &PropertyDescriptor<T>,
7373        ) -> Result<bool, JsValue>;
7374
7375        /// The static `Reflect.defineProperty()` method is like
7376        /// `Object.defineProperty()` but returns a `Boolean`.
7377        ///
7378        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty)
7379        #[wasm_bindgen(js_namespace = Reflect, js_name = defineProperty, catch)]
7380        pub fn define_property_str<T>(
7381            target: &Object<T>,
7382            property_key: &JsString,
7383            attributes: &PropertyDescriptor<T>,
7384        ) -> Result<bool, JsValue>;
7385
7386        /// The static `Reflect.deleteProperty()` method allows to delete
7387        /// properties.  It is like the `delete` operator as a function.
7388        ///
7389        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/deleteProperty)
7390        #[wasm_bindgen(js_namespace = Reflect, js_name = deleteProperty, catch)]
7391        pub fn delete_property<T>(target: &Object<T>, key: &JsValue) -> Result<bool, JsValue>;
7392
7393        /// The static `Reflect.deleteProperty()` method allows to delete
7394        /// properties.  It is like the `delete` operator as a function.
7395        ///
7396        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/deleteProperty)
7397        #[wasm_bindgen(js_namespace = Reflect, js_name = deleteProperty, catch)]
7398        pub fn delete_property_str<T>(target: &Object<T>, key: &JsString) -> Result<bool, JsValue>;
7399
7400        /// The static `Reflect.get()` method works like getting a property from
7401        /// an object (`target[propertyKey]`) as a function.
7402        ///
7403        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get)
7404        #[cfg(not(js_sys_unstable_apis))]
7405        #[wasm_bindgen(js_namespace = Reflect, catch)]
7406        pub fn get(target: &JsValue, key: &JsValue) -> Result<JsValue, JsValue>;
7407
7408        /// The static `Reflect.get()` method works like getting a property from
7409        /// an object (`target[propertyKey]`) as a function.
7410        ///
7411        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get)
7412        #[cfg(js_sys_unstable_apis)]
7413        #[wasm_bindgen(js_namespace = Reflect, catch)]
7414        pub fn get<T>(target: &Object<T>, key: &JsString) -> Result<Option<T>, JsValue>;
7415
7416        /// The static `Reflect.get()` method works like getting a property from
7417        /// an object (`target[propertyKey]`) as a function.
7418        ///
7419        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get)
7420        #[wasm_bindgen(js_namespace = Reflect, js_name = get, catch)]
7421        pub fn get_str<T>(target: &Object<T>, key: &JsString) -> Result<Option<T>, JsValue>;
7422
7423        /// The static `Reflect.get()` method works like getting a property from
7424        /// an object (`target[propertyKey]`) as a function.
7425        ///
7426        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get)
7427        #[wasm_bindgen(js_namespace = Reflect, js_name = get, catch)]
7428        pub fn get_symbol<T>(target: &Object<T>, key: &Symbol) -> Result<JsValue, JsValue>;
7429
7430        /// The same as [`get`](fn.get.html)
7431        /// except the key is an `f64`, which is slightly faster.
7432        #[wasm_bindgen(js_namespace = Reflect, js_name = get, catch)]
7433        pub fn get_f64(target: &JsValue, key: f64) -> Result<JsValue, JsValue>;
7434
7435        /// The same as [`get`](fn.get.html)
7436        /// except the key is a `u32`, which is slightly faster.
7437        #[wasm_bindgen(js_namespace = Reflect, js_name = get, catch)]
7438        pub fn get_u32(target: &JsValue, key: u32) -> Result<JsValue, JsValue>;
7439
7440        /// The static `Reflect.getOwnPropertyDescriptor()` method is similar to
7441        /// `Object.getOwnPropertyDescriptor()`. It returns a property descriptor
7442        /// of the given property if it exists on the object, `undefined` otherwise.
7443        ///
7444        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getOwnPropertyDescriptor)
7445        #[wasm_bindgen(js_namespace = Reflect, js_name = getOwnPropertyDescriptor, catch)]
7446        pub fn get_own_property_descriptor<T>(
7447            target: &Object<T>,
7448            property_key: &JsValue,
7449        ) -> Result<JsValue, JsValue>;
7450
7451        /// The static `Reflect.getOwnPropertyDescriptor()` method is similar to
7452        /// `Object.getOwnPropertyDescriptor()`. It returns a property descriptor
7453        /// of the given property if it exists on the object, `undefined` otherwise.
7454        ///
7455        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getOwnPropertyDescriptor)
7456        #[wasm_bindgen(js_namespace = Reflect, js_name = getOwnPropertyDescriptor, catch)]
7457        pub fn get_own_property_descriptor_str<T>(
7458            target: &Object<T>,
7459            property_key: &JsString,
7460        ) -> Result<PropertyDescriptor<T>, JsValue>;
7461
7462        /// The static `Reflect.getPrototypeOf()` method is almost the same
7463        /// method as `Object.getPrototypeOf()`. It returns the prototype
7464        /// (i.e. the value of the internal `[[Prototype]]` property) of
7465        /// the specified object.
7466        ///
7467        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getPrototypeOf)
7468        #[cfg(not(js_sys_unstable_apis))]
7469        #[wasm_bindgen(js_namespace = Reflect, js_name = getPrototypeOf, catch)]
7470        pub fn get_prototype_of(target: &JsValue) -> Result<Object, JsValue>;
7471
7472        /// The static `Reflect.getPrototypeOf()` method is almost the same
7473        /// method as `Object.getPrototypeOf()`. It returns the prototype
7474        /// (i.e. the value of the internal `[[Prototype]]` property) of
7475        /// the specified object.
7476        ///
7477        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getPrototypeOf)
7478        #[cfg(js_sys_unstable_apis)]
7479        #[wasm_bindgen(js_namespace = Reflect, js_name = getPrototypeOf, catch)]
7480        pub fn get_prototype_of(target: &Object) -> Result<Object, JsValue>;
7481
7482        /// The static `Reflect.has()` method works like the in operator as a
7483        /// function.
7484        ///
7485        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has)
7486        #[cfg(not(js_sys_unstable_apis))]
7487        #[wasm_bindgen(js_namespace = Reflect, catch)]
7488        pub fn has(target: &JsValue, property_key: &JsValue) -> Result<bool, JsValue>;
7489
7490        /// The static `Reflect.has()` method works like the in operator as a
7491        /// function.
7492        ///
7493        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has)
7494        #[cfg(js_sys_unstable_apis)]
7495        #[wasm_bindgen(js_namespace = Reflect, catch)]
7496        pub fn has(target: &JsValue, property_key: &Symbol) -> Result<bool, JsValue>;
7497
7498        // Next major: deprecate
7499        /// The static `Reflect.has()` method works like the in operator as a
7500        /// function.
7501        ///
7502        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has)
7503        #[wasm_bindgen(js_namespace = Reflect, js_name = has, catch)]
7504        pub fn has_str<T>(target: &Object<T>, property_key: &JsString) -> Result<bool, JsValue>;
7505
7506        /// The static `Reflect.has()` method works like the in operator as a
7507        /// function.
7508        ///
7509        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has)
7510        #[wasm_bindgen(js_namespace = Reflect, js_name = has, catch)]
7511        pub fn has_symbol<T>(target: &Object<T>, property_key: &Symbol) -> Result<bool, JsValue>;
7512
7513        /// The static `Reflect.isExtensible()` method determines if an object is
7514        /// extensible (whether it can have new properties added to it). It is
7515        /// similar to `Object.isExtensible()`, but with some differences.
7516        ///
7517        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/isExtensible)
7518        #[wasm_bindgen(js_namespace = Reflect, js_name = isExtensible, catch)]
7519        pub fn is_extensible<T>(target: &Object<T>) -> Result<bool, JsValue>;
7520
7521        /// The static `Reflect.ownKeys()` method returns an array of the
7522        /// target object's own property keys.
7523        ///
7524        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/ownKeys)
7525        #[wasm_bindgen(js_namespace = Reflect, js_name = ownKeys, catch)]
7526        pub fn own_keys(target: &JsValue) -> Result<Array, JsValue>;
7527
7528        /// The static `Reflect.preventExtensions()` method prevents new
7529        /// properties from ever being added to an object (i.e. prevents
7530        /// future extensions to the object). It is similar to
7531        /// `Object.preventExtensions()`, but with some differences.
7532        ///
7533        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/preventExtensions)
7534        #[wasm_bindgen(js_namespace = Reflect, js_name = preventExtensions, catch)]
7535        pub fn prevent_extensions<T>(target: &Object<T>) -> Result<bool, JsValue>;
7536
7537        /// The static `Reflect.set()` method works like setting a
7538        /// property on an object.
7539        ///
7540        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
7541        #[cfg(not(js_sys_unstable_apis))]
7542        #[wasm_bindgen(js_namespace = Reflect, catch)]
7543        pub fn set(
7544            target: &JsValue,
7545            property_key: &JsValue,
7546            value: &JsValue,
7547        ) -> Result<bool, JsValue>;
7548
7549        /// The static `Reflect.set()` method works like setting a
7550        /// property on an object.
7551        ///
7552        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
7553        #[cfg(js_sys_unstable_apis)]
7554        #[wasm_bindgen(js_namespace = Reflect, catch)]
7555        pub fn set<T>(
7556            target: &Object<T>,
7557            property_key: &JsString,
7558            value: &T,
7559        ) -> Result<bool, JsValue>;
7560
7561        /// The static `Reflect.set()` method works like setting a
7562        /// property on an object.
7563        ///
7564        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
7565        #[cfg(js_sys_unstable_apis)]
7566        #[wasm_bindgen(js_namespace = Reflect, catch)]
7567        pub fn set_symbol<T>(
7568            target: &Object<T>,
7569            property_key: &Symbol,
7570            value: &JsValue,
7571        ) -> Result<bool, JsValue>;
7572
7573        // Next major: deprecate
7574        /// The static `Reflect.set()` method works like setting a
7575        /// property on an object.
7576        ///
7577        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
7578        #[wasm_bindgen(js_namespace = Reflect, js_name = set, catch)]
7579        pub fn set_str<T>(
7580            target: &Object<T>,
7581            property_key: &JsString,
7582            value: &T,
7583        ) -> Result<bool, JsValue>;
7584
7585        /// The same as [`set`](fn.set.html)
7586        /// except the key is an `f64`, which is slightly faster.
7587        #[wasm_bindgen(js_namespace = Reflect, js_name = set, catch)]
7588        pub fn set_f64(
7589            target: &JsValue,
7590            property_key: f64,
7591            value: &JsValue,
7592        ) -> Result<bool, JsValue>;
7593
7594        /// The same as [`set`](fn.set.html)
7595        /// except the key is a `u32`, which is slightly faster.
7596        #[wasm_bindgen(js_namespace = Reflect, js_name = set, catch)]
7597        pub fn set_u32(
7598            target: &JsValue,
7599            property_key: u32,
7600            value: &JsValue,
7601        ) -> Result<bool, JsValue>;
7602
7603        /// The static `Reflect.set()` method works like setting a
7604        /// property on an object.
7605        ///
7606        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
7607        #[wasm_bindgen(js_namespace = Reflect, js_name = set, catch)]
7608        pub fn set_with_receiver(
7609            target: &JsValue,
7610            property_key: &JsValue,
7611            value: &JsValue,
7612            receiver: &JsValue,
7613        ) -> Result<bool, JsValue>;
7614
7615        /// The static `Reflect.setPrototypeOf()` method is the same
7616        /// method as `Object.setPrototypeOf()`. It sets the prototype
7617        /// (i.e., the internal `[[Prototype]]` property) of a specified
7618        /// object to another object or to null.
7619        ///
7620        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/setPrototypeOf)
7621        #[wasm_bindgen(js_namespace = Reflect, js_name = setPrototypeOf, catch)]
7622        pub fn set_prototype_of<T>(
7623            target: &Object<T>,
7624            prototype: &JsValue,
7625        ) -> Result<bool, JsValue>;
7626    }
7627}
7628
7629// RegExp
7630#[wasm_bindgen]
7631extern "C" {
7632    #[wasm_bindgen(extends = Object, typescript_type = "RegExp")]
7633    #[derive(Clone, Debug, PartialEq, Eq)]
7634    pub type RegExp;
7635
7636    /// The `exec()` method executes a search for a match in a specified
7637    /// string. Returns a result array, or null.
7638    ///
7639    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec)
7640    #[cfg(not(js_sys_unstable_apis))]
7641    #[wasm_bindgen(method)]
7642    pub fn exec(this: &RegExp, text: &str) -> Option<Array<JsString>>;
7643
7644    /// The `exec()` method executes a search for a match in a specified
7645    /// string. Returns a result array, or null.
7646    ///
7647    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec)
7648    #[cfg(js_sys_unstable_apis)]
7649    #[wasm_bindgen(method)]
7650    pub fn exec(this: &RegExp, text: &str) -> Option<RegExpMatchArray>;
7651
7652    /// The flags property returns a string consisting of the flags of
7653    /// the current regular expression object.
7654    ///
7655    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/flags)
7656    #[wasm_bindgen(method, getter)]
7657    pub fn flags(this: &RegExp) -> JsString;
7658
7659    /// The global property indicates whether or not the "g" flag is
7660    /// used with the regular expression. global is a read-only
7661    /// property of an individual regular expression instance.
7662    ///
7663    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/global)
7664    #[wasm_bindgen(method, getter)]
7665    pub fn global(this: &RegExp) -> bool;
7666
7667    /// The ignoreCase property indicates whether or not the "i" flag
7668    /// is used with the regular expression. ignoreCase is a read-only
7669    /// property of an individual regular expression instance.
7670    ///
7671    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/ignoreCase)
7672    #[wasm_bindgen(method, getter, js_name = ignoreCase)]
7673    pub fn ignore_case(this: &RegExp) -> bool;
7674
7675    /// The non-standard input property is a static property of
7676    /// regular expressions that contains the string against which a
7677    /// regular expression is matched. RegExp.$_ is an alias for this
7678    /// property.
7679    ///
7680    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/input)
7681    #[wasm_bindgen(static_method_of = RegExp, getter)]
7682    pub fn input() -> JsString;
7683
7684    /// The lastIndex is a read/write integer property of regular expression
7685    /// instances that specifies the index at which to start the next match.
7686    ///
7687    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex)
7688    #[wasm_bindgen(structural, getter = lastIndex, method)]
7689    pub fn last_index(this: &RegExp) -> u32;
7690
7691    /// The lastIndex is a read/write integer property of regular expression
7692    /// instances that specifies the index at which to start the next match.
7693    ///
7694    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex)
7695    #[wasm_bindgen(structural, setter = lastIndex, method)]
7696    pub fn set_last_index(this: &RegExp, index: u32);
7697
7698    /// The non-standard lastMatch property is a static and read-only
7699    /// property of regular expressions that contains the last matched
7700    /// characters. `RegExp.$&` is an alias for this property.
7701    ///
7702    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastMatch)
7703    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = lastMatch)]
7704    pub fn last_match() -> JsString;
7705
7706    /// The non-standard lastParen property is a static and read-only
7707    /// property of regular expressions that contains the last
7708    /// parenthesized substring match, if any. `RegExp.$+` is an alias
7709    /// for this property.
7710    ///
7711    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastParen)
7712    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = lastParen)]
7713    pub fn last_paren() -> JsString;
7714
7715    /// The non-standard leftContext property is a static and
7716    /// read-only property of regular expressions that contains the
7717    /// substring preceding the most recent match. `RegExp.$`` is an
7718    /// alias for this property.
7719    ///
7720    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/leftContext)
7721    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = leftContext)]
7722    pub fn left_context() -> JsString;
7723
7724    /// The multiline property indicates whether or not the "m" flag
7725    /// is used with the regular expression. multiline is a read-only
7726    /// property of an individual regular expression instance.
7727    ///
7728    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/multiline)
7729    #[wasm_bindgen(method, getter)]
7730    pub fn multiline(this: &RegExp) -> bool;
7731
7732    /// The non-standard $1, $2, $3, $4, $5, $6, $7, $8, $9 properties
7733    /// are static and read-only properties of regular expressions
7734    /// that contain parenthesized substring matches.
7735    ///
7736    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/n)
7737    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$1")]
7738    pub fn n1() -> JsString;
7739    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$2")]
7740    pub fn n2() -> JsString;
7741    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$3")]
7742    pub fn n3() -> JsString;
7743    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$4")]
7744    pub fn n4() -> JsString;
7745    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$5")]
7746    pub fn n5() -> JsString;
7747    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$6")]
7748    pub fn n6() -> JsString;
7749    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$7")]
7750    pub fn n7() -> JsString;
7751    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$8")]
7752    pub fn n8() -> JsString;
7753    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$9")]
7754    pub fn n9() -> JsString;
7755
7756    /// The `RegExp` constructor creates a regular expression object for matching text with a pattern.
7757    ///
7758    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp)
7759    #[wasm_bindgen(constructor)]
7760    pub fn new(pattern: &str, flags: &str) -> RegExp;
7761    #[wasm_bindgen(constructor)]
7762    pub fn new_regexp(pattern: &RegExp, flags: &str) -> RegExp;
7763
7764    /// The non-standard rightContext property is a static and
7765    /// read-only property of regular expressions that contains the
7766    /// substring following the most recent match. `RegExp.$'` is an
7767    /// alias for this property.
7768    ///
7769    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/rightContext)
7770    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = rightContext)]
7771    pub fn right_context() -> JsString;
7772
7773    /// The source property returns a String containing the source
7774    /// text of the regexp object, and it doesn't contain the two
7775    /// forward slashes on both sides and any flags.
7776    ///
7777    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/source)
7778    #[wasm_bindgen(method, getter)]
7779    pub fn source(this: &RegExp) -> JsString;
7780
7781    /// The sticky property reflects whether or not the search is
7782    /// sticky (searches in strings only from the index indicated by
7783    /// the lastIndex property of this regular expression). sticky is
7784    /// a read-only property of an individual regular expression
7785    /// object.
7786    ///
7787    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/sticky)
7788    #[wasm_bindgen(method, getter)]
7789    pub fn sticky(this: &RegExp) -> bool;
7790
7791    /// The `test()` method executes a search for a match between a
7792    /// regular expression and a specified string. Returns true or
7793    /// false.
7794    ///
7795    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)
7796    #[wasm_bindgen(method)]
7797    pub fn test(this: &RegExp, text: &str) -> bool;
7798
7799    /// The `toString()` method returns a string representing the
7800    /// regular expression.
7801    ///
7802    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/toString)
7803    #[cfg(not(js_sys_unstable_apis))]
7804    #[wasm_bindgen(method, js_name = toString)]
7805    pub fn to_string(this: &RegExp) -> JsString;
7806
7807    /// The unicode property indicates whether or not the "u" flag is
7808    /// used with a regular expression. unicode is a read-only
7809    /// property of an individual regular expression instance.
7810    ///
7811    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode)
7812    #[wasm_bindgen(method, getter)]
7813    pub fn unicode(this: &RegExp) -> bool;
7814}
7815
7816// RegExpMatchArray
7817#[wasm_bindgen]
7818extern "C" {
7819    /// The result array from `RegExp.exec()` or `String.matchAll()`.
7820    ///
7821    /// This is an array of strings with additional properties `index`, `input`, and `groups`.
7822    ///
7823    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec#return_value)
7824    #[wasm_bindgen(extends = Object, extends = Array, typescript_type = "RegExpMatchArray")]
7825    #[derive(Clone, Debug, PartialEq, Eq)]
7826    pub type RegExpMatchArray;
7827
7828    /// The 0-based index of the match in the string.
7829    #[wasm_bindgen(method, getter)]
7830    pub fn index(this: &RegExpMatchArray) -> u32;
7831
7832    /// The original string that was matched against.
7833    #[wasm_bindgen(method, getter)]
7834    pub fn input(this: &RegExpMatchArray) -> JsString;
7835
7836    /// An object of named capturing groups whose keys are the names and valuestype Array
7837    /// are the capturing groups, or `undefined` if no named capturing groups were defined.
7838    #[wasm_bindgen(method, getter)]
7839    pub fn groups(this: &RegExpMatchArray) -> Option<Object>;
7840
7841    /// The number of elements in the match array (full match + capture groups).
7842    #[wasm_bindgen(method, getter)]
7843    pub fn length(this: &RegExpMatchArray) -> u32;
7844
7845    /// Gets the matched string or capture group at the given index.
7846    /// Index 0 is the full match, indices 1+ are capture groups.
7847    #[wasm_bindgen(method, indexing_getter)]
7848    pub fn get(this: &RegExpMatchArray, index: u32) -> Option<JsString>;
7849}
7850
7851// Set
7852#[wasm_bindgen]
7853extern "C" {
7854    #[wasm_bindgen(extends = Object, typescript_type = "Set<any>")]
7855    #[derive(Clone, Debug, PartialEq, Eq)]
7856    pub type Set<T = JsValue>;
7857
7858    /// The [`Set`] object lets you store unique values of any type, whether
7859    /// primitive values or object references.
7860    ///
7861    /// **Note:** Consider using [`Set::new_typed`] to support typing.
7862    ///
7863    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
7864    #[cfg(not(js_sys_unstable_apis))]
7865    #[wasm_bindgen(constructor)]
7866    pub fn new(init: &JsValue) -> Set;
7867
7868    /// The [`Set`] object lets you store unique values of any type, whether
7869    /// primitive values or object references.
7870    ///
7871    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
7872    #[cfg(js_sys_unstable_apis)]
7873    #[wasm_bindgen(constructor)]
7874    pub fn new<T>() -> Set<T>;
7875
7876    // Next major: deprecate
7877    /// The [`Set`] object lets you store unique values of any type, whether
7878    /// primitive values or object references.
7879    ///
7880    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
7881    #[wasm_bindgen(constructor)]
7882    pub fn new_typed<T>() -> Set<T>;
7883
7884    /// The [`Set`] object lets you store unique values of any type, whether
7885    /// primitive values or object references.
7886    ///
7887    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
7888    #[wasm_bindgen(constructor, js_name = new)]
7889    pub fn new_empty<T>() -> Set<T>;
7890
7891    /// The [`Set`] object lets you store unique values of any type, whether
7892    /// primitive values or object references.
7893    ///
7894    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
7895    #[wasm_bindgen(constructor, js_name = new)]
7896    pub fn new_from_items<T>(items: &[T]) -> Set<T>;
7897
7898    /// The [`Set`] object lets you store unique values of any type, whether
7899    /// primitive values or object references.
7900    ///
7901    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
7902    #[wasm_bindgen(constructor, js_name = new, catch)]
7903    pub fn new_from_iterable<T, I: Iterable<Item = T>>(iterable: I) -> Result<Set<T>, JsValue>;
7904
7905    /// The `add()` method appends a new element with a specified value to the
7906    /// end of a [`Set`] object.
7907    ///
7908    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/add)
7909    #[wasm_bindgen(method)]
7910    pub fn add<T>(this: &Set<T>, value: &T) -> Set<T>;
7911
7912    /// The `clear()` method removes all elements from a [`Set`] object.
7913    ///
7914    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/clear)
7915    #[wasm_bindgen(method)]
7916    pub fn clear<T>(this: &Set<T>);
7917
7918    /// The `delete()` method removes the specified element from a [`Set`]
7919    /// object.
7920    ///
7921    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/delete)
7922    #[wasm_bindgen(method)]
7923    pub fn delete<T>(this: &Set<T>, value: &T) -> bool;
7924
7925    /// The `forEach()` method executes a provided function once for each value
7926    /// in the Set object, in insertion order.
7927    ///
7928    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/forEach)
7929    #[cfg(not(js_sys_unstable_apis))]
7930    #[wasm_bindgen(method, js_name = forEach)]
7931    pub fn for_each<T>(this: &Set<T>, callback: &mut dyn FnMut(T, T, Set<T>));
7932
7933    /// The `forEach()` method executes a provided function once for each value
7934    /// in the Set object, in insertion order.
7935    ///
7936    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/forEach)
7937    #[cfg(js_sys_unstable_apis)]
7938    #[wasm_bindgen(method, js_name = forEach)]
7939    pub fn for_each<T>(this: &Set<T>, callback: &mut dyn FnMut(T));
7940
7941    /// The `forEach()` method executes a provided function once for each value
7942    /// in the Set object, in insertion order.
7943    ///
7944    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/forEach)
7945    #[wasm_bindgen(method, js_name = forEach, catch)]
7946    pub fn try_for_each<T>(
7947        this: &Set<T>,
7948        callback: &mut dyn FnMut(T) -> Result<(), JsError>,
7949    ) -> Result<(), JsValue>;
7950
7951    /// The `has()` method returns a boolean indicating whether an element with
7952    /// the specified value exists in a [`Set`] object or not.
7953    ///
7954    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/has)
7955    #[wasm_bindgen(method)]
7956    pub fn has<T>(this: &Set<T>, value: &T) -> bool;
7957
7958    /// The size accessor property returns the number of elements in a [`Set`]
7959    /// object.
7960    ///
7961    /// [MDN documentation](https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Set/size)
7962    #[wasm_bindgen(method, getter)]
7963    pub fn size<T>(this: &Set<T>) -> u32;
7964
7965    /// The `union()` method returns a new set containing elements which are in
7966    /// either or both of this set and the given set.
7967    ///
7968    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/union)
7969    #[wasm_bindgen(method)]
7970    pub fn union<T>(this: &Set<T>, other: &Set<T>) -> Set<T>;
7971
7972    /// The `intersection()` method returns a new set containing elements which are
7973    /// in both this set and the given set.
7974    ///
7975    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/intersection)
7976    #[wasm_bindgen(method)]
7977    pub fn intersection<T>(this: &Set<T>, other: &Set<T>) -> Set<T>;
7978
7979    /// The `difference()` method returns a new set containing elements which are
7980    /// in this set but not in the given set.
7981    ///
7982    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/difference)
7983    #[wasm_bindgen(method)]
7984    pub fn difference<T>(this: &Set<T>, other: &Set<T>) -> Set<T>;
7985
7986    /// The `symmetricDifference()` method returns a new set containing elements
7987    /// which are in either this set or the given set, but not in both.
7988    ///
7989    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/symmetricDifference)
7990    #[wasm_bindgen(method, js_name = symmetricDifference)]
7991    pub fn symmetric_difference<T>(this: &Set<T>, other: &Set<T>) -> Set<T>;
7992
7993    /// The `isSubsetOf()` method returns a boolean indicating whether all elements
7994    /// of this set are in the given set.
7995    ///
7996    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/isSubsetOf)
7997    #[wasm_bindgen(method, js_name = isSubsetOf)]
7998    pub fn is_subset_of<T>(this: &Set<T>, other: &Set<T>) -> bool;
7999
8000    /// The `isSupersetOf()` method returns a boolean indicating whether all elements
8001    /// of the given set are in this set.
8002    ///
8003    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/isSupersetOf)
8004    #[wasm_bindgen(method, js_name = isSupersetOf)]
8005    pub fn is_superset_of<T>(this: &Set<T>, other: &Set<T>) -> bool;
8006
8007    /// The `isDisjointFrom()` method returns a boolean indicating whether this set
8008    /// has no elements in common with the given set.
8009    ///
8010    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/isDisjointFrom)
8011    #[wasm_bindgen(method, js_name = isDisjointFrom)]
8012    pub fn is_disjoint_from<T>(this: &Set<T>, other: &Set<T>) -> bool;
8013}
8014
8015impl Default for Set<JsValue> {
8016    fn default() -> Self {
8017        Self::new_typed()
8018    }
8019}
8020
8021impl<T> Iterable for Set<T> {
8022    type Item = T;
8023}
8024
8025// SetIterator
8026#[wasm_bindgen]
8027extern "C" {
8028    /// The `entries()` method returns a new Iterator object that contains an
8029    /// array of [value, value] for each element in the Set object, in insertion
8030    /// order. For Set objects there is no key like in Map objects. However, to
8031    /// keep the API similar to the Map object, each entry has the same value
8032    /// for its key and value here, so that an array [value, value] is returned.
8033    ///
8034    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/entries)
8035    #[cfg(not(js_sys_unstable_apis))]
8036    #[wasm_bindgen(method)]
8037    pub fn entries<T>(set: &Set<T>) -> Iterator;
8038
8039    /// The `entries()` method returns a new Iterator object that contains an
8040    /// array of [value, value] for each element in the Set object, in insertion
8041    /// order. For Set objects there is no key like in Map objects. However, to
8042    /// keep the API similar to the Map object, each entry has the same value
8043    /// for its key and value here, so that an array [value, value] is returned.
8044    ///
8045    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/entries)
8046    #[cfg(js_sys_unstable_apis)]
8047    #[wasm_bindgen(method, js_name = entries)]
8048    pub fn entries<T: JsGeneric>(set: &Set<T>) -> Iterator<ArrayTuple<(T, T)>>;
8049
8050    // Next major: deprecate
8051    /// The `entries()` method returns a new Iterator object that contains an
8052    /// array of [value, value] for each element in the Set object, in insertion
8053    /// order. For Set objects there is no key like in Map objects. However, to
8054    /// keep the API similar to the Map object, each entry has the same value
8055    /// for its key and value here, so that an array [value, value] is returned.
8056    ///
8057    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/entries)
8058    #[wasm_bindgen(method, js_name = entries)]
8059    pub fn entries_typed<T: JsGeneric>(set: &Set<T>) -> Iterator<ArrayTuple<(T, T)>>;
8060
8061    /// The `keys()` method is an alias for this method (for similarity with
8062    /// Map objects); it behaves exactly the same and returns values
8063    /// of Set elements.
8064    ///
8065    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/values)
8066    #[wasm_bindgen(method)]
8067    pub fn keys<T>(set: &Set<T>) -> Iterator<T>;
8068
8069    /// The `values()` method returns a new Iterator object that contains the
8070    /// values for each element in the Set object in insertion order.
8071    ///
8072    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/values)
8073    #[wasm_bindgen(method)]
8074    pub fn values<T>(set: &Set<T>) -> Iterator<T>;
8075}
8076
8077// SyntaxError
8078#[wasm_bindgen]
8079extern "C" {
8080    /// A `SyntaxError` is thrown when the JavaScript engine encounters tokens or
8081    /// token order that does not conform to the syntax of the language when
8082    /// parsing code.
8083    ///
8084    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError)
8085    #[wasm_bindgen(extends = Error, extends = Object, typescript_type = "SyntaxError")]
8086    #[derive(Clone, Debug, PartialEq, Eq)]
8087    pub type SyntaxError;
8088
8089    /// A `SyntaxError` is thrown when the JavaScript engine encounters tokens or
8090    /// token order that does not conform to the syntax of the language when
8091    /// parsing code.
8092    ///
8093    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError)
8094    #[wasm_bindgen(constructor)]
8095    pub fn new(message: &str) -> SyntaxError;
8096}
8097
8098// TypeError
8099#[wasm_bindgen]
8100extern "C" {
8101    /// The `TypeError` object represents an error when a value is not of the
8102    /// expected type.
8103    ///
8104    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError)
8105    #[wasm_bindgen(extends = Error, extends = Object, typescript_type = "TypeError")]
8106    #[derive(Clone, Debug, PartialEq, Eq)]
8107    pub type TypeError;
8108
8109    /// The `TypeError` object represents an error when a value is not of the
8110    /// expected type.
8111    ///
8112    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError)
8113    #[wasm_bindgen(constructor)]
8114    pub fn new(message: &str) -> TypeError;
8115}
8116
8117// URIError
8118#[wasm_bindgen]
8119extern "C" {
8120    /// The `URIError` object represents an error when a global URI handling
8121    /// function was used in a wrong way.
8122    ///
8123    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError)
8124    #[wasm_bindgen(extends = Error, extends = Object, js_name = URIError, typescript_type = "URIError")]
8125    #[derive(Clone, Debug, PartialEq, Eq)]
8126    pub type UriError;
8127
8128    /// The `URIError` object represents an error when a global URI handling
8129    /// function was used in a wrong way.
8130    ///
8131    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError)
8132    #[wasm_bindgen(constructor, js_class = "URIError")]
8133    pub fn new(message: &str) -> UriError;
8134}
8135
8136// WeakMap
8137#[wasm_bindgen]
8138extern "C" {
8139    #[wasm_bindgen(extends = Object, typescript_type = "WeakMap<object, any>")]
8140    #[derive(Clone, Debug, PartialEq, Eq)]
8141    pub type WeakMap<K = Object, V = JsValue>;
8142
8143    /// The [`WeakMap`] object is a collection of key/value pairs in which the
8144    /// keys are weakly referenced.  The keys must be objects and the values can
8145    /// be arbitrary values.
8146    ///
8147    /// **Note:** Consider using [`WeakMap::new_typed`] to support typing.
8148    ///
8149    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap)
8150    #[cfg(not(js_sys_unstable_apis))]
8151    #[wasm_bindgen(constructor)]
8152    pub fn new() -> WeakMap;
8153
8154    /// The [`WeakMap`] object is a collection of key/value pairs in which the
8155    /// keys are weakly referenced.  The keys must be objects and the values can
8156    /// be arbitrary values.
8157    ///
8158    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap)
8159    #[cfg(js_sys_unstable_apis)]
8160    #[wasm_bindgen(constructor)]
8161    pub fn new<K: JsGeneric = Object, V: JsGeneric = Object>() -> WeakMap<K, V>;
8162
8163    // Next major: deprecate
8164    /// The [`WeakMap`] object is a collection of key/value pairs in which the
8165    /// keys are weakly referenced.  The keys must be objects and the values can
8166    /// be arbitrary values.
8167    ///
8168    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap)
8169    #[wasm_bindgen(constructor)]
8170    pub fn new_typed<K: JsGeneric = Object, V: JsGeneric = Object>() -> WeakMap<K, V>;
8171
8172    /// The `set()` method sets the value for the key in the [`WeakMap`] object.
8173    /// Returns the [`WeakMap`] object.
8174    ///
8175    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/set)
8176    #[wasm_bindgen(method, js_class = "WeakMap")]
8177    pub fn set<K, V>(this: &WeakMap<K, V>, key: &K, value: &V) -> WeakMap<K, V>;
8178
8179    /// The `get()` method returns a specified by key element
8180    /// from a [`WeakMap`] object. Returns `undefined` if the key is not found.
8181    ///
8182    /// **Note:** Consider using [`WeakMap::get_checked`] to get an `Option<V>` instead.
8183    ///
8184    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/get)
8185    #[cfg(not(js_sys_unstable_apis))]
8186    #[wasm_bindgen(method)]
8187    pub fn get<K, V>(this: &WeakMap<K, V>, key: &K) -> V;
8188
8189    /// The `get()` method returns a specified by key element
8190    /// from a [`WeakMap`] object. Returns `None` if the key is not found.
8191    ///
8192    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/get)
8193    #[cfg(js_sys_unstable_apis)]
8194    #[wasm_bindgen(method)]
8195    pub fn get<K, V>(this: &WeakMap<K, V>, key: &K) -> Option<V>;
8196
8197    /// The `get()` method returns a specified by key element
8198    /// from a [`WeakMap`] object. Returns `None` if the key is not found.
8199    ///
8200    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/get)
8201    #[wasm_bindgen(method, js_name = get)]
8202    pub fn get_checked<K, V>(this: &WeakMap<K, V>, key: &K) -> Option<V>;
8203
8204    /// The `has()` method returns a boolean indicating whether an element with
8205    /// the specified key exists in the [`WeakMap`] object or not.
8206    ///
8207    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/has)
8208    #[wasm_bindgen(method)]
8209    pub fn has<K, V>(this: &WeakMap<K, V>, key: &K) -> bool;
8210
8211    /// The `delete()` method removes the specified element from a [`WeakMap`]
8212    /// object.
8213    ///
8214    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/delete)
8215    #[wasm_bindgen(method)]
8216    pub fn delete<K, V>(this: &WeakMap<K, V>, key: &K) -> bool;
8217}
8218
8219impl Default for WeakMap {
8220    fn default() -> Self {
8221        Self::new()
8222    }
8223}
8224
8225// WeakSet
8226#[wasm_bindgen]
8227extern "C" {
8228    #[wasm_bindgen(extends = Object, typescript_type = "WeakSet<object>")]
8229    #[derive(Clone, Debug, PartialEq, Eq)]
8230    pub type WeakSet<T = Object>;
8231
8232    /// The `WeakSet` object lets you store weakly held objects in a collection.
8233    ///
8234    /// **Note:** Consider using [`WeakSet::new_typed`] for typed sets.
8235    ///
8236    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet)
8237    #[cfg(not(js_sys_unstable_apis))]
8238    #[wasm_bindgen(constructor)]
8239    pub fn new() -> WeakSet;
8240
8241    /// The `WeakSet` object lets you store weakly held objects in a collection.
8242    ///
8243    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet)
8244    #[cfg(js_sys_unstable_apis)]
8245    #[wasm_bindgen(constructor)]
8246    pub fn new<T = Object>() -> WeakSet<T>;
8247
8248    // Next major: deprecate
8249    /// The `WeakSet` object lets you store weakly held objects in a collection.
8250    ///
8251    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet)
8252    #[wasm_bindgen(constructor)]
8253    pub fn new_typed<T = Object>() -> WeakSet<T>;
8254
8255    /// The `has()` method returns a boolean indicating whether an object exists
8256    /// in a WeakSet or not.
8257    ///
8258    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/has)
8259    #[wasm_bindgen(method)]
8260    pub fn has<T>(this: &WeakSet<T>, value: &T) -> bool;
8261
8262    /// The `add()` method appends a new object to the end of a WeakSet object.
8263    ///
8264    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/add)
8265    #[wasm_bindgen(method)]
8266    pub fn add<T>(this: &WeakSet<T>, value: &T) -> WeakSet<T>;
8267
8268    /// The `delete()` method removes the specified element from a WeakSet
8269    /// object.
8270    ///
8271    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/delete)
8272    #[wasm_bindgen(method)]
8273    pub fn delete<T>(this: &WeakSet<T>, value: &T) -> bool;
8274}
8275
8276impl Default for WeakSet {
8277    fn default() -> Self {
8278        Self::new()
8279    }
8280}
8281
8282// WeakRef
8283#[wasm_bindgen]
8284extern "C" {
8285    #[wasm_bindgen(extends = Object, typescript_type = "WeakRef<object>")]
8286    #[derive(Clone, Debug, PartialEq, Eq)]
8287    pub type WeakRef<T = Object>;
8288
8289    /// The `WeakRef` object contains a weak reference to an object. A weak
8290    /// reference to an object is a reference that does not prevent the object
8291    /// from being reclaimed by the garbage collector.
8292    ///
8293    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakRef)
8294    #[wasm_bindgen(constructor)]
8295    pub fn new<T = Object>(target: &T) -> WeakRef<T>;
8296
8297    /// Returns the `Object` this `WeakRef` points to, or `None` if the
8298    /// object has been garbage collected.
8299    ///
8300    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakRef/deref)
8301    #[wasm_bindgen(method)]
8302    pub fn deref<T>(this: &WeakRef<T>) -> Option<T>;
8303}
8304
8305#[cfg(js_sys_unstable_apis)]
8306#[allow(non_snake_case)]
8307pub mod Temporal;
8308
8309#[allow(non_snake_case)]
8310pub mod WebAssembly {
8311    use super::*;
8312
8313    // WebAssembly
8314    #[wasm_bindgen]
8315    extern "C" {
8316        /// The `WebAssembly.compile()` function compiles a `WebAssembly.Module`
8317        /// from WebAssembly binary code.  This function is useful if it is
8318        /// necessary to a compile a module before it can be instantiated
8319        /// (otherwise, the `WebAssembly.instantiate()` function should be used).
8320        ///
8321        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compile)
8322        #[cfg(not(js_sys_unstable_apis))]
8323        #[wasm_bindgen(js_namespace = WebAssembly)]
8324        pub fn compile(buffer_source: &JsValue) -> Promise<JsValue>;
8325
8326        /// The `WebAssembly.compile()` function compiles a `WebAssembly.Module`
8327        /// from WebAssembly binary code.  This function is useful if it is
8328        /// necessary to a compile a module before it can be instantiated
8329        /// (otherwise, the `WebAssembly.instantiate()` function should be used).
8330        ///
8331        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compile)
8332        #[cfg(js_sys_unstable_apis)]
8333        #[wasm_bindgen(js_namespace = WebAssembly)]
8334        pub fn compile(buffer_source: &JsValue) -> Promise<Module>;
8335
8336        /// The `WebAssembly.compileStreaming()` function compiles a
8337        /// `WebAssembly.Module` module directly from a streamed underlying
8338        /// source. This function is useful if it is necessary to a compile a
8339        /// module before it can be instantiated (otherwise, the
8340        /// `WebAssembly.instantiateStreaming()` function should be used).
8341        ///
8342        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming)
8343        #[cfg(not(js_sys_unstable_apis))]
8344        #[wasm_bindgen(js_namespace = WebAssembly, js_name = compileStreaming)]
8345        pub fn compile_streaming(response: &Promise) -> Promise<JsValue>;
8346
8347        /// The `WebAssembly.compileStreaming()` function compiles a
8348        /// `WebAssembly.Module` module directly from a streamed underlying
8349        /// source. This function is useful if it is necessary to a compile a
8350        /// module before it can be instantiated (otherwise, the
8351        /// `WebAssembly.instantiateStreaming()` function should be used).
8352        ///
8353        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming)
8354        #[cfg(js_sys_unstable_apis)]
8355        #[wasm_bindgen(js_namespace = WebAssembly, js_name = compileStreaming)]
8356        pub fn compile_streaming(response: &Promise) -> Promise<Module>;
8357
8358        /// The `WebAssembly.instantiate()` function allows you to compile and
8359        /// instantiate WebAssembly code.
8360        ///
8361        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate)
8362        #[cfg(not(js_sys_unstable_apis))]
8363        #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiate)]
8364        pub fn instantiate_buffer(buffer: &[u8], imports: &Object) -> Promise<JsValue>;
8365
8366        /// The `WebAssembly.instantiate()` function allows you to compile and
8367        /// instantiate WebAssembly code.
8368        ///
8369        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate)
8370        #[cfg(js_sys_unstable_apis)]
8371        #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiate)]
8372        pub fn instantiate_buffer(buffer: &[u8], imports: &Object) -> Promise<Instance>;
8373
8374        /// The `WebAssembly.instantiate()` function allows you to compile and
8375        /// instantiate WebAssembly code.
8376        ///
8377        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate)
8378        #[cfg(not(js_sys_unstable_apis))]
8379        #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiate)]
8380        pub fn instantiate_module(module: &Module, imports: &Object) -> Promise<JsValue>;
8381
8382        /// The `WebAssembly.instantiate()` function allows you to compile and
8383        /// instantiate WebAssembly code.
8384        ///
8385        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate)
8386        #[cfg(js_sys_unstable_apis)]
8387        #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiate)]
8388        pub fn instantiate_module(module: &Module, imports: &Object) -> Promise<Instance>;
8389
8390        /// The `WebAssembly.instantiateStreaming()` function compiles and
8391        /// instantiates a WebAssembly module directly from a streamed
8392        /// underlying source. This is the most efficient, optimized way to load
8393        /// Wasm code.
8394        ///
8395        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming)
8396        #[cfg(not(js_sys_unstable_apis))]
8397        #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiateStreaming)]
8398        pub fn instantiate_streaming(response: &JsValue, imports: &Object) -> Promise<JsValue>;
8399
8400        /// The `WebAssembly.instantiateStreaming()` function compiles and
8401        /// instantiates a WebAssembly module directly from a streamed
8402        /// underlying source. This is the most efficient, optimized way to load
8403        /// Wasm code.
8404        ///
8405        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming)
8406        #[cfg(js_sys_unstable_apis)]
8407        #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiateStreaming)]
8408        pub fn instantiate_streaming(response: &JsValue, imports: &Object) -> Promise<Instance>;
8409
8410        /// The `WebAssembly.validate()` function validates a given typed
8411        /// array of WebAssembly binary code, returning whether the bytes
8412        /// form a valid Wasm module (`true`) or not (`false`).
8413        ///
8414        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/validate)
8415        #[wasm_bindgen(js_namespace = WebAssembly, catch)]
8416        pub fn validate(buffer_source: &JsValue) -> Result<bool, JsValue>;
8417    }
8418
8419    // WebAssembly.CompileError
8420    #[wasm_bindgen]
8421    extern "C" {
8422        /// The `WebAssembly.CompileError()` constructor creates a new
8423        /// WebAssembly `CompileError` object, which indicates an error during
8424        /// WebAssembly decoding or validation.
8425        ///
8426        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError)
8427        #[wasm_bindgen(extends = Error, js_namespace = WebAssembly, typescript_type = "WebAssembly.CompileError")]
8428        #[derive(Clone, Debug, PartialEq, Eq)]
8429        pub type CompileError;
8430
8431        /// The `WebAssembly.CompileError()` constructor creates a new
8432        /// WebAssembly `CompileError` object, which indicates an error during
8433        /// WebAssembly decoding or validation.
8434        ///
8435        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError)
8436        #[wasm_bindgen(constructor, js_namespace = WebAssembly)]
8437        pub fn new(message: &str) -> CompileError;
8438    }
8439
8440    // WebAssembly.Instance
8441    #[wasm_bindgen]
8442    extern "C" {
8443        /// A `WebAssembly.Instance` object is a stateful, executable instance
8444        /// of a `WebAssembly.Module`. Instance objects contain all the exported
8445        /// WebAssembly functions that allow calling into WebAssembly code from
8446        /// JavaScript.
8447        ///
8448        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance)
8449        #[wasm_bindgen(extends = Object, js_namespace = WebAssembly, typescript_type = "WebAssembly.Instance")]
8450        #[derive(Clone, Debug, PartialEq, Eq)]
8451        pub type Instance;
8452
8453        /// The `WebAssembly.Instance()` constructor function can be called to
8454        /// synchronously instantiate a given `WebAssembly.Module`
8455        /// object. However, the primary way to get an `Instance` is through the
8456        /// asynchronous `WebAssembly.instantiateStreaming()` function.
8457        ///
8458        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance)
8459        #[wasm_bindgen(catch, constructor, js_namespace = WebAssembly)]
8460        pub fn new(module: &Module, imports: &Object) -> Result<Instance, JsValue>;
8461
8462        /// The `exports` readonly property of the `WebAssembly.Instance` object
8463        /// prototype returns an object containing as its members all the
8464        /// functions exported from the WebAssembly module instance, to allow
8465        /// them to be accessed and used by JavaScript.
8466        ///
8467        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/exports)
8468        #[wasm_bindgen(getter, method, js_namespace = WebAssembly)]
8469        pub fn exports(this: &Instance) -> Object;
8470    }
8471
8472    // WebAssembly.LinkError
8473    #[wasm_bindgen]
8474    extern "C" {
8475        /// The `WebAssembly.LinkError()` constructor creates a new WebAssembly
8476        /// LinkError object, which indicates an error during module
8477        /// instantiation (besides traps from the start function).
8478        ///
8479        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError)
8480        #[wasm_bindgen(extends = Error, js_namespace = WebAssembly, typescript_type = "WebAssembly.LinkError")]
8481        #[derive(Clone, Debug, PartialEq, Eq)]
8482        pub type LinkError;
8483
8484        /// The `WebAssembly.LinkError()` constructor creates a new WebAssembly
8485        /// LinkError object, which indicates an error during module
8486        /// instantiation (besides traps from the start function).
8487        ///
8488        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError)
8489        #[wasm_bindgen(constructor, js_namespace = WebAssembly)]
8490        pub fn new(message: &str) -> LinkError;
8491    }
8492
8493    // WebAssembly.RuntimeError
8494    #[wasm_bindgen]
8495    extern "C" {
8496        /// The `WebAssembly.RuntimeError()` constructor creates a new WebAssembly
8497        /// `RuntimeError` object — the type that is thrown whenever WebAssembly
8498        /// specifies a trap.
8499        ///
8500        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError)
8501        #[wasm_bindgen(extends = Error, js_namespace = WebAssembly, typescript_type = "WebAssembly.RuntimeError")]
8502        #[derive(Clone, Debug, PartialEq, Eq)]
8503        pub type RuntimeError;
8504
8505        /// The `WebAssembly.RuntimeError()` constructor creates a new WebAssembly
8506        /// `RuntimeError` object — the type that is thrown whenever WebAssembly
8507        /// specifies a trap.
8508        ///
8509        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError)
8510        #[wasm_bindgen(constructor, js_namespace = WebAssembly)]
8511        pub fn new(message: &str) -> RuntimeError;
8512    }
8513
8514    // WebAssembly.Module
8515    #[wasm_bindgen]
8516    extern "C" {
8517        /// A `WebAssembly.Module` object contains stateless WebAssembly code
8518        /// that has already been compiled by the browser and can be
8519        /// efficiently shared with Workers, and instantiated multiple times.
8520        ///
8521        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module)
8522        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Module")]
8523        #[derive(Clone, Debug, PartialEq, Eq)]
8524        pub type Module;
8525
8526        /// A `WebAssembly.Module` object contains stateless WebAssembly code
8527        /// that has already been compiled by the browser and can be
8528        /// efficiently shared with Workers, and instantiated multiple times.
8529        ///
8530        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module)
8531        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8532        pub fn new(buffer_source: &JsValue) -> Result<Module, JsValue>;
8533
8534        /// The `WebAssembly.customSections()` function returns a copy of the
8535        /// contents of all custom sections in the given module with the given
8536        /// string name.
8537        ///
8538        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/customSections)
8539        #[wasm_bindgen(static_method_of = Module, js_namespace = WebAssembly, js_name = customSections)]
8540        pub fn custom_sections(module: &Module, sectionName: &str) -> Array;
8541
8542        /// The `WebAssembly.exports()` function returns an array containing
8543        /// descriptions of all the declared exports of the given `Module`.
8544        ///
8545        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/exports)
8546        #[wasm_bindgen(static_method_of = Module, js_namespace = WebAssembly)]
8547        pub fn exports(module: &Module) -> Array;
8548
8549        /// The `WebAssembly.imports()` function returns an array containing
8550        /// descriptions of all the declared imports of the given `Module`.
8551        ///
8552        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/imports)
8553        #[wasm_bindgen(static_method_of = Module, js_namespace = WebAssembly)]
8554        pub fn imports(module: &Module) -> Array;
8555    }
8556
8557    // WebAssembly.Table
8558    #[wasm_bindgen]
8559    extern "C" {
8560        /// The `WebAssembly.Table()` constructor creates a new `Table` object
8561        /// of the given size and element type.
8562        ///
8563        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table)
8564        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Table")]
8565        #[derive(Clone, Debug, PartialEq, Eq)]
8566        pub type Table;
8567
8568        /// The `WebAssembly.Table()` constructor creates a new `Table` object
8569        /// of the given size and element type.
8570        ///
8571        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table)
8572        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8573        pub fn new(table_descriptor: &Object) -> Result<Table, JsValue>;
8574
8575        /// The `WebAssembly.Table()` constructor creates a new `Table` object
8576        /// of the given size and element type.
8577        ///
8578        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table)
8579        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8580        pub fn new_with_value(table_descriptor: &Object, value: JsValue) -> Result<Table, JsValue>;
8581
8582        /// The length prototype property of the `WebAssembly.Table` object
8583        /// returns the length of the table, i.e. the number of elements in the
8584        /// table.
8585        ///
8586        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/length)
8587        #[wasm_bindgen(method, getter, js_namespace = WebAssembly)]
8588        pub fn length(this: &Table) -> u32;
8589
8590        /// The `get()` prototype method of the `WebAssembly.Table()` object
8591        /// retrieves a function reference stored at a given index.
8592        ///
8593        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/get)
8594        #[wasm_bindgen(method, catch, js_namespace = WebAssembly)]
8595        pub fn get(this: &Table, index: u32) -> Result<Function, JsValue>;
8596
8597        /// The `get()` prototype method of the `WebAssembly.Table()` object
8598        /// retrieves a function reference stored at a given index.
8599        ///
8600        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/get)
8601        #[wasm_bindgen(method, catch, js_namespace = WebAssembly, js_name = get)]
8602        pub fn get_raw(this: &Table, index: u32) -> Result<JsValue, JsValue>;
8603
8604        /// The `grow()` prototype method of the `WebAssembly.Table` object
8605        /// increases the size of the `Table` instance by a specified number of
8606        /// elements.
8607        ///
8608        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/grow)
8609        #[wasm_bindgen(method, catch, js_namespace = WebAssembly)]
8610        pub fn grow(this: &Table, additional_capacity: u32) -> Result<u32, JsValue>;
8611
8612        /// The `grow()` prototype method of the `WebAssembly.Table` object
8613        /// increases the size of the `Table` instance by a specified number of
8614        /// elements.
8615        ///
8616        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/grow)
8617        #[wasm_bindgen(method, catch, js_namespace = WebAssembly, js_name = grow)]
8618        pub fn grow_with_value(
8619            this: &Table,
8620            additional_capacity: u32,
8621            value: JsValue,
8622        ) -> Result<u32, JsValue>;
8623
8624        /// The `set()` prototype method of the `WebAssembly.Table` object mutates a
8625        /// reference stored at a given index to a different value.
8626        ///
8627        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/set)
8628        #[wasm_bindgen(method, catch, js_namespace = WebAssembly)]
8629        pub fn set(this: &Table, index: u32, function: &Function) -> Result<(), JsValue>;
8630
8631        /// The `set()` prototype method of the `WebAssembly.Table` object mutates a
8632        /// reference stored at a given index to a different value.
8633        ///
8634        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/set)
8635        #[wasm_bindgen(method, catch, js_namespace = WebAssembly, js_name = set)]
8636        pub fn set_raw(this: &Table, index: u32, value: &JsValue) -> Result<(), JsValue>;
8637    }
8638
8639    // WebAssembly.Tag
8640    #[wasm_bindgen]
8641    extern "C" {
8642        /// The `WebAssembly.Tag()` constructor creates a new `Tag` object
8643        ///
8644        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Tag)
8645        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Tag")]
8646        #[derive(Clone, Debug, PartialEq, Eq)]
8647        pub type Tag;
8648
8649        /// The `WebAssembly.Tag()` constructor creates a new `Tag` object
8650        ///
8651        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Tag)
8652        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8653        pub fn new(tag_descriptor: &Object) -> Result<Tag, JsValue>;
8654    }
8655
8656    // WebAssembly.Exception
8657    #[wasm_bindgen]
8658    extern "C" {
8659        /// The `WebAssembly.Exception()` constructor creates a new `Exception` object
8660        ///
8661        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Exception)
8662        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Exception")]
8663        #[derive(Clone, Debug, PartialEq, Eq)]
8664        pub type Exception;
8665
8666        /// The `WebAssembly.Exception()` constructor creates a new `Exception` object
8667        ///
8668        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Exception)
8669        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8670        pub fn new(tag: &Tag, payload: &Array) -> Result<Exception, JsValue>;
8671
8672        /// The `WebAssembly.Exception()` constructor creates a new `Exception` object
8673        ///
8674        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Exception)
8675        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8676        pub fn new_with_options(
8677            tag: &Tag,
8678            payload: &Array,
8679            options: &Object,
8680        ) -> Result<Exception, JsValue>;
8681
8682        /// The `is()` prototype method of the `WebAssembly.Exception` can be used to
8683        /// test if the Exception matches a given tag.
8684        ///
8685        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Exception/is)
8686        #[wasm_bindgen(method, js_namespace = WebAssembly)]
8687        pub fn is(this: &Exception, tag: &Tag) -> bool;
8688
8689        /// The `getArg()` prototype method of the `WebAssembly.Exception` can be used
8690        /// to get the value of a specified item in the exception's data arguments
8691        ///
8692        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Exception/getArg)
8693        #[wasm_bindgen(method, js_namespace = WebAssembly, js_name = getArg, catch)]
8694        pub fn get_arg(this: &Exception, tag: &Tag, index: u32) -> Result<JsValue, JsValue>;
8695    }
8696
8697    // WebAssembly.Global
8698    #[wasm_bindgen]
8699    extern "C" {
8700        /// The `WebAssembly.Global()` constructor creates a new `Global` object
8701        /// of the given type and value.
8702        ///
8703        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global)
8704        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Global")]
8705        #[derive(Clone, Debug, PartialEq, Eq)]
8706        pub type Global;
8707
8708        /// The `WebAssembly.Global()` constructor creates a new `Global` object
8709        /// of the given type and value.
8710        ///
8711        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global)
8712        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8713        pub fn new(global_descriptor: &Object, value: &JsValue) -> Result<Global, JsValue>;
8714
8715        /// The value prototype property of the `WebAssembly.Global` object
8716        /// returns the value of the global.
8717        ///
8718        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global)
8719        #[wasm_bindgen(method, getter, js_namespace = WebAssembly)]
8720        pub fn value(this: &Global) -> JsValue;
8721        #[wasm_bindgen(method, setter = value, js_namespace = WebAssembly)]
8722        pub fn set_value(this: &Global, value: &JsValue);
8723    }
8724
8725    // WebAssembly.Memory
8726    #[wasm_bindgen]
8727    extern "C" {
8728        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory)
8729        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Memory")]
8730        #[derive(Clone, Debug, PartialEq, Eq)]
8731        pub type Memory;
8732
8733        /// The `WebAssembly.Memory()` constructor creates a new `Memory` object
8734        /// which is a resizable `ArrayBuffer` that holds the raw bytes of
8735        /// memory accessed by a WebAssembly `Instance`.
8736        ///
8737        /// A memory created by JavaScript or in WebAssembly code will be
8738        /// accessible and mutable from both JavaScript and WebAssembly.
8739        ///
8740        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory)
8741        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8742        pub fn new(descriptor: &Object) -> Result<Memory, JsValue>;
8743
8744        /// An accessor property that returns the buffer contained in the
8745        /// memory.
8746        ///
8747        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/buffer)
8748        #[wasm_bindgen(method, getter, js_namespace = WebAssembly)]
8749        pub fn buffer(this: &Memory) -> JsValue;
8750
8751        /// The `grow()` prototype method of the `Memory` object increases the
8752        /// size of the memory instance by a specified number of WebAssembly
8753        /// pages.
8754        ///
8755        /// Takes the number of pages to grow (64KiB in size) and returns the
8756        /// previous size of memory, in pages.
8757        ///
8758        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/grow)
8759        #[wasm_bindgen(method, js_namespace = WebAssembly)]
8760        pub fn grow(this: &Memory, pages: u32) -> u32;
8761    }
8762}
8763
8764/// The `JSON` object contains methods for parsing [JavaScript Object
8765/// Notation (JSON)](https://json.org/) and converting values to JSON. It
8766/// can't be called or constructed, and aside from its two method
8767/// properties, it has no interesting functionality of its own.
8768#[allow(non_snake_case)]
8769pub mod JSON {
8770    use super::*;
8771
8772    // JSON
8773    #[wasm_bindgen]
8774    extern "C" {
8775        /// The `JSON.parse()` method parses a JSON string, constructing the
8776        /// JavaScript value or object described by the string.
8777        ///
8778        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse)
8779        #[wasm_bindgen(catch, js_namespace = JSON)]
8780        pub fn parse(text: &str) -> Result<JsValue, JsValue>;
8781
8782        /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
8783        ///
8784        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
8785        #[wasm_bindgen(catch, js_namespace = JSON)]
8786        pub fn stringify(obj: &JsValue) -> Result<JsString, JsValue>;
8787
8788        /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
8789        ///
8790        /// The `replacer` argument is a function that alters the behavior of the stringification
8791        /// process, or an array of String and Number objects that serve as a whitelist
8792        /// for selecting/filtering the properties of the value object to be included
8793        /// in the JSON string. If this value is null or not provided, all properties
8794        /// of the object are included in the resulting JSON string.
8795        ///
8796        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
8797        #[cfg(not(js_sys_unstable_apis))]
8798        #[wasm_bindgen(catch, js_namespace = JSON, js_name = stringify)]
8799        pub fn stringify_with_replacer(
8800            obj: &JsValue,
8801            replacer: &JsValue,
8802        ) -> Result<JsString, JsValue>;
8803
8804        /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
8805        ///
8806        /// The `replacer` argument is a function that alters the behavior of the stringification
8807        /// process, or an array of String and Number objects that serve as a whitelist
8808        /// for selecting/filtering the properties of the value object to be included
8809        /// in the JSON string. If this value is null or not provided, all properties
8810        /// of the object are included in the resulting JSON string.
8811        ///
8812        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
8813        #[cfg(js_sys_unstable_apis)]
8814        #[wasm_bindgen(catch, js_namespace = JSON, js_name = stringify)]
8815        pub fn stringify_with_replacer<'a>(
8816            obj: &JsValue,
8817            replacer: &mut dyn FnMut(JsString, JsValue) -> Result<Option<JsValue>, JsError>,
8818            space: Option<u32>,
8819        ) -> Result<JsString, JsValue>;
8820
8821        // Next major: deprecate
8822        /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
8823        ///
8824        /// The `replacer` argument is a function that alters the behavior of the stringification
8825        /// process, or an array of String and Number objects that serve as a whitelist
8826        /// for selecting/filtering the properties of the value object to be included
8827        /// in the JSON string. If this value is null or not provided, all properties
8828        /// of the object are included in the resulting JSON string.
8829        ///
8830        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
8831        #[wasm_bindgen(catch, js_namespace = JSON, js_name = stringify)]
8832        pub fn stringify_with_replacer_func<'a>(
8833            obj: &JsValue,
8834            replacer: &mut dyn FnMut(JsString, JsValue) -> Result<Option<JsValue>, JsError>,
8835            space: Option<u32>,
8836        ) -> Result<JsString, JsValue>;
8837
8838        /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
8839        ///
8840        /// The `replacer` argument is a function that alters the behavior of the stringification
8841        /// process, or an array of String and Number objects that serve as a whitelist
8842        /// for selecting/filtering the properties of the value object to be included
8843        /// in the JSON string. If this value is null or not provided, all properties
8844        /// of the object are included in the resulting JSON string.
8845        ///
8846        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
8847        #[wasm_bindgen(catch, js_namespace = JSON, js_name = stringify)]
8848        pub fn stringify_with_replacer_list(
8849            obj: &JsValue,
8850            replacer: Vec<String>,
8851            space: Option<u32>,
8852        ) -> Result<JsString, JsValue>;
8853
8854        // Next major: deprecate
8855        /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
8856        ///
8857        /// The `replacer` argument is a function that alters the behavior of the stringification
8858        /// process, or an array of String and Number objects that serve as a whitelist
8859        /// for selecting/filtering the properties of the value object to be included
8860        /// in the JSON string. If this value is null or not provided, all properties
8861        /// of the object are included in the resulting JSON string.
8862        ///
8863        /// The `space` argument is a String or Number object that's used to insert white space into
8864        /// the output JSON string for readability purposes. If this is a Number, it
8865        /// indicates the number of space characters to use as white space; this number
8866        /// is capped at 10 (if it is greater, the value is just 10). Values less than
8867        /// 1 indicate that no space should be used. If this is a String, the string
8868        /// (or the first 10 characters of the string, if it's longer than that) is
8869        /// used as white space. If this parameter is not provided (or is null), no
8870        /// white space is used.
8871        ///
8872        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
8873        #[wasm_bindgen(catch, js_namespace = JSON, js_name = stringify)]
8874        pub fn stringify_with_replacer_and_space(
8875            obj: &JsValue,
8876            replacer: &JsValue,
8877            space: &JsValue,
8878        ) -> Result<JsString, JsValue>;
8879    }
8880}
8881// JsString
8882#[wasm_bindgen]
8883extern "C" {
8884    #[wasm_bindgen(js_name = String, extends = Object, is_type_of = JsValue::is_string, typescript_type = "string")]
8885    #[derive(Clone, PartialEq, Eq)]
8886    pub type JsString;
8887
8888    /// The length property of a String object indicates the length of a string,
8889    /// in UTF-16 code units.
8890    ///
8891    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length)
8892    #[wasm_bindgen(method, getter)]
8893    pub fn length(this: &JsString) -> u32;
8894
8895    /// The 'at()' method returns a new string consisting of the single UTF-16
8896    /// code unit located at the specified offset into the string, counting from
8897    /// the end if it's negative.
8898    ///
8899    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/at)
8900    #[wasm_bindgen(method, js_class = "String")]
8901    pub fn at(this: &JsString, index: i32) -> Option<JsString>;
8902
8903    /// The String object's `charAt()` method returns a new string consisting of
8904    /// the single UTF-16 code unit located at the specified offset into the
8905    /// string.
8906    ///
8907    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt)
8908    #[wasm_bindgen(method, js_class = "String", js_name = charAt)]
8909    pub fn char_at(this: &JsString, index: u32) -> JsString;
8910
8911    /// The `charCodeAt()` method returns an integer between 0 and 65535
8912    /// representing the UTF-16 code unit at the given index (the UTF-16 code
8913    /// unit matches the Unicode code point for code points representable in a
8914    /// single UTF-16 code unit, but might also be the first code unit of a
8915    /// surrogate pair for code points not representable in a single UTF-16 code
8916    /// unit, e.g. Unicode code points > 0x10000).  If you want the entire code
8917    /// point value, use `codePointAt()`.
8918    ///
8919    /// Returns `NaN` if index is out of range.
8920    ///
8921    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt)
8922    #[wasm_bindgen(method, js_class = "String", js_name = charCodeAt)]
8923    pub fn char_code_at(this: &JsString, index: u32) -> f64;
8924
8925    /// The `codePointAt()` method returns a non-negative integer that is the
8926    /// Unicode code point value.
8927    ///
8928    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)
8929    #[cfg(not(js_sys_unstable_apis))]
8930    #[wasm_bindgen(method, js_class = "String", js_name = codePointAt)]
8931    pub fn code_point_at(this: &JsString, pos: u32) -> JsValue;
8932
8933    /// The `codePointAt()` method returns a non-negative integer that is the
8934    /// Unicode code point value.
8935    ///
8936    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)
8937    #[cfg(js_sys_unstable_apis)]
8938    #[wasm_bindgen(method, js_class = "String", js_name = codePointAt)]
8939    pub fn code_point_at(this: &JsString, pos: u32) -> Option<u32>;
8940
8941    // Next major: deprecate
8942    /// The `codePointAt()` method returns a non-negative integer that is the
8943    /// Unicode code point value.
8944    ///
8945    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)
8946    #[wasm_bindgen(method, js_class = "String", js_name = codePointAt)]
8947    pub fn try_code_point_at(this: &JsString, pos: u32) -> Option<u16>;
8948
8949    /// The `concat()` method concatenates the string arguments to the calling
8950    /// string and returns a new string.
8951    ///
8952    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat)
8953    #[cfg(not(js_sys_unstable_apis))]
8954    #[wasm_bindgen(method, js_class = "String")]
8955    pub fn concat(this: &JsString, string_2: &JsValue) -> JsString;
8956
8957    /// The `concat()` method concatenates the string arguments to the calling
8958    /// string and returns a new string.
8959    ///
8960    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat)
8961    #[cfg(js_sys_unstable_apis)]
8962    #[wasm_bindgen(method, js_class = "String")]
8963    pub fn concat(this: &JsString, string: &JsString) -> JsString;
8964
8965    /// The `concat()` method concatenates the string arguments to the calling
8966    /// string and returns a new string.
8967    ///
8968    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat)
8969    #[wasm_bindgen(method, js_class = "String")]
8970    pub fn concat_many(this: &JsString, strings: &[JsString]) -> JsString;
8971
8972    /// The `endsWith()` method determines whether a string ends with the characters of a
8973    /// specified string, returning true or false as appropriate.
8974    ///
8975    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith)
8976    #[cfg(not(js_sys_unstable_apis))]
8977    #[wasm_bindgen(method, js_class = "String", js_name = endsWith)]
8978    pub fn ends_with(this: &JsString, search_string: &str, length: i32) -> bool;
8979
8980    /// The `endsWith()` method determines whether a string ends with the characters of a
8981    /// specified string, returning true or false as appropriate.
8982    ///
8983    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith)
8984    #[cfg(js_sys_unstable_apis)]
8985    #[wasm_bindgen(method, js_class = "String", js_name = endsWith)]
8986    pub fn ends_with(this: &JsString, search_string: &str) -> bool;
8987
8988    /// The static `String.fromCharCode()` method returns a string created from
8989    /// the specified sequence of UTF-16 code units.
8990    ///
8991    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
8992    ///
8993    /// # Notes
8994    ///
8995    /// There are a few bindings to `from_char_code` in `js-sys`: `from_char_code1`, `from_char_code2`, etc...
8996    /// with different arities.
8997    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode, variadic)]
8998    pub fn from_char_code(char_codes: &[u16]) -> JsString;
8999
9000    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9001    #[cfg(not(js_sys_unstable_apis))]
9002    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9003    pub fn from_char_code1(a: u32) -> JsString;
9004
9005    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9006    #[cfg(js_sys_unstable_apis)]
9007    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9008    pub fn from_char_code1(a: u16) -> JsString;
9009
9010    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9011    #[cfg(not(js_sys_unstable_apis))]
9012    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9013    pub fn from_char_code2(a: u32, b: u32) -> JsString;
9014
9015    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9016    #[cfg(js_sys_unstable_apis)]
9017    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9018    pub fn from_char_code2(a: u16, b: u16) -> JsString;
9019
9020    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9021    #[cfg(not(js_sys_unstable_apis))]
9022    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9023    pub fn from_char_code3(a: u32, b: u32, c: u32) -> JsString;
9024
9025    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9026    #[cfg(js_sys_unstable_apis)]
9027    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9028    pub fn from_char_code3(a: u16, b: u16, c: u16) -> JsString;
9029
9030    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9031    #[cfg(not(js_sys_unstable_apis))]
9032    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9033    pub fn from_char_code4(a: u32, b: u32, c: u32, d: u32) -> JsString;
9034
9035    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9036    #[cfg(js_sys_unstable_apis)]
9037    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9038    pub fn from_char_code4(a: u16, b: u16, c: u16, d: u16) -> JsString;
9039
9040    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9041    #[cfg(not(js_sys_unstable_apis))]
9042    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9043    pub fn from_char_code5(a: u32, b: u32, c: u32, d: u32, e: u32) -> JsString;
9044
9045    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9046    #[cfg(js_sys_unstable_apis)]
9047    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9048    pub fn from_char_code5(a: u16, b: u16, c: u16, d: u16, e: u16) -> JsString;
9049
9050    /// The static `String.fromCodePoint()` method returns a string created by
9051    /// using the specified sequence of code points.
9052    ///
9053    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
9054    ///
9055    /// # Exceptions
9056    ///
9057    /// A RangeError is thrown if an invalid Unicode code point is given
9058    ///
9059    /// # Notes
9060    ///
9061    /// There are a few bindings to `from_code_point` in `js-sys`: `from_code_point1`, `from_code_point2`, etc...
9062    /// with different arities.
9063    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint, variadic)]
9064    pub fn from_code_point(code_points: &[u32]) -> Result<JsString, JsValue>;
9065
9066    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
9067    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint)]
9068    pub fn from_code_point1(a: u32) -> Result<JsString, JsValue>;
9069
9070    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
9071    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint)]
9072    pub fn from_code_point2(a: u32, b: u32) -> Result<JsString, JsValue>;
9073
9074    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
9075    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint)]
9076    pub fn from_code_point3(a: u32, b: u32, c: u32) -> Result<JsString, JsValue>;
9077
9078    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
9079    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint)]
9080    pub fn from_code_point4(a: u32, b: u32, c: u32, d: u32) -> Result<JsString, JsValue>;
9081
9082    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
9083    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint)]
9084    pub fn from_code_point5(a: u32, b: u32, c: u32, d: u32, e: u32) -> Result<JsString, JsValue>;
9085
9086    /// The `includes()` method determines whether one string may be found
9087    /// within another string, returning true or false as appropriate.
9088    ///
9089    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes)
9090    #[wasm_bindgen(method, js_class = "String")]
9091    pub fn includes(this: &JsString, search_string: &str, position: i32) -> bool;
9092
9093    /// The `indexOf()` method returns the index within the calling String
9094    /// object of the first occurrence of the specified value, starting the
9095    /// search at fromIndex.  Returns -1 if the value is not found.
9096    ///
9097    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf)
9098    #[wasm_bindgen(method, js_class = "String", js_name = indexOf)]
9099    pub fn index_of(this: &JsString, search_value: &str, from_index: i32) -> i32;
9100
9101    /// The `lastIndexOf()` method returns the index within the calling String
9102    /// object of the last occurrence of the specified value, searching
9103    /// backwards from fromIndex.  Returns -1 if the value is not found.
9104    ///
9105    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf)
9106    #[wasm_bindgen(method, js_class = "String", js_name = lastIndexOf)]
9107    pub fn last_index_of(this: &JsString, search_value: &str, from_index: i32) -> i32;
9108
9109    /// The `localeCompare()` method returns a number indicating whether
9110    /// a reference string comes before or after or is the same as
9111    /// the given string in sort order.
9112    ///
9113    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare)
9114    #[cfg(not(js_sys_unstable_apis))]
9115    #[wasm_bindgen(method, js_class = "String", js_name = localeCompare)]
9116    pub fn locale_compare(
9117        this: &JsString,
9118        compare_string: &str,
9119        locales: &Array,
9120        options: &Object,
9121    ) -> i32;
9122
9123    /// The `localeCompare()` method returns a number indicating whether
9124    /// a reference string comes before or after or is the same as
9125    /// the given string in sort order.
9126    ///
9127    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare)
9128    #[cfg(js_sys_unstable_apis)]
9129    #[wasm_bindgen(method, js_class = "String", js_name = localeCompare)]
9130    pub fn locale_compare(
9131        this: &JsString,
9132        compare_string: &str,
9133        locales: &[JsString],
9134        options: &Intl::CollatorOptions,
9135    ) -> i32;
9136
9137    /// The `match()` method retrieves the matches when matching a string against a regular expression.
9138    ///
9139    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match)
9140    #[wasm_bindgen(method, js_class = "String", js_name = match)]
9141    pub fn match_(this: &JsString, pattern: &RegExp) -> Option<Object>;
9142
9143    /// The `match_all()` method is similar to `match()`, but gives an iterator of `exec()` arrays, which preserve capture groups.
9144    ///
9145    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/matchAll)
9146    #[cfg(not(js_sys_unstable_apis))]
9147    #[wasm_bindgen(method, js_class = "String", js_name = matchAll)]
9148    pub fn match_all(this: &JsString, pattern: &RegExp) -> Iterator;
9149
9150    /// The `match_all()` method is similar to `match()`, but gives an iterator of `exec()` arrays, which preserve capture groups.
9151    ///
9152    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/matchAll)
9153    #[cfg(js_sys_unstable_apis)]
9154    #[wasm_bindgen(method, js_class = "String", js_name = matchAll)]
9155    pub fn match_all(this: &JsString, pattern: &RegExp) -> Iterator<RegExpMatchArray>;
9156
9157    /// The `normalize()` method returns the Unicode Normalization Form
9158    /// of a given string (if the value isn't a string, it will be converted to one first).
9159    ///
9160    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
9161    #[wasm_bindgen(method, js_class = "String")]
9162    pub fn normalize(this: &JsString, form: &str) -> JsString;
9163
9164    /// The `padEnd()` method pads the current string with a given string
9165    /// (repeated, if needed) so that the resulting string reaches a given
9166    /// length. The padding is applied from the end (right) of the current
9167    /// string.
9168    ///
9169    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd)
9170    #[wasm_bindgen(method, js_class = "String", js_name = padEnd)]
9171    pub fn pad_end(this: &JsString, target_length: u32, pad_string: &str) -> JsString;
9172
9173    /// The `padStart()` method pads the current string with another string
9174    /// (repeated, if needed) so that the resulting string reaches the given
9175    /// length. The padding is applied from the start (left) of the current
9176    /// string.
9177    ///
9178    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart)
9179    #[wasm_bindgen(method, js_class = "String", js_name = padStart)]
9180    pub fn pad_start(this: &JsString, target_length: u32, pad_string: &str) -> JsString;
9181
9182    /// The `repeat()` method constructs and returns a new string which contains the specified
9183    /// number of copies of the string on which it was called, concatenated together.
9184    ///
9185    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat)
9186    #[wasm_bindgen(method, js_class = "String")]
9187    pub fn repeat(this: &JsString, count: i32) -> JsString;
9188
9189    /// The `replace()` method returns a new string with some or all matches of a pattern
9190    /// replaced by a replacement. The pattern can be a string or a RegExp, and
9191    /// the replacement can be a string or a function to be called for each match.
9192    ///
9193    /// Note: The original string will remain unchanged.
9194    ///
9195    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
9196    #[wasm_bindgen(method, js_class = "String")]
9197    pub fn replace(this: &JsString, pattern: &str, replacement: &str) -> JsString;
9198
9199    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
9200    #[cfg(not(js_sys_unstable_apis))]
9201    #[wasm_bindgen(method, js_class = "String", js_name = replace)]
9202    pub fn replace_with_function(
9203        this: &JsString,
9204        pattern: &str,
9205        replacement: &Function,
9206    ) -> JsString;
9207
9208    /// The replacer function signature is `(match, offset, string) -> replacement`
9209    /// for patterns without capture groups, or `(match, p1, p2, ..., pN, offset, string, groups) -> replacement`
9210    /// when capture groups are present.
9211    ///
9212    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
9213    #[cfg(js_sys_unstable_apis)]
9214    #[wasm_bindgen(method, js_class = "String", js_name = replace)]
9215    pub fn replace_with_function(
9216        this: &JsString,
9217        pattern: &str,
9218        replacement: &Function<fn(JsString) -> JsString>,
9219    ) -> JsString;
9220
9221    #[wasm_bindgen(method, js_class = "String", js_name = replace)]
9222    pub fn replace_by_pattern(this: &JsString, pattern: &RegExp, replacement: &str) -> JsString;
9223
9224    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
9225    #[cfg(not(js_sys_unstable_apis))]
9226    #[wasm_bindgen(method, js_class = "String", js_name = replace)]
9227    pub fn replace_by_pattern_with_function(
9228        this: &JsString,
9229        pattern: &RegExp,
9230        replacement: &Function,
9231    ) -> JsString;
9232
9233    /// The replacer function signature is `(match, offset, string) -> replacement`
9234    /// for patterns without capture groups, or `(match, p1, p2, ..., pN, offset, string, groups) -> replacement`
9235    /// when capture groups are present.
9236    ///
9237    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
9238    #[cfg(js_sys_unstable_apis)]
9239    #[wasm_bindgen(method, js_class = "String", js_name = replace)]
9240    pub fn replace_by_pattern_with_function(
9241        this: &JsString,
9242        pattern: &RegExp,
9243        replacement: &Function<fn(JsString) -> JsString>,
9244    ) -> JsString;
9245
9246    /// The `replace_all()` method returns a new string with all matches of a pattern
9247    /// replaced by a replacement. The pattern can be a string or a global RegExp, and
9248    /// the replacement can be a string or a function to be called for each match.
9249    ///
9250    /// Note: The original string will remain unchanged.
9251    ///
9252    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll)
9253    #[wasm_bindgen(method, js_class = "String", js_name = replaceAll)]
9254    pub fn replace_all(this: &JsString, pattern: &str, replacement: &str) -> JsString;
9255
9256    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll)
9257    #[cfg(not(js_sys_unstable_apis))]
9258    #[wasm_bindgen(method, js_class = "String", js_name = replaceAll)]
9259    pub fn replace_all_with_function(
9260        this: &JsString,
9261        pattern: &str,
9262        replacement: &Function,
9263    ) -> JsString;
9264
9265    /// The replacer function signature is `(match, offset, string) -> replacement`
9266    /// for patterns without capture groups, or `(match, p1, p2, ..., pN, offset, string, groups) -> replacement`
9267    /// when capture groups are present.
9268    ///
9269    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll)
9270    #[cfg(js_sys_unstable_apis)]
9271    #[wasm_bindgen(method, js_class = "String", js_name = replaceAll)]
9272    pub fn replace_all_with_function(
9273        this: &JsString,
9274        pattern: &str,
9275        replacement: &Function<fn(JsString) -> JsString>,
9276    ) -> JsString;
9277
9278    #[wasm_bindgen(method, js_class = "String", js_name = replaceAll)]
9279    pub fn replace_all_by_pattern(this: &JsString, pattern: &RegExp, replacement: &str)
9280        -> JsString;
9281
9282    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll)
9283    #[cfg(not(js_sys_unstable_apis))]
9284    #[wasm_bindgen(method, js_class = "String", js_name = replaceAll)]
9285    pub fn replace_all_by_pattern_with_function(
9286        this: &JsString,
9287        pattern: &RegExp,
9288        replacement: &Function,
9289    ) -> JsString;
9290
9291    /// The replacer function signature is `(match, offset, string) -> replacement`
9292    /// for patterns without capture groups, or `(match, p1, p2, ..., pN, offset, string, groups) -> replacement`
9293    /// when capture groups are present.
9294    ///
9295    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll)
9296    #[cfg(js_sys_unstable_apis)]
9297    #[wasm_bindgen(method, js_class = "String", js_name = replaceAll)]
9298    pub fn replace_all_by_pattern_with_function(
9299        this: &JsString,
9300        pattern: &RegExp,
9301        replacement: &Function<fn(JsString) -> JsString>,
9302    ) -> JsString;
9303
9304    /// The `search()` method executes a search for a match between
9305    /// a regular expression and this String object.
9306    ///
9307    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/search)
9308    #[wasm_bindgen(method, js_class = "String")]
9309    pub fn search(this: &JsString, pattern: &RegExp) -> i32;
9310
9311    /// The `slice()` method extracts a section of a string and returns it as a
9312    /// new string, without modifying the original string.
9313    ///
9314    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice)
9315    #[wasm_bindgen(method, js_class = "String")]
9316    pub fn slice(this: &JsString, start: u32, end: u32) -> JsString;
9317
9318    /// The `split()` method splits a String object into an array of strings by separating the string
9319    /// into substrings, using a specified separator string to determine where to make each split.
9320    ///
9321    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
9322    #[wasm_bindgen(method, js_class = "String")]
9323    pub fn split(this: &JsString, separator: &str) -> Array;
9324
9325    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
9326    #[wasm_bindgen(method, js_class = "String", js_name = split)]
9327    pub fn split_limit(this: &JsString, separator: &str, limit: u32) -> Array;
9328
9329    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
9330    #[wasm_bindgen(method, js_class = "String", js_name = split)]
9331    pub fn split_by_pattern(this: &JsString, pattern: &RegExp) -> Array;
9332
9333    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
9334    #[wasm_bindgen(method, js_class = "String", js_name = split)]
9335    pub fn split_by_pattern_limit(this: &JsString, pattern: &RegExp, limit: u32) -> Array;
9336
9337    /// The `startsWith()` method determines whether a string begins with the
9338    /// characters of a specified string, returning true or false as
9339    /// appropriate.
9340    ///
9341    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith)
9342    #[wasm_bindgen(method, js_class = "String", js_name = startsWith)]
9343    pub fn starts_with(this: &JsString, search_string: &str, position: u32) -> bool;
9344
9345    /// The `substring()` method returns the part of the string between the
9346    /// start and end indexes, or to the end of the string.
9347    ///
9348    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring)
9349    #[wasm_bindgen(method, js_class = "String")]
9350    pub fn substring(this: &JsString, index_start: u32, index_end: u32) -> JsString;
9351
9352    /// The `substr()` method returns the part of a string between
9353    /// the start index and a number of characters after it.
9354    ///
9355    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr)
9356    #[wasm_bindgen(method, js_class = "String")]
9357    pub fn substr(this: &JsString, start: i32, length: i32) -> JsString;
9358
9359    /// The `toLocaleLowerCase()` method returns the calling string value converted to lower case,
9360    /// according to any locale-specific case mappings.
9361    ///
9362    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase)
9363    #[wasm_bindgen(method, js_class = "String", js_name = toLocaleLowerCase)]
9364    pub fn to_locale_lower_case(this: &JsString, locale: Option<&str>) -> JsString;
9365
9366    /// The `toLocaleUpperCase()` method returns the calling string value converted to upper case,
9367    /// according to any locale-specific case mappings.
9368    ///
9369    /// [MDN documentation](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase)
9370    #[wasm_bindgen(method, js_class = "String", js_name = toLocaleUpperCase)]
9371    pub fn to_locale_upper_case(this: &JsString, locale: Option<&str>) -> JsString;
9372
9373    /// The `toLowerCase()` method returns the calling string value
9374    /// converted to lower case.
9375    ///
9376    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase)
9377    #[wasm_bindgen(method, js_class = "String", js_name = toLowerCase)]
9378    pub fn to_lower_case(this: &JsString) -> JsString;
9379
9380    /// The `toString()` method returns a string representing the specified
9381    /// object.
9382    ///
9383    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toString)
9384    #[cfg(not(js_sys_unstable_apis))]
9385    #[wasm_bindgen(method, js_class = "String", js_name = toString)]
9386    pub fn to_string(this: &JsString) -> JsString;
9387
9388    /// The `toUpperCase()` method returns the calling string value converted to
9389    /// uppercase (the value will be converted to a string if it isn't one).
9390    ///
9391    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase)
9392    #[wasm_bindgen(method, js_class = "String", js_name = toUpperCase)]
9393    pub fn to_upper_case(this: &JsString) -> JsString;
9394
9395    /// The `trim()` method removes whitespace from both ends of a string.
9396    /// Whitespace in this context is all the whitespace characters (space, tab,
9397    /// no-break space, etc.) and all the line terminator characters (LF, CR,
9398    /// etc.).
9399    ///
9400    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim)
9401    #[wasm_bindgen(method, js_class = "String")]
9402    pub fn trim(this: &JsString) -> JsString;
9403
9404    /// The `trimEnd()` method removes whitespace from the end of a string.
9405    /// `trimRight()` is an alias of this method.
9406    ///
9407    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd)
9408    #[wasm_bindgen(method, js_class = "String", js_name = trimEnd)]
9409    pub fn trim_end(this: &JsString) -> JsString;
9410
9411    /// The `trimEnd()` method removes whitespace from the end of a string.
9412    /// `trimRight()` is an alias of this method.
9413    ///
9414    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd)
9415    #[wasm_bindgen(method, js_class = "String", js_name = trimRight)]
9416    pub fn trim_right(this: &JsString) -> JsString;
9417
9418    /// The `trimStart()` method removes whitespace from the beginning of a
9419    /// string. `trimLeft()` is an alias of this method.
9420    ///
9421    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart)
9422    #[wasm_bindgen(method, js_class = "String", js_name = trimStart)]
9423    pub fn trim_start(this: &JsString) -> JsString;
9424
9425    /// The `trimStart()` method removes whitespace from the beginning of a
9426    /// string. `trimLeft()` is an alias of this method.
9427    ///
9428    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart)
9429    #[wasm_bindgen(method, js_class = "String", js_name = trimLeft)]
9430    pub fn trim_left(this: &JsString) -> JsString;
9431
9432    /// The `valueOf()` method returns the primitive value of a `String` object.
9433    ///
9434    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/valueOf)
9435    #[wasm_bindgen(method, js_class = "String", js_name = valueOf)]
9436    pub fn value_of(this: &JsString) -> JsString;
9437
9438    /// The static `raw()` method is a tag function of template literals,
9439    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9440    ///
9441    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9442    #[wasm_bindgen(catch, variadic, static_method_of = JsString, js_class = "String")]
9443    pub fn raw(call_site: &Object, substitutions: &Array) -> Result<JsString, JsValue>;
9444
9445    /// The static `raw()` method is a tag function of template literals,
9446    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9447    ///
9448    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9449    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
9450    pub fn raw_0(call_site: &Object) -> Result<JsString, JsValue>;
9451
9452    /// The static `raw()` method is a tag function of template literals,
9453    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9454    ///
9455    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9456    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
9457    pub fn raw_1(call_site: &Object, substitutions_1: &str) -> Result<JsString, JsValue>;
9458
9459    /// The static `raw()` method is a tag function of template literals,
9460    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9461    ///
9462    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9463    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
9464    pub fn raw_2(
9465        call_site: &Object,
9466        substitutions1: &str,
9467        substitutions2: &str,
9468    ) -> Result<JsString, JsValue>;
9469
9470    /// The static `raw()` method is a tag function of template literals,
9471    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9472    ///
9473    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9474    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
9475    pub fn raw_3(
9476        call_site: &Object,
9477        substitutions1: &str,
9478        substitutions2: &str,
9479        substitutions3: &str,
9480    ) -> Result<JsString, JsValue>;
9481
9482    /// The static `raw()` method is a tag function of template literals,
9483    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9484    ///
9485    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9486    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
9487    pub fn raw_4(
9488        call_site: &Object,
9489        substitutions1: &str,
9490        substitutions2: &str,
9491        substitutions3: &str,
9492        substitutions4: &str,
9493    ) -> Result<JsString, JsValue>;
9494
9495    /// The static `raw()` method is a tag function of template literals,
9496    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9497    ///
9498    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9499    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
9500    pub fn raw_5(
9501        call_site: &Object,
9502        substitutions1: &str,
9503        substitutions2: &str,
9504        substitutions3: &str,
9505        substitutions4: &str,
9506        substitutions5: &str,
9507    ) -> Result<JsString, JsValue>;
9508
9509    /// The static `raw()` method is a tag function of template literals,
9510    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9511    ///
9512    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9513    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
9514    pub fn raw_6(
9515        call_site: &Object,
9516        substitutions1: &str,
9517        substitutions2: &str,
9518        substitutions3: &str,
9519        substitutions4: &str,
9520        substitutions5: &str,
9521        substitutions6: &str,
9522    ) -> Result<JsString, JsValue>;
9523
9524    /// The static `raw()` method is a tag function of template literals,
9525    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9526    ///
9527    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9528    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
9529    pub fn raw_7(
9530        call_site: &Object,
9531        substitutions1: &str,
9532        substitutions2: &str,
9533        substitutions3: &str,
9534        substitutions4: &str,
9535        substitutions5: &str,
9536        substitutions6: &str,
9537        substitutions7: &str,
9538    ) -> Result<JsString, JsValue>;
9539}
9540
9541// These upcasts are non-castable due to the constraints on the function
9542// but the UpcastFrom covariance must still extend through closure types.
9543// (impl UpcastFrom really just means CovariantGeneric relation)
9544impl UpcastFrom<String> for JsString {}
9545impl UpcastFrom<JsString> for String {}
9546
9547impl UpcastFrom<&str> for JsString {}
9548impl UpcastFrom<JsString> for &str {}
9549
9550impl UpcastFrom<char> for JsString {}
9551impl UpcastFrom<JsString> for char {}
9552
9553impl JsString {
9554    /// Returns the `JsString` value of this JS value if it's an instance of a
9555    /// string.
9556    ///
9557    /// If this JS value is not an instance of a string then this returns
9558    /// `None`.
9559    #[cfg(not(js_sys_unstable_apis))]
9560    #[deprecated(note = "recommended to use dyn_ref instead which is now equivalent")]
9561    pub fn try_from(val: &JsValue) -> Option<&JsString> {
9562        val.dyn_ref()
9563    }
9564
9565    /// Returns whether this string is a valid UTF-16 string.
9566    ///
9567    /// This is useful for learning whether `String::from(..)` will return a
9568    /// lossless representation of the JS string. If this string contains
9569    /// unpaired surrogates then `String::from` will succeed but it will be a
9570    /// lossy representation of the JS string because unpaired surrogates will
9571    /// become replacement characters.
9572    ///
9573    /// If this function returns `false` then to get a lossless representation
9574    /// of the string you'll need to manually use the `iter` method (or the
9575    /// `char_code_at` accessor) to view the raw character codes.
9576    ///
9577    /// For more information, see the documentation on [JS strings vs Rust
9578    /// strings][docs]
9579    ///
9580    /// [docs]: https://wasm-bindgen.github.io/wasm-bindgen/reference/types/str.html
9581    pub fn is_valid_utf16(&self) -> bool {
9582        core::char::decode_utf16(self.iter()).all(|i| i.is_ok())
9583    }
9584
9585    /// Returns an iterator over the `u16` character codes that make up this JS
9586    /// string.
9587    ///
9588    /// This method will call `char_code_at` for each code in this JS string,
9589    /// returning an iterator of the codes in sequence.
9590    pub fn iter(
9591        &self,
9592    ) -> impl ExactSizeIterator<Item = u16> + DoubleEndedIterator<Item = u16> + '_ {
9593        (0..self.length()).map(move |i| self.char_code_at(i) as u16)
9594    }
9595
9596    /// If this string consists of a single Unicode code point, then this method
9597    /// converts it into a Rust `char` without doing any allocations.
9598    ///
9599    /// If this JS value is not a valid UTF-8 or consists of more than a single
9600    /// codepoint, then this returns `None`.
9601    ///
9602    /// Note that a single Unicode code point might be represented as more than
9603    /// one code unit on the JavaScript side. For example, a JavaScript string
9604    /// `"\uD801\uDC37"` is actually a single Unicode code point U+10437 which
9605    /// corresponds to a character '𐐷'.
9606    pub fn as_char(&self) -> Option<char> {
9607        let len = self.length();
9608
9609        if len == 0 || len > 2 {
9610            return None;
9611        }
9612
9613        #[cfg(not(js_sys_unstable_apis))]
9614        let cp = self.code_point_at(0).as_f64().unwrap_throw() as u32;
9615        #[cfg(js_sys_unstable_apis)]
9616        let cp = self.code_point_at(0)?;
9617
9618        let c = core::char::from_u32(cp)?;
9619
9620        if c.len_utf16() as u32 == len {
9621            Some(c)
9622        } else {
9623            None
9624        }
9625    }
9626}
9627
9628impl PartialEq<str> for JsString {
9629    #[allow(clippy::cmp_owned)] // prevent infinite recursion
9630    fn eq(&self, other: &str) -> bool {
9631        String::from(self) == other
9632    }
9633}
9634
9635impl<'a> PartialEq<&'a str> for JsString {
9636    fn eq(&self, other: &&'a str) -> bool {
9637        <JsString as PartialEq<str>>::eq(self, other)
9638    }
9639}
9640
9641impl PartialEq<String> for JsString {
9642    fn eq(&self, other: &String) -> bool {
9643        <JsString as PartialEq<str>>::eq(self, other)
9644    }
9645}
9646
9647impl<'a> PartialEq<&'a String> for JsString {
9648    fn eq(&self, other: &&'a String) -> bool {
9649        <JsString as PartialEq<str>>::eq(self, other)
9650    }
9651}
9652
9653impl Default for JsString {
9654    fn default() -> Self {
9655        Self::from("")
9656    }
9657}
9658
9659impl<'a> From<&'a str> for JsString {
9660    fn from(s: &'a str) -> Self {
9661        JsString::unchecked_from_js(JsValue::from_str(s))
9662    }
9663}
9664
9665impl From<String> for JsString {
9666    fn from(s: String) -> Self {
9667        From::from(&*s)
9668    }
9669}
9670
9671impl From<char> for JsString {
9672    #[inline]
9673    fn from(c: char) -> Self {
9674        JsString::from_code_point1(c as u32).unwrap_throw()
9675    }
9676}
9677
9678impl<'a> From<&'a JsString> for String {
9679    fn from(s: &'a JsString) -> Self {
9680        s.obj.as_string().unwrap_throw()
9681    }
9682}
9683
9684impl From<JsString> for String {
9685    fn from(s: JsString) -> Self {
9686        From::from(&s)
9687    }
9688}
9689
9690impl fmt::Debug for JsString {
9691    #[inline]
9692    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
9693        fmt::Debug::fmt(&String::from(self), f)
9694    }
9695}
9696
9697impl fmt::Display for JsString {
9698    #[inline]
9699    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
9700        fmt::Display::fmt(&String::from(self), f)
9701    }
9702}
9703
9704impl str::FromStr for JsString {
9705    type Err = convert::Infallible;
9706    fn from_str(s: &str) -> Result<Self, Self::Err> {
9707        Ok(JsString::from(s))
9708    }
9709}
9710
9711// Symbol
9712#[wasm_bindgen]
9713extern "C" {
9714    #[wasm_bindgen(is_type_of = JsValue::is_symbol, typescript_type = "Symbol")]
9715    #[derive(Clone, Debug)]
9716    pub type Symbol;
9717
9718    /// The `Symbol.hasInstance` well-known symbol is used to determine
9719    /// if a constructor object recognizes an object as its instance.
9720    /// The `instanceof` operator's behavior can be customized by this symbol.
9721    ///
9722    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/hasInstance)
9723    #[wasm_bindgen(static_method_of = Symbol, getter, js_name = hasInstance)]
9724    pub fn has_instance() -> Symbol;
9725
9726    /// The `Symbol.isConcatSpreadable` well-known symbol is used to configure
9727    /// if an object should be flattened to its array elements when using the
9728    /// `Array.prototype.concat()` method.
9729    ///
9730    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/isConcatSpreadable)
9731    #[wasm_bindgen(static_method_of = Symbol, getter, js_name = isConcatSpreadable)]
9732    pub fn is_concat_spreadable() -> Symbol;
9733
9734    /// The `Symbol.asyncIterator` well-known symbol specifies the default AsyncIterator for an object.
9735    /// If this property is set on an object, it is an async iterable and can be used in a `for await...of` loop.
9736    ///
9737    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator)
9738    #[wasm_bindgen(static_method_of = Symbol, getter, js_name = asyncIterator)]
9739    pub fn async_iterator() -> Symbol;
9740
9741    /// The `Symbol.iterator` well-known symbol specifies the default iterator
9742    /// for an object.  Used by `for...of`.
9743    ///
9744    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/iterator)
9745    #[wasm_bindgen(static_method_of = Symbol, getter)]
9746    pub fn iterator() -> Symbol;
9747
9748    /// The `Symbol.match` well-known symbol specifies the matching of a regular
9749    /// expression against a string. This function is called by the
9750    /// `String.prototype.match()` method.
9751    ///
9752    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/match)
9753    #[wasm_bindgen(static_method_of = Symbol, getter, js_name = match)]
9754    pub fn match_() -> Symbol;
9755
9756    /// The `Symbol.replace` well-known symbol specifies the method that
9757    /// replaces matched substrings of a string.  This function is called by the
9758    /// `String.prototype.replace()` method.
9759    ///
9760    /// For more information, see `RegExp.prototype[@@replace]()` and
9761    /// `String.prototype.replace()`.
9762    ///
9763    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/replace)
9764    #[wasm_bindgen(static_method_of = Symbol, getter)]
9765    pub fn replace() -> Symbol;
9766
9767    /// The `Symbol.search` well-known symbol specifies the method that returns
9768    /// the index within a string that matches the regular expression.  This
9769    /// function is called by the `String.prototype.search()` method.
9770    ///
9771    /// For more information, see `RegExp.prototype[@@search]()` and
9772    /// `String.prototype.search()`.
9773    ///
9774    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/search)
9775    #[wasm_bindgen(static_method_of = Symbol, getter)]
9776    pub fn search() -> Symbol;
9777
9778    /// The well-known symbol `Symbol.species` specifies a function-valued
9779    /// property that the constructor function uses to create derived objects.
9780    ///
9781    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/species)
9782    #[wasm_bindgen(static_method_of = Symbol, getter)]
9783    pub fn species() -> Symbol;
9784
9785    /// The `Symbol.split` well-known symbol specifies the method that splits a
9786    /// string at the indices that match a regular expression.  This function is
9787    /// called by the `String.prototype.split()` method.
9788    ///
9789    /// For more information, see `RegExp.prototype[@@split]()` and
9790    /// `String.prototype.split()`.
9791    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/split)
9792    #[wasm_bindgen(static_method_of = Symbol, getter)]
9793    pub fn split() -> Symbol;
9794
9795    /// The `Symbol.toPrimitive` is a symbol that specifies a function valued
9796    /// property that is called to convert an object to a corresponding
9797    /// primitive value.
9798    ///
9799    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toPrimitive)
9800    #[wasm_bindgen(static_method_of = Symbol, getter, js_name = toPrimitive)]
9801    pub fn to_primitive() -> Symbol;
9802
9803    /// The `Symbol.toStringTag` well-known symbol is a string valued property
9804    /// that is used in the creation of the default string description of an
9805    /// object.  It is accessed internally by the `Object.prototype.toString()`
9806    /// method.
9807    ///
9808    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toString)
9809    #[wasm_bindgen(static_method_of = Symbol, getter, js_name = toStringTag)]
9810    pub fn to_string_tag() -> Symbol;
9811
9812    /// The `Symbol.for(key)` method searches for existing symbols in a runtime-wide symbol registry with
9813    /// the given key and returns it if found.
9814    /// Otherwise a new symbol gets created in the global symbol registry with this key.
9815    ///
9816    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/for)
9817    #[wasm_bindgen(static_method_of = Symbol, js_name = for)]
9818    pub fn for_(key: &str) -> Symbol;
9819
9820    /// The `Symbol.keyFor(sym)` method retrieves a shared symbol key from the global symbol registry for the given symbol.
9821    ///
9822    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/keyFor)
9823    #[wasm_bindgen(static_method_of = Symbol, js_name = keyFor)]
9824    pub fn key_for(sym: &Symbol) -> JsValue;
9825
9826    // Next major: deprecate
9827    /// The `toString()` method returns a string representing the specified Symbol object.
9828    ///
9829    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toString)
9830    #[wasm_bindgen(method, js_name = toString)]
9831    pub fn to_string(this: &Symbol) -> JsString;
9832
9833    /// The `toString()` method returns a string representing the specified Symbol object.
9834    ///
9835    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toString)
9836    #[wasm_bindgen(method, js_name = toString)]
9837    pub fn to_js_string(this: &Symbol) -> JsString;
9838
9839    /// The `Symbol.unscopables` well-known symbol is used to specify an object
9840    /// value of whose own and inherited property names are excluded from the
9841    /// with environment bindings of the associated object.
9842    ///
9843    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/unscopables)
9844    #[wasm_bindgen(static_method_of = Symbol, getter)]
9845    pub fn unscopables() -> Symbol;
9846
9847    /// The `valueOf()` method returns the primitive value of a Symbol object.
9848    ///
9849    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/valueOf)
9850    #[wasm_bindgen(method, js_name = valueOf)]
9851    pub fn value_of(this: &Symbol) -> Symbol;
9852}
9853
9854#[allow(non_snake_case)]
9855pub mod Intl {
9856    use super::*;
9857
9858    // Intl
9859    #[wasm_bindgen]
9860    extern "C" {
9861        /// The `Intl.getCanonicalLocales()` method returns an array containing
9862        /// the canonical locale names. Duplicates will be omitted and elements
9863        /// will be validated as structurally valid language tags.
9864        ///
9865        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales)
9866        #[cfg(not(js_sys_unstable_apis))]
9867        #[wasm_bindgen(js_name = getCanonicalLocales, js_namespace = Intl)]
9868        pub fn get_canonical_locales(s: &JsValue) -> Array;
9869
9870        /// The `Intl.getCanonicalLocales()` method returns an array containing
9871        /// the canonical locale names. Duplicates will be omitted and elements
9872        /// will be validated as structurally valid language tags.
9873        ///
9874        /// Throws a `RangeError` if any of the strings are not valid locale identifiers.
9875        ///
9876        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales)
9877        #[cfg(js_sys_unstable_apis)]
9878        #[wasm_bindgen(js_name = getCanonicalLocales, js_namespace = Intl, catch)]
9879        pub fn get_canonical_locales(s: &[JsString]) -> Result<Array<JsString>, JsValue>;
9880
9881        /// The `Intl.supportedValuesOf()` method returns an array containing the
9882        /// supported calendar, collation, currency, numbering system, or unit values
9883        /// supported by the implementation.
9884        ///
9885        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/supportedValuesOf)
9886        #[wasm_bindgen(js_name = supportedValuesOf, js_namespace = Intl)]
9887        pub fn supported_values_of(key: SupportedValuesKey) -> Array<JsString>;
9888    }
9889
9890    // Intl string enums
9891
9892    /// Key for `Intl.supportedValuesOf()`.
9893    #[wasm_bindgen]
9894    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
9895    pub enum SupportedValuesKey {
9896        Calendar = "calendar",
9897        Collation = "collation",
9898        Currency = "currency",
9899        NumberingSystem = "numberingSystem",
9900        TimeZone = "timeZone",
9901        Unit = "unit",
9902    }
9903
9904    /// Locale matching algorithm for Intl constructors.
9905    #[wasm_bindgen]
9906    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
9907    pub enum LocaleMatcher {
9908        Lookup = "lookup",
9909        BestFit = "best fit",
9910    }
9911
9912    /// Usage for `Intl.Collator`.
9913    #[wasm_bindgen]
9914    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
9915    pub enum CollatorUsage {
9916        Sort = "sort",
9917        Search = "search",
9918    }
9919
9920    /// Sensitivity for `Intl.Collator`.
9921    #[wasm_bindgen]
9922    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
9923    pub enum CollatorSensitivity {
9924        Base = "base",
9925        Accent = "accent",
9926        Case = "case",
9927        Variant = "variant",
9928    }
9929
9930    /// Case first option for `Intl.Collator`.
9931    #[wasm_bindgen]
9932    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
9933    pub enum CollatorCaseFirst {
9934        Upper = "upper",
9935        Lower = "lower",
9936        False = "false",
9937    }
9938
9939    /// Style for `Intl.NumberFormat`.
9940    #[wasm_bindgen]
9941    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
9942    pub enum NumberFormatStyle {
9943        Decimal = "decimal",
9944        Currency = "currency",
9945        Percent = "percent",
9946        Unit = "unit",
9947    }
9948
9949    /// Currency display for `Intl.NumberFormat`.
9950    #[wasm_bindgen]
9951    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
9952    pub enum CurrencyDisplay {
9953        Code = "code",
9954        Symbol = "symbol",
9955        NarrowSymbol = "narrowSymbol",
9956        Name = "name",
9957    }
9958
9959    /// Currency sign for `Intl.NumberFormat`.
9960    #[wasm_bindgen]
9961    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
9962    pub enum CurrencySign {
9963        Standard = "standard",
9964        Accounting = "accounting",
9965    }
9966
9967    /// Unit display for `Intl.NumberFormat`.
9968    #[wasm_bindgen]
9969    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
9970    pub enum UnitDisplay {
9971        Short = "short",
9972        Narrow = "narrow",
9973        Long = "long",
9974    }
9975
9976    /// Notation for `Intl.NumberFormat`.
9977    #[wasm_bindgen]
9978    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
9979    pub enum NumberFormatNotation {
9980        Standard = "standard",
9981        Scientific = "scientific",
9982        Engineering = "engineering",
9983        Compact = "compact",
9984    }
9985
9986    /// Compact display for `Intl.NumberFormat`.
9987    #[wasm_bindgen]
9988    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
9989    pub enum CompactDisplay {
9990        Short = "short",
9991        Long = "long",
9992    }
9993
9994    /// Sign display for `Intl.NumberFormat`.
9995    #[wasm_bindgen]
9996    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
9997    pub enum SignDisplay {
9998        Auto = "auto",
9999        Never = "never",
10000        Always = "always",
10001        ExceptZero = "exceptZero",
10002    }
10003
10004    /// Rounding mode for `Intl.NumberFormat`.
10005    #[wasm_bindgen]
10006    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10007    pub enum RoundingMode {
10008        Ceil = "ceil",
10009        Floor = "floor",
10010        Expand = "expand",
10011        Trunc = "trunc",
10012        HalfCeil = "halfCeil",
10013        HalfFloor = "halfFloor",
10014        HalfExpand = "halfExpand",
10015        HalfTrunc = "halfTrunc",
10016        HalfEven = "halfEven",
10017    }
10018
10019    /// Rounding priority for `Intl.NumberFormat`.
10020    #[wasm_bindgen]
10021    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10022    pub enum RoundingPriority {
10023        Auto = "auto",
10024        MorePrecision = "morePrecision",
10025        LessPrecision = "lessPrecision",
10026    }
10027
10028    /// Trailing zero display for `Intl.NumberFormat`.
10029    #[wasm_bindgen]
10030    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10031    pub enum TrailingZeroDisplay {
10032        Auto = "auto",
10033        StripIfInteger = "stripIfInteger",
10034    }
10035
10036    /// Use grouping option for `Intl.NumberFormat`.
10037    ///
10038    /// Determines whether to use grouping separators, such as thousands
10039    /// separators or thousand/lakh/crore separators.
10040    ///
10041    /// The default is `Min2` if notation is "compact", and `Auto` otherwise.
10042    ///
10043    /// Note: The string values `"true"` and `"false"` are accepted by JavaScript
10044    /// but are always converted to the default value. Use `True` and `False`
10045    /// variants for the boolean behavior.
10046    ///
10047    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#usegrouping)
10048    #[wasm_bindgen]
10049    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10050    pub enum UseGrouping {
10051        /// Display grouping separators even if the locale prefers otherwise.
10052        Always = "always",
10053        /// Display grouping separators based on the locale preference,
10054        /// which may also be dependent on the currency.
10055        Auto = "auto",
10056        /// Display grouping separators when there are at least 2 digits in a group.
10057        Min2 = "min2",
10058        /// Same as `Always`. Display grouping separators even if the locale prefers otherwise.
10059        True = "true",
10060        /// Display no grouping separators.
10061        False = "false",
10062    }
10063
10064    /// Date/time style for `Intl.DateTimeFormat`.
10065    #[wasm_bindgen]
10066    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10067    pub enum DateTimeStyle {
10068        Full = "full",
10069        Long = "long",
10070        Medium = "medium",
10071        Short = "short",
10072    }
10073
10074    /// Hour cycle for `Intl.DateTimeFormat`.
10075    #[wasm_bindgen]
10076    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10077    pub enum HourCycle {
10078        H11 = "h11",
10079        H12 = "h12",
10080        H23 = "h23",
10081        H24 = "h24",
10082    }
10083
10084    /// Weekday format for `Intl.DateTimeFormat`.
10085    #[wasm_bindgen]
10086    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10087    pub enum WeekdayFormat {
10088        Narrow = "narrow",
10089        Short = "short",
10090        Long = "long",
10091    }
10092
10093    /// Era format for `Intl.DateTimeFormat`.
10094    #[wasm_bindgen]
10095    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10096    pub enum EraFormat {
10097        Narrow = "narrow",
10098        Short = "short",
10099        Long = "long",
10100    }
10101
10102    /// Year format for `Intl.DateTimeFormat`.
10103    #[wasm_bindgen]
10104    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10105    pub enum YearFormat {
10106        Numeric = "numeric",
10107        TwoDigit = "2-digit",
10108    }
10109
10110    /// Month format for `Intl.DateTimeFormat`.
10111    #[wasm_bindgen]
10112    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10113    pub enum MonthFormat {
10114        #[wasm_bindgen]
10115        Numeric = "numeric",
10116        #[wasm_bindgen]
10117        TwoDigit = "2-digit",
10118        #[wasm_bindgen]
10119        Narrow = "narrow",
10120        #[wasm_bindgen]
10121        Short = "short",
10122        #[wasm_bindgen]
10123        Long = "long",
10124    }
10125
10126    /// Day format for `Intl.DateTimeFormat`.
10127    #[wasm_bindgen]
10128    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10129    pub enum DayFormat {
10130        #[wasm_bindgen]
10131        Numeric = "numeric",
10132        #[wasm_bindgen]
10133        TwoDigit = "2-digit",
10134    }
10135
10136    /// Hour/minute/second format for `Intl.DateTimeFormat`.
10137    #[wasm_bindgen]
10138    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10139    pub enum NumericFormat {
10140        #[wasm_bindgen]
10141        Numeric = "numeric",
10142        #[wasm_bindgen]
10143        TwoDigit = "2-digit",
10144    }
10145
10146    /// Time zone name format for `Intl.DateTimeFormat`.
10147    #[wasm_bindgen]
10148    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10149    pub enum TimeZoneNameFormat {
10150        Short = "short",
10151        Long = "long",
10152        ShortOffset = "shortOffset",
10153        LongOffset = "longOffset",
10154        ShortGeneric = "shortGeneric",
10155        LongGeneric = "longGeneric",
10156    }
10157
10158    /// Day period format for `Intl.DateTimeFormat`.
10159    #[wasm_bindgen]
10160    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10161    pub enum DayPeriodFormat {
10162        Narrow = "narrow",
10163        Short = "short",
10164        Long = "long",
10165    }
10166
10167    /// Part type for `DateTimeFormat.formatToParts()`.
10168    #[wasm_bindgen]
10169    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10170    pub enum DateTimeFormatPartType {
10171        Day = "day",
10172        DayPeriod = "dayPeriod",
10173        Era = "era",
10174        FractionalSecond = "fractionalSecond",
10175        Hour = "hour",
10176        Literal = "literal",
10177        Minute = "minute",
10178        Month = "month",
10179        RelatedYear = "relatedYear",
10180        Second = "second",
10181        TimeZoneName = "timeZoneName",
10182        Weekday = "weekday",
10183        Year = "year",
10184        YearName = "yearName",
10185    }
10186
10187    /// Part type for `NumberFormat.formatToParts()`.
10188    #[wasm_bindgen]
10189    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10190    pub enum NumberFormatPartType {
10191        Compact = "compact",
10192        Currency = "currency",
10193        Decimal = "decimal",
10194        ExponentInteger = "exponentInteger",
10195        ExponentMinusSign = "exponentMinusSign",
10196        ExponentSeparator = "exponentSeparator",
10197        Fraction = "fraction",
10198        Group = "group",
10199        Infinity = "infinity",
10200        Integer = "integer",
10201        Literal = "literal",
10202        MinusSign = "minusSign",
10203        Nan = "nan",
10204        PercentSign = "percentSign",
10205        PlusSign = "plusSign",
10206        Unit = "unit",
10207        Unknown = "unknown",
10208    }
10209
10210    /// Type for `Intl.PluralRules` (cardinal or ordinal).
10211    #[wasm_bindgen]
10212    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10213    pub enum PluralRulesType {
10214        Cardinal = "cardinal",
10215        Ordinal = "ordinal",
10216    }
10217
10218    /// Plural category returned by `PluralRules.select()`.
10219    #[wasm_bindgen]
10220    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10221    pub enum PluralCategory {
10222        Zero = "zero",
10223        One = "one",
10224        Two = "two",
10225        Few = "few",
10226        Many = "many",
10227        Other = "other",
10228    }
10229
10230    /// Numeric option for `Intl.RelativeTimeFormat`.
10231    #[wasm_bindgen]
10232    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10233    pub enum RelativeTimeFormatNumeric {
10234        Always = "always",
10235        Auto = "auto",
10236    }
10237
10238    /// Style for `Intl.RelativeTimeFormat`.
10239    #[wasm_bindgen]
10240    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10241    pub enum RelativeTimeFormatStyle {
10242        Long = "long",
10243        Short = "short",
10244        Narrow = "narrow",
10245    }
10246
10247    /// Unit for `RelativeTimeFormat.format()`.
10248    #[wasm_bindgen]
10249    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10250    pub enum RelativeTimeFormatUnit {
10251        Year = "year",
10252        Years = "years",
10253        Quarter = "quarter",
10254        Quarters = "quarters",
10255        Month = "month",
10256        Months = "months",
10257        Week = "week",
10258        Weeks = "weeks",
10259        Day = "day",
10260        Days = "days",
10261        Hour = "hour",
10262        Hours = "hours",
10263        Minute = "minute",
10264        Minutes = "minutes",
10265        Second = "second",
10266        Seconds = "seconds",
10267    }
10268
10269    /// Part type for `RelativeTimeFormat.formatToParts()`.
10270    #[wasm_bindgen]
10271    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10272    pub enum RelativeTimeFormatPartType {
10273        Literal = "literal",
10274        Integer = "integer",
10275        Decimal = "decimal",
10276        Fraction = "fraction",
10277    }
10278
10279    /// Source indicator for range format parts.
10280    ///
10281    /// Indicates which part of the range (start, end, or shared) a formatted
10282    /// part belongs to when using `formatRangeToParts()`.
10283    ///
10284    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatRangeToParts#description)
10285    #[wasm_bindgen]
10286    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10287    pub enum RangeSource {
10288        /// The part is from the start of the range.
10289        StartRange = "startRange",
10290        /// The part is from the end of the range.
10291        EndRange = "endRange",
10292        /// The part is shared between start and end (e.g., a separator or common element).
10293        Shared = "shared",
10294    }
10295
10296    /// Type for `Intl.ListFormat`.
10297    #[wasm_bindgen]
10298    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10299    pub enum ListFormatType {
10300        /// For lists of standalone items (default).
10301        Conjunction = "conjunction",
10302        /// For lists representing alternatives.
10303        Disjunction = "disjunction",
10304        /// For lists of values with units.
10305        Unit = "unit",
10306    }
10307
10308    /// Style for `Intl.ListFormat`.
10309    #[wasm_bindgen]
10310    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10311    pub enum ListFormatStyle {
10312        /// "A, B, and C" (default).
10313        Long = "long",
10314        /// "A, B, C".
10315        Short = "short",
10316        /// "A B C".
10317        Narrow = "narrow",
10318    }
10319
10320    /// Part type for `Intl.ListFormat.formatToParts()`.
10321    #[wasm_bindgen]
10322    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10323    pub enum ListFormatPartType {
10324        /// A value from the list.
10325        Element = "element",
10326        /// A linguistic construct (e.g., ", ", " and ").
10327        Literal = "literal",
10328    }
10329
10330    /// Type for `Intl.Segmenter`.
10331    #[wasm_bindgen]
10332    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10333    pub enum SegmenterGranularity {
10334        /// Segment by grapheme clusters (user-perceived characters).
10335        Grapheme = "grapheme",
10336        /// Segment by words.
10337        Word = "word",
10338        /// Segment by sentences.
10339        Sentence = "sentence",
10340    }
10341
10342    /// Type for `Intl.DisplayNames`.
10343    #[wasm_bindgen]
10344    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10345    pub enum DisplayNamesType {
10346        /// Language display names.
10347        Language = "language",
10348        /// Region display names.
10349        Region = "region",
10350        /// Script display names.
10351        Script = "script",
10352        /// Currency display names.
10353        Currency = "currency",
10354        /// Calendar display names.
10355        Calendar = "calendar",
10356        /// Date/time field display names.
10357        DateTimeField = "dateTimeField",
10358    }
10359
10360    /// Style for `Intl.DisplayNames`.
10361    #[wasm_bindgen]
10362    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10363    pub enum DisplayNamesStyle {
10364        /// Full display name (default).
10365        Long = "long",
10366        /// Abbreviated display name.
10367        Short = "short",
10368        /// Minimal display name.
10369        Narrow = "narrow",
10370    }
10371
10372    /// Fallback for `Intl.DisplayNames`.
10373    #[wasm_bindgen]
10374    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10375    pub enum DisplayNamesFallback {
10376        /// Return the input code if no display name is available (default).
10377        Code = "code",
10378        /// Return undefined if no display name is available.
10379        None = "none",
10380    }
10381
10382    /// Language display for `Intl.DisplayNames`.
10383    #[wasm_bindgen]
10384    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10385    pub enum DisplayNamesLanguageDisplay {
10386        /// Use dialect names (e.g., "British English").
10387        Dialect = "dialect",
10388        /// Use standard names (e.g., "English (United Kingdom)").
10389        Standard = "standard",
10390    }
10391
10392    // Intl.RelativeTimeFormatOptions
10393    #[wasm_bindgen]
10394    extern "C" {
10395        /// Options for `Intl.RelativeTimeFormat` constructor.
10396        ///
10397        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat#options)
10398        #[wasm_bindgen(extends = Object)]
10399        #[derive(Clone, Debug)]
10400        pub type RelativeTimeFormatOptions;
10401
10402        #[wasm_bindgen(method, getter = localeMatcher)]
10403        pub fn get_locale_matcher(this: &RelativeTimeFormatOptions) -> Option<LocaleMatcher>;
10404        #[wasm_bindgen(method, setter = localeMatcher)]
10405        pub fn set_locale_matcher(this: &RelativeTimeFormatOptions, value: LocaleMatcher);
10406
10407        #[wasm_bindgen(method, getter = numeric)]
10408        pub fn get_numeric(this: &RelativeTimeFormatOptions) -> Option<RelativeTimeFormatNumeric>;
10409        #[wasm_bindgen(method, setter = numeric)]
10410        pub fn set_numeric(this: &RelativeTimeFormatOptions, value: RelativeTimeFormatNumeric);
10411
10412        #[wasm_bindgen(method, getter = style)]
10413        pub fn get_style(this: &RelativeTimeFormatOptions) -> Option<RelativeTimeFormatStyle>;
10414        #[wasm_bindgen(method, setter = style)]
10415        pub fn set_style(this: &RelativeTimeFormatOptions, value: RelativeTimeFormatStyle);
10416    }
10417
10418    impl RelativeTimeFormatOptions {
10419        pub fn new() -> RelativeTimeFormatOptions {
10420            JsCast::unchecked_into(Object::new())
10421        }
10422    }
10423
10424    impl Default for RelativeTimeFormatOptions {
10425        fn default() -> Self {
10426            RelativeTimeFormatOptions::new()
10427        }
10428    }
10429
10430    // Intl.ResolvedRelativeTimeFormatOptions
10431    #[wasm_bindgen]
10432    extern "C" {
10433        /// Resolved options returned by `Intl.RelativeTimeFormat.prototype.resolvedOptions()`.
10434        ///
10435        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/resolvedOptions)
10436        #[wasm_bindgen(extends = RelativeTimeFormatOptions)]
10437        #[derive(Clone, Debug)]
10438        pub type ResolvedRelativeTimeFormatOptions;
10439
10440        /// The resolved locale string.
10441        #[wasm_bindgen(method, getter = locale)]
10442        pub fn get_locale(this: &ResolvedRelativeTimeFormatOptions) -> JsString;
10443
10444        /// The numbering system used.
10445        #[wasm_bindgen(method, getter = numberingSystem)]
10446        pub fn get_numbering_system(this: &ResolvedRelativeTimeFormatOptions) -> JsString;
10447    }
10448
10449    // Intl.RelativeTimeFormatPart
10450    #[wasm_bindgen]
10451    extern "C" {
10452        /// A part of the formatted relative time returned by `formatToParts()`.
10453        ///
10454        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/formatToParts)
10455        #[wasm_bindgen(extends = Object)]
10456        #[derive(Clone, Debug)]
10457        pub type RelativeTimeFormatPart;
10458
10459        /// The type of this part.
10460        #[wasm_bindgen(method, getter = type)]
10461        pub fn type_(this: &RelativeTimeFormatPart) -> RelativeTimeFormatPartType;
10462
10463        /// The string value of this part.
10464        #[wasm_bindgen(method, getter = value)]
10465        pub fn value(this: &RelativeTimeFormatPart) -> JsString;
10466
10467        /// The unit used in this part (only for integer parts).
10468        #[wasm_bindgen(method, getter = unit)]
10469        pub fn unit(this: &RelativeTimeFormatPart) -> Option<JsString>;
10470    }
10471
10472    // Intl.LocaleMatcherOptions
10473    #[wasm_bindgen]
10474    extern "C" {
10475        /// Options for `supportedLocalesOf` methods.
10476        #[wasm_bindgen(extends = Object)]
10477        #[derive(Clone, Debug)]
10478        pub type LocaleMatcherOptions;
10479
10480        #[wasm_bindgen(method, getter = localeMatcher)]
10481        pub fn get_locale_matcher(this: &LocaleMatcherOptions) -> Option<LocaleMatcher>;
10482
10483        #[wasm_bindgen(method, setter = localeMatcher)]
10484        pub fn set_locale_matcher(this: &LocaleMatcherOptions, value: LocaleMatcher);
10485    }
10486
10487    impl LocaleMatcherOptions {
10488        pub fn new() -> LocaleMatcherOptions {
10489            JsCast::unchecked_into(Object::new())
10490        }
10491    }
10492
10493    impl Default for LocaleMatcherOptions {
10494        fn default() -> Self {
10495            LocaleMatcherOptions::new()
10496        }
10497    }
10498
10499    // Intl.Collator Options
10500    #[wasm_bindgen]
10501    extern "C" {
10502        /// Options for `Intl.Collator` and `String.prototype.localeCompare`.
10503        ///
10504        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator/Collator#options)
10505        #[wasm_bindgen(extends = Object)]
10506        #[derive(Clone, Debug)]
10507        pub type CollatorOptions;
10508
10509        #[wasm_bindgen(method, getter = localeMatcher)]
10510        pub fn get_locale_matcher(this: &CollatorOptions) -> Option<LocaleMatcher>;
10511        #[wasm_bindgen(method, setter = localeMatcher)]
10512        pub fn set_locale_matcher(this: &CollatorOptions, value: LocaleMatcher);
10513
10514        #[wasm_bindgen(method, getter = usage)]
10515        pub fn get_usage(this: &CollatorOptions) -> Option<CollatorUsage>;
10516        #[wasm_bindgen(method, setter = usage)]
10517        pub fn set_usage(this: &CollatorOptions, value: CollatorUsage);
10518
10519        #[wasm_bindgen(method, getter = sensitivity)]
10520        pub fn get_sensitivity(this: &CollatorOptions) -> Option<CollatorSensitivity>;
10521        #[wasm_bindgen(method, setter = sensitivity)]
10522        pub fn set_sensitivity(this: &CollatorOptions, value: CollatorSensitivity);
10523
10524        #[wasm_bindgen(method, getter = ignorePunctuation)]
10525        pub fn get_ignore_punctuation(this: &CollatorOptions) -> Option<bool>;
10526        #[wasm_bindgen(method, setter = ignorePunctuation)]
10527        pub fn set_ignore_punctuation(this: &CollatorOptions, value: bool);
10528
10529        #[wasm_bindgen(method, getter = numeric)]
10530        pub fn get_numeric(this: &CollatorOptions) -> Option<bool>;
10531        #[wasm_bindgen(method, setter = numeric)]
10532        pub fn set_numeric(this: &CollatorOptions, value: bool);
10533
10534        #[wasm_bindgen(method, getter = caseFirst)]
10535        pub fn get_case_first(this: &CollatorOptions) -> Option<CollatorCaseFirst>;
10536        #[wasm_bindgen(method, setter = caseFirst)]
10537        pub fn set_case_first(this: &CollatorOptions, value: CollatorCaseFirst);
10538    }
10539    impl CollatorOptions {
10540        pub fn new() -> CollatorOptions {
10541            JsCast::unchecked_into(Object::new())
10542        }
10543    }
10544    impl Default for CollatorOptions {
10545        fn default() -> Self {
10546            CollatorOptions::new()
10547        }
10548    }
10549
10550    // Intl.Collator ResolvedCollatorOptions
10551    #[wasm_bindgen]
10552    extern "C" {
10553        #[wasm_bindgen(extends = CollatorOptions)]
10554        pub type ResolvedCollatorOptions;
10555
10556        #[wasm_bindgen(method, getter = locale)]
10557        pub fn get_locale(this: &ResolvedCollatorOptions) -> JsString; // not Option, always present
10558        #[wasm_bindgen(method, getter = collation)]
10559        pub fn get_collation(this: &ResolvedCollatorOptions) -> JsString;
10560    }
10561
10562    // Intl.Collator
10563    #[wasm_bindgen]
10564    extern "C" {
10565        /// The `Intl.Collator` object is a constructor for collators, objects
10566        /// that enable language sensitive string comparison.
10567        ///
10568        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator)
10569        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.Collator")]
10570        #[derive(Clone, Debug)]
10571        pub type Collator;
10572
10573        /// The `Intl.Collator` object is a constructor for collators, objects
10574        /// that enable language sensitive string comparison.
10575        ///
10576        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator)
10577        #[cfg(not(js_sys_unstable_apis))]
10578        #[wasm_bindgen(constructor, js_namespace = Intl)]
10579        pub fn new(locales: &Array, options: &Object) -> Collator;
10580
10581        /// The `Intl.Collator` object is a constructor for collators, objects
10582        /// that enable language sensitive string comparison.
10583        ///
10584        /// Throws a `RangeError` if locales contain invalid values.
10585        ///
10586        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator)
10587        #[cfg(js_sys_unstable_apis)]
10588        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
10589        pub fn new(locales: &[JsString], options: &CollatorOptions) -> Result<Collator, JsValue>;
10590
10591        /// The Intl.Collator.prototype.compare property returns a function that
10592        /// compares two strings according to the sort order of this Collator
10593        /// object.
10594        ///
10595        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/compare)
10596        #[cfg(not(js_sys_unstable_apis))]
10597        #[wasm_bindgen(method, getter, js_class = "Intl.Collator")]
10598        pub fn compare(this: &Collator) -> Function;
10599
10600        /// Compares two strings according to the sort order of this Collator.
10601        ///
10602        /// Returns a negative value if `a` comes before `b`, positive if `a` comes
10603        /// after `b`, and zero if they are equal.
10604        ///
10605        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator/compare)
10606        #[cfg(js_sys_unstable_apis)]
10607        #[wasm_bindgen(method, js_class = "Intl.Collator")]
10608        pub fn compare(this: &Collator, a: &str, b: &str) -> i32;
10609
10610        /// The `Intl.Collator.prototype.resolvedOptions()` method returns a new
10611        /// object with properties reflecting the locale and collation options
10612        /// computed during initialization of this Collator object.
10613        ///
10614        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/resolvedOptions)
10615        #[cfg(not(js_sys_unstable_apis))]
10616        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
10617        pub fn resolved_options(this: &Collator) -> Object;
10618
10619        /// The `Intl.Collator.prototype.resolvedOptions()` method returns a new
10620        /// object with properties reflecting the locale and collation options
10621        /// computed during initialization of this Collator object.
10622        ///
10623        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/resolvedOptions)
10624        #[cfg(js_sys_unstable_apis)]
10625        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
10626        pub fn resolved_options(this: &Collator) -> ResolvedCollatorOptions;
10627
10628        /// The `Intl.Collator.supportedLocalesOf()` method returns an array
10629        /// containing those of the provided locales that are supported in
10630        /// collation without having to fall back to the runtime's default
10631        /// locale.
10632        ///
10633        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/supportedLocalesOf)
10634        #[cfg(not(js_sys_unstable_apis))]
10635        #[wasm_bindgen(static_method_of = Collator, js_namespace = Intl, js_name = supportedLocalesOf)]
10636        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
10637
10638        /// The `Intl.Collator.supportedLocalesOf()` method returns an array
10639        /// containing those of the provided locales that are supported in
10640        /// collation without having to fall back to the runtime's default
10641        /// locale.
10642        ///
10643        /// Throws a `RangeError` if locales contain invalid values.
10644        ///
10645        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/supportedLocalesOf)
10646        #[cfg(js_sys_unstable_apis)]
10647        #[wasm_bindgen(static_method_of = Collator, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
10648        pub fn supported_locales_of(
10649            locales: &[JsString],
10650            options: &LocaleMatcherOptions,
10651        ) -> Result<Array<JsString>, JsValue>;
10652    }
10653
10654    #[cfg(not(js_sys_unstable_apis))]
10655    impl Default for Collator {
10656        fn default() -> Self {
10657            Self::new(
10658                &JsValue::UNDEFINED.unchecked_into(),
10659                &JsValue::UNDEFINED.unchecked_into(),
10660            )
10661        }
10662    }
10663
10664    #[cfg(js_sys_unstable_apis)]
10665    impl Default for Collator {
10666        fn default() -> Self {
10667            Self::new(&[], &Default::default()).unwrap()
10668        }
10669    }
10670
10671    // Intl.DateTimeFormatOptions
10672    #[wasm_bindgen]
10673    extern "C" {
10674        /// Options for `Intl.DateTimeFormat` constructor.
10675        ///
10676        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#options)
10677        #[wasm_bindgen(extends = Object)]
10678        #[derive(Clone, Debug)]
10679        pub type DateTimeFormatOptions;
10680
10681        // Locale matching
10682        #[wasm_bindgen(method, getter = localeMatcher)]
10683        pub fn get_locale_matcher(this: &DateTimeFormatOptions) -> Option<LocaleMatcher>;
10684        #[wasm_bindgen(method, setter = localeMatcher)]
10685        pub fn set_locale_matcher(this: &DateTimeFormatOptions, value: LocaleMatcher);
10686
10687        // Calendar/numbering (free-form strings, no enum)
10688        #[wasm_bindgen(method, getter = calendar)]
10689        pub fn get_calendar(this: &DateTimeFormatOptions) -> Option<JsString>;
10690        #[wasm_bindgen(method, setter = calendar)]
10691        pub fn set_calendar(this: &DateTimeFormatOptions, value: &str);
10692
10693        #[wasm_bindgen(method, getter = numberingSystem)]
10694        pub fn get_numbering_system(this: &DateTimeFormatOptions) -> Option<JsString>;
10695        #[wasm_bindgen(method, setter = numberingSystem)]
10696        pub fn set_numbering_system(this: &DateTimeFormatOptions, value: &str);
10697
10698        // Timezone (free-form string)
10699        #[wasm_bindgen(method, getter = timeZone)]
10700        pub fn get_time_zone(this: &DateTimeFormatOptions) -> Option<JsString>;
10701        #[wasm_bindgen(method, setter = timeZone)]
10702        pub fn set_time_zone(this: &DateTimeFormatOptions, value: &str);
10703
10704        // Hour cycle
10705        #[wasm_bindgen(method, getter = hour12)]
10706        pub fn get_hour12(this: &DateTimeFormatOptions) -> Option<bool>;
10707        #[wasm_bindgen(method, setter = hour12)]
10708        pub fn set_hour12(this: &DateTimeFormatOptions, value: bool);
10709
10710        #[wasm_bindgen(method, getter = hourCycle)]
10711        pub fn get_hour_cycle(this: &DateTimeFormatOptions) -> Option<HourCycle>;
10712        #[wasm_bindgen(method, setter = hourCycle)]
10713        pub fn set_hour_cycle(this: &DateTimeFormatOptions, value: HourCycle);
10714
10715        // Style shortcuts
10716        #[wasm_bindgen(method, getter = dateStyle)]
10717        pub fn get_date_style(this: &DateTimeFormatOptions) -> Option<DateTimeStyle>;
10718        #[wasm_bindgen(method, setter = dateStyle)]
10719        pub fn set_date_style(this: &DateTimeFormatOptions, value: DateTimeStyle);
10720
10721        #[wasm_bindgen(method, getter = timeStyle)]
10722        pub fn get_time_style(this: &DateTimeFormatOptions) -> Option<DateTimeStyle>;
10723        #[wasm_bindgen(method, setter = timeStyle)]
10724        pub fn set_time_style(this: &DateTimeFormatOptions, value: DateTimeStyle);
10725
10726        // Component options
10727        #[wasm_bindgen(method, getter = weekday)]
10728        pub fn get_weekday(this: &DateTimeFormatOptions) -> Option<WeekdayFormat>;
10729        #[wasm_bindgen(method, setter = weekday)]
10730        pub fn set_weekday(this: &DateTimeFormatOptions, value: WeekdayFormat);
10731
10732        #[wasm_bindgen(method, getter = era)]
10733        pub fn get_era(this: &DateTimeFormatOptions) -> Option<EraFormat>;
10734        #[wasm_bindgen(method, setter = era)]
10735        pub fn set_era(this: &DateTimeFormatOptions, value: EraFormat);
10736
10737        #[wasm_bindgen(method, getter = year)]
10738        pub fn get_year(this: &DateTimeFormatOptions) -> Option<YearFormat>;
10739        #[wasm_bindgen(method, setter = year)]
10740        pub fn set_year(this: &DateTimeFormatOptions, value: YearFormat);
10741
10742        #[wasm_bindgen(method, getter = month)]
10743        pub fn get_month(this: &DateTimeFormatOptions) -> Option<MonthFormat>;
10744        #[wasm_bindgen(method, setter = month)]
10745        pub fn set_month(this: &DateTimeFormatOptions, value: MonthFormat);
10746
10747        #[wasm_bindgen(method, getter = day)]
10748        pub fn get_day(this: &DateTimeFormatOptions) -> Option<DayFormat>;
10749        #[wasm_bindgen(method, setter = day)]
10750        pub fn set_day(this: &DateTimeFormatOptions, value: DayFormat);
10751
10752        #[wasm_bindgen(method, getter = hour)]
10753        pub fn get_hour(this: &DateTimeFormatOptions) -> Option<NumericFormat>;
10754        #[wasm_bindgen(method, setter = hour)]
10755        pub fn set_hour(this: &DateTimeFormatOptions, value: NumericFormat);
10756
10757        #[wasm_bindgen(method, getter = minute)]
10758        pub fn get_minute(this: &DateTimeFormatOptions) -> Option<NumericFormat>;
10759        #[wasm_bindgen(method, setter = minute)]
10760        pub fn set_minute(this: &DateTimeFormatOptions, value: NumericFormat);
10761
10762        #[wasm_bindgen(method, getter = second)]
10763        pub fn get_second(this: &DateTimeFormatOptions) -> Option<NumericFormat>;
10764        #[wasm_bindgen(method, setter = second)]
10765        pub fn set_second(this: &DateTimeFormatOptions, value: NumericFormat);
10766
10767        #[wasm_bindgen(method, getter = fractionalSecondDigits)]
10768        pub fn get_fractional_second_digits(this: &DateTimeFormatOptions) -> Option<u8>;
10769        #[wasm_bindgen(method, setter = fractionalSecondDigits)]
10770        pub fn set_fractional_second_digits(this: &DateTimeFormatOptions, value: u8);
10771
10772        #[wasm_bindgen(method, getter = timeZoneName)]
10773        pub fn get_time_zone_name(this: &DateTimeFormatOptions) -> Option<TimeZoneNameFormat>;
10774        #[wasm_bindgen(method, setter = timeZoneName)]
10775        pub fn set_time_zone_name(this: &DateTimeFormatOptions, value: TimeZoneNameFormat);
10776
10777        #[wasm_bindgen(method, getter = dayPeriod)]
10778        pub fn get_day_period(this: &DateTimeFormatOptions) -> Option<DayPeriodFormat>;
10779        #[wasm_bindgen(method, setter = dayPeriod)]
10780        pub fn set_day_period(this: &DateTimeFormatOptions, value: DayPeriodFormat);
10781    }
10782
10783    impl DateTimeFormatOptions {
10784        pub fn new() -> DateTimeFormatOptions {
10785            JsCast::unchecked_into(Object::new())
10786        }
10787    }
10788
10789    impl Default for DateTimeFormatOptions {
10790        fn default() -> Self {
10791            DateTimeFormatOptions::new()
10792        }
10793    }
10794
10795    // Intl.ResolvedDateTimeFormatOptions
10796    #[wasm_bindgen]
10797    extern "C" {
10798        /// Resolved options returned by `Intl.DateTimeFormat.prototype.resolvedOptions()`.
10799        ///
10800        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/resolvedOptions)
10801        #[wasm_bindgen(extends = DateTimeFormatOptions)]
10802        #[derive(Clone, Debug)]
10803        pub type ResolvedDateTimeFormatOptions;
10804
10805        /// The resolved locale string.
10806        #[wasm_bindgen(method, getter = locale)]
10807        pub fn get_locale(this: &ResolvedDateTimeFormatOptions) -> JsString;
10808    }
10809
10810    // Intl.DateTimeFormatPart
10811    #[wasm_bindgen]
10812    extern "C" {
10813        /// A part of the formatted date returned by `formatToParts()`.
10814        ///
10815        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts)
10816        #[wasm_bindgen(extends = Object)]
10817        #[derive(Clone, Debug)]
10818        pub type DateTimeFormatPart;
10819
10820        /// The type of the part (e.g., "day", "month", "year", "literal", etc.)
10821        #[wasm_bindgen(method, getter = type)]
10822        pub fn type_(this: &DateTimeFormatPart) -> DateTimeFormatPartType;
10823
10824        /// The value of the part.
10825        #[wasm_bindgen(method, getter)]
10826        pub fn value(this: &DateTimeFormatPart) -> JsString;
10827    }
10828
10829    // Intl.DateTimeRangeFormatPart
10830    #[wasm_bindgen]
10831    extern "C" {
10832        /// A part of the formatted date range returned by `formatRangeToParts()`.
10833        ///
10834        /// Extends `DateTimeFormatPart` with a `source` property indicating whether
10835        /// the part is from the start date, end date, or shared between them.
10836        ///
10837        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatRangeToParts)
10838        #[wasm_bindgen(extends = DateTimeFormatPart)]
10839        #[derive(Clone, Debug)]
10840        pub type DateTimeRangeFormatPart;
10841
10842        /// The source of the part: "startRange", "endRange", or "shared".
10843        #[wasm_bindgen(method, getter)]
10844        pub fn source(this: &DateTimeRangeFormatPart) -> RangeSource;
10845    }
10846
10847    // Intl.DateTimeFormat
10848    #[wasm_bindgen]
10849    extern "C" {
10850        /// The `Intl.DateTimeFormat` object is a constructor for objects
10851        /// that enable language-sensitive date and time formatting.
10852        ///
10853        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat)
10854        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.DateTimeFormat")]
10855        #[derive(Clone, Debug)]
10856        pub type DateTimeFormat;
10857
10858        /// The `Intl.DateTimeFormat` object is a constructor for objects
10859        /// that enable language-sensitive date and time formatting.
10860        ///
10861        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat)
10862        #[cfg(not(js_sys_unstable_apis))]
10863        #[wasm_bindgen(constructor, js_namespace = Intl)]
10864        pub fn new(locales: &Array, options: &Object) -> DateTimeFormat;
10865
10866        /// The `Intl.DateTimeFormat` object is a constructor for objects
10867        /// that enable language-sensitive date and time formatting.
10868        ///
10869        /// Throws a `RangeError` if locales contain invalid values.
10870        ///
10871        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat)
10872        #[cfg(js_sys_unstable_apis)]
10873        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
10874        pub fn new(
10875            locales: &[JsString],
10876            options: &DateTimeFormatOptions,
10877        ) -> Result<DateTimeFormat, JsValue>;
10878
10879        /// The Intl.DateTimeFormat.prototype.format property returns a getter function that
10880        /// formats a date according to the locale and formatting options of this
10881        /// Intl.DateTimeFormat object.
10882        ///
10883        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/format)
10884        #[cfg(not(js_sys_unstable_apis))]
10885        #[wasm_bindgen(method, getter, js_class = "Intl.DateTimeFormat")]
10886        pub fn format(this: &DateTimeFormat) -> Function;
10887
10888        /// Formats a date according to the locale and formatting options of this
10889        /// `Intl.DateTimeFormat` object.
10890        ///
10891        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/format)
10892        #[cfg(js_sys_unstable_apis)]
10893        #[wasm_bindgen(method, js_class = "Intl.DateTimeFormat")]
10894        pub fn format(this: &DateTimeFormat, date: &Date) -> JsString;
10895
10896        /// The `Intl.DateTimeFormat.prototype.formatToParts()` method allows locale-aware
10897        /// formatting of strings produced by DateTimeFormat formatters.
10898        ///
10899        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts)
10900        #[cfg(not(js_sys_unstable_apis))]
10901        #[wasm_bindgen(method, js_class = "Intl.DateTimeFormat", js_name = formatToParts)]
10902        pub fn format_to_parts(this: &DateTimeFormat, date: &Date) -> Array;
10903
10904        /// The `Intl.DateTimeFormat.prototype.formatToParts()` method allows locale-aware
10905        /// formatting of strings produced by DateTimeFormat formatters.
10906        ///
10907        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts)
10908        #[cfg(js_sys_unstable_apis)]
10909        #[wasm_bindgen(method, js_class = "Intl.DateTimeFormat", js_name = formatToParts)]
10910        pub fn format_to_parts(this: &DateTimeFormat, date: &Date) -> Array<DateTimeFormatPart>;
10911
10912        /// The `Intl.DateTimeFormat.prototype.formatRange()` method formats a date range
10913        /// in the most concise way based on the locales and options provided when
10914        /// instantiating this `Intl.DateTimeFormat` object.
10915        ///
10916        /// Throws a `TypeError` if the dates are invalid.
10917        ///
10918        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatRange)
10919        #[wasm_bindgen(method, js_class = "Intl.DateTimeFormat", js_name = formatRange, catch)]
10920        pub fn format_range(
10921            this: &DateTimeFormat,
10922            start_date: &Date,
10923            end_date: &Date,
10924        ) -> Result<JsString, JsValue>;
10925
10926        /// The `Intl.DateTimeFormat.prototype.formatRangeToParts()` method returns an array
10927        /// of locale-specific tokens representing each part of the formatted date range
10928        /// produced by `Intl.DateTimeFormat` formatters.
10929        ///
10930        /// Throws a `TypeError` if the dates are invalid.
10931        ///
10932        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatRangeToParts)
10933        #[wasm_bindgen(method, js_class = "Intl.DateTimeFormat", js_name = formatRangeToParts, catch)]
10934        pub fn format_range_to_parts(
10935            this: &DateTimeFormat,
10936            start_date: &Date,
10937            end_date: &Date,
10938        ) -> Result<Array<DateTimeRangeFormatPart>, JsValue>;
10939
10940        /// The `Intl.DateTimeFormat.prototype.resolvedOptions()` method returns a new
10941        /// object with properties reflecting the locale and date and time formatting
10942        /// options computed during initialization of this DateTimeFormat object.
10943        ///
10944        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/resolvedOptions)
10945        #[cfg(not(js_sys_unstable_apis))]
10946        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
10947        pub fn resolved_options(this: &DateTimeFormat) -> Object;
10948
10949        /// The `Intl.DateTimeFormat.prototype.resolvedOptions()` method returns a new
10950        /// object with properties reflecting the locale and date and time formatting
10951        /// options computed during initialization of this DateTimeFormat object.
10952        ///
10953        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/resolvedOptions)
10954        #[cfg(js_sys_unstable_apis)]
10955        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
10956        pub fn resolved_options(this: &DateTimeFormat) -> ResolvedDateTimeFormatOptions;
10957
10958        /// The `Intl.DateTimeFormat.supportedLocalesOf()` method returns an array
10959        /// containing those of the provided locales that are supported in date
10960        /// and time formatting without having to fall back to the runtime's default
10961        /// locale.
10962        ///
10963        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/supportedLocalesOf)
10964        #[cfg(not(js_sys_unstable_apis))]
10965        #[wasm_bindgen(static_method_of = DateTimeFormat, js_namespace = Intl, js_name = supportedLocalesOf)]
10966        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
10967
10968        /// The `Intl.DateTimeFormat.supportedLocalesOf()` method returns an array
10969        /// containing those of the provided locales that are supported in date
10970        /// and time formatting without having to fall back to the runtime's default
10971        /// locale.
10972        ///
10973        /// Throws a `RangeError` if locales contain invalid values.
10974        ///
10975        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/supportedLocalesOf)
10976        #[cfg(js_sys_unstable_apis)]
10977        #[wasm_bindgen(static_method_of = DateTimeFormat, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
10978        pub fn supported_locales_of(
10979            locales: &[JsString],
10980            options: &LocaleMatcherOptions,
10981        ) -> Result<Array<JsString>, JsValue>;
10982    }
10983
10984    #[cfg(not(js_sys_unstable_apis))]
10985    impl Default for DateTimeFormat {
10986        fn default() -> Self {
10987            Self::new(
10988                &JsValue::UNDEFINED.unchecked_into(),
10989                &JsValue::UNDEFINED.unchecked_into(),
10990            )
10991        }
10992    }
10993
10994    #[cfg(js_sys_unstable_apis)]
10995    impl Default for DateTimeFormat {
10996        fn default() -> Self {
10997            Self::new(&[], &Default::default()).unwrap()
10998        }
10999    }
11000
11001    // Intl.NumberFormatOptions
11002    #[wasm_bindgen]
11003    extern "C" {
11004        /// Options for `Intl.NumberFormat` constructor.
11005        ///
11006        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#options)
11007        #[wasm_bindgen(extends = Object)]
11008        #[derive(Clone, Debug)]
11009        pub type NumberFormatOptions;
11010
11011        // Locale matching
11012        #[wasm_bindgen(method, getter = localeMatcher)]
11013        pub fn get_locale_matcher(this: &NumberFormatOptions) -> Option<LocaleMatcher>;
11014        #[wasm_bindgen(method, setter = localeMatcher)]
11015        pub fn set_locale_matcher(this: &NumberFormatOptions, value: LocaleMatcher);
11016
11017        // Numbering system (free-form string)
11018        #[wasm_bindgen(method, getter = numberingSystem)]
11019        pub fn get_numbering_system(this: &NumberFormatOptions) -> Option<JsString>;
11020        #[wasm_bindgen(method, setter = numberingSystem)]
11021        pub fn set_numbering_system(this: &NumberFormatOptions, value: &str);
11022
11023        // Style
11024        #[wasm_bindgen(method, getter = style)]
11025        pub fn get_style(this: &NumberFormatOptions) -> Option<NumberFormatStyle>;
11026        #[wasm_bindgen(method, setter = style)]
11027        pub fn set_style(this: &NumberFormatOptions, value: NumberFormatStyle);
11028
11029        // Currency options (currency code is free-form ISO 4217 string)
11030        #[wasm_bindgen(method, getter = currency)]
11031        pub fn get_currency(this: &NumberFormatOptions) -> Option<JsString>;
11032        #[wasm_bindgen(method, setter = currency)]
11033        pub fn set_currency(this: &NumberFormatOptions, value: &str);
11034
11035        #[wasm_bindgen(method, getter = currencyDisplay)]
11036        pub fn get_currency_display(this: &NumberFormatOptions) -> Option<CurrencyDisplay>;
11037        #[wasm_bindgen(method, setter = currencyDisplay)]
11038        pub fn set_currency_display(this: &NumberFormatOptions, value: CurrencyDisplay);
11039
11040        #[wasm_bindgen(method, getter = currencySign)]
11041        pub fn get_currency_sign(this: &NumberFormatOptions) -> Option<CurrencySign>;
11042        #[wasm_bindgen(method, setter = currencySign)]
11043        pub fn set_currency_sign(this: &NumberFormatOptions, value: CurrencySign);
11044
11045        // Unit options (unit name is free-form string)
11046        #[wasm_bindgen(method, getter = unit)]
11047        pub fn get_unit(this: &NumberFormatOptions) -> Option<JsString>;
11048        #[wasm_bindgen(method, setter = unit)]
11049        pub fn set_unit(this: &NumberFormatOptions, value: &str);
11050
11051        #[wasm_bindgen(method, getter = unitDisplay)]
11052        pub fn get_unit_display(this: &NumberFormatOptions) -> Option<UnitDisplay>;
11053        #[wasm_bindgen(method, setter = unitDisplay)]
11054        pub fn set_unit_display(this: &NumberFormatOptions, value: UnitDisplay);
11055
11056        // Notation
11057        #[wasm_bindgen(method, getter = notation)]
11058        pub fn get_notation(this: &NumberFormatOptions) -> Option<NumberFormatNotation>;
11059        #[wasm_bindgen(method, setter = notation)]
11060        pub fn set_notation(this: &NumberFormatOptions, value: NumberFormatNotation);
11061
11062        #[wasm_bindgen(method, getter = compactDisplay)]
11063        pub fn get_compact_display(this: &NumberFormatOptions) -> Option<CompactDisplay>;
11064        #[wasm_bindgen(method, setter = compactDisplay)]
11065        pub fn set_compact_display(this: &NumberFormatOptions, value: CompactDisplay);
11066
11067        // Sign display
11068        #[wasm_bindgen(method, getter = signDisplay)]
11069        pub fn get_sign_display(this: &NumberFormatOptions) -> Option<SignDisplay>;
11070        #[wasm_bindgen(method, setter = signDisplay)]
11071        pub fn set_sign_display(this: &NumberFormatOptions, value: SignDisplay);
11072
11073        // Digit options
11074        #[wasm_bindgen(method, getter = minimumIntegerDigits)]
11075        pub fn get_minimum_integer_digits(this: &NumberFormatOptions) -> Option<u8>;
11076        #[wasm_bindgen(method, setter = minimumIntegerDigits)]
11077        pub fn set_minimum_integer_digits(this: &NumberFormatOptions, value: u8);
11078
11079        #[wasm_bindgen(method, getter = minimumFractionDigits)]
11080        pub fn get_minimum_fraction_digits(this: &NumberFormatOptions) -> Option<u8>;
11081        #[wasm_bindgen(method, setter = minimumFractionDigits)]
11082        pub fn set_minimum_fraction_digits(this: &NumberFormatOptions, value: u8);
11083
11084        #[wasm_bindgen(method, getter = maximumFractionDigits)]
11085        pub fn get_maximum_fraction_digits(this: &NumberFormatOptions) -> Option<u8>;
11086        #[wasm_bindgen(method, setter = maximumFractionDigits)]
11087        pub fn set_maximum_fraction_digits(this: &NumberFormatOptions, value: u8);
11088
11089        #[wasm_bindgen(method, getter = minimumSignificantDigits)]
11090        pub fn get_minimum_significant_digits(this: &NumberFormatOptions) -> Option<u8>;
11091        #[wasm_bindgen(method, setter = minimumSignificantDigits)]
11092        pub fn set_minimum_significant_digits(this: &NumberFormatOptions, value: u8);
11093
11094        #[wasm_bindgen(method, getter = maximumSignificantDigits)]
11095        pub fn get_maximum_significant_digits(this: &NumberFormatOptions) -> Option<u8>;
11096        #[wasm_bindgen(method, setter = maximumSignificantDigits)]
11097        pub fn set_maximum_significant_digits(this: &NumberFormatOptions, value: u8);
11098
11099        // Grouping
11100        #[wasm_bindgen(method, getter = useGrouping)]
11101        pub fn get_use_grouping(this: &NumberFormatOptions) -> Option<UseGrouping>;
11102        #[wasm_bindgen(method, setter = useGrouping)]
11103        pub fn set_use_grouping(this: &NumberFormatOptions, value: UseGrouping);
11104
11105        // Rounding
11106        #[wasm_bindgen(method, getter = roundingMode)]
11107        pub fn get_rounding_mode(this: &NumberFormatOptions) -> Option<RoundingMode>;
11108        #[wasm_bindgen(method, setter = roundingMode)]
11109        pub fn set_rounding_mode(this: &NumberFormatOptions, value: RoundingMode);
11110
11111        #[wasm_bindgen(method, getter = roundingPriority)]
11112        pub fn get_rounding_priority(this: &NumberFormatOptions) -> Option<RoundingPriority>;
11113        #[wasm_bindgen(method, setter = roundingPriority)]
11114        pub fn set_rounding_priority(this: &NumberFormatOptions, value: RoundingPriority);
11115
11116        #[wasm_bindgen(method, getter = roundingIncrement)]
11117        pub fn get_rounding_increment(this: &NumberFormatOptions) -> Option<u32>;
11118        #[wasm_bindgen(method, setter = roundingIncrement)]
11119        pub fn set_rounding_increment(this: &NumberFormatOptions, value: u32);
11120
11121        #[wasm_bindgen(method, getter = trailingZeroDisplay)]
11122        pub fn get_trailing_zero_display(this: &NumberFormatOptions)
11123            -> Option<TrailingZeroDisplay>;
11124        #[wasm_bindgen(method, setter = trailingZeroDisplay)]
11125        pub fn set_trailing_zero_display(this: &NumberFormatOptions, value: TrailingZeroDisplay);
11126    }
11127
11128    impl NumberFormatOptions {
11129        pub fn new() -> NumberFormatOptions {
11130            JsCast::unchecked_into(Object::new())
11131        }
11132    }
11133
11134    impl Default for NumberFormatOptions {
11135        fn default() -> Self {
11136            NumberFormatOptions::new()
11137        }
11138    }
11139
11140    // Intl.ResolvedNumberFormatOptions
11141    #[wasm_bindgen]
11142    extern "C" {
11143        /// Resolved options returned by `Intl.NumberFormat.prototype.resolvedOptions()`.
11144        ///
11145        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/resolvedOptions)
11146        #[wasm_bindgen(extends = NumberFormatOptions)]
11147        #[derive(Clone, Debug)]
11148        pub type ResolvedNumberFormatOptions;
11149
11150        /// The resolved locale string.
11151        #[wasm_bindgen(method, getter = locale)]
11152        pub fn get_locale(this: &ResolvedNumberFormatOptions) -> JsString;
11153    }
11154
11155    // Intl.NumberFormatPart
11156    #[wasm_bindgen]
11157    extern "C" {
11158        /// A part of the formatted number returned by `formatToParts()`.
11159        ///
11160        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatToParts)
11161        #[wasm_bindgen(extends = Object)]
11162        #[derive(Clone, Debug)]
11163        pub type NumberFormatPart;
11164
11165        /// The type of the part (e.g., "integer", "decimal", "fraction", "currency", etc.)
11166        #[wasm_bindgen(method, getter = type)]
11167        pub fn type_(this: &NumberFormatPart) -> NumberFormatPartType;
11168
11169        /// The value of the part.
11170        #[wasm_bindgen(method, getter)]
11171        pub fn value(this: &NumberFormatPart) -> JsString;
11172    }
11173
11174    // Intl.NumberRangeFormatPart
11175    #[wasm_bindgen]
11176    extern "C" {
11177        /// A part of the formatted number range returned by `formatRangeToParts()`.
11178        ///
11179        /// Extends `NumberFormatPart` with a `source` property indicating whether
11180        /// the part is from the start number, end number, or shared between them.
11181        ///
11182        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatRangeToParts)
11183        #[wasm_bindgen(extends = NumberFormatPart)]
11184        #[derive(Clone, Debug)]
11185        pub type NumberRangeFormatPart;
11186
11187        /// The source of the part: "startRange", "endRange", or "shared".
11188        #[wasm_bindgen(method, getter)]
11189        pub fn source(this: &NumberRangeFormatPart) -> RangeSource;
11190    }
11191
11192    // Intl.NumberFormat
11193    #[wasm_bindgen]
11194    extern "C" {
11195        /// The `Intl.NumberFormat` object is a constructor for objects
11196        /// that enable language sensitive number formatting.
11197        ///
11198        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat)
11199        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.NumberFormat")]
11200        #[derive(Clone, Debug)]
11201        pub type NumberFormat;
11202
11203        /// The `Intl.NumberFormat` object is a constructor for objects
11204        /// that enable language sensitive number formatting.
11205        ///
11206        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat)
11207        #[cfg(not(js_sys_unstable_apis))]
11208        #[wasm_bindgen(constructor, js_namespace = Intl)]
11209        pub fn new(locales: &Array, options: &Object) -> NumberFormat;
11210
11211        /// The `Intl.NumberFormat` object is a constructor for objects
11212        /// that enable language sensitive number formatting.
11213        ///
11214        /// Throws a `RangeError` if locales contain invalid values.
11215        ///
11216        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat)
11217        #[cfg(js_sys_unstable_apis)]
11218        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
11219        pub fn new(
11220            locales: &[JsString],
11221            options: &NumberFormatOptions,
11222        ) -> Result<NumberFormat, JsValue>;
11223
11224        /// The Intl.NumberFormat.prototype.format property returns a getter function that
11225        /// formats a number according to the locale and formatting options of this
11226        /// NumberFormat object.
11227        ///
11228        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/format)
11229        #[cfg(not(js_sys_unstable_apis))]
11230        #[wasm_bindgen(method, getter, js_class = "Intl.NumberFormat")]
11231        pub fn format(this: &NumberFormat) -> Function;
11232
11233        /// Formats a number according to the locale and formatting options of this
11234        /// `Intl.NumberFormat` object.
11235        ///
11236        /// Accepts numeric strings for BigInt/arbitrary precision (e.g., `"123n"` → `"123"`,
11237        /// or use E notation: `"1000000E-6"` → `"1"`).
11238        ///
11239        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/format)
11240        #[cfg(js_sys_unstable_apis)]
11241        #[wasm_bindgen(method, js_class = "Intl.NumberFormat")]
11242        pub fn format(this: &NumberFormat, value: &JsString) -> JsString;
11243
11244        /// The `Intl.Numberformat.prototype.formatToParts()` method allows locale-aware
11245        /// formatting of strings produced by NumberTimeFormat formatters.
11246        ///
11247        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/formatToParts)
11248        #[cfg(not(js_sys_unstable_apis))]
11249        #[wasm_bindgen(method, js_class = "Intl.NumberFormat", js_name = formatToParts)]
11250        pub fn format_to_parts(this: &NumberFormat, number: f64) -> Array;
11251
11252        /// The `Intl.NumberFormat.prototype.formatToParts()` method allows locale-aware
11253        /// formatting of strings produced by `Intl.NumberFormat` formatters.
11254        ///
11255        /// Accepts numeric strings for BigInt/arbitrary precision (e.g., `"123n"` → `"123"`,
11256        /// or use E notation: `"1000000E-6"` → `"1"`).
11257        ///
11258        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatToParts)
11259        #[cfg(js_sys_unstable_apis)]
11260        #[wasm_bindgen(method, js_class = "Intl.NumberFormat", js_name = formatToParts)]
11261        pub fn format_to_parts(this: &NumberFormat, value: &JsString) -> Array<NumberFormatPart>;
11262
11263        /// Formats a range of numbers according to the locale and formatting options
11264        /// of this `Intl.NumberFormat` object.
11265        ///
11266        /// Accepts numeric strings for BigInt/arbitrary precision (e.g., `"123n"` → `"123"`,
11267        /// or use E notation: `"1000000E-6"` → `"1"`).
11268        ///
11269        /// Throws a `TypeError` if the values are invalid.
11270        ///
11271        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatRange)
11272        #[wasm_bindgen(method, js_class = "Intl.NumberFormat", js_name = formatRange, catch)]
11273        pub fn format_range(
11274            this: &NumberFormat,
11275            start: &JsString,
11276            end: &JsString,
11277        ) -> Result<JsString, JsValue>;
11278
11279        /// Returns an array of locale-specific tokens representing each part of
11280        /// the formatted number range.
11281        ///
11282        /// Accepts numeric strings for BigInt/arbitrary precision (e.g., `"123n"` → `"123"`,
11283        /// or use E notation: `"1000000E-6"` → `"1"`).
11284        ///
11285        /// Throws a `TypeError` if the values are invalid.
11286        ///
11287        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatRangeToParts)
11288        #[wasm_bindgen(method, js_class = "Intl.NumberFormat", js_name = formatRangeToParts, catch)]
11289        pub fn format_range_to_parts(
11290            this: &NumberFormat,
11291            start: &JsString,
11292            end: &JsString,
11293        ) -> Result<Array<NumberRangeFormatPart>, JsValue>;
11294
11295        /// The `Intl.NumberFormat.prototype.resolvedOptions()` method returns a new
11296        /// object with properties reflecting the locale and number formatting
11297        /// options computed during initialization of this NumberFormat object.
11298        ///
11299        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/resolvedOptions)
11300        #[cfg(not(js_sys_unstable_apis))]
11301        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11302        pub fn resolved_options(this: &NumberFormat) -> Object;
11303
11304        /// The `Intl.NumberFormat.prototype.resolvedOptions()` method returns a new
11305        /// object with properties reflecting the locale and number formatting
11306        /// options computed during initialization of this NumberFormat object.
11307        ///
11308        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/resolvedOptions)
11309        #[cfg(js_sys_unstable_apis)]
11310        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11311        pub fn resolved_options(this: &NumberFormat) -> ResolvedNumberFormatOptions;
11312
11313        /// The `Intl.NumberFormat.supportedLocalesOf()` method returns an array
11314        /// containing those of the provided locales that are supported in number
11315        /// formatting without having to fall back to the runtime's default locale.
11316        ///
11317        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/supportedLocalesOf)
11318        #[cfg(not(js_sys_unstable_apis))]
11319        #[wasm_bindgen(static_method_of = NumberFormat, js_namespace = Intl, js_name = supportedLocalesOf)]
11320        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
11321
11322        /// The `Intl.NumberFormat.supportedLocalesOf()` method returns an array
11323        /// containing those of the provided locales that are supported in number
11324        /// formatting without having to fall back to the runtime's default locale.
11325        ///
11326        /// Throws a `RangeError` if locales contain invalid values.
11327        ///
11328        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/supportedLocalesOf)
11329        #[cfg(js_sys_unstable_apis)]
11330        #[wasm_bindgen(static_method_of = NumberFormat, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
11331        pub fn supported_locales_of(
11332            locales: &[JsString],
11333            options: &LocaleMatcherOptions,
11334        ) -> Result<Array<JsString>, JsValue>;
11335    }
11336
11337    #[cfg(not(js_sys_unstable_apis))]
11338    impl Default for NumberFormat {
11339        fn default() -> Self {
11340            Self::new(
11341                &JsValue::UNDEFINED.unchecked_into(),
11342                &JsValue::UNDEFINED.unchecked_into(),
11343            )
11344        }
11345    }
11346
11347    #[cfg(js_sys_unstable_apis)]
11348    impl Default for NumberFormat {
11349        fn default() -> Self {
11350            Self::new(&[], &Default::default()).unwrap()
11351        }
11352    }
11353
11354    // Intl.PluralRulesOptions
11355    #[wasm_bindgen]
11356    extern "C" {
11357        /// Options for `Intl.PluralRules` constructor.
11358        ///
11359        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/PluralRules#options)
11360        #[wasm_bindgen(extends = Object)]
11361        #[derive(Clone, Debug)]
11362        pub type PluralRulesOptions;
11363
11364        #[wasm_bindgen(method, getter = localeMatcher)]
11365        pub fn get_locale_matcher(this: &PluralRulesOptions) -> Option<LocaleMatcher>;
11366        #[wasm_bindgen(method, setter = localeMatcher)]
11367        pub fn set_locale_matcher(this: &PluralRulesOptions, value: LocaleMatcher);
11368
11369        #[wasm_bindgen(method, getter = type)]
11370        pub fn get_type(this: &PluralRulesOptions) -> Option<PluralRulesType>;
11371        #[wasm_bindgen(method, setter = type)]
11372        pub fn set_type(this: &PluralRulesOptions, value: PluralRulesType);
11373
11374        #[wasm_bindgen(method, getter = minimumIntegerDigits)]
11375        pub fn get_minimum_integer_digits(this: &PluralRulesOptions) -> Option<u8>;
11376        #[wasm_bindgen(method, setter = minimumIntegerDigits)]
11377        pub fn set_minimum_integer_digits(this: &PluralRulesOptions, value: u8);
11378
11379        #[wasm_bindgen(method, getter = minimumFractionDigits)]
11380        pub fn get_minimum_fraction_digits(this: &PluralRulesOptions) -> Option<u8>;
11381        #[wasm_bindgen(method, setter = minimumFractionDigits)]
11382        pub fn set_minimum_fraction_digits(this: &PluralRulesOptions, value: u8);
11383
11384        #[wasm_bindgen(method, getter = maximumFractionDigits)]
11385        pub fn get_maximum_fraction_digits(this: &PluralRulesOptions) -> Option<u8>;
11386        #[wasm_bindgen(method, setter = maximumFractionDigits)]
11387        pub fn set_maximum_fraction_digits(this: &PluralRulesOptions, value: u8);
11388
11389        #[wasm_bindgen(method, getter = minimumSignificantDigits)]
11390        pub fn get_minimum_significant_digits(this: &PluralRulesOptions) -> Option<u8>;
11391        #[wasm_bindgen(method, setter = minimumSignificantDigits)]
11392        pub fn set_minimum_significant_digits(this: &PluralRulesOptions, value: u8);
11393
11394        #[wasm_bindgen(method, getter = maximumSignificantDigits)]
11395        pub fn get_maximum_significant_digits(this: &PluralRulesOptions) -> Option<u8>;
11396        #[wasm_bindgen(method, setter = maximumSignificantDigits)]
11397        pub fn set_maximum_significant_digits(this: &PluralRulesOptions, value: u8);
11398
11399        #[wasm_bindgen(method, getter = roundingPriority)]
11400        pub fn get_rounding_priority(this: &PluralRulesOptions) -> Option<RoundingPriority>;
11401        #[wasm_bindgen(method, setter = roundingPriority)]
11402        pub fn set_rounding_priority(this: &PluralRulesOptions, value: RoundingPriority);
11403
11404        #[wasm_bindgen(method, getter = roundingIncrement)]
11405        pub fn get_rounding_increment(this: &PluralRulesOptions) -> Option<u32>;
11406        #[wasm_bindgen(method, setter = roundingIncrement)]
11407        pub fn set_rounding_increment(this: &PluralRulesOptions, value: u32);
11408
11409        #[wasm_bindgen(method, getter = roundingMode)]
11410        pub fn get_rounding_mode(this: &PluralRulesOptions) -> Option<RoundingMode>;
11411        #[wasm_bindgen(method, setter = roundingMode)]
11412        pub fn set_rounding_mode(this: &PluralRulesOptions, value: RoundingMode);
11413
11414        #[wasm_bindgen(method, getter = trailingZeroDisplay)]
11415        pub fn get_trailing_zero_display(this: &PluralRulesOptions) -> Option<TrailingZeroDisplay>;
11416        #[wasm_bindgen(method, setter = trailingZeroDisplay)]
11417        pub fn set_trailing_zero_display(this: &PluralRulesOptions, value: TrailingZeroDisplay);
11418    }
11419
11420    impl PluralRulesOptions {
11421        pub fn new() -> PluralRulesOptions {
11422            JsCast::unchecked_into(Object::new())
11423        }
11424    }
11425
11426    impl Default for PluralRulesOptions {
11427        fn default() -> Self {
11428            PluralRulesOptions::new()
11429        }
11430    }
11431
11432    // Intl.ResolvedPluralRulesOptions
11433    #[wasm_bindgen]
11434    extern "C" {
11435        /// Resolved options returned by `Intl.PluralRules.prototype.resolvedOptions()`.
11436        ///
11437        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/resolvedOptions)
11438        #[wasm_bindgen(extends = PluralRulesOptions)]
11439        #[derive(Clone, Debug)]
11440        pub type ResolvedPluralRulesOptions;
11441
11442        /// The resolved locale string.
11443        #[wasm_bindgen(method, getter = locale)]
11444        pub fn get_locale(this: &ResolvedPluralRulesOptions) -> JsString;
11445
11446        /// The plural categories used by the locale.
11447        #[wasm_bindgen(method, getter = pluralCategories)]
11448        pub fn get_plural_categories(this: &ResolvedPluralRulesOptions) -> Array<JsString>;
11449    }
11450
11451    // Intl.PluralRules
11452    #[wasm_bindgen]
11453    extern "C" {
11454        /// The `Intl.PluralRules` object is a constructor for objects
11455        /// that enable plural sensitive formatting and plural language rules.
11456        ///
11457        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules)
11458        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.PluralRules")]
11459        #[derive(Clone, Debug)]
11460        pub type PluralRules;
11461
11462        /// The `Intl.PluralRules` object is a constructor for objects
11463        /// that enable plural sensitive formatting and plural language rules.
11464        ///
11465        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules)
11466        #[cfg(not(js_sys_unstable_apis))]
11467        #[wasm_bindgen(constructor, js_namespace = Intl)]
11468        pub fn new(locales: &Array, options: &Object) -> PluralRules;
11469
11470        /// The `Intl.PluralRules` object is a constructor for objects
11471        /// that enable plural sensitive formatting and plural language rules.
11472        ///
11473        /// Throws a `RangeError` if locales contain invalid values.
11474        ///
11475        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules)
11476        #[cfg(js_sys_unstable_apis)]
11477        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
11478        pub fn new(
11479            locales: &[JsString],
11480            options: &PluralRulesOptions,
11481        ) -> Result<PluralRules, JsValue>;
11482
11483        /// The `Intl.PluralRules.prototype.resolvedOptions()` method returns a new
11484        /// object with properties reflecting the locale and plural formatting
11485        /// options computed during initialization of this PluralRules object.
11486        ///
11487        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/resolvedOptions)
11488        #[cfg(not(js_sys_unstable_apis))]
11489        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11490        pub fn resolved_options(this: &PluralRules) -> Object;
11491
11492        /// The `Intl.PluralRules.prototype.resolvedOptions()` method returns a new
11493        /// object with properties reflecting the locale and plural formatting
11494        /// options computed during initialization of this PluralRules object.
11495        ///
11496        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/resolvedOptions)
11497        #[cfg(js_sys_unstable_apis)]
11498        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11499        pub fn resolved_options(this: &PluralRules) -> ResolvedPluralRulesOptions;
11500
11501        /// The `Intl.PluralRules.prototype.select()` method returns a String indicating
11502        /// which plural rule to use for locale-aware formatting.
11503        ///
11504        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/select)
11505        #[cfg(not(js_sys_unstable_apis))]
11506        #[wasm_bindgen(method, js_namespace = Intl)]
11507        pub fn select(this: &PluralRules, number: f64) -> JsString;
11508
11509        /// The `Intl.PluralRules.prototype.select()` method returns a String indicating
11510        /// which plural rule to use for locale-aware formatting.
11511        ///
11512        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/select)
11513        #[cfg(js_sys_unstable_apis)]
11514        #[wasm_bindgen(method, js_namespace = Intl)]
11515        pub fn select(this: &PluralRules, number: f64) -> PluralCategory;
11516
11517        /// The `Intl.PluralRules.prototype.selectRange()` method returns a string indicating
11518        /// which plural rule to use for locale-aware formatting of a range of numbers.
11519        ///
11520        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/selectRange)
11521        #[cfg(not(js_sys_unstable_apis))]
11522        #[wasm_bindgen(method, js_namespace = Intl, js_name = selectRange)]
11523        pub fn select_range(this: &PluralRules, start: f64, end: f64) -> JsString;
11524
11525        /// The `Intl.PluralRules.prototype.selectRange()` method returns a string indicating
11526        /// which plural rule to use for locale-aware formatting of a range of numbers.
11527        ///
11528        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/selectRange)
11529        #[cfg(js_sys_unstable_apis)]
11530        #[wasm_bindgen(method, js_namespace = Intl, js_name = selectRange)]
11531        pub fn select_range(this: &PluralRules, start: f64, end: f64) -> PluralCategory;
11532
11533        /// The `Intl.PluralRules.supportedLocalesOf()` method returns an array
11534        /// containing those of the provided locales that are supported in plural
11535        /// formatting without having to fall back to the runtime's default locale.
11536        ///
11537        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/supportedLocalesOf)
11538        #[cfg(not(js_sys_unstable_apis))]
11539        #[wasm_bindgen(static_method_of = PluralRules, js_namespace = Intl, js_name = supportedLocalesOf)]
11540        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
11541
11542        /// The `Intl.PluralRules.supportedLocalesOf()` method returns an array
11543        /// containing those of the provided locales that are supported in plural
11544        /// formatting without having to fall back to the runtime's default locale.
11545        ///
11546        /// Throws a `RangeError` if locales contain invalid values.
11547        ///
11548        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/supportedLocalesOf)
11549        #[cfg(js_sys_unstable_apis)]
11550        #[wasm_bindgen(static_method_of = PluralRules, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
11551        pub fn supported_locales_of(
11552            locales: &[JsString],
11553            options: &LocaleMatcherOptions,
11554        ) -> Result<Array<JsString>, JsValue>;
11555    }
11556
11557    #[cfg(not(js_sys_unstable_apis))]
11558    impl Default for PluralRules {
11559        fn default() -> Self {
11560            Self::new(
11561                &JsValue::UNDEFINED.unchecked_into(),
11562                &JsValue::UNDEFINED.unchecked_into(),
11563            )
11564        }
11565    }
11566
11567    #[cfg(js_sys_unstable_apis)]
11568    impl Default for PluralRules {
11569        fn default() -> Self {
11570            Self::new(&[], &Default::default()).unwrap()
11571        }
11572    }
11573
11574    // Intl.RelativeTimeFormat
11575    #[wasm_bindgen]
11576    extern "C" {
11577        /// The `Intl.RelativeTimeFormat` object is a constructor for objects
11578        /// that enable language-sensitive relative time formatting.
11579        ///
11580        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat)
11581        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.RelativeTimeFormat")]
11582        #[derive(Clone, Debug)]
11583        pub type RelativeTimeFormat;
11584
11585        /// The `Intl.RelativeTimeFormat` object is a constructor for objects
11586        /// that enable language-sensitive relative time formatting.
11587        ///
11588        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat)
11589        #[cfg(not(js_sys_unstable_apis))]
11590        #[wasm_bindgen(constructor, js_namespace = Intl)]
11591        pub fn new(locales: &Array, options: &Object) -> RelativeTimeFormat;
11592
11593        /// The `Intl.RelativeTimeFormat` object is a constructor for objects
11594        /// that enable language-sensitive relative time formatting.
11595        ///
11596        /// Throws a `RangeError` if locales contain invalid values.
11597        ///
11598        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat)
11599        #[cfg(js_sys_unstable_apis)]
11600        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
11601        pub fn new(locales: &[JsString]) -> Result<RelativeTimeFormat, JsValue>;
11602
11603        /// The `Intl.RelativeTimeFormat` object is a constructor for objects
11604        /// that enable language-sensitive relative time formatting.
11605        ///
11606        /// Throws a `RangeError` if locales or options contain invalid values.
11607        ///
11608        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat)
11609        #[cfg(js_sys_unstable_apis)]
11610        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
11611        pub fn new_with_options(
11612            locales: &[JsString],
11613            options: &RelativeTimeFormatOptions,
11614        ) -> Result<RelativeTimeFormat, JsValue>;
11615
11616        /// The `Intl.RelativeTimeFormat.prototype.format` method formats a `value` and `unit`
11617        /// according to the locale and formatting options of this Intl.RelativeTimeFormat object.
11618        ///
11619        /// Throws a `RangeError` if unit is invalid.
11620        ///
11621        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/format)
11622        #[cfg(not(js_sys_unstable_apis))]
11623        #[wasm_bindgen(method, js_class = "Intl.RelativeTimeFormat")]
11624        pub fn format(this: &RelativeTimeFormat, value: f64, unit: &str) -> JsString;
11625
11626        /// The `Intl.RelativeTimeFormat.prototype.format` method formats a `value` and `unit`
11627        /// according to the locale and formatting options of this Intl.RelativeTimeFormat object.
11628        ///
11629        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/format)
11630        #[cfg(js_sys_unstable_apis)]
11631        #[wasm_bindgen(method, js_class = "Intl.RelativeTimeFormat")]
11632        pub fn format(
11633            this: &RelativeTimeFormat,
11634            value: f64,
11635            unit: RelativeTimeFormatUnit,
11636        ) -> JsString;
11637
11638        /// The `Intl.RelativeTimeFormat.prototype.formatToParts()` method returns an array of
11639        /// objects representing the relative time format in parts that can be used for custom locale-aware formatting.
11640        ///
11641        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/formatToParts)
11642        #[cfg(not(js_sys_unstable_apis))]
11643        #[wasm_bindgen(method, js_class = "Intl.RelativeTimeFormat", js_name = formatToParts)]
11644        pub fn format_to_parts(this: &RelativeTimeFormat, value: f64, unit: &str) -> Array;
11645
11646        /// The `Intl.RelativeTimeFormat.prototype.formatToParts()` method returns an array of
11647        /// objects representing the relative time format in parts that can be used for custom locale-aware formatting.
11648        ///
11649        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/formatToParts)
11650        #[cfg(js_sys_unstable_apis)]
11651        #[wasm_bindgen(method, js_class = "Intl.RelativeTimeFormat", js_name = formatToParts)]
11652        pub fn format_to_parts(
11653            this: &RelativeTimeFormat,
11654            value: f64,
11655            unit: RelativeTimeFormatUnit,
11656        ) -> Array<RelativeTimeFormatPart>;
11657
11658        /// The `Intl.RelativeTimeFormat.prototype.resolvedOptions()` method returns a new
11659        /// object with properties reflecting the locale and relative time formatting
11660        /// options computed during initialization of this RelativeTimeFormat object.
11661        ///
11662        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/resolvedOptions)
11663        #[cfg(not(js_sys_unstable_apis))]
11664        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11665        pub fn resolved_options(this: &RelativeTimeFormat) -> Object;
11666
11667        /// The `Intl.RelativeTimeFormat.prototype.resolvedOptions()` method returns a new
11668        /// object with properties reflecting the locale and relative time formatting
11669        /// options computed during initialization of this RelativeTimeFormat object.
11670        ///
11671        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/resolvedOptions)
11672        #[cfg(js_sys_unstable_apis)]
11673        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11674        pub fn resolved_options(this: &RelativeTimeFormat) -> ResolvedRelativeTimeFormatOptions;
11675
11676        /// The `Intl.RelativeTimeFormat.supportedLocalesOf()` method returns an array
11677        /// containing those of the provided locales that are supported in date and time
11678        /// formatting without having to fall back to the runtime's default locale.
11679        ///
11680        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat/supportedLocalesOf)
11681        #[cfg(not(js_sys_unstable_apis))]
11682        #[wasm_bindgen(static_method_of = RelativeTimeFormat, js_namespace = Intl, js_name = supportedLocalesOf)]
11683        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
11684
11685        /// The `Intl.RelativeTimeFormat.supportedLocalesOf()` method returns an array
11686        /// containing those of the provided locales that are supported in date and time
11687        /// formatting without having to fall back to the runtime's default locale.
11688        ///
11689        /// Throws a `RangeError` if locales contain invalid values.
11690        ///
11691        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat/supportedLocalesOf)
11692        #[cfg(js_sys_unstable_apis)]
11693        #[wasm_bindgen(static_method_of = RelativeTimeFormat, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
11694        pub fn supported_locales_of(
11695            locales: &[JsString],
11696            options: &LocaleMatcherOptions,
11697        ) -> Result<Array<JsString>, JsValue>;
11698    }
11699
11700    #[cfg(not(js_sys_unstable_apis))]
11701    impl Default for RelativeTimeFormat {
11702        fn default() -> Self {
11703            Self::new(
11704                &JsValue::UNDEFINED.unchecked_into(),
11705                &JsValue::UNDEFINED.unchecked_into(),
11706            )
11707        }
11708    }
11709
11710    #[cfg(js_sys_unstable_apis)]
11711    impl Default for RelativeTimeFormat {
11712        fn default() -> Self {
11713            Self::new(&[]).unwrap()
11714        }
11715    }
11716
11717    // Intl.ListFormatOptions
11718    #[wasm_bindgen]
11719    extern "C" {
11720        /// Options for `Intl.ListFormat` constructor.
11721        ///
11722        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat#options)
11723        #[wasm_bindgen(extends = Object)]
11724        #[derive(Clone, Debug)]
11725        pub type ListFormatOptions;
11726
11727        #[wasm_bindgen(method, getter = localeMatcher)]
11728        pub fn get_locale_matcher(this: &ListFormatOptions) -> Option<LocaleMatcher>;
11729        #[wasm_bindgen(method, setter = localeMatcher)]
11730        pub fn set_locale_matcher(this: &ListFormatOptions, value: LocaleMatcher);
11731
11732        #[wasm_bindgen(method, getter = type)]
11733        pub fn get_type(this: &ListFormatOptions) -> Option<ListFormatType>;
11734        #[wasm_bindgen(method, setter = type)]
11735        pub fn set_type(this: &ListFormatOptions, value: ListFormatType);
11736
11737        #[wasm_bindgen(method, getter = style)]
11738        pub fn get_style(this: &ListFormatOptions) -> Option<ListFormatStyle>;
11739        #[wasm_bindgen(method, setter = style)]
11740        pub fn set_style(this: &ListFormatOptions, value: ListFormatStyle);
11741    }
11742
11743    impl ListFormatOptions {
11744        pub fn new() -> ListFormatOptions {
11745            JsCast::unchecked_into(Object::new())
11746        }
11747    }
11748
11749    impl Default for ListFormatOptions {
11750        fn default() -> Self {
11751            ListFormatOptions::new()
11752        }
11753    }
11754
11755    // Intl.ResolvedListFormatOptions
11756    #[wasm_bindgen]
11757    extern "C" {
11758        /// Resolved options returned by `Intl.ListFormat.prototype.resolvedOptions()`.
11759        ///
11760        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/resolvedOptions)
11761        #[wasm_bindgen(extends = ListFormatOptions)]
11762        #[derive(Clone, Debug)]
11763        pub type ResolvedListFormatOptions;
11764
11765        /// The resolved locale string.
11766        #[wasm_bindgen(method, getter = locale)]
11767        pub fn get_locale(this: &ResolvedListFormatOptions) -> JsString;
11768    }
11769
11770    // Intl.ListFormatPart
11771    #[wasm_bindgen]
11772    extern "C" {
11773        /// A part of the formatted list returned by `formatToParts()`.
11774        ///
11775        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/formatToParts)
11776        #[wasm_bindgen(extends = Object)]
11777        #[derive(Clone, Debug)]
11778        pub type ListFormatPart;
11779
11780        /// The type of the part ("element" or "literal").
11781        #[wasm_bindgen(method, getter = type)]
11782        pub fn type_(this: &ListFormatPart) -> ListFormatPartType;
11783
11784        /// The value of the part.
11785        #[wasm_bindgen(method, getter)]
11786        pub fn value(this: &ListFormatPart) -> JsString;
11787    }
11788
11789    // Intl.ListFormat
11790    #[wasm_bindgen]
11791    extern "C" {
11792        /// The `Intl.ListFormat` object enables language-sensitive list formatting.
11793        ///
11794        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat)
11795        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.ListFormat")]
11796        #[derive(Clone, Debug)]
11797        pub type ListFormat;
11798
11799        /// Creates a new `Intl.ListFormat` object.
11800        ///
11801        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat)
11802        #[cfg(not(js_sys_unstable_apis))]
11803        #[wasm_bindgen(constructor, js_namespace = Intl)]
11804        pub fn new(locales: &Array, options: &Object) -> ListFormat;
11805
11806        /// Creates a new `Intl.ListFormat` object.
11807        ///
11808        /// Throws a `RangeError` if locales or options contain invalid values.
11809        ///
11810        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat)
11811        #[cfg(js_sys_unstable_apis)]
11812        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
11813        pub fn new(
11814            locales: &[JsString],
11815            options: &ListFormatOptions,
11816        ) -> Result<ListFormat, JsValue>;
11817
11818        /// Formats a list of strings according to the locale and options.
11819        ///
11820        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/format)
11821        #[cfg(not(js_sys_unstable_apis))]
11822        #[wasm_bindgen(method, js_class = "Intl.ListFormat")]
11823        pub fn format(this: &ListFormat, list: &Array) -> JsString;
11824
11825        /// Formats a list of strings according to the locale and options.
11826        ///
11827        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/format)
11828        #[cfg(js_sys_unstable_apis)]
11829        #[wasm_bindgen(method, js_class = "Intl.ListFormat")]
11830        pub fn format(this: &ListFormat, list: &[JsString]) -> JsString;
11831
11832        /// Returns an array of objects representing the list in parts.
11833        ///
11834        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/formatToParts)
11835        #[cfg(not(js_sys_unstable_apis))]
11836        #[wasm_bindgen(method, js_class = "Intl.ListFormat", js_name = formatToParts)]
11837        pub fn format_to_parts(this: &ListFormat, list: &Array) -> Array;
11838
11839        /// Returns an array of objects representing the list in parts.
11840        ///
11841        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/formatToParts)
11842        #[cfg(js_sys_unstable_apis)]
11843        #[wasm_bindgen(method, js_class = "Intl.ListFormat", js_name = formatToParts)]
11844        pub fn format_to_parts(this: &ListFormat, list: &[JsString]) -> Array<ListFormatPart>;
11845
11846        /// Returns an object with properties reflecting the options used.
11847        ///
11848        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/resolvedOptions)
11849        #[cfg(not(js_sys_unstable_apis))]
11850        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11851        pub fn resolved_options(this: &ListFormat) -> Object;
11852
11853        /// Returns an object with properties reflecting the options used.
11854        ///
11855        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/resolvedOptions)
11856        #[cfg(js_sys_unstable_apis)]
11857        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11858        pub fn resolved_options(this: &ListFormat) -> ResolvedListFormatOptions;
11859
11860        /// Returns an array of supported locales.
11861        ///
11862        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/supportedLocalesOf)
11863        #[cfg(not(js_sys_unstable_apis))]
11864        #[wasm_bindgen(static_method_of = ListFormat, js_namespace = Intl, js_name = supportedLocalesOf)]
11865        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
11866
11867        /// Returns an array of supported locales.
11868        ///
11869        /// Throws a `RangeError` if locales contain invalid values.
11870        ///
11871        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/supportedLocalesOf)
11872        #[cfg(js_sys_unstable_apis)]
11873        #[wasm_bindgen(static_method_of = ListFormat, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
11874        pub fn supported_locales_of(
11875            locales: &[JsString],
11876            options: &LocaleMatcherOptions,
11877        ) -> Result<Array<JsString>, JsValue>;
11878    }
11879
11880    #[cfg(not(js_sys_unstable_apis))]
11881    impl Default for ListFormat {
11882        fn default() -> Self {
11883            Self::new(
11884                &JsValue::UNDEFINED.unchecked_into(),
11885                &JsValue::UNDEFINED.unchecked_into(),
11886            )
11887        }
11888    }
11889
11890    #[cfg(js_sys_unstable_apis)]
11891    impl Default for ListFormat {
11892        fn default() -> Self {
11893            Self::new(&[], &Default::default()).unwrap()
11894        }
11895    }
11896
11897    // Intl.SegmenterOptions
11898    #[wasm_bindgen]
11899    extern "C" {
11900        /// Options for `Intl.Segmenter` constructor.
11901        ///
11902        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/Segmenter#options)
11903        #[wasm_bindgen(extends = Object)]
11904        #[derive(Clone, Debug)]
11905        pub type SegmenterOptions;
11906
11907        #[wasm_bindgen(method, getter = localeMatcher)]
11908        pub fn get_locale_matcher(this: &SegmenterOptions) -> Option<LocaleMatcher>;
11909        #[wasm_bindgen(method, setter = localeMatcher)]
11910        pub fn set_locale_matcher(this: &SegmenterOptions, value: LocaleMatcher);
11911
11912        #[wasm_bindgen(method, getter = granularity)]
11913        pub fn get_granularity(this: &SegmenterOptions) -> Option<SegmenterGranularity>;
11914        #[wasm_bindgen(method, setter = granularity)]
11915        pub fn set_granularity(this: &SegmenterOptions, value: SegmenterGranularity);
11916    }
11917
11918    impl SegmenterOptions {
11919        pub fn new() -> SegmenterOptions {
11920            JsCast::unchecked_into(Object::new())
11921        }
11922    }
11923
11924    impl Default for SegmenterOptions {
11925        fn default() -> Self {
11926            SegmenterOptions::new()
11927        }
11928    }
11929
11930    // Intl.ResolvedSegmenterOptions
11931    #[wasm_bindgen]
11932    extern "C" {
11933        /// Resolved options returned by `Intl.Segmenter.prototype.resolvedOptions()`.
11934        ///
11935        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/resolvedOptions)
11936        #[wasm_bindgen(extends = SegmenterOptions)]
11937        #[derive(Clone, Debug)]
11938        pub type ResolvedSegmenterOptions;
11939
11940        /// The resolved locale string.
11941        #[wasm_bindgen(method, getter = locale)]
11942        pub fn get_locale(this: &ResolvedSegmenterOptions) -> JsString;
11943    }
11944
11945    // Intl.SegmentData
11946    #[wasm_bindgen]
11947    extern "C" {
11948        /// Data about a segment returned by the Segments iterator.
11949        ///
11950        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment/Segments#segment_data)
11951        #[wasm_bindgen(extends = Object)]
11952        #[derive(Clone, Debug)]
11953        pub type SegmentData;
11954
11955        /// The segment string.
11956        #[wasm_bindgen(method, getter)]
11957        pub fn segment(this: &SegmentData) -> JsString;
11958
11959        /// The index of the segment in the original string.
11960        #[wasm_bindgen(method, getter)]
11961        pub fn index(this: &SegmentData) -> u32;
11962
11963        /// The original input string.
11964        #[wasm_bindgen(method, getter)]
11965        pub fn input(this: &SegmentData) -> JsString;
11966
11967        /// Whether the segment is word-like (only for word granularity).
11968        #[wasm_bindgen(method, getter = isWordLike)]
11969        pub fn is_word_like(this: &SegmentData) -> Option<bool>;
11970    }
11971
11972    // Intl.Segments
11973    #[wasm_bindgen]
11974    extern "C" {
11975        /// The Segments object is an iterable collection of segments of a string.
11976        ///
11977        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment/Segments)
11978        #[wasm_bindgen(extends = Object)]
11979        #[derive(Clone, Debug)]
11980        pub type Segments;
11981
11982        /// Returns segment data for the segment containing the character at the given index.
11983        ///
11984        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment/Segments/containing)
11985        #[wasm_bindgen(method)]
11986        pub fn containing(this: &Segments, index: u32) -> Option<SegmentData>;
11987    }
11988
11989    // Intl.Segmenter
11990    #[wasm_bindgen]
11991    extern "C" {
11992        /// The `Intl.Segmenter` object enables locale-sensitive text segmentation.
11993        ///
11994        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter)
11995        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.Segmenter")]
11996        #[derive(Clone, Debug)]
11997        pub type Segmenter;
11998
11999        /// Creates a new `Intl.Segmenter` object.
12000        ///
12001        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/Segmenter)
12002        #[cfg(not(js_sys_unstable_apis))]
12003        #[wasm_bindgen(constructor, js_namespace = Intl)]
12004        pub fn new(locales: &Array, options: &Object) -> Segmenter;
12005
12006        /// Creates a new `Intl.Segmenter` object.
12007        ///
12008        /// Throws a `RangeError` if locales or options contain invalid values.
12009        ///
12010        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/Segmenter)
12011        #[cfg(js_sys_unstable_apis)]
12012        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
12013        pub fn new(locales: &[JsString], options: &SegmenterOptions) -> Result<Segmenter, JsValue>;
12014
12015        /// Returns a Segments object containing the segments of the input string.
12016        ///
12017        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment)
12018        #[wasm_bindgen(method, js_class = "Intl.Segmenter")]
12019        pub fn segment(this: &Segmenter, input: &str) -> Segments;
12020
12021        /// Returns an object with properties reflecting the options used.
12022        ///
12023        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/resolvedOptions)
12024        #[cfg(not(js_sys_unstable_apis))]
12025        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
12026        pub fn resolved_options(this: &Segmenter) -> Object;
12027
12028        /// Returns an object with properties reflecting the options used.
12029        ///
12030        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/resolvedOptions)
12031        #[cfg(js_sys_unstable_apis)]
12032        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
12033        pub fn resolved_options(this: &Segmenter) -> ResolvedSegmenterOptions;
12034
12035        /// Returns an array of supported locales.
12036        ///
12037        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/supportedLocalesOf)
12038        #[cfg(not(js_sys_unstable_apis))]
12039        #[wasm_bindgen(static_method_of = Segmenter, js_namespace = Intl, js_name = supportedLocalesOf)]
12040        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
12041
12042        /// Returns an array of supported locales.
12043        ///
12044        /// Throws a `RangeError` if locales contain invalid values.
12045        ///
12046        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/supportedLocalesOf)
12047        #[cfg(js_sys_unstable_apis)]
12048        #[wasm_bindgen(static_method_of = Segmenter, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
12049        pub fn supported_locales_of(
12050            locales: &[JsString],
12051            options: &LocaleMatcherOptions,
12052        ) -> Result<Array<JsString>, JsValue>;
12053    }
12054
12055    #[cfg(not(js_sys_unstable_apis))]
12056    impl Default for Segmenter {
12057        fn default() -> Self {
12058            Self::new(
12059                &JsValue::UNDEFINED.unchecked_into(),
12060                &JsValue::UNDEFINED.unchecked_into(),
12061            )
12062        }
12063    }
12064
12065    #[cfg(js_sys_unstable_apis)]
12066    impl Default for Segmenter {
12067        fn default() -> Self {
12068            Self::new(&[], &Default::default()).unwrap()
12069        }
12070    }
12071
12072    // Intl.DisplayNamesOptions
12073    #[wasm_bindgen]
12074    extern "C" {
12075        /// Options for `Intl.DisplayNames` constructor.
12076        ///
12077        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames#options)
12078        #[wasm_bindgen(extends = Object)]
12079        #[derive(Clone, Debug)]
12080        pub type DisplayNamesOptions;
12081
12082        #[wasm_bindgen(method, getter = localeMatcher)]
12083        pub fn get_locale_matcher(this: &DisplayNamesOptions) -> Option<LocaleMatcher>;
12084        #[wasm_bindgen(method, setter = localeMatcher)]
12085        pub fn set_locale_matcher(this: &DisplayNamesOptions, value: LocaleMatcher);
12086
12087        #[wasm_bindgen(method, getter = type)]
12088        pub fn get_type(this: &DisplayNamesOptions) -> Option<DisplayNamesType>;
12089        #[wasm_bindgen(method, setter = type)]
12090        pub fn set_type(this: &DisplayNamesOptions, value: DisplayNamesType);
12091
12092        #[wasm_bindgen(method, getter = style)]
12093        pub fn get_style(this: &DisplayNamesOptions) -> Option<DisplayNamesStyle>;
12094        #[wasm_bindgen(method, setter = style)]
12095        pub fn set_style(this: &DisplayNamesOptions, value: DisplayNamesStyle);
12096
12097        #[wasm_bindgen(method, getter = fallback)]
12098        pub fn get_fallback(this: &DisplayNamesOptions) -> Option<DisplayNamesFallback>;
12099        #[wasm_bindgen(method, setter = fallback)]
12100        pub fn set_fallback(this: &DisplayNamesOptions, value: DisplayNamesFallback);
12101
12102        #[wasm_bindgen(method, getter = languageDisplay)]
12103        pub fn get_language_display(
12104            this: &DisplayNamesOptions,
12105        ) -> Option<DisplayNamesLanguageDisplay>;
12106        #[wasm_bindgen(method, setter = languageDisplay)]
12107        pub fn set_language_display(this: &DisplayNamesOptions, value: DisplayNamesLanguageDisplay);
12108    }
12109
12110    impl DisplayNamesOptions {
12111        pub fn new() -> DisplayNamesOptions {
12112            JsCast::unchecked_into(Object::new())
12113        }
12114    }
12115
12116    impl Default for DisplayNamesOptions {
12117        fn default() -> Self {
12118            DisplayNamesOptions::new()
12119        }
12120    }
12121
12122    // Intl.ResolvedDisplayNamesOptions
12123    #[wasm_bindgen]
12124    extern "C" {
12125        /// Resolved options returned by `Intl.DisplayNames.prototype.resolvedOptions()`.
12126        ///
12127        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/resolvedOptions)
12128        #[wasm_bindgen(extends = DisplayNamesOptions)]
12129        #[derive(Clone, Debug)]
12130        pub type ResolvedDisplayNamesOptions;
12131
12132        /// The resolved locale string.
12133        #[wasm_bindgen(method, getter = locale)]
12134        pub fn get_locale(this: &ResolvedDisplayNamesOptions) -> JsString;
12135    }
12136
12137    // Intl.DisplayNames
12138    #[wasm_bindgen]
12139    extern "C" {
12140        /// The `Intl.DisplayNames` object enables the consistent translation of
12141        /// language, region, and script display names.
12142        ///
12143        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames)
12144        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.DisplayNames")]
12145        #[derive(Clone, Debug)]
12146        pub type DisplayNames;
12147
12148        /// Creates a new `Intl.DisplayNames` object.
12149        ///
12150        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames)
12151        #[cfg(not(js_sys_unstable_apis))]
12152        #[wasm_bindgen(constructor, js_namespace = Intl)]
12153        pub fn new(locales: &Array, options: &Object) -> DisplayNames;
12154
12155        /// Creates a new `Intl.DisplayNames` object.
12156        ///
12157        /// Throws a `RangeError` if locales or options contain invalid values.
12158        ///
12159        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames)
12160        #[cfg(js_sys_unstable_apis)]
12161        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
12162        pub fn new(
12163            locales: &[JsString],
12164            options: &DisplayNamesOptions,
12165        ) -> Result<DisplayNames, JsValue>;
12166
12167        /// Returns the display name for the given code.
12168        ///
12169        /// Returns `undefined` if fallback is "none" and no name is available.
12170        ///
12171        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/of)
12172        #[wasm_bindgen(method, js_class = "Intl.DisplayNames")]
12173        pub fn of(this: &DisplayNames, code: &str) -> Option<JsString>;
12174
12175        /// Returns an object with properties reflecting the options used.
12176        ///
12177        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/resolvedOptions)
12178        #[cfg(not(js_sys_unstable_apis))]
12179        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
12180        pub fn resolved_options(this: &DisplayNames) -> Object;
12181
12182        /// Returns an object with properties reflecting the options used.
12183        ///
12184        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/resolvedOptions)
12185        #[cfg(js_sys_unstable_apis)]
12186        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
12187        pub fn resolved_options(this: &DisplayNames) -> ResolvedDisplayNamesOptions;
12188
12189        /// Returns an array of supported locales.
12190        ///
12191        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/supportedLocalesOf)
12192        #[cfg(not(js_sys_unstable_apis))]
12193        #[wasm_bindgen(static_method_of = DisplayNames, js_namespace = Intl, js_name = supportedLocalesOf)]
12194        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
12195
12196        /// Returns an array of supported locales.
12197        ///
12198        /// Throws a `RangeError` if locales contain invalid values.
12199        ///
12200        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/supportedLocalesOf)
12201        #[cfg(js_sys_unstable_apis)]
12202        #[wasm_bindgen(static_method_of = DisplayNames, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
12203        pub fn supported_locales_of(
12204            locales: &[JsString],
12205            options: &LocaleMatcherOptions,
12206        ) -> Result<Array<JsString>, JsValue>;
12207    }
12208
12209    // Intl.Locale
12210    #[wasm_bindgen]
12211    extern "C" {
12212        /// The `Intl.Locale` object is a standard built-in property of the Intl object
12213        /// that represents a Unicode locale identifier.
12214        ///
12215        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale)
12216        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.Locale")]
12217        #[derive(Clone, Debug)]
12218        pub type Locale;
12219
12220        /// Creates a new `Intl.Locale` object.
12221        ///
12222        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/Locale)
12223        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
12224        pub fn new(tag: &str) -> Result<Locale, JsValue>;
12225
12226        /// Creates a new `Intl.Locale` object with options.
12227        ///
12228        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/Locale)
12229        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
12230        pub fn new_with_options(tag: &str, options: &Object) -> Result<Locale, JsValue>;
12231
12232        /// The base name of the locale (language + region + script).
12233        ///
12234        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/baseName)
12235        #[wasm_bindgen(method, getter = baseName)]
12236        pub fn base_name(this: &Locale) -> JsString;
12237
12238        /// The calendar type for the locale.
12239        ///
12240        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/calendar)
12241        #[wasm_bindgen(method, getter)]
12242        pub fn calendar(this: &Locale) -> Option<JsString>;
12243
12244        /// The case first sorting option.
12245        ///
12246        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/caseFirst)
12247        #[wasm_bindgen(method, getter = caseFirst)]
12248        pub fn case_first(this: &Locale) -> Option<JsString>;
12249
12250        /// The collation type for the locale.
12251        ///
12252        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/collation)
12253        #[wasm_bindgen(method, getter)]
12254        pub fn collation(this: &Locale) -> Option<JsString>;
12255
12256        /// The hour cycle for the locale.
12257        ///
12258        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/hourCycle)
12259        #[wasm_bindgen(method, getter = hourCycle)]
12260        pub fn hour_cycle(this: &Locale) -> Option<JsString>;
12261
12262        /// The language code for the locale.
12263        ///
12264        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/language)
12265        #[wasm_bindgen(method, getter)]
12266        pub fn language(this: &Locale) -> JsString;
12267
12268        /// The numbering system for the locale.
12269        ///
12270        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/numberingSystem)
12271        #[wasm_bindgen(method, getter = numberingSystem)]
12272        pub fn numbering_system(this: &Locale) -> Option<JsString>;
12273
12274        /// Whether the locale uses numeric collation.
12275        ///
12276        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/numeric)
12277        #[wasm_bindgen(method, getter)]
12278        pub fn numeric(this: &Locale) -> bool;
12279
12280        /// The region code for the locale.
12281        ///
12282        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/region)
12283        #[wasm_bindgen(method, getter)]
12284        pub fn region(this: &Locale) -> Option<JsString>;
12285
12286        /// The script code for the locale.
12287        ///
12288        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/script)
12289        #[wasm_bindgen(method, getter)]
12290        pub fn script(this: &Locale) -> Option<JsString>;
12291
12292        /// Returns an array of available calendars for the locale.
12293        ///
12294        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getCalendars)
12295        #[wasm_bindgen(method, js_class = "Intl.Locale", js_name = getCalendars)]
12296        pub fn get_calendars(this: &Locale) -> Array<JsString>;
12297
12298        /// Returns an array of available collations for the locale.
12299        ///
12300        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getCollations)
12301        #[wasm_bindgen(method, js_class = "Intl.Locale", js_name = getCollations)]
12302        pub fn get_collations(this: &Locale) -> Array<JsString>;
12303
12304        /// Returns an array of available hour cycles for the locale.
12305        ///
12306        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getHourCycles)
12307        #[wasm_bindgen(method, js_class = "Intl.Locale", js_name = getHourCycles)]
12308        pub fn get_hour_cycles(this: &Locale) -> Array<JsString>;
12309
12310        /// Returns an array of available numbering systems for the locale.
12311        ///
12312        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getNumberingSystems)
12313        #[wasm_bindgen(method, js_class = "Intl.Locale", js_name = getNumberingSystems)]
12314        pub fn get_numbering_systems(this: &Locale) -> Array<JsString>;
12315
12316        /// Returns an array of available time zones for the locale's region.
12317        ///
12318        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTimeZones)
12319        #[wasm_bindgen(method, js_class = "Intl.Locale", js_name = getTimeZones)]
12320        pub fn get_time_zones(this: &Locale) -> Option<Array<JsString>>;
12321
12322        /// Returns week information for the locale.
12323        ///
12324        /// May not be available in all environments.
12325        ///
12326        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getWeekInfo)
12327        #[wasm_bindgen(method, js_class = "Intl.Locale", js_name = getWeekInfo, catch)]
12328        pub fn get_week_info(this: &Locale) -> Result<WeekInfo, JsValue>;
12329
12330        /// Returns text layout information for the locale.
12331        ///
12332        /// May not be available in all environments.
12333        ///
12334        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo)
12335        #[wasm_bindgen(method, js_class = "Intl.Locale", js_name = getTextInfo, catch)]
12336        pub fn get_text_info(this: &Locale) -> Result<TextInfo, JsValue>;
12337
12338        /// Returns a new Locale with the specified calendar.
12339        ///
12340        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/maximize)
12341        #[wasm_bindgen(method, js_class = "Intl.Locale")]
12342        pub fn maximize(this: &Locale) -> Locale;
12343
12344        /// Returns a new Locale with the minimal subtags.
12345        ///
12346        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/minimize)
12347        #[wasm_bindgen(method, js_class = "Intl.Locale")]
12348        pub fn minimize(this: &Locale) -> Locale;
12349    }
12350
12351    // Intl.Locale WeekInfo
12352    #[wasm_bindgen]
12353    extern "C" {
12354        /// Week information for a locale.
12355        ///
12356        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getWeekInfo)
12357        #[wasm_bindgen(extends = Object)]
12358        #[derive(Clone, Debug)]
12359        pub type WeekInfo;
12360
12361        /// The first day of the week (1 = Monday, 7 = Sunday).
12362        #[wasm_bindgen(method, getter = firstDay)]
12363        pub fn first_day(this: &WeekInfo) -> u8;
12364
12365        /// Array of weekend days.
12366        #[wasm_bindgen(method, getter)]
12367        pub fn weekend(this: &WeekInfo) -> Array<Number>;
12368
12369        /// Minimal days in the first week of the year.
12370        #[wasm_bindgen(method, getter = minimalDays)]
12371        pub fn minimal_days(this: &WeekInfo) -> u8;
12372    }
12373
12374    // Intl.Locale TextInfo
12375    #[wasm_bindgen]
12376    extern "C" {
12377        /// Text layout information for a locale.
12378        ///
12379        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo)
12380        #[wasm_bindgen(extends = Object)]
12381        #[derive(Clone, Debug)]
12382        pub type TextInfo;
12383
12384        /// The text direction ("ltr" or "rtl").
12385        #[wasm_bindgen(method, getter)]
12386        pub fn direction(this: &TextInfo) -> JsString;
12387    }
12388
12389    // Intl.DurationFormat enums
12390
12391    /// The style for duration formatting.
12392    ///
12393    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat#style)
12394    #[wasm_bindgen]
12395    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
12396    pub enum DurationFormatStyle {
12397        Long = "long",
12398        Short = "short",
12399        Narrow = "narrow",
12400        Digital = "digital",
12401    }
12402
12403    /// The display style for individual duration units.
12404    ///
12405    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat#years)
12406    #[wasm_bindgen]
12407    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
12408    pub enum DurationUnitStyle {
12409        Long = "long",
12410        Short = "short",
12411        Narrow = "narrow",
12412    }
12413
12414    /// The display style for time duration units (hours, minutes, seconds).
12415    ///
12416    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat#hours)
12417    #[wasm_bindgen]
12418    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
12419    pub enum DurationTimeUnitStyle {
12420        Long = "long",
12421        Short = "short",
12422        Narrow = "narrow",
12423        Numeric = "numeric",
12424        #[wasm_bindgen(js_name = "2-digit")]
12425        TwoDigit = "2-digit",
12426    }
12427
12428    /// The display option for duration units.
12429    ///
12430    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat#yearsdisplay)
12431    #[wasm_bindgen]
12432    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
12433    pub enum DurationUnitDisplay {
12434        Auto = "auto",
12435        Always = "always",
12436    }
12437
12438    /// The type of a duration format part.
12439    ///
12440    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/formatToParts#type)
12441    #[wasm_bindgen]
12442    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
12443    pub enum DurationFormatPartType {
12444        Years = "years",
12445        Months = "months",
12446        Weeks = "weeks",
12447        Days = "days",
12448        Hours = "hours",
12449        Minutes = "minutes",
12450        Seconds = "seconds",
12451        Milliseconds = "milliseconds",
12452        Microseconds = "microseconds",
12453        Nanoseconds = "nanoseconds",
12454        Literal = "literal",
12455        Integer = "integer",
12456        Decimal = "decimal",
12457        Fraction = "fraction",
12458    }
12459
12460    // Intl.DurationFormatOptions
12461    #[wasm_bindgen]
12462    extern "C" {
12463        /// Options for `Intl.DurationFormat` constructor.
12464        ///
12465        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat#options)
12466        #[wasm_bindgen(extends = Object)]
12467        #[derive(Clone, Debug)]
12468        pub type DurationFormatOptions;
12469
12470        #[wasm_bindgen(method, getter = localeMatcher)]
12471        pub fn get_locale_matcher(this: &DurationFormatOptions) -> Option<LocaleMatcher>;
12472        #[wasm_bindgen(method, setter = localeMatcher)]
12473        pub fn set_locale_matcher(this: &DurationFormatOptions, value: LocaleMatcher);
12474
12475        #[wasm_bindgen(method, getter = style)]
12476        pub fn get_style(this: &DurationFormatOptions) -> Option<DurationFormatStyle>;
12477        #[wasm_bindgen(method, setter = style)]
12478        pub fn set_style(this: &DurationFormatOptions, value: DurationFormatStyle);
12479
12480        #[wasm_bindgen(method, getter = years)]
12481        pub fn get_years(this: &DurationFormatOptions) -> Option<DurationUnitStyle>;
12482        #[wasm_bindgen(method, setter = years)]
12483        pub fn set_years(this: &DurationFormatOptions, value: DurationUnitStyle);
12484
12485        #[wasm_bindgen(method, getter = yearsDisplay)]
12486        pub fn get_years_display(this: &DurationFormatOptions) -> Option<DurationUnitDisplay>;
12487        #[wasm_bindgen(method, setter = yearsDisplay)]
12488        pub fn set_years_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12489
12490        #[wasm_bindgen(method, getter = months)]
12491        pub fn get_months(this: &DurationFormatOptions) -> Option<DurationUnitStyle>;
12492        #[wasm_bindgen(method, setter = months)]
12493        pub fn set_months(this: &DurationFormatOptions, value: DurationUnitStyle);
12494
12495        #[wasm_bindgen(method, getter = monthsDisplay)]
12496        pub fn get_months_display(this: &DurationFormatOptions) -> Option<DurationUnitDisplay>;
12497        #[wasm_bindgen(method, setter = monthsDisplay)]
12498        pub fn set_months_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12499
12500        #[wasm_bindgen(method, getter = weeks)]
12501        pub fn get_weeks(this: &DurationFormatOptions) -> Option<DurationUnitStyle>;
12502        #[wasm_bindgen(method, setter = weeks)]
12503        pub fn set_weeks(this: &DurationFormatOptions, value: DurationUnitStyle);
12504
12505        #[wasm_bindgen(method, getter = weeksDisplay)]
12506        pub fn get_weeks_display(this: &DurationFormatOptions) -> Option<DurationUnitDisplay>;
12507        #[wasm_bindgen(method, setter = weeksDisplay)]
12508        pub fn set_weeks_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12509
12510        #[wasm_bindgen(method, getter = days)]
12511        pub fn get_days(this: &DurationFormatOptions) -> Option<DurationUnitStyle>;
12512        #[wasm_bindgen(method, setter = days)]
12513        pub fn set_days(this: &DurationFormatOptions, value: DurationUnitStyle);
12514
12515        #[wasm_bindgen(method, getter = daysDisplay)]
12516        pub fn get_days_display(this: &DurationFormatOptions) -> Option<DurationUnitDisplay>;
12517        #[wasm_bindgen(method, setter = daysDisplay)]
12518        pub fn set_days_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12519
12520        #[wasm_bindgen(method, getter = hours)]
12521        pub fn get_hours(this: &DurationFormatOptions) -> Option<DurationTimeUnitStyle>;
12522        #[wasm_bindgen(method, setter = hours)]
12523        pub fn set_hours(this: &DurationFormatOptions, value: DurationTimeUnitStyle);
12524
12525        #[wasm_bindgen(method, getter = hoursDisplay)]
12526        pub fn get_hours_display(this: &DurationFormatOptions) -> Option<DurationUnitDisplay>;
12527        #[wasm_bindgen(method, setter = hoursDisplay)]
12528        pub fn set_hours_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12529
12530        #[wasm_bindgen(method, getter = minutes)]
12531        pub fn get_minutes(this: &DurationFormatOptions) -> Option<DurationTimeUnitStyle>;
12532        #[wasm_bindgen(method, setter = minutes)]
12533        pub fn set_minutes(this: &DurationFormatOptions, value: DurationTimeUnitStyle);
12534
12535        #[wasm_bindgen(method, getter = minutesDisplay)]
12536        pub fn get_minutes_display(this: &DurationFormatOptions) -> Option<DurationUnitDisplay>;
12537        #[wasm_bindgen(method, setter = minutesDisplay)]
12538        pub fn set_minutes_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12539
12540        #[wasm_bindgen(method, getter = seconds)]
12541        pub fn get_seconds(this: &DurationFormatOptions) -> Option<DurationTimeUnitStyle>;
12542        #[wasm_bindgen(method, setter = seconds)]
12543        pub fn set_seconds(this: &DurationFormatOptions, value: DurationTimeUnitStyle);
12544
12545        #[wasm_bindgen(method, getter = secondsDisplay)]
12546        pub fn get_seconds_display(this: &DurationFormatOptions) -> Option<DurationUnitDisplay>;
12547        #[wasm_bindgen(method, setter = secondsDisplay)]
12548        pub fn set_seconds_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12549
12550        #[wasm_bindgen(method, getter = milliseconds)]
12551        pub fn get_milliseconds(this: &DurationFormatOptions) -> Option<DurationUnitStyle>;
12552        #[wasm_bindgen(method, setter = milliseconds)]
12553        pub fn set_milliseconds(this: &DurationFormatOptions, value: DurationUnitStyle);
12554
12555        #[wasm_bindgen(method, getter = millisecondsDisplay)]
12556        pub fn get_milliseconds_display(
12557            this: &DurationFormatOptions,
12558        ) -> Option<DurationUnitDisplay>;
12559        #[wasm_bindgen(method, setter = millisecondsDisplay)]
12560        pub fn set_milliseconds_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12561
12562        #[wasm_bindgen(method, getter = microseconds)]
12563        pub fn get_microseconds(this: &DurationFormatOptions) -> Option<DurationUnitStyle>;
12564        #[wasm_bindgen(method, setter = microseconds)]
12565        pub fn set_microseconds(this: &DurationFormatOptions, value: DurationUnitStyle);
12566
12567        #[wasm_bindgen(method, getter = microsecondsDisplay)]
12568        pub fn get_microseconds_display(
12569            this: &DurationFormatOptions,
12570        ) -> Option<DurationUnitDisplay>;
12571        #[wasm_bindgen(method, setter = microsecondsDisplay)]
12572        pub fn set_microseconds_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12573
12574        #[wasm_bindgen(method, getter = nanoseconds)]
12575        pub fn get_nanoseconds(this: &DurationFormatOptions) -> Option<DurationUnitStyle>;
12576        #[wasm_bindgen(method, setter = nanoseconds)]
12577        pub fn set_nanoseconds(this: &DurationFormatOptions, value: DurationUnitStyle);
12578
12579        #[wasm_bindgen(method, getter = nanosecondsDisplay)]
12580        pub fn get_nanoseconds_display(this: &DurationFormatOptions)
12581            -> Option<DurationUnitDisplay>;
12582        #[wasm_bindgen(method, setter = nanosecondsDisplay)]
12583        pub fn set_nanoseconds_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12584
12585        #[wasm_bindgen(method, getter = fractionalDigits)]
12586        pub fn get_fractional_digits(this: &DurationFormatOptions) -> Option<u8>;
12587        #[wasm_bindgen(method, setter = fractionalDigits)]
12588        pub fn set_fractional_digits(this: &DurationFormatOptions, value: u8);
12589    }
12590
12591    impl DurationFormatOptions {
12592        pub fn new() -> DurationFormatOptions {
12593            JsCast::unchecked_into(Object::new())
12594        }
12595    }
12596
12597    impl Default for DurationFormatOptions {
12598        fn default() -> Self {
12599            DurationFormatOptions::new()
12600        }
12601    }
12602
12603    // Intl.ResolvedDurationFormatOptions
12604    #[wasm_bindgen]
12605    extern "C" {
12606        /// Resolved options returned by `Intl.DurationFormat.prototype.resolvedOptions()`.
12607        ///
12608        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/resolvedOptions)
12609        #[wasm_bindgen(extends = DurationFormatOptions)]
12610        #[derive(Clone, Debug)]
12611        pub type ResolvedDurationFormatOptions;
12612
12613        /// The resolved locale string.
12614        #[wasm_bindgen(method, getter = locale)]
12615        pub fn get_locale(this: &ResolvedDurationFormatOptions) -> JsString;
12616
12617        /// The resolved numbering system.
12618        #[wasm_bindgen(method, getter = numberingSystem)]
12619        pub fn get_numbering_system(this: &ResolvedDurationFormatOptions) -> JsString;
12620    }
12621
12622    // Intl.Duration (input object for DurationFormat)
12623    #[wasm_bindgen]
12624    extern "C" {
12625        /// A duration object used as input to `Intl.DurationFormat.format()`.
12626        ///
12627        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/format#duration)
12628        #[wasm_bindgen(extends = Object)]
12629        #[derive(Clone, Debug)]
12630        pub type Duration;
12631
12632        #[wasm_bindgen(method, getter)]
12633        pub fn years(this: &Duration) -> Option<f64>;
12634        #[wasm_bindgen(method, setter)]
12635        pub fn set_years(this: &Duration, value: f64);
12636
12637        #[wasm_bindgen(method, getter)]
12638        pub fn months(this: &Duration) -> Option<f64>;
12639        #[wasm_bindgen(method, setter)]
12640        pub fn set_months(this: &Duration, value: f64);
12641
12642        #[wasm_bindgen(method, getter)]
12643        pub fn weeks(this: &Duration) -> Option<f64>;
12644        #[wasm_bindgen(method, setter)]
12645        pub fn set_weeks(this: &Duration, value: f64);
12646
12647        #[wasm_bindgen(method, getter)]
12648        pub fn days(this: &Duration) -> Option<f64>;
12649        #[wasm_bindgen(method, setter)]
12650        pub fn set_days(this: &Duration, value: f64);
12651
12652        #[wasm_bindgen(method, getter)]
12653        pub fn hours(this: &Duration) -> Option<f64>;
12654        #[wasm_bindgen(method, setter)]
12655        pub fn set_hours(this: &Duration, value: f64);
12656
12657        #[wasm_bindgen(method, getter)]
12658        pub fn minutes(this: &Duration) -> Option<f64>;
12659        #[wasm_bindgen(method, setter)]
12660        pub fn set_minutes(this: &Duration, value: f64);
12661
12662        #[wasm_bindgen(method, getter)]
12663        pub fn seconds(this: &Duration) -> Option<f64>;
12664        #[wasm_bindgen(method, setter)]
12665        pub fn set_seconds(this: &Duration, value: f64);
12666
12667        #[wasm_bindgen(method, getter)]
12668        pub fn milliseconds(this: &Duration) -> Option<f64>;
12669        #[wasm_bindgen(method, setter)]
12670        pub fn set_milliseconds(this: &Duration, value: f64);
12671
12672        #[wasm_bindgen(method, getter)]
12673        pub fn microseconds(this: &Duration) -> Option<f64>;
12674        #[wasm_bindgen(method, setter)]
12675        pub fn set_microseconds(this: &Duration, value: f64);
12676
12677        #[wasm_bindgen(method, getter)]
12678        pub fn nanoseconds(this: &Duration) -> Option<f64>;
12679        #[wasm_bindgen(method, setter)]
12680        pub fn set_nanoseconds(this: &Duration, value: f64);
12681    }
12682
12683    impl Duration {
12684        pub fn new() -> Duration {
12685            JsCast::unchecked_into(Object::new())
12686        }
12687    }
12688
12689    impl Default for Duration {
12690        fn default() -> Self {
12691            Duration::new()
12692        }
12693    }
12694
12695    // Intl.DurationFormatPart
12696    #[wasm_bindgen]
12697    extern "C" {
12698        /// A part of the formatted duration returned by `formatToParts()`.
12699        ///
12700        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/formatToParts)
12701        #[wasm_bindgen(extends = Object)]
12702        #[derive(Clone, Debug)]
12703        pub type DurationFormatPart;
12704
12705        /// The type of the part.
12706        #[wasm_bindgen(method, getter = type)]
12707        pub fn type_(this: &DurationFormatPart) -> DurationFormatPartType;
12708
12709        /// The value of the part.
12710        #[wasm_bindgen(method, getter)]
12711        pub fn value(this: &DurationFormatPart) -> JsString;
12712
12713        /// The unit this part represents (if applicable).
12714        #[wasm_bindgen(method, getter)]
12715        pub fn unit(this: &DurationFormatPart) -> Option<JsString>;
12716    }
12717
12718    // Intl.DurationFormat
12719    #[wasm_bindgen]
12720    extern "C" {
12721        /// The `Intl.DurationFormat` object enables language-sensitive duration formatting.
12722        ///
12723        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat)
12724        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.DurationFormat")]
12725        #[derive(Clone, Debug)]
12726        pub type DurationFormat;
12727
12728        /// Creates a new `Intl.DurationFormat` object.
12729        ///
12730        /// Throws a `RangeError` if locales or options contain invalid values.
12731        ///
12732        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat)
12733        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
12734        pub fn new(
12735            locales: &[JsString],
12736            options: &DurationFormatOptions,
12737        ) -> Result<DurationFormat, JsValue>;
12738
12739        /// Formats a duration according to the locale and formatting options.
12740        ///
12741        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/format)
12742        #[wasm_bindgen(method, js_class = "Intl.DurationFormat")]
12743        pub fn format(this: &DurationFormat, duration: &Duration) -> JsString;
12744
12745        /// Returns an array of objects representing the formatted duration in parts.
12746        ///
12747        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/formatToParts)
12748        #[wasm_bindgen(method, js_class = "Intl.DurationFormat", js_name = formatToParts)]
12749        pub fn format_to_parts(
12750            this: &DurationFormat,
12751            duration: &Duration,
12752        ) -> Array<DurationFormatPart>;
12753
12754        /// Returns an object with properties reflecting the options used.
12755        ///
12756        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/resolvedOptions)
12757        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
12758        pub fn resolved_options(this: &DurationFormat) -> ResolvedDurationFormatOptions;
12759
12760        /// Returns an array of supported locales.
12761        ///
12762        /// Throws a `RangeError` if locales contain invalid values.
12763        ///
12764        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/supportedLocalesOf)
12765        #[wasm_bindgen(static_method_of = DurationFormat, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
12766        pub fn supported_locales_of(
12767            locales: &[JsString],
12768            options: &LocaleMatcherOptions,
12769        ) -> Result<Array<JsString>, JsValue>;
12770    }
12771
12772    impl Default for DurationFormat {
12773        fn default() -> Self {
12774            Self::new(&[], &Default::default()).unwrap()
12775        }
12776    }
12777}
12778
12779#[wasm_bindgen]
12780extern "C" {
12781    /// The `PromiseState` object represents the the status of the promise,
12782    /// as used in `allSettled`.
12783    ///
12784    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled)
12785    #[must_use]
12786    #[wasm_bindgen(extends = Object, typescript_type = "any")]
12787    #[derive(Clone, Debug)]
12788    pub type PromiseState<T = JsValue>;
12789
12790    /// A string, either "fulfilled" or "rejected", indicating the eventual state of the promise.
12791    #[wasm_bindgen(method, getter = status)]
12792    pub fn get_status<T>(this: &PromiseState<T>) -> String;
12793
12794    /// Only present if status is "fulfilled". The value that the promise was fulfilled with.
12795    #[wasm_bindgen(method, getter = value)]
12796    pub fn get_value<T>(this: &PromiseState<T>) -> Option<T>;
12797
12798    /// Only present if status is "rejected". The reason that the promise was rejected with.
12799    #[wasm_bindgen(method, getter = reason)]
12800    pub fn get_reason<T>(this: &PromiseState<T>) -> Option<JsValue>;
12801}
12802
12803impl<T> PromiseState<T> {
12804    pub fn is_fulfilled(&self) -> bool {
12805        self.get_status() == "fulfilled"
12806    }
12807
12808    pub fn is_rejected(&self) -> bool {
12809        self.get_status() == "rejected"
12810    }
12811}
12812
12813// Promise
12814#[wasm_bindgen]
12815extern "C" {
12816    /// The `Promise` object represents the eventual completion (or failure) of
12817    /// an asynchronous operation, and its resulting value.
12818    ///
12819    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
12820    #[must_use]
12821    #[wasm_bindgen(extends = Object, typescript_type = "Promise<any>", no_promising)]
12822    #[derive(Clone, Debug)]
12823    pub type Promise<T = JsValue>;
12824
12825    /// Creates a new `Promise` with the provided executor `cb`
12826    ///
12827    /// The `cb` is a function that is passed with the arguments `resolve` and
12828    /// `reject`. The `cb` function is executed immediately by the `Promise`
12829    /// implementation, passing `resolve` and `reject` functions (the executor
12830    /// is called before the `Promise` constructor even returns the created
12831    /// object). The `resolve` and `reject` functions, when called, resolve or
12832    /// reject the promise, respectively. The executor normally initiates
12833    /// some asynchronous work, and then, once that completes, either calls
12834    /// the `resolve` function to resolve the promise or else rejects it if an
12835    /// error occurred.
12836    ///
12837    /// If an error is thrown in the executor function, the promise is rejected.
12838    /// The return value of the executor is ignored.
12839    ///
12840    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
12841    #[cfg(not(js_sys_unstable_apis))]
12842    #[wasm_bindgen(constructor)]
12843    pub fn new(cb: &mut dyn FnMut(Function, Function)) -> Promise;
12844
12845    /// Creates a new `Promise` with the provided executor `cb`
12846    ///
12847    /// The `cb` is a function that is passed with the arguments `resolve` and
12848    /// `reject`. The `cb` function is executed immediately by the `Promise`
12849    /// implementation, passing `resolve` and `reject` functions (the executor
12850    /// is called before the `Promise` constructor even returns the created
12851    /// object). The `resolve` and `reject` functions, when called, resolve or
12852    /// reject the promise, respectively. The executor normally initiates
12853    /// some asynchronous work, and then, once that completes, either calls
12854    /// the `resolve` function to resolve the promise or else rejects it if an
12855    /// error occurred.
12856    ///
12857    /// If an error is thrown in the executor function, the promise is rejected.
12858    /// The return value of the executor is ignored.
12859    ///
12860    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
12861    #[cfg(js_sys_unstable_apis)]
12862    #[wasm_bindgen(constructor)]
12863    pub fn new<T: JsGeneric>(
12864        cb: &mut dyn FnMut(Function<fn(T) -> Undefined>, Function<fn(JsValue) -> Undefined>),
12865    ) -> Promise<T>;
12866
12867    // Next major: deprecate
12868    /// Creates a new `Promise` with the provided executor `cb`
12869    ///
12870    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
12871    #[wasm_bindgen(constructor)]
12872    pub fn new_typed<T: JsGeneric>(
12873        cb: &mut dyn FnMut(Function<fn(T) -> Undefined>, Function<fn(JsValue) -> Undefined>),
12874    ) -> Promise<T>;
12875
12876    /// The `Promise.all(iterable)` method returns a single `Promise` that
12877    /// resolves when all of the promises in the iterable argument have resolved
12878    /// or when the iterable argument contains no promises. It rejects with the
12879    /// reason of the first promise that rejects.
12880    ///
12881    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all)
12882    #[cfg(not(js_sys_unstable_apis))]
12883    #[wasm_bindgen(static_method_of = Promise)]
12884    pub fn all(obj: &JsValue) -> Promise;
12885
12886    /// The `Promise.all(iterable)` method returns a single `Promise` that
12887    /// resolves when all of the promises in the iterable argument have resolved
12888    /// or when the iterable argument contains no promises. It rejects with the
12889    /// reason of the first promise that rejects.
12890    ///
12891    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all)
12892    #[cfg(js_sys_unstable_apis)]
12893    #[wasm_bindgen(static_method_of = Promise, js_name = all)]
12894    pub fn all<I: Iterable>(obj: &I) -> Promise<Array<<I::Item as Promising>::Resolution>>
12895    where
12896        I::Item: Promising;
12897
12898    // Next major: deprecate
12899    /// The `Promise.all(iterable)` method returns a single `Promise` that
12900    /// resolves when all of the promises in the iterable argument have resolved
12901    /// or when the iterable argument contains no promises. It rejects with the
12902    /// reason of the first promise that rejects.
12903    ///
12904    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all)
12905    #[wasm_bindgen(static_method_of = Promise, js_name = all)]
12906    pub fn all_iterable<I: Iterable>(obj: &I) -> Promise<Array<<I::Item as Promising>::Resolution>>
12907    where
12908        I::Item: Promising;
12909
12910    /// The `Promise.allSettled(iterable)` method returns a single `Promise` that
12911    /// resolves when all of the promises in the iterable argument have either
12912    /// fulfilled or rejected or when the iterable argument contains no promises.
12913    ///
12914    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled)
12915    #[cfg(not(js_sys_unstable_apis))]
12916    #[wasm_bindgen(static_method_of = Promise, js_name = allSettled)]
12917    pub fn all_settled(obj: &JsValue) -> Promise;
12918
12919    /// The `Promise.allSettled(iterable)` method returns a single `Promise` that
12920    /// resolves when all of the promises in the iterable argument have either
12921    /// fulfilled or rejected or when the iterable argument contains no promises.
12922    ///
12923    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled)
12924    #[cfg(js_sys_unstable_apis)]
12925    #[wasm_bindgen(static_method_of = Promise, js_name = allSettled)]
12926    pub fn all_settled<I: Iterable>(
12927        obj: &I,
12928    ) -> Promise<Array<PromiseState<<I::Item as Promising>::Resolution>>>
12929    where
12930        I::Item: Promising;
12931
12932    // Next major: deprecate
12933    /// The `Promise.allSettled(iterable)` method returns a single `Promise` that
12934    /// resolves when all of the promises in the iterable argument have either
12935    /// fulfilled or rejected or when the iterable argument contains no promises.
12936    ///
12937    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled)
12938    #[wasm_bindgen(static_method_of = Promise, js_name = allSettled)]
12939    pub fn all_settled_iterable<I: Iterable>(
12940        obj: &I,
12941    ) -> Promise<Array<PromiseState<<I::Item as Promising>::Resolution>>>
12942    where
12943        I::Item: Promising;
12944
12945    /// The `Promise.any(iterable)` method returns a single `Promise` that
12946    /// resolves when any of the promises in the iterable argument have resolved
12947    /// or when the iterable argument contains no promises. It rejects with an
12948    /// `AggregateError` if all promises in the iterable rejected.
12949    ///
12950    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/any)
12951    #[cfg(not(js_sys_unstable_apis))]
12952    #[wasm_bindgen(static_method_of = Promise)]
12953    pub fn any(obj: &JsValue) -> Promise;
12954
12955    /// The `Promise.any(iterable)` method returns a single `Promise` that
12956    /// resolves when any of the promises in the iterable argument have resolved
12957    /// or when the iterable argument contains no promises. It rejects with an
12958    /// `AggregateError` if all promises in the iterable rejected.
12959    ///
12960    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/any)
12961    #[cfg(js_sys_unstable_apis)]
12962    #[wasm_bindgen(static_method_of = Promise, js_name = any)]
12963    pub fn any<I: Iterable>(obj: &I) -> Promise<<I::Item as Promising>::Resolution>
12964    where
12965        I::Item: Promising;
12966
12967    // Next major: deprecate
12968    /// The `Promise.any(iterable)` method returns a single `Promise` that
12969    /// resolves when any of the promises in the iterable argument have resolved
12970    /// or when the iterable argument contains no promises. It rejects with an
12971    /// `AggregateError` if all promises in the iterable rejected.
12972    ///
12973    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/any)
12974    #[cfg(not(js_sys_unstable_apis))]
12975    #[wasm_bindgen(static_method_of = Promise, js_name = any)]
12976    pub fn any_iterable<I: Iterable>(obj: &I) -> Promise<<I::Item as Promising>::Resolution>
12977    where
12978        I::Item: Promising;
12979
12980    /// The `Promise.race(iterable)` method returns a promise that resolves or
12981    /// rejects as soon as one of the promises in the iterable resolves or
12982    /// rejects, with the value or reason from that promise.
12983    ///
12984    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race)
12985    #[cfg(not(js_sys_unstable_apis))]
12986    #[wasm_bindgen(static_method_of = Promise)]
12987    pub fn race(obj: &JsValue) -> Promise;
12988
12989    /// The `Promise.race(iterable)` method returns a promise that resolves or
12990    /// rejects as soon as one of the promises in the iterable resolves or
12991    /// rejects, with the value or reason from that promise.
12992    ///
12993    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race)
12994    #[cfg(js_sys_unstable_apis)]
12995    #[wasm_bindgen(static_method_of = Promise, js_name = race)]
12996    pub fn race<I: Iterable>(obj: &I) -> Promise<<I::Item as Promising>::Resolution>
12997    where
12998        I::Item: Promising;
12999
13000    // Next major: deprecate
13001    /// The `Promise.race(iterable)` method returns a promise that resolves or
13002    /// rejects as soon as one of the promises in the iterable resolves or
13003    /// rejects, with the value or reason from that promise.
13004    ///
13005    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race)
13006    #[wasm_bindgen(static_method_of = Promise, js_name = race)]
13007    pub fn race_iterable<I: Iterable>(obj: &I) -> Promise<<I::Item as Promising>::Resolution>
13008    where
13009        I::Item: Promising;
13010
13011    /// The `Promise.reject(reason)` method returns a `Promise` object that is
13012    /// rejected with the given reason.
13013    ///
13014    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject)
13015    #[cfg(not(js_sys_unstable_apis))]
13016    #[wasm_bindgen(static_method_of = Promise)]
13017    pub fn reject(obj: &JsValue) -> Promise;
13018
13019    /// The `Promise.reject(reason)` method returns a `Promise` object that is
13020    /// rejected with the given reason.
13021    ///
13022    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject)
13023    #[cfg(js_sys_unstable_apis)]
13024    #[wasm_bindgen(static_method_of = Promise, js_name = reject)]
13025    pub fn reject<T>(obj: &JsValue) -> Promise<T>;
13026
13027    // Next major: deprecate
13028    /// The `Promise.reject(reason)` method returns a `Promise` object that is
13029    /// rejected with the given reason.
13030    ///
13031    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject)
13032    #[wasm_bindgen(static_method_of = Promise, js_name = reject)]
13033    pub fn reject_typed<T>(obj: &JsValue) -> Promise<T>;
13034
13035    /// The `Promise.resolve(value)` method returns a `Promise` object that is
13036    /// resolved with the given value. If the value is a promise, that promise
13037    /// is returned; if the value is a thenable (i.e. has a "then" method), the
13038    /// returned promise will "follow" that thenable, adopting its eventual
13039    /// state; otherwise the returned promise will be fulfilled with the value.
13040    ///
13041    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve)
13042    #[wasm_bindgen(static_method_of = Promise, js_name = resolve)]
13043    pub fn resolve<U: Promising>(obj: &U) -> Promise<U::Resolution>;
13044
13045    /// The `catch()` method returns a `Promise` and deals with rejected cases
13046    /// only.  It behaves the same as calling `Promise.prototype.then(undefined,
13047    /// onRejected)` (in fact, calling `obj.catch(onRejected)` internally calls
13048    /// `obj.then(undefined, onRejected)`).
13049    ///
13050    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch)
13051    #[cfg(not(js_sys_unstable_apis))]
13052    #[wasm_bindgen(method)]
13053    pub fn catch<T>(this: &Promise<T>, cb: &ScopedClosure<dyn FnMut(JsValue)>) -> Promise<JsValue>;
13054
13055    /// The `catch()` method returns a `Promise` and deals with rejected cases
13056    /// only.  It behaves the same as calling `Promise.prototype.then(undefined,
13057    /// onRejected)` (in fact, calling `obj.catch(onRejected)` internally calls
13058    /// `obj.then(undefined, onRejected)`).
13059    ///
13060    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch)
13061    #[cfg(js_sys_unstable_apis)]
13062    #[wasm_bindgen(method, js_name = catch)]
13063    pub fn catch<'a, T, R: Promising>(
13064        this: &Promise<T>,
13065        cb: &ScopedClosure<'a, dyn FnMut(T) -> Result<R, JsError>>,
13066    ) -> Promise<R::Resolution>;
13067
13068    // Next major: deprecate
13069    /// Same as `catch`, but returning a result to become the new Promise value.
13070    #[wasm_bindgen(method, js_name = catch)]
13071    pub fn catch_map<'a, T, R: Promising>(
13072        this: &Promise<T>,
13073        cb: &ScopedClosure<'a, dyn FnMut(T) -> Result<R, JsError>>,
13074    ) -> Promise<R::Resolution>;
13075
13076    /// The `then()` method returns a `Promise`. It takes up to two arguments:
13077    /// callback functions for the success and failure cases of the `Promise`.
13078    ///
13079    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then)
13080    #[cfg(not(js_sys_unstable_apis))]
13081    #[wasm_bindgen(method)]
13082    pub fn then<'a, T>(this: &Promise<T>, cb: &ScopedClosure<'a, dyn FnMut(T)>)
13083        -> Promise<JsValue>;
13084
13085    /// The `then()` method returns a `Promise`. It takes up to two arguments:
13086    /// callback functions for the success and failure cases of the `Promise`.
13087    ///
13088    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then)
13089    #[cfg(js_sys_unstable_apis)]
13090    #[wasm_bindgen(method, js_name = then)]
13091    pub fn then<'a, T, R: Promising>(
13092        this: &Promise<T>,
13093        cb: &ScopedClosure<'a, dyn FnMut(T) -> Result<R, JsError>>,
13094    ) -> Promise<R::Resolution>;
13095
13096    /// The `then()` method returns a `Promise`. It takes up to two arguments:
13097    /// callback functions for the success and failure cases of the `Promise`.
13098    ///
13099    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then)
13100    #[wasm_bindgen(method, js_name = then)]
13101    pub fn then_with_reject<'a, T, R: Promising>(
13102        this: &Promise<T>,
13103        resolve: &ScopedClosure<'a, dyn FnMut(T) -> Result<R, JsError>>,
13104        reject: &ScopedClosure<'a, dyn FnMut(JsValue) -> Result<R, JsError>>,
13105    ) -> Promise<R::Resolution>;
13106
13107    // Next major: deprecate
13108    /// Alias for `then()` with a return value.
13109    /// The `then()` method returns a `Promise`. It takes up to two arguments:
13110    /// callback functions for the success and failure cases of the `Promise`.
13111    ///
13112    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then)
13113    #[wasm_bindgen(method, js_name = then)]
13114    pub fn then_map<'a, T, R: Promising>(
13115        this: &Promise<T>,
13116        cb: &ScopedClosure<'a, dyn FnMut(T) -> Result<R, JsError>>,
13117    ) -> Promise<R::Resolution>;
13118
13119    /// Same as `then`, only with both arguments provided.
13120    ///
13121    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then)
13122    #[wasm_bindgen(method, js_name = then)]
13123    pub fn then2(
13124        this: &Promise,
13125        resolve: &ScopedClosure<dyn FnMut(JsValue)>,
13126        reject: &ScopedClosure<dyn FnMut(JsValue)>,
13127    ) -> Promise;
13128
13129    /// The `finally()` method returns a `Promise`. When the promise is settled,
13130    /// whether fulfilled or rejected, the specified callback function is
13131    /// executed. This provides a way for code that must be executed once the
13132    /// `Promise` has been dealt with to be run whether the promise was
13133    /// fulfilled successfully or rejected.
13134    ///
13135    /// This lets you avoid duplicating code in both the promise's `then()` and
13136    /// `catch()` handlers.
13137    ///
13138    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/finally)
13139    #[wasm_bindgen(method)]
13140    pub fn finally<T>(this: &Promise<T>, cb: &ScopedClosure<dyn FnMut()>) -> Promise<JsValue>;
13141}
13142
13143impl<T: JsGeneric> Promising for Promise<T> {
13144    type Resolution = T;
13145}
13146
13147/// Returns a handle to the global scope object.
13148///
13149/// This allows access to the global properties and global names by accessing
13150/// the `Object` returned.
13151pub fn global() -> Object {
13152    use once_cell::unsync::Lazy;
13153
13154    struct Wrapper<T>(Lazy<T>);
13155
13156    #[cfg(not(target_feature = "atomics"))]
13157    unsafe impl<T> Sync for Wrapper<T> {}
13158
13159    #[cfg(not(target_feature = "atomics"))]
13160    unsafe impl<T> Send for Wrapper<T> {}
13161
13162    #[cfg_attr(target_feature = "atomics", thread_local)]
13163    static GLOBAL: Wrapper<Object> = Wrapper(Lazy::new(get_global_object));
13164
13165    return GLOBAL.0.clone();
13166
13167    fn get_global_object() -> Object {
13168        // Accessing the global object is not an easy thing to do, and what we
13169        // basically want is `globalThis` but we can't rely on that existing
13170        // everywhere. In the meantime we've got the fallbacks mentioned in:
13171        //
13172        // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis
13173        //
13174        // Note that this is pretty heavy code-size wise but it at least gets
13175        // the job largely done for now and avoids the `Function` constructor at
13176        // the end which triggers CSP errors.
13177        #[wasm_bindgen]
13178        extern "C" {
13179            type Global;
13180
13181            #[wasm_bindgen(thread_local_v2, js_name = globalThis)]
13182            static GLOBAL_THIS: Option<Object>;
13183
13184            #[wasm_bindgen(thread_local_v2, js_name = self)]
13185            static SELF: Option<Object>;
13186
13187            #[wasm_bindgen(thread_local_v2, js_name = window)]
13188            static WINDOW: Option<Object>;
13189
13190            #[wasm_bindgen(thread_local_v2, js_name = global)]
13191            static GLOBAL: Option<Object>;
13192        }
13193
13194        // The order is important: in Firefox Extension Content Scripts `globalThis`
13195        // is a Sandbox (not Window), so `globalThis` must be checked after `window`.
13196        let static_object = SELF
13197            .with(Option::clone)
13198            .or_else(|| WINDOW.with(Option::clone))
13199            .or_else(|| GLOBAL_THIS.with(Option::clone))
13200            .or_else(|| GLOBAL.with(Option::clone));
13201        if let Some(obj) = static_object {
13202            if !obj.is_undefined() {
13203                return obj;
13204            }
13205        }
13206
13207        // Global object not found
13208        JsValue::undefined().unchecked_into()
13209    }
13210}
13211
13212// Float16Array
13213//
13214// Rust does not yet have a stable builtin `f16`, so the raw JS bindings live
13215// here and any Rust-side helper APIs use explicit `u16` / `f32` naming. The
13216// unsuffixed float APIs are reserved for a future native `f16` binding.
13217#[wasm_bindgen]
13218extern "C" {
13219    #[wasm_bindgen(extends = Object, typescript_type = "Float16Array")]
13220    #[derive(Clone, Debug)]
13221    pub type Float16Array;
13222
13223    /// The `Float16Array()` constructor creates a new array.
13224    ///
13225    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float16Array)
13226    #[wasm_bindgen(constructor)]
13227    pub fn new(constructor_arg: &JsValue) -> Float16Array;
13228
13229    /// The `Float16Array()` constructor creates an array with an internal
13230    /// buffer large enough for `length` elements.
13231    ///
13232    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float16Array)
13233    #[wasm_bindgen(constructor)]
13234    pub fn new_with_length(length: u32) -> Float16Array;
13235
13236    /// The `Float16Array()` constructor creates an array with the given
13237    /// buffer but is a view starting at `byte_offset`.
13238    ///
13239    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float16Array)
13240    #[wasm_bindgen(constructor)]
13241    pub fn new_with_byte_offset(buffer: &JsValue, byte_offset: u32) -> Float16Array;
13242
13243    /// The `Float16Array()` constructor creates an array with the given
13244    /// buffer but is a view starting at `byte_offset` for `length` elements.
13245    ///
13246    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float16Array)
13247    #[wasm_bindgen(constructor)]
13248    pub fn new_with_byte_offset_and_length(
13249        buffer: &JsValue,
13250        byte_offset: u32,
13251        length: u32,
13252    ) -> Float16Array;
13253
13254    /// The `fill()` method fills all elements from a start index to an end
13255    /// index with a static `f32` value.
13256    ///
13257    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill)
13258    #[wasm_bindgen(method, js_name = fill)]
13259    pub fn fill_with_f32(this: &Float16Array, value: f32, start: u32, end: u32) -> Float16Array;
13260
13261    /// The buffer accessor property represents the `ArrayBuffer` referenced
13262    /// by a `TypedArray` at construction time.
13263    #[wasm_bindgen(getter, method)]
13264    pub fn buffer(this: &Float16Array) -> ArrayBuffer;
13265
13266    /// The `subarray()` method returns a new `TypedArray` on the same
13267    /// `ArrayBuffer` store and with the same element types as this array.
13268    #[wasm_bindgen(method)]
13269    pub fn subarray(this: &Float16Array, begin: u32, end: u32) -> Float16Array;
13270
13271    /// The `slice()` method returns a shallow copy of a portion of a typed
13272    /// array into a new typed array object.
13273    #[wasm_bindgen(method)]
13274    pub fn slice(this: &Float16Array, begin: u32, end: u32) -> Float16Array;
13275
13276    /// The `forEach()` method executes a provided function once per array
13277    /// element, passing values as `f32`.
13278    #[wasm_bindgen(method, js_name = forEach)]
13279    pub fn for_each_as_f32(this: &Float16Array, callback: &mut dyn FnMut(f32, u32, Float16Array));
13280
13281    /// The `forEach()` method executes a provided function once per array
13282    /// element, passing values as `f32`.
13283    #[wasm_bindgen(method, js_name = forEach, catch)]
13284    pub fn try_for_each_as_f32(
13285        this: &Float16Array,
13286        callback: &mut dyn FnMut(f32, u32, Float16Array) -> Result<(), JsError>,
13287    ) -> Result<(), JsValue>;
13288
13289    /// The length accessor property represents the length (in elements) of a
13290    /// typed array.
13291    #[wasm_bindgen(method, getter)]
13292    pub fn length(this: &Float16Array) -> u32;
13293
13294    /// The byteLength accessor property represents the length (in bytes) of a
13295    /// typed array.
13296    #[wasm_bindgen(method, getter, js_name = byteLength)]
13297    pub fn byte_length(this: &Float16Array) -> u32;
13298
13299    /// The byteOffset accessor property represents the offset (in bytes) of a
13300    /// typed array from the start of its `ArrayBuffer`.
13301    #[wasm_bindgen(method, getter, js_name = byteOffset)]
13302    pub fn byte_offset(this: &Float16Array) -> u32;
13303
13304    /// The `set()` method stores multiple values in the typed array, reading
13305    /// input values from a specified array.
13306    #[wasm_bindgen(method)]
13307    pub fn set(this: &Float16Array, src: &JsValue, offset: u32);
13308
13309    /// Gets the value at `idx` as an `f32`, counting from the end if negative.
13310    #[wasm_bindgen(method, js_name = at)]
13311    pub fn at_as_f32(this: &Float16Array, idx: i32) -> Option<f32>;
13312
13313    /// The `copyWithin()` method shallow copies part of a typed array to another
13314    /// location in the same typed array and returns it, without modifying its size.
13315    ///
13316    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/copyWithin)
13317    #[wasm_bindgen(method, js_name = copyWithin)]
13318    pub fn copy_within(this: &Float16Array, target: i32, start: i32, end: i32) -> Float16Array;
13319
13320    /// Gets the value at `idx` as an `f32`, equivalent to JavaScript
13321    /// `arr[idx]`.
13322    #[wasm_bindgen(method, indexing_getter)]
13323    pub fn get_index_as_f32(this: &Float16Array, idx: u32) -> f32;
13324
13325    /// Sets the value at `idx` from an `f32`, equivalent to JavaScript
13326    /// `arr[idx] = value`.
13327    #[wasm_bindgen(method, indexing_setter)]
13328    pub fn set_index_from_f32(this: &Float16Array, idx: u32, value: f32);
13329}
13330
13331impl Default for Float16Array {
13332    fn default() -> Self {
13333        Self::new(&JsValue::UNDEFINED.unchecked_into())
13334    }
13335}
13336
13337impl TypedArray for Float16Array {}
13338
13339impl Float16Array {
13340    fn as_uint16_view(&self) -> Uint16Array {
13341        let buffer = self.buffer();
13342        Uint16Array::new_with_byte_offset_and_length(
13343            buffer.as_ref(),
13344            self.byte_offset(),
13345            self.length(),
13346        )
13347    }
13348
13349    /// Creates an array from raw IEEE 754 binary16 bit patterns.
13350    ///
13351    /// This pairs naturally with the optional `half` crate:
13352    ///
13353    /// ```rust
13354    /// use half::f16;
13355    /// use js_sys::Float16Array;
13356    ///
13357    /// let values = [f16::from_f32(1.0), f16::from_f32(-2.0)];
13358    /// let bits = values.map(f16::to_bits);
13359    /// let array = Float16Array::new_from_u16_slice(&bits);
13360    /// ```
13361    pub fn new_from_u16_slice(slice: &[u16]) -> Float16Array {
13362        let array = Float16Array::new_with_length(slice.len() as u32);
13363        array.copy_from_u16_slice(slice);
13364        array
13365    }
13366
13367    /// Copy the raw IEEE 754 binary16 bit patterns from this JS typed array
13368    /// into the destination Rust slice.
13369    ///
13370    /// # Panics
13371    ///
13372    /// This function will panic if this typed array's length is different than
13373    /// the length of the provided `dst` array.
13374    ///
13375    /// Values copied into `dst` can be converted back into `half::f16` with
13376    /// `half::f16::from_bits`.
13377    pub fn copy_to_u16_slice(&self, dst: &mut [u16]) {
13378        self.as_uint16_view().copy_to(dst);
13379    }
13380
13381    /// Copy raw IEEE 754 binary16 bit patterns from the source Rust slice into
13382    /// this JS typed array.
13383    ///
13384    /// # Panics
13385    ///
13386    /// This function will panic if this typed array's length is different than
13387    /// the length of the provided `src` array.
13388    ///
13389    /// When using the optional `half` crate, populate `src` with
13390    /// `half::f16::to_bits()`.
13391    pub fn copy_from_u16_slice(&self, src: &[u16]) {
13392        self.as_uint16_view().copy_from(src);
13393    }
13394
13395    /// Efficiently copies the contents of this JS typed array into a new Vec of
13396    /// raw IEEE 754 binary16 bit patterns.
13397    ///
13398    /// This makes it easy to round-trip through the optional `half` crate:
13399    ///
13400    /// ```rust
13401    /// use half::f16;
13402    ///
13403    /// let bits = array.to_u16_vec();
13404    /// let values: Vec<f16> = bits.into_iter().map(f16::from_bits).collect();
13405    /// ```
13406    pub fn to_u16_vec(&self) -> Vec<u16> {
13407        self.as_uint16_view().to_vec()
13408    }
13409}
13410
13411macro_rules! arrays {
13412    ($(#[doc = $ctor:literal] #[doc = $mdn:literal] $name:ident: $ty:ident,)*) => ($(
13413        #[wasm_bindgen]
13414        extern "C" {
13415            #[wasm_bindgen(extends = Object, typescript_type = $name)]
13416            #[derive(Clone, Debug)]
13417            pub type $name;
13418
13419            /// The
13420            #[doc = $ctor]
13421            /// constructor creates a new array.
13422            ///
13423            /// [MDN documentation](
13424            #[doc = $mdn]
13425            /// )
13426            #[wasm_bindgen(constructor)]
13427            pub fn new(constructor_arg: &JsValue) -> $name;
13428
13429            /// An
13430            #[doc = $ctor]
13431            /// which creates an array with an internal buffer large
13432            /// enough for `length` elements.
13433            ///
13434            /// [MDN documentation](
13435            #[doc = $mdn]
13436            /// )
13437            #[wasm_bindgen(constructor)]
13438            pub fn new_with_length(length: u32) -> $name;
13439
13440            /// An
13441            #[doc = $ctor]
13442            /// which creates an array from a Rust slice.
13443            ///
13444            /// [MDN documentation](
13445            #[doc = $mdn]
13446            /// )
13447            #[wasm_bindgen(constructor)]
13448            pub fn new_from_slice(slice: &[$ty]) -> $name;
13449
13450            /// An
13451            #[doc = $ctor]
13452            /// which creates an array with the given buffer but is a
13453            /// view starting at `byte_offset`.
13454            ///
13455            /// [MDN documentation](
13456            #[doc = $mdn]
13457            /// )
13458            #[wasm_bindgen(constructor)]
13459            pub fn new_with_byte_offset(buffer: &JsValue, byte_offset: u32) -> $name;
13460
13461            /// An
13462            #[doc = $ctor]
13463            /// which creates an array with the given buffer but is a
13464            /// view starting at `byte_offset` for `length` elements.
13465            ///
13466            /// [MDN documentation](
13467            #[doc = $mdn]
13468            /// )
13469            #[wasm_bindgen(constructor)]
13470            pub fn new_with_byte_offset_and_length(
13471                buffer: &JsValue,
13472                byte_offset: u32,
13473                length: u32,
13474            ) -> $name;
13475
13476            /// The `fill()` method fills all the elements of an array from a start index
13477            /// to an end index with a static value. The end index is not included.
13478            ///
13479            /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill)
13480            #[wasm_bindgen(method)]
13481            pub fn fill(this: &$name, value: $ty, start: u32, end: u32) -> $name;
13482
13483            /// The buffer accessor property represents the `ArrayBuffer` referenced
13484            /// by a `TypedArray` at construction time.
13485            #[wasm_bindgen(getter, method)]
13486            pub fn buffer(this: &$name) -> ArrayBuffer;
13487
13488            /// The `subarray()` method returns a new `TypedArray` on the same
13489            /// `ArrayBuffer` store and with the same element types as for this
13490            /// `TypedArray` object.
13491            #[wasm_bindgen(method)]
13492            pub fn subarray(this: &$name, begin: u32, end: u32) -> $name;
13493
13494            /// The `slice()` method returns a shallow copy of a portion of a typed
13495            /// array into a new typed array object. This method has the same algorithm
13496            /// as `Array.prototype.slice()`.
13497            #[wasm_bindgen(method)]
13498            pub fn slice(this: &$name, begin: u32, end: u32) -> $name;
13499
13500            /// The `forEach()` method executes a provided function once per array
13501            /// element. This method has the same algorithm as
13502            /// `Array.prototype.forEach()`. `TypedArray` is one of the typed array
13503            /// types here.
13504            #[wasm_bindgen(method, js_name = forEach)]
13505            pub fn for_each(this: &$name, callback: &mut dyn FnMut($ty, u32, $name));
13506
13507            /// The `forEach()` method executes a provided function once per array
13508            /// element. This method has the same algorithm as
13509            /// `Array.prototype.forEach()`. `TypedArray` is one of the typed array
13510            /// types here.
13511            #[wasm_bindgen(method, js_name = forEach, catch)]
13512            pub fn try_for_each(this: &$name, callback: &mut dyn FnMut($ty, u32, $name) -> Result<(), JsError>) -> Result<(), JsValue>;
13513
13514            /// The length accessor property represents the length (in elements) of a
13515            /// typed array.
13516            #[wasm_bindgen(method, getter)]
13517            pub fn length(this: &$name) -> u32;
13518
13519            /// The byteLength accessor property represents the length (in bytes) of a
13520            /// typed array.
13521            #[wasm_bindgen(method, getter, js_name = byteLength)]
13522            pub fn byte_length(this: &$name) -> u32;
13523
13524            /// The byteOffset accessor property represents the offset (in bytes) of a
13525            /// typed array from the start of its `ArrayBuffer`.
13526            #[wasm_bindgen(method, getter, js_name = byteOffset)]
13527            pub fn byte_offset(this: &$name) -> u32;
13528
13529            /// The `set()` method stores multiple values in the typed array, reading
13530            /// input values from a specified array.
13531            #[wasm_bindgen(method)]
13532            pub fn set(this: &$name, src: &JsValue, offset: u32);
13533
13534            /// Gets the value at `idx`, counting from the end if negative.
13535            #[wasm_bindgen(method)]
13536            pub fn at(this: &$name, idx: i32) -> Option<$ty>;
13537
13538            /// The `copyWithin()` method shallow copies part of a typed array to another
13539            /// location in the same typed array and returns it, without modifying its size.
13540            ///
13541            /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/copyWithin)
13542            #[wasm_bindgen(method, js_name = copyWithin)]
13543            pub fn copy_within(this: &$name, target: i32, start: i32, end: i32) -> $name;
13544
13545            /// Gets the value at `idx`, equivalent to the javascript `my_var = arr[idx]`.
13546            #[wasm_bindgen(method, indexing_getter)]
13547            pub fn get_index(this: &$name, idx: u32) -> $ty;
13548
13549            /// Sets the value at `idx`, equivalent to the javascript `arr[idx] = value`.
13550            #[wasm_bindgen(method, indexing_setter)]
13551            pub fn set_index(this: &$name, idx: u32, value: $ty);
13552
13553            /// Copies the Rust slice's data to self.
13554            ///
13555            /// This method is not expected to be public. It requires the length of the
13556            /// TypedArray to be the same as the slice, use `self.copy_from(slice)` instead.
13557            #[wasm_bindgen(method, js_name = set)]
13558            fn copy_from_slice(this: &$name, slice: &[$ty]);
13559
13560            /// Copies this TypedArray's data to Rust slice;
13561            ///
13562            /// This method is not expected to be public. It requires the length of the
13563            /// TypedArray to be the same as the slice, use `self.copy_to(slice)` instead.
13564            ///
13565            /// # Workaround
13566            ///
13567            /// We actually need `slice.set(typed_array)` here, but since slice cannot be treated as
13568            /// `Uint8Array` on the Rust side, we use `Uint8Array.prototype.set.call`, which allows
13569            /// us to specify the `this` value inside the function.
13570            ///
13571            /// Therefore, `Uint8Array.prototype.set.call(slice, typed_array)` is equivalent to
13572            /// `slice.set(typed_array)`.
13573            #[wasm_bindgen(js_namespace = $name, js_name = "prototype.set.call")]
13574            fn copy_to_slice(slice: &mut [$ty], this: &$name);
13575        }
13576
13577        impl $name {
13578            /// Creates a JS typed array which is a view into wasm's linear
13579            /// memory at the slice specified.
13580            ///
13581            /// This function returns a new typed array which is a view into
13582            /// wasm's memory. This view does not copy the underlying data.
13583            ///
13584            /// # Safety
13585            ///
13586            /// Views into WebAssembly memory are only valid so long as the
13587            /// backing buffer isn't resized in JS. Once this function is called
13588            /// any future calls to `Box::new` (or malloc of any form) may cause
13589            /// the returned value here to be invalidated. Use with caution!
13590            ///
13591            /// Additionally the returned object can be safely mutated but the
13592            /// input slice isn't guaranteed to be mutable.
13593            ///
13594            /// Finally, the returned object is disconnected from the input
13595            /// slice's lifetime, so there's no guarantee that the data is read
13596            /// at the right time.
13597            pub unsafe fn view(rust: &[$ty]) -> $name {
13598                wasm_bindgen::__rt::wbg_cast(rust)
13599            }
13600
13601            /// Creates a JS typed array which is a view into wasm's linear
13602            /// memory at the specified pointer with specified length.
13603            ///
13604            /// This function returns a new typed array which is a view into
13605            /// wasm's memory. This view does not copy the underlying data.
13606            ///
13607            /// # Safety
13608            ///
13609            /// Views into WebAssembly memory are only valid so long as the
13610            /// backing buffer isn't resized in JS. Once this function is called
13611            /// any future calls to `Box::new` (or malloc of any form) may cause
13612            /// the returned value here to be invalidated. Use with caution!
13613            ///
13614            /// Additionally the returned object can be safely mutated,
13615            /// the changes are guaranteed to be reflected in the input array.
13616            pub unsafe fn view_mut_raw(ptr: *mut $ty, length: usize) -> $name {
13617                let slice = core::slice::from_raw_parts_mut(ptr, length);
13618                Self::view(slice)
13619            }
13620
13621            /// Copy the contents of this JS typed array into the destination
13622            /// Rust pointer.
13623            ///
13624            /// This function will efficiently copy the memory from a typed
13625            /// array into this Wasm module's own linear memory, initializing
13626            /// the memory destination provided.
13627            ///
13628            /// # Safety
13629            ///
13630            /// This function requires `dst` to point to a buffer
13631            /// large enough to fit this array's contents.
13632            pub unsafe fn raw_copy_to_ptr(&self, dst: *mut $ty) {
13633                let slice = core::slice::from_raw_parts_mut(dst, self.length() as usize);
13634                self.copy_to(slice);
13635            }
13636
13637            /// Copy the contents of this JS typed array into the destination
13638            /// Rust slice.
13639            ///
13640            /// This function will efficiently copy the memory from a typed
13641            /// array into this Wasm module's own linear memory, initializing
13642            /// the memory destination provided.
13643            ///
13644            /// # Panics
13645            ///
13646            /// This function will panic if this typed array's length is
13647            /// different than the length of the provided `dst` array.
13648            pub fn copy_to(&self, dst: &mut [$ty]) {
13649                core::assert_eq!(self.length() as usize, dst.len());
13650                $name::copy_to_slice(dst, self);
13651            }
13652
13653            /// Copy the contents of this JS typed array into the destination
13654            /// Rust slice.
13655            ///
13656            /// This function will efficiently copy the memory from a typed
13657            /// array into this Wasm module's own linear memory, initializing
13658            /// the memory destination provided.
13659            ///
13660            /// # Panics
13661            ///
13662            /// This function will panic if this typed array's length is
13663            /// different than the length of the provided `dst` array.
13664            pub fn copy_to_uninit<'dst>(&self, dst: &'dst mut [MaybeUninit<$ty>]) -> &'dst mut [$ty] {
13665                core::assert_eq!(self.length() as usize, dst.len());
13666                let dst = unsafe { &mut *(dst as *mut [MaybeUninit<$ty>] as *mut [$ty]) };
13667                self.copy_to(dst);
13668                dst
13669            }
13670
13671            /// Copy the contents of the source Rust slice into this
13672            /// JS typed array.
13673            ///
13674            /// This function will efficiently copy the memory from within
13675            /// the Wasm module's own linear memory to this typed array.
13676            ///
13677            /// # Panics
13678            ///
13679            /// This function will panic if this typed array's length is
13680            /// different than the length of the provided `src` array.
13681            pub fn copy_from(&self, src: &[$ty]) {
13682                core::assert_eq!(self.length() as usize, src.len());
13683                self.copy_from_slice(src);
13684            }
13685
13686            /// Efficiently copies the contents of this JS typed array into a new Vec.
13687            pub fn to_vec(&self) -> Vec<$ty> {
13688                let len = self.length() as usize;
13689                let mut output = Vec::with_capacity(len);
13690                // Safety: the capacity has been set
13691                unsafe {
13692                    self.raw_copy_to_ptr(output.as_mut_ptr());
13693                    output.set_len(len);
13694                }
13695                output
13696            }
13697        }
13698
13699        impl<'a> From<&'a [$ty]> for $name {
13700            #[inline]
13701            fn from(slice: &'a [$ty]) -> $name {
13702                // This is safe because the `new` function makes a copy if its argument is a TypedArray
13703                $name::new_from_slice(slice)
13704            }
13705        }
13706
13707        impl Default for $name {
13708            fn default() -> Self {
13709                Self::new(&JsValue::UNDEFINED.unchecked_into())
13710            }
13711        }
13712
13713        impl TypedArray for $name {}
13714
13715
13716    )*);
13717}
13718
13719arrays! {
13720    /// `Int8Array()`
13721    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array
13722    Int8Array: i8,
13723
13724    /// `Int16Array()`
13725    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array
13726    Int16Array: i16,
13727
13728    /// `Int32Array()`
13729    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array
13730    Int32Array: i32,
13731
13732    /// `Uint8Array()`
13733    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array
13734    Uint8Array: u8,
13735
13736    /// `Uint8ClampedArray()`
13737    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray
13738    Uint8ClampedArray: u8,
13739
13740    /// `Uint16Array()`
13741    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array
13742    Uint16Array: u16,
13743
13744    /// `Uint32Array()`
13745    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array
13746    Uint32Array: u32,
13747
13748    /// `Float32Array()`
13749    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array
13750    Float32Array: f32,
13751
13752    /// `Float64Array()`
13753    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array
13754    Float64Array: f64,
13755
13756    /// `BigInt64Array()`
13757    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array
13758    BigInt64Array: i64,
13759
13760    /// `BigUint64Array()`
13761    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigUint64Array
13762    BigUint64Array: u64,
13763}
13764
13765/// Bridging between JavaScript `Promise`s and Rust `Future`s.
13766///
13767/// Enables `promise.await` directly on any [`Promise`] when this feature is active.
13768/// This module is automatically available when depending on `wasm-bindgen-futures`.
13769#[cfg(feature = "futures")]
13770pub mod futures;