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(target_feature = "atomics", feature(stdarch_wasm_atomic_wait))]
31
32extern crate alloc;
33
34use alloc::string::String;
35use alloc::vec::Vec;
36use core::cmp::Ordering;
37#[cfg(not(js_sys_unstable_apis))]
38use core::convert::Infallible;
39use core::convert::{self, TryFrom};
40use core::f64;
41use core::fmt;
42use core::iter::{self, Product, Sum};
43use core::marker::PhantomData;
44use core::mem::MaybeUninit;
45use core::ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Neg, Not, Rem, Shl, Shr, Sub};
46use core::str;
47use core::str::FromStr;
48pub use wasm_bindgen;
49use wasm_bindgen::closure::{ScopedClosure, WasmClosure};
50use wasm_bindgen::convert::{FromWasmAbi, IntoWasmAbi, Upcast, UpcastFrom};
51use wasm_bindgen::prelude::*;
52use wasm_bindgen::JsError;
53
54// Re-export sys types as js-sys types
55pub use wasm_bindgen::sys::{JsOption, Null, Promising, Undefined};
56pub use wasm_bindgen::{IntoJsGeneric, JsGeneric};
57
58// When adding new imports:
59//
60// * Keep imports in alphabetical order.
61//
62// * Rename imports with `js_name = ...` according to the note about `camelCase`
63//   and `snake_case` in the module's documentation above.
64//
65// * Include the one sentence summary of the import from the MDN link in the
66//   module's documentation above, and the MDN link itself.
67//
68// * If a function or method can throw an exception, make it catchable by adding
69//   `#[wasm_bindgen(catch)]`.
70//
71// * Add a new `#[test]` into the appropriate file in the
72//   `crates/js-sys/tests/wasm/` directory. If the imported function or method
73//   can throw an exception, make sure to also add test coverage for that case.
74//
75// * Arguments that are `JsValue`s or imported JavaScript types should be taken
76//   by reference.
77//
78// * Name JavaScript's `toString()` method as `to_js_string()` to avoid conflict
79//   with Rust's `ToString` trait.
80
81macro_rules! forward_deref_unop {
82    (impl $imp:ident, $method:ident for $t:ty) => {
83        impl $imp for $t {
84            type Output = <&'static $t as $imp>::Output;
85
86            #[inline]
87            fn $method(self) -> Self::Output {
88                $imp::$method(&self)
89            }
90        }
91    };
92    (impl<$($gen:ident),+> $imp:ident, $method:ident for $t:ty) => {
93        impl<$($gen),+> $imp for $t {
94            type Output = <&'static $t as $imp>::Output;
95
96            #[inline]
97            fn $method(self) -> Self::Output {
98                $imp::$method(&self)
99            }
100        }
101    };
102}
103
104macro_rules! forward_deref_binop {
105    (impl $imp:ident, $method:ident for $t:ty) => {
106        impl<'a> $imp<$t> for &'a $t {
107            type Output = <&'static $t as $imp<&'static $t>>::Output;
108
109            #[inline]
110            fn $method(self, other: $t) -> Self::Output {
111                $imp::$method(self, &other)
112            }
113        }
114
115        impl $imp<&$t> for $t {
116            type Output = <&'static $t as $imp<&'static $t>>::Output;
117
118            #[inline]
119            fn $method(self, other: &$t) -> Self::Output {
120                $imp::$method(&self, other)
121            }
122        }
123
124        impl $imp<$t> for $t {
125            type Output = <&'static $t as $imp<&'static $t>>::Output;
126
127            #[inline]
128            fn $method(self, other: $t) -> Self::Output {
129                $imp::$method(&self, &other)
130            }
131        }
132    };
133    (impl<$($gen:ident),+> $imp:ident, $method:ident for $t:ty) => {
134        impl<'a, $($gen),+> $imp<$t> for &'a $t {
135            type Output = <&'static $t as $imp<&'static $t>>::Output;
136
137            #[inline]
138            fn $method(self, other: $t) -> Self::Output {
139                $imp::$method(self, &other)
140            }
141        }
142
143        impl<$($gen),+> $imp<&$t> for $t {
144            type Output = <&'static $t as $imp<&'static $t>>::Output;
145
146            #[inline]
147            fn $method(self, other: &$t) -> Self::Output {
148                $imp::$method(&self, other)
149            }
150        }
151
152        impl<$($gen),+> $imp<$t> for $t {
153            type Output = <&'static $t as $imp<&'static $t>>::Output;
154
155            #[inline]
156            fn $method(self, other: $t) -> Self::Output {
157                $imp::$method(&self, &other)
158            }
159        }
160    };
161}
162
163macro_rules! forward_js_unop {
164    (impl $imp:ident, $method:ident for $t:ty) => {
165        impl $imp for &$t {
166            type Output = $t;
167
168            #[inline]
169            fn $method(self) -> Self::Output {
170                $imp::$method(JsValue::as_ref(self)).unchecked_into()
171            }
172        }
173
174        forward_deref_unop!(impl $imp, $method for $t);
175    };
176    (impl<$($gen:ident),+> $imp:ident, $method:ident for $t:ty) => {
177        impl<$($gen),+> $imp for &$t {
178            type Output = $t;
179
180            #[inline]
181            fn $method(self) -> Self::Output {
182                $imp::$method(JsValue::as_ref(self)).unchecked_into()
183            }
184        }
185
186        forward_deref_unop!(impl<$($gen),+> $imp, $method for $t);
187    };
188}
189
190macro_rules! forward_js_binop {
191    (impl $imp:ident, $method:ident for $t:ty) => {
192        impl $imp<&$t> for &$t {
193            type Output = $t;
194
195            #[inline]
196            fn $method(self, other: &$t) -> Self::Output {
197                $imp::$method(JsValue::as_ref(self), JsValue::as_ref(other)).unchecked_into()
198            }
199        }
200
201        forward_deref_binop!(impl $imp, $method for $t);
202    };
203    (impl<$($gen:ident),+> $imp:ident, $method:ident for $t:ty) => {
204        impl<$($gen),+> $imp<&$t> for &$t {
205            type Output = $t;
206
207            #[inline]
208            fn $method(self, other: &$t) -> Self::Output {
209                $imp::$method(JsValue::as_ref(self), JsValue::as_ref(other)).unchecked_into()
210            }
211        }
212
213        forward_deref_binop!(impl<$($gen),+> $imp, $method for $t);
214    };
215}
216
217macro_rules! sum_product {
218    ($($a:ident)*) => ($(
219        impl Sum for $a {
220            #[inline]
221            fn sum<I: iter::Iterator<Item=Self>>(iter: I) -> Self {
222                iter.fold(
223                    $a::from(0),
224                    |a, b| a + b,
225                )
226            }
227        }
228
229        impl Product for $a {
230            #[inline]
231            fn product<I: iter::Iterator<Item=Self>>(iter: I) -> Self {
232                iter.fold(
233                    $a::from(1),
234                    |a, b| a * b,
235                )
236            }
237        }
238
239        impl<'a> Sum<&'a $a> for $a {
240            fn sum<I: iter::Iterator<Item=&'a Self>>(iter: I) -> Self {
241                iter.fold(
242                    $a::from(0),
243                    |a, b| a + b,
244                )
245            }
246        }
247
248        impl<'a> Product<&'a $a> for $a {
249            #[inline]
250            fn product<I: iter::Iterator<Item=&'a Self>>(iter: I) -> Self {
251                iter.fold(
252                    $a::from(1),
253                    |a, b| a * b,
254                )
255            }
256        }
257    )*);
258    // Generic variant: impl<T> for Type<T>
259    (impl<$gen:ident> $a:ident<$g2:ident>) => {
260        impl<$gen> Sum for $a<$g2>
261        where
262            $a<$g2>: From<$gen>,
263            $g2: From<u32>
264        {
265            #[inline]
266            fn sum<I: iter::Iterator<Item=Self>>(iter: I) -> Self {
267                iter.fold(
268                    $a::from($g2::from(0)),
269                    |a, b| a + b,
270                )
271            }
272        }
273
274        impl<$gen> Product for $a<$g2>
275        where
276            $a<$g2>: From<$gen>,
277            $g2: From<u32>
278        {
279            #[inline]
280            fn product<I: iter::Iterator<Item=Self>>(iter: I) -> Self {
281                iter.fold(
282                    $a::from($g2::from(1)),
283                    |a, b| a * b,
284                )
285            }
286        }
287
288        impl<'a, $gen> Sum<&'a $a<$g2>> for $a<$g2>
289        where
290            $a<$g2>: From<$gen>,
291            $g2: From<u32>
292        {
293            fn sum<I: iter::Iterator<Item=&'a Self>>(iter: I) -> Self {
294                iter.fold(
295                    $a::from($g2::from(0)),
296                    |a, b| a + b,
297                )
298            }
299        }
300
301        impl<'a, $gen> Product<&'a $a<$g2>> for $a<$g2>
302        where
303            $a<$g2>: From<$gen>,
304            $g2: From<u32>
305        {
306            #[inline]
307            fn product<I: iter::Iterator<Item=&'a Self>>(iter: I) -> Self {
308                iter.fold(
309                    $a::from($g2::from(1)),
310                    |a, b| a * b,
311                )
312            }
313        }
314    };
315}
316
317macro_rules! partialord_ord {
318    ($t:ident) => {
319        impl PartialOrd for $t {
320            #[inline]
321            fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
322                Some(self.cmp(other))
323            }
324
325            #[inline]
326            fn lt(&self, other: &Self) -> bool {
327                JsValue::as_ref(self).lt(JsValue::as_ref(other))
328            }
329
330            #[inline]
331            fn le(&self, other: &Self) -> bool {
332                JsValue::as_ref(self).le(JsValue::as_ref(other))
333            }
334
335            #[inline]
336            fn ge(&self, other: &Self) -> bool {
337                JsValue::as_ref(self).ge(JsValue::as_ref(other))
338            }
339
340            #[inline]
341            fn gt(&self, other: &Self) -> bool {
342                JsValue::as_ref(self).gt(JsValue::as_ref(other))
343            }
344        }
345
346        impl Ord for $t {
347            #[inline]
348            fn cmp(&self, other: &Self) -> Ordering {
349                if self == other {
350                    Ordering::Equal
351                } else if self.lt(other) {
352                    Ordering::Less
353                } else {
354                    Ordering::Greater
355                }
356            }
357        }
358    };
359}
360
361#[wasm_bindgen]
362extern "C" {
363    /// The `decodeURI()` function decodes a Uniform Resource Identifier (URI)
364    /// previously created by `encodeURI` or by a similar routine.
365    ///
366    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURI)
367    #[wasm_bindgen(catch, js_name = decodeURI)]
368    pub fn decode_uri(encoded: &str) -> Result<JsString, JsValue>;
369
370    /// The `decodeURIComponent()` function decodes a Uniform Resource Identifier (URI) component
371    /// previously created by `encodeURIComponent` or by a similar routine.
372    ///
373    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent)
374    #[wasm_bindgen(catch, js_name = decodeURIComponent)]
375    pub fn decode_uri_component(encoded: &str) -> Result<JsString, JsValue>;
376
377    /// The `encodeURI()` function encodes a Uniform Resource Identifier (URI)
378    /// by replacing each instance of certain characters by one, two, three, or
379    /// four escape sequences representing the UTF-8 encoding of the character
380    /// (will only be four escape sequences for characters composed of two
381    /// "surrogate" characters).
382    ///
383    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI)
384    #[wasm_bindgen(js_name = encodeURI)]
385    pub fn encode_uri(decoded: &str) -> JsString;
386
387    /// The `encodeURIComponent()` function encodes a Uniform Resource Identifier (URI) component
388    /// by replacing each instance of certain characters by one, two, three, or four escape sequences
389    /// representing the UTF-8 encoding of the character
390    /// (will only be four escape sequences for characters composed of two "surrogate" characters).
391    ///
392    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent)
393    #[wasm_bindgen(js_name = encodeURIComponent)]
394    pub fn encode_uri_component(decoded: &str) -> JsString;
395
396    /// The `eval()` function evaluates JavaScript code represented as a string.
397    ///
398    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval)
399    #[cfg(feature = "unsafe-eval")]
400    #[wasm_bindgen(catch)]
401    pub fn eval(js_source_text: &str) -> Result<JsValue, JsValue>;
402
403    /// The global `isFinite()` function determines whether the passed value is a finite number.
404    /// If needed, the parameter is first converted to a number.
405    ///
406    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isFinite)
407    #[wasm_bindgen(js_name = isFinite)]
408    pub fn is_finite(value: &JsValue) -> bool;
409
410    /// The `parseInt()` function parses a string argument and returns an integer
411    /// of the specified radix (the base in mathematical numeral systems), or NaN on error.
412    ///
413    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt)
414    #[wasm_bindgen(js_name = parseInt)]
415    pub fn parse_int(text: &str, radix: u8) -> f64;
416
417    /// The `parseFloat()` function parses an argument and returns a floating point number,
418    /// or NaN on error.
419    ///
420    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat)
421    #[wasm_bindgen(js_name = parseFloat)]
422    pub fn parse_float(text: &str) -> f64;
423
424    /// The `escape()` function computes a new string in which certain characters have been
425    /// replaced by a hexadecimal escape sequence.
426    ///
427    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/escape)
428    #[wasm_bindgen]
429    pub fn escape(string: &str) -> JsString;
430
431    /// The `unescape()` function computes a new string in which hexadecimal escape
432    /// sequences are replaced with the character that it represents. The escape sequences might
433    /// be introduced by a function like `escape`. Usually, `decodeURI` or `decodeURIComponent`
434    /// are preferred over `unescape`.
435    ///
436    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/unescape)
437    #[wasm_bindgen]
438    pub fn unescape(string: &str) -> JsString;
439}
440
441// Array
442#[wasm_bindgen]
443extern "C" {
444    #[wasm_bindgen(extends = Object, is_type_of = Array::is_array, typescript_type = "Array<any>")]
445    #[derive(Clone, Debug, PartialEq, Eq)]
446    pub type Array<T = JsValue>;
447
448    /// Creates a new empty array.
449    ///
450    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Array)
451    #[cfg(not(js_sys_unstable_apis))]
452    #[wasm_bindgen(constructor)]
453    pub fn new() -> Array;
454
455    /// Creates a new empty array.
456    ///
457    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Array)
458    #[cfg(js_sys_unstable_apis)]
459    #[wasm_bindgen(constructor)]
460    pub fn new<T>() -> Array<T>;
461
462    // Next major: deprecate
463    /// Creates a new empty array.
464    ///
465    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Array)
466    #[wasm_bindgen(constructor)]
467    pub fn new_typed<T>() -> Array<T>;
468
469    /// Creates a new array with the specified length (elements are initialized to `undefined`).
470    ///
471    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Array)
472    #[cfg(not(js_sys_unstable_apis))]
473    #[wasm_bindgen(constructor)]
474    pub fn new_with_length(len: u32) -> Array;
475
476    /// Creates a new array with the specified length (elements are initialized to `undefined`).
477    ///
478    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Array)
479    #[cfg(js_sys_unstable_apis)]
480    #[wasm_bindgen(constructor)]
481    pub fn new_with_length<T>(len: u32) -> Array<T>;
482
483    // Next major: deprecate
484    /// Creates a new array with the specified length (elements are initialized to `undefined`).
485    ///
486    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Array)
487    #[wasm_bindgen(constructor)]
488    pub fn new_with_length_typed<T>(len: u32) -> Array<T>;
489
490    /// Retrieves the element at the index, counting from the end if negative
491    /// (returns `undefined` if the index is out of range).
492    ///
493    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at)
494    #[cfg(not(js_sys_unstable_apis))]
495    #[wasm_bindgen(method)]
496    pub fn at<T>(this: &Array<T>, index: i32) -> T;
497
498    /// Retrieves the element at the index, counting from the end if negative
499    /// (returns `None` if the index is out of range).
500    ///
501    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at)
502    #[cfg(js_sys_unstable_apis)]
503    #[wasm_bindgen(method)]
504    pub fn at<T>(this: &Array<T>, index: i32) -> Option<T>;
505
506    /// Retrieves the element at the index (returns `undefined` if the index is out of range).
507    ///
508    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at)
509    #[cfg(not(js_sys_unstable_apis))]
510    #[wasm_bindgen(method, indexing_getter)]
511    pub fn get<T>(this: &Array<T>, index: u32) -> T;
512
513    /// Retrieves the element at the index (returns `None` if the index is out of range).
514    ///
515    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at)
516    #[cfg(js_sys_unstable_apis)]
517    #[wasm_bindgen(method, indexing_getter)]
518    pub fn get<T>(this: &Array<T>, index: u32) -> Option<T>;
519
520    /// Retrieves the element at the index (returns `undefined` if the index is out of range).
521    ///
522    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at)
523    #[wasm_bindgen(method, indexing_getter)]
524    pub fn get_unchecked<T>(this: &Array<T>, index: u32) -> T;
525
526    // Next major: deprecate
527    /// Retrieves the element at the index (returns `None` if the index is out of range,
528    /// or if the element is explicitly `undefined`).
529    #[wasm_bindgen(method, indexing_getter)]
530    pub fn get_checked<T>(this: &Array<T>, index: u32) -> Option<T>;
531
532    /// Sets the element at the index (auto-enlarges the array if the index is out of range).
533    #[cfg(not(js_sys_unstable_apis))]
534    #[wasm_bindgen(method, indexing_setter)]
535    pub fn set<T>(this: &Array<T>, index: u32, value: T);
536
537    /// Sets the element at the index (auto-enlarges the array if the index is out of range).
538    #[cfg(js_sys_unstable_apis)]
539    #[wasm_bindgen(method, indexing_setter)]
540    pub fn set<T>(this: &Array<T>, index: u32, value: &T);
541
542    // Next major: deprecate
543    /// Sets the element at the index (auto-enlarges the array if the index is out of range).
544    #[wasm_bindgen(method, indexing_setter)]
545    pub fn set_ref<T>(this: &Array<T>, index: u32, value: &T);
546
547    /// Deletes the element at the index (does nothing if the index is out of range).
548    ///
549    /// The element at the index is set to `undefined`.
550    ///
551    /// This does not resize the array, the array will still be the same length.
552    #[wasm_bindgen(method, indexing_deleter)]
553    pub fn delete<T>(this: &Array<T>, index: u32);
554
555    /// The `Array.from()` static method creates a new, shallow-copied `Array` instance
556    /// from an array-like or iterable object.
557    ///
558    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from)
559    #[cfg(not(js_sys_unstable_apis))]
560    #[wasm_bindgen(static_method_of = Array)]
561    pub fn from(val: &JsValue) -> Array;
562
563    /// The `Array.from()` static method creates a new, shallow-copied `Array` instance
564    /// from an array-like or iterable object.
565    ///
566    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from)
567    #[cfg(js_sys_unstable_apis)]
568    #[wasm_bindgen(static_method_of = Array, catch, js_name = from)]
569    pub fn from<I: Iterable>(val: &I) -> Result<Array<I::Item>, JsValue>;
570
571    // Next major: deprecate
572    /// The `Array.from()` static method creates a new, shallow-copied `Array` instance
573    /// from an array-like or iterable object.
574    ///
575    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from)
576    #[wasm_bindgen(static_method_of = Array, catch, js_name = from)]
577    pub fn from_iterable<I: Iterable>(val: &I) -> Result<Array<I::Item>, JsValue>;
578
579    /// The `Array.from()` static method with a map function creates a new, shallow-copied
580    /// `Array` instance from an array-like or iterable object, applying the map function
581    /// to each value.
582    ///
583    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from)
584    #[wasm_bindgen(static_method_of = Array, catch, js_name = from)]
585    pub fn from_iterable_map<I: Iterable, U>(
586        val: &I,
587        map: &mut dyn FnMut(I::Item, u32) -> Result<U, JsError>,
588    ) -> Result<Array<U>, JsValue>;
589
590    /// The `Array.fromAsync()` static method creates a new, shallow-copied `Array` instance
591    /// from an async iterable, iterable or array-like object.
592    ///
593    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fromAsync)
594    #[wasm_bindgen(static_method_of = Array, catch, js_name = fromAsync)]
595    pub fn from_async<I: AsyncIterable>(val: &I) -> Result<Promise<Array<I::Item>>, JsValue>;
596
597    /// The `Array.fromAsync()` static method with a map function creates a new, shallow-copied
598    /// `Array` instance from an async iterable, iterable or array-like object, applying the map
599    /// function to each value.
600    ///
601    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fromAsync)
602    #[wasm_bindgen(static_method_of = Array, catch, js_name = fromAsync)]
603    pub fn from_async_map<'a, I: AsyncIterable, R: Promising>(
604        val: &I,
605        map: &ScopedClosure<'a, dyn FnMut(I::Item, u32) -> Result<R, JsError>>,
606    ) -> Result<Promise<Array<R::Resolution>>, JsValue>;
607
608    /// The `copyWithin()` method shallow copies part of an array to another
609    /// location in the same array and returns it, without modifying its size.
610    ///
611    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin)
612    #[wasm_bindgen(method, js_name = copyWithin)]
613    pub fn copy_within<T>(this: &Array<T>, target: i32, start: i32, end: i32) -> Array<T>;
614
615    /// The `concat()` method is used to merge two or more arrays. This method
616    /// does not change the existing arrays, but instead returns a new array.
617    ///
618    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat)
619    #[wasm_bindgen(method)]
620    pub fn concat<T, U: Upcast<T>>(this: &Array<T>, array: &Array<U>) -> Array<T>;
621
622    /// The `concat()` method is used to merge two or more arrays. This method
623    /// does not change the existing arrays, but instead returns a new array.
624    ///
625    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat)
626    #[wasm_bindgen(method)]
627    pub fn concat_many<T, U: Upcast<T>>(this: &Array<T>, array: &[Array<U>]) -> Array<T>;
628
629    /// The `every()` method tests whether all elements in the array pass the test
630    /// implemented by the provided function.
631    ///
632    /// **Note:** Consider using [`Array::try_every`] if the predicate might throw an error.
633    ///
634    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every)
635    #[wasm_bindgen(method)]
636    pub fn every<T>(this: &Array<T>, predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool) -> bool;
637
638    /// The `every()` method tests whether all elements in the array pass the test
639    /// implemented by the provided function. _(Fallible variation)_
640    ///
641    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every)
642    #[wasm_bindgen(method, js_name = every, catch)]
643    pub fn try_every<T>(
644        this: &Array<T>,
645        predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
646    ) -> Result<bool, JsValue>;
647
648    /// The `fill()` method fills all the elements of an array from a start index
649    /// to an end index with a static value. The end index is not included.
650    ///
651    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill)
652    #[wasm_bindgen(method)]
653    pub fn fill<T>(this: &Array<T>, value: &T, start: u32, end: u32) -> Array<T>;
654
655    /// The `filter()` method creates a new array with all elements that pass the
656    /// test implemented by the provided function.
657    ///
658    /// **Note:** Consider using [`Array::try_filter`] if the predicate might throw an error.
659    ///
660    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
661    #[wasm_bindgen(method)]
662    pub fn filter<T>(
663        this: &Array<T>,
664        predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool,
665    ) -> Array<T>;
666
667    /// The `filter()` method creates a new array with all elements that pass the
668    /// test implemented by the provided function. _(Fallible variation)_
669    ///
670    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
671    #[wasm_bindgen(method, js_name = filter, catch)]
672    pub fn try_filter<T>(
673        this: &Array<T>,
674        predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
675    ) -> Result<Array<T>, JsValue>;
676
677    /// The `find()` method returns the value of the first element in the array that satisfies
678    /// the provided testing function. Otherwise `undefined` is returned.
679    ///
680    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)
681    #[cfg(not(js_sys_unstable_apis))]
682    #[wasm_bindgen(method)]
683    pub fn find<T>(this: &Array<T>, predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool) -> T;
684
685    /// The `find()` method returns the value of the first element in the array that satisfies
686    /// the provided testing function. Returns `None` if no element matches.
687    ///
688    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)
689    #[cfg(js_sys_unstable_apis)]
690    #[wasm_bindgen(method)]
691    pub fn find<T>(
692        this: &Array<T>,
693        predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool,
694    ) -> Option<T>;
695
696    /// The `find()` method returns the value of the first element in the array that satisfies
697    ///  the provided testing function. Otherwise `undefined` is returned. _(Fallible variation)_
698    ///
699    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)
700    #[wasm_bindgen(method, js_name = find, catch)]
701    pub fn try_find<T>(
702        this: &Array<T>,
703        predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
704    ) -> Result<Option<T>, JsValue>;
705
706    /// The `findIndex()` method returns the index of the first element in the array that
707    /// satisfies the provided testing function. Otherwise -1 is returned.
708    ///
709    /// **Note:** Consider using [`Array::try_find_index`] if the predicate might throw an error.
710    ///
711    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex)
712    #[wasm_bindgen(method, js_name = findIndex)]
713    pub fn find_index<T>(
714        this: &Array<T>,
715        predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool,
716    ) -> i32;
717
718    /// The `findIndex()` method returns the index of the first element in the array that
719    /// satisfies the provided testing function. Otherwise -1 is returned. _(Fallible variation)_
720    ///
721    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex)
722    #[wasm_bindgen(method, js_name = findIndex, catch)]
723    pub fn try_find_index<T>(
724        this: &Array<T>,
725        predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
726    ) -> Result<i32, JsValue>;
727
728    /// The `findLast()` method of Array instances iterates the array in reverse order
729    /// and returns the value of the first element that satisfies the provided testing function.
730    /// If no elements satisfy the testing function, undefined is returned.
731    ///
732    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast)
733    #[cfg(not(js_sys_unstable_apis))]
734    #[wasm_bindgen(method, js_name = findLast)]
735    pub fn find_last<T>(this: &Array<T>, predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool) -> T;
736
737    /// The `findLast()` method of Array instances iterates the array in reverse order
738    /// and returns the value of the first element that satisfies the provided testing function.
739    /// Returns `None` if no element matches.
740    ///
741    /// **Note:** Consider using [`Array::try_find_last`] if the predicate might throw an error.
742    ///
743    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast)
744    #[cfg(js_sys_unstable_apis)]
745    #[wasm_bindgen(method, js_name = findLast)]
746    pub fn find_last<T>(this: &Array<T>, predicate: &mut dyn FnMut(T, u32) -> bool) -> Option<T>;
747
748    /// The `findLast()` method of Array instances iterates the array in reverse order
749    /// and returns the value of the first element that satisfies the provided testing function.
750    /// If no elements satisfy the testing function, undefined is returned. _(Fallible variation)_
751    ///
752    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast)
753    #[wasm_bindgen(method, js_name = findLast, catch)]
754    pub fn try_find_last<T>(
755        this: &Array<T>,
756        predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
757    ) -> Result<Option<T>, JsValue>;
758
759    /// The `findLastIndex()` method of Array instances iterates the array in reverse order
760    /// and returns the index of the first element that satisfies the provided testing function.
761    /// If no elements satisfy the testing function, -1 is returned.
762    ///
763    /// **Note:** Consider using [`Array::try_find_last_index`] if the predicate might throw an error.
764    ///
765    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex)
766    #[wasm_bindgen(method, js_name = findLastIndex)]
767    pub fn find_last_index<T>(
768        this: &Array<T>,
769        predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool,
770    ) -> i32;
771
772    /// The `findLastIndex()` method of Array instances iterates the array in reverse order
773    /// and returns the index of the first element that satisfies the provided testing function.
774    /// If no elements satisfy the testing function, -1 is returned. _(Fallible variation)_
775    ///
776    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex)
777    #[wasm_bindgen(method, js_name = findLastIndex, catch)]
778    pub fn try_find_last_index<T>(
779        this: &Array<T>,
780        predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
781    ) -> Result<i32, JsValue>;
782
783    /// The `flat()` method creates a new array with all sub-array elements concatenated into it
784    /// recursively up to the specified depth.
785    ///
786    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat)
787    #[wasm_bindgen(method)]
788    pub fn flat<T>(this: &Array<T>, depth: i32) -> Array<JsValue>;
789
790    /// The `flatMap()` method first maps each element using a mapping function, then flattens
791    /// the result into a new array.
792    ///
793    /// **Note:** Consider using [`Array::try_flat_map`] for safer fallible handling.
794    ///
795    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap)
796    #[wasm_bindgen(method, js_name = flatMap)]
797    pub fn flat_map<T, U>(
798        this: &Array<T>,
799        callback: &mut dyn FnMut(T, u32, Array<T>) -> Vec<U>,
800    ) -> Array<U>;
801
802    /// The `flatMap()` method first maps each element using a mapping function, then flattens
803    /// the result into a new array.
804    ///
805    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap)
806    #[wasm_bindgen(method, js_name = flatMap, catch)]
807    pub fn try_flat_map<T, U>(
808        this: &Array<T>,
809        callback: &mut dyn FnMut(T, u32) -> Vec<U>,
810    ) -> Result<Array<U>, JsValue>;
811
812    /// The `forEach()` method executes a provided function once for each array element.
813    ///
814    /// **Note:** Consider using [`Array::try_for_each`] if the callback might throw an error.
815    ///
816    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)
817    #[wasm_bindgen(method, js_name = forEach)]
818    pub fn for_each<T: JsGeneric>(this: &Array<T>, callback: &mut dyn FnMut(T, u32, Array<T>));
819
820    /// The `forEach()` method executes a provided function once for each array element. _(Fallible variation)_
821    ///
822    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)
823    #[wasm_bindgen(method, js_name = forEach, catch)]
824    pub fn try_for_each<T>(
825        this: &Array<T>,
826        callback: &mut dyn FnMut(T, u32) -> Result<(), JsError>,
827    ) -> Result<(), JsValue>;
828
829    /// The `includes()` method determines whether an array includes a certain
830    /// element, returning true or false as appropriate.
831    ///
832    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes)
833    #[wasm_bindgen(method)]
834    pub fn includes<T>(this: &Array<T>, value: &T, from_index: i32) -> bool;
835
836    /// The `indexOf()` method returns the first index at which a given element
837    /// can be found in the array, or -1 if it is not present.
838    ///
839    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf)
840    #[wasm_bindgen(method, js_name = indexOf)]
841    pub fn index_of<T>(this: &Array<T>, value: &T, from_index: i32) -> i32;
842
843    /// The `Array.isArray()` method determines whether the passed value is an Array.
844    ///
845    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray)
846    #[wasm_bindgen(static_method_of = Array, js_name = isArray)]
847    pub fn is_array(value: &JsValue) -> bool;
848
849    /// The `join()` method joins all elements of an array (or an array-like object)
850    /// into a string and returns this string.
851    ///
852    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join)
853    #[wasm_bindgen(method)]
854    pub fn join<T>(this: &Array<T>, delimiter: &str) -> JsString;
855
856    /// The `lastIndexOf()` method returns the last index at which a given element
857    /// can be found in the array, or -1 if it is not present. The array is
858    /// searched backwards, starting at fromIndex.
859    ///
860    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf)
861    #[wasm_bindgen(method, js_name = lastIndexOf)]
862    pub fn last_index_of<T>(this: &Array<T>, value: &T, from_index: i32) -> i32;
863
864    /// The length property of an object which is an instance of type Array
865    /// sets or returns the number of elements in that array. The value is an
866    /// unsigned, 32-bit integer that is always numerically greater than the
867    /// highest index in the array.
868    ///
869    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length)
870    #[wasm_bindgen(method, getter)]
871    pub fn length<T>(this: &Array<T>) -> u32;
872
873    /// Sets the length of the array.
874    ///
875    /// If it is set to less than the current length of the array, it will
876    /// shrink the array.
877    ///
878    /// If it is set to more than the current length of the array, it will
879    /// increase the length of the array, filling the new space with empty
880    /// slots.
881    ///
882    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length)
883    #[wasm_bindgen(method, setter)]
884    pub fn set_length<T>(this: &Array<T>, value: u32);
885
886    /// `map()` calls a provided callback function once for each element in an array,
887    /// in order, and constructs a new array from the results. callback is invoked
888    /// only for indexes of the array which have assigned values, including undefined.
889    /// It is not called for missing elements of the array (that is, indexes that have
890    /// never been set, which have been deleted or which have never been assigned a value).
891    ///
892    /// **Note:** Consider using [`Array::try_map`] for safer fallible handling.
893    ///
894    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
895    #[wasm_bindgen(method)]
896    pub fn map<T, U>(this: &Array<T>, predicate: &mut dyn FnMut(T, u32, Array<T>) -> U)
897        -> Array<U>;
898
899    /// `map()` calls a provided callback function once for each element in an array,
900    /// in order, and constructs a new array from the results. callback is invoked
901    /// only for indexes of the array which have assigned values, including undefined.
902    /// It is not called for missing elements of the array (that is, indexes that have
903    /// never been set, which have been deleted or which have never been assigned a value).
904    /// _(Fallible variation)_
905    ///
906    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
907    #[wasm_bindgen(method, js_name = map, catch)]
908    pub fn try_map<T, U>(
909        this: &Array<T>,
910        predicate: &mut dyn FnMut(T, u32) -> Result<U, JsError>,
911    ) -> Result<Array<U>, JsValue>;
912
913    /// The `Array.of()` method creates a new Array instance with a variable
914    /// number of arguments, regardless of number or type of the arguments.
915    ///
916    /// Note: For type inference use `Array::<T>::of(&[T])`.
917    ///
918    /// The difference between `Array.of()` and the `Array` constructor is in the
919    /// handling of integer arguments: `Array.of(7)` creates an array with a single
920    /// element, `7`, whereas `Array(7)` creates an empty array with a `length`
921    /// property of `7` (Note: this implies an array of 7 empty slots, not slots
922    /// with actual undefined values).
923    ///
924    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
925    #[wasm_bindgen(static_method_of = Array, js_name = of, variadic)]
926    pub fn of<T>(values: &[T]) -> Array<T>;
927
928    // Next major: deprecate these
929    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
930    #[wasm_bindgen(static_method_of = Array, js_name = of)]
931    pub fn of1(a: &JsValue) -> Array;
932
933    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
934    #[wasm_bindgen(static_method_of = Array, js_name = of)]
935    pub fn of2(a: &JsValue, b: &JsValue) -> Array;
936
937    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
938    #[wasm_bindgen(static_method_of = Array, js_name = of)]
939    pub fn of3(a: &JsValue, b: &JsValue, c: &JsValue) -> Array;
940
941    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
942    #[wasm_bindgen(static_method_of = Array, js_name = of)]
943    pub fn of4(a: &JsValue, b: &JsValue, c: &JsValue, d: &JsValue) -> Array;
944
945    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
946    #[wasm_bindgen(static_method_of = Array, js_name = of)]
947    pub fn of5(a: &JsValue, b: &JsValue, c: &JsValue, d: &JsValue, e: &JsValue) -> Array;
948
949    /// The `pop()` method removes the last element from an array and returns that
950    /// element. This method changes the length of the array.
951    ///
952    /// **Note:** Consider using [`Array::pop_checked`] for handling empty arrays.
953    ///
954    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop)
955    #[cfg(not(js_sys_unstable_apis))]
956    #[wasm_bindgen(method)]
957    pub fn pop<T>(this: &Array<T>) -> T;
958
959    /// The `pop()` method removes the last element from an array and returns that
960    /// element. This method changes the length of the array.
961    /// Returns `None` if the array is empty.
962    ///
963    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop)
964    #[cfg(js_sys_unstable_apis)]
965    #[wasm_bindgen(method)]
966    pub fn pop<T>(this: &Array<T>) -> Option<T>;
967
968    // Next major: deprecate
969    /// The `pop()` method removes the last element from an array and returns that
970    /// element. This method changes the length of the array.
971    ///
972    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop)
973    #[wasm_bindgen(method, js_name = pop)]
974    pub fn pop_checked<T>(this: &Array<T>) -> Option<T>;
975
976    /// The `push()` method adds one element to the end of an array and
977    /// returns the new length of the array.
978    ///
979    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push)
980    #[wasm_bindgen(method)]
981    pub fn push<T>(this: &Array<T>, value: &T) -> u32;
982
983    /// The `push()` method adds one or more elements to the end of an array and
984    /// returns the new length of the array.
985    ///
986    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push)
987    #[wasm_bindgen(method, js_name = push, variadic)]
988    pub fn push_many<T>(this: &Array<T>, values: &[T]) -> u32;
989
990    /// The `reduce()` method applies a function against an accumulator and each element in
991    /// the array (from left to right) to reduce it to a single value.
992    ///
993    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce)
994    #[cfg(not(js_sys_unstable_apis))]
995    #[wasm_bindgen(method)]
996    pub fn reduce<T>(
997        this: &Array<T>,
998        predicate: &mut dyn FnMut(JsValue, T, u32, Array<T>) -> JsValue,
999        initial_value: &JsValue,
1000    ) -> JsValue;
1001
1002    /// The `reduce()` method applies a function against an accumulator and each element in
1003    /// the array (from left to right) to reduce it to a single value.
1004    ///
1005    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce)
1006    #[cfg(js_sys_unstable_apis)]
1007    #[wasm_bindgen(method)]
1008    pub fn reduce<T, A>(
1009        this: &Array<T>,
1010        predicate: &mut dyn FnMut(A, T, u32, Array<T>) -> A,
1011        initial_value: &A,
1012    ) -> A;
1013
1014    /// The `reduce()` method applies a function against an accumulator and each element in
1015    /// the array (from left to right) to reduce it to a single value. _(Fallible variation)_
1016    ///
1017    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce)
1018    #[wasm_bindgen(method, js_name = reduce, catch)]
1019    pub fn try_reduce<T, A>(
1020        this: &Array<T>,
1021        predicate: &mut dyn FnMut(A, T, u32) -> Result<A, JsError>,
1022        initial_value: &A,
1023    ) -> Result<A, JsValue>;
1024
1025    /// The `reduceRight()` method applies a function against an accumulator and each value
1026    /// of the array (from right-to-left) to reduce it to a single value.
1027    ///
1028    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/ReduceRight)
1029    #[cfg(not(js_sys_unstable_apis))]
1030    #[wasm_bindgen(method, js_name = reduceRight)]
1031    pub fn reduce_right<T>(
1032        this: &Array<T>,
1033        predicate: &mut dyn FnMut(JsValue, T, u32, Array<T>) -> JsValue,
1034        initial_value: &JsValue,
1035    ) -> JsValue;
1036
1037    /// The `reduceRight()` method applies a function against an accumulator and each value
1038    /// of the array (from right-to-left) to reduce it to a single value.
1039    ///
1040    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/ReduceRight)
1041    #[cfg(js_sys_unstable_apis)]
1042    #[wasm_bindgen(method, js_name = reduceRight)]
1043    pub fn reduce_right<T, A>(
1044        this: &Array<T>,
1045        predicate: &mut dyn FnMut(A, T, u32, Array<T>) -> A,
1046        initial_value: &A,
1047    ) -> A;
1048
1049    /// The `reduceRight()` method applies a function against an accumulator and each value
1050    /// of the array (from right-to-left) to reduce it to a single value. _(Fallible variation)_
1051    ///
1052    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/ReduceRight)
1053    #[wasm_bindgen(method, js_name = reduceRight, catch)]
1054    pub fn try_reduce_right<T, A>(
1055        this: &Array<T>,
1056        predicate: &mut dyn FnMut(JsValue, T, u32) -> Result<A, JsError>,
1057        initial_value: &A,
1058    ) -> Result<A, JsValue>;
1059
1060    /// The `reverse()` method reverses an array in place. The first array
1061    /// element becomes the last, and the last array element becomes the first.
1062    ///
1063    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse)
1064    #[wasm_bindgen(method)]
1065    pub fn reverse<T>(this: &Array<T>) -> Array<T>;
1066
1067    /// The `shift()` method removes the first element from an array and returns
1068    /// that removed element. This method changes the length of the array.
1069    ///
1070    /// **Note:** Consider using [`Array::shift_checked`] for handling empty arrays.
1071    ///
1072    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift)
1073    #[cfg(not(js_sys_unstable_apis))]
1074    #[wasm_bindgen(method)]
1075    pub fn shift<T>(this: &Array<T>) -> T;
1076
1077    /// The `shift()` method removes the first element from an array and returns
1078    /// that removed element. This method changes the length of the array.
1079    /// Returns `None` if the array is empty.
1080    ///
1081    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift)
1082    #[cfg(js_sys_unstable_apis)]
1083    #[wasm_bindgen(method)]
1084    pub fn shift<T>(this: &Array<T>) -> Option<T>;
1085
1086    // Next major: deprecate
1087    /// The `shift()` method removes the first element from an array and returns
1088    /// that removed element. This method changes the length of the array.
1089    ///
1090    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift)
1091    #[wasm_bindgen(method, js_name = shift)]
1092    pub fn shift_checked<T>(this: &Array<T>) -> Option<T>;
1093
1094    /// The `slice()` method returns a shallow copy of a portion of an array into
1095    /// a new array object selected from begin to end (end not included).
1096    /// The original array will not be modified.
1097    ///
1098    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)
1099    #[cfg(not(js_sys_unstable_apis))]
1100    #[wasm_bindgen(method)]
1101    pub fn slice<T>(this: &Array<T>, start: u32, end: u32) -> Array<T>;
1102
1103    /// The `slice()` method returns a shallow copy of a portion of an array into
1104    /// a new array object selected from begin to end (end not included).
1105    /// The original array will not be modified. Negative indices count from the end.
1106    ///
1107    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)
1108    #[cfg(js_sys_unstable_apis)]
1109    #[wasm_bindgen(method)]
1110    pub fn slice<T>(this: &Array<T>, start: i32, end: i32) -> Array<T>;
1111
1112    /// The `slice()` method returns a shallow copy of a portion of an array into
1113    /// a new array object selected from the given index to the end.
1114    /// The original array will not be modified.
1115    ///
1116    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)
1117    #[cfg(not(js_sys_unstable_apis))]
1118    #[wasm_bindgen(method, js_name = slice)]
1119    pub fn slice_from<T>(this: &Array<T>, start: u32) -> Array<T>;
1120
1121    /// The `slice()` method returns a shallow copy of a portion of an array into
1122    /// a new array object selected from the given index to the end.
1123    /// The original array will not be modified. Negative indices count from the end.
1124    ///
1125    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)
1126    #[cfg(js_sys_unstable_apis)]
1127    #[wasm_bindgen(method, js_name = slice)]
1128    pub fn slice_from<T>(this: &Array<T>, start: i32) -> Array<T>;
1129
1130    /// The `some()` method tests whether at least one element in the array passes the test implemented
1131    /// by the provided function.
1132    /// Note: This method returns false for any condition put on an empty array.
1133    ///
1134    /// **Note:** Consider using [`Array::try_some`] if the predicate might throw an error.
1135    ///
1136    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some)
1137    #[wasm_bindgen(method)]
1138    pub fn some<T>(this: &Array<T>, predicate: &mut dyn FnMut(T) -> bool) -> bool;
1139
1140    /// The `some()` method tests whether at least one element in the array passes the test implemented
1141    /// by the provided function. _(Fallible variation)_
1142    /// Note: This method returns false for any condition put on an empty array.
1143    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some)
1144    #[wasm_bindgen(method, js_name = some, catch)]
1145    pub fn try_some<T>(
1146        this: &Array<T>,
1147        predicate: &mut dyn FnMut(T) -> Result<bool, JsError>,
1148    ) -> Result<bool, JsValue>;
1149
1150    /// The `sort()` method sorts the elements of an array in place and returns
1151    /// the array. The sort is not necessarily stable. The default sort
1152    /// order is according to string Unicode code points.
1153    ///
1154    /// The time and space complexity of the sort cannot be guaranteed as it
1155    /// is implementation dependent.
1156    ///
1157    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)
1158    #[wasm_bindgen(method)]
1159    pub fn sort<T>(this: &Array<T>) -> Array<T>;
1160
1161    /// The `sort()` method with a custom compare function.
1162    ///
1163    /// **Note:** Consider using [`Array::try_sort_by`] if the predicate might throw an error.
1164    ///
1165    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)
1166    #[wasm_bindgen(method, js_name = sort)]
1167    pub fn sort_by<T>(this: &Array<T>, compare_fn: &mut dyn FnMut(T, T) -> i32) -> Array<T>;
1168
1169    /// The `sort()` method with a custom compare function. _(Fallible variation)_
1170    ///
1171    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)
1172    #[wasm_bindgen(method, js_name = sort, catch)]
1173    pub fn try_sort_by<T>(
1174        this: &Array<T>,
1175        compare_fn: &mut dyn FnMut(T, T) -> Result<i32, JsError>,
1176    ) -> Result<Array<T>, JsValue>;
1177
1178    /// The `splice()` method changes the contents of an array by removing existing elements and/or
1179    /// adding new elements.
1180    ///
1181    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice)
1182    #[wasm_bindgen(method)]
1183    pub fn splice<T>(this: &Array<T>, start: u32, delete_count: u32, item: &T) -> Array<T>;
1184
1185    /// The `splice()` method changes the contents of an array by removing existing elements and/or
1186    /// adding new elements.
1187    ///
1188    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice)
1189    #[wasm_bindgen(method, js_name = splice, variadic)]
1190    pub fn splice_many<T>(this: &Array<T>, start: u32, delete_count: u32, items: &[T]) -> Array<T>;
1191
1192    /// The `toLocaleString()` method returns a string representing the elements of the array.
1193    /// The elements are converted to Strings using their toLocaleString methods and these
1194    /// Strings are separated by a locale-specific String (such as a comma ",").
1195    ///
1196    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString)
1197    #[cfg(not(js_sys_unstable_apis))]
1198    #[wasm_bindgen(method, js_name = toLocaleString)]
1199    pub fn to_locale_string<T>(this: &Array<T>, locales: &JsValue, options: &JsValue) -> JsString;
1200
1201    /// The `toLocaleString()` method returns a string representing the elements of the array.
1202    /// The elements are converted to Strings using their toLocaleString methods and these
1203    /// Strings are separated by a locale-specific String (such as a comma ",").
1204    ///
1205    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString)
1206    #[cfg(js_sys_unstable_apis)]
1207    #[wasm_bindgen(method, js_name = toLocaleString)]
1208    pub fn to_locale_string<T>(
1209        this: &Array<T>,
1210        locales: &[JsString],
1211        options: &Intl::NumberFormatOptions,
1212    ) -> JsString;
1213
1214    /// The `toReversed()` method returns a new array with the elements in reversed order,
1215    /// without modifying the original array.
1216    ///
1217    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toReversed)
1218    #[wasm_bindgen(method, js_name = toReversed)]
1219    pub fn to_reversed<T>(this: &Array<T>) -> Array<T>;
1220
1221    /// The `toSorted()` method returns a new array with the elements sorted in ascending order,
1222    /// without modifying the original array.
1223    ///
1224    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSorted)
1225    #[wasm_bindgen(method, js_name = toSorted)]
1226    pub fn to_sorted<T>(this: &Array<T>) -> Array<T>;
1227
1228    /// The `toSorted()` method with a custom compare function.
1229    ///
1230    /// **Note:** Consider using [`Array::try_to_sorted_by`] if the predicate might throw an error.
1231    ///
1232    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSorted)
1233    #[wasm_bindgen(method, js_name = toSorted)]
1234    pub fn to_sorted_by<T>(this: &Array<T>, compare_fn: &mut dyn FnMut(T, T) -> i32) -> Array<T>;
1235
1236    /// The `toSorted()` method with a custom compare function. _(Fallible variation)_
1237    ///
1238    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSorted)
1239    #[wasm_bindgen(method, js_name = toSorted, catch)]
1240    pub fn try_to_sorted_by<T>(
1241        this: &Array<T>,
1242        compare_fn: &mut dyn FnMut(T, T) -> Result<i32, JsError>,
1243    ) -> Result<Array<T>, JsValue>;
1244
1245    /// The `toSpliced()` method returns a new array with some elements removed and/or
1246    /// replaced at a given index, without modifying the original array.
1247    ///
1248    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSpliced)
1249    #[wasm_bindgen(method, js_name = toSpliced, variadic)]
1250    pub fn to_spliced<T>(this: &Array<T>, start: u32, delete_count: u32, items: &[T]) -> Array<T>;
1251
1252    /// The `toString()` method returns a string representing the specified array
1253    /// and its elements.
1254    ///
1255    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString)
1256    #[cfg(not(js_sys_unstable_apis))]
1257    #[wasm_bindgen(method, js_name = toString)]
1258    pub fn to_string<T>(this: &Array<T>) -> JsString;
1259
1260    /// Converts the Array into a Vector.
1261    #[wasm_bindgen(method, js_name = slice)]
1262    pub fn to_vec<T>(this: &Array<T>) -> Vec<T>;
1263
1264    /// The `unshift()` method adds one element to the beginning of an
1265    /// array and returns the new length of the array.
1266    ///
1267    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift)
1268    #[wasm_bindgen(method)]
1269    pub fn unshift<T>(this: &Array<T>, value: &T) -> u32;
1270
1271    /// The `unshift()` method adds one or more elements to the beginning of an
1272    /// array and returns the new length of the array.
1273    ///
1274    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift)
1275    #[wasm_bindgen(method, js_name = unshift, variadic)]
1276    pub fn unshift_many<T>(this: &Array<T>, values: &[T]) -> u32;
1277
1278    /// The `with()` method returns a new array with the element at the given index
1279    /// replaced with the given value, without modifying the original array.
1280    ///
1281    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/with)
1282    #[wasm_bindgen(method, js_name = with)]
1283    pub fn with<T>(this: &Array<T>, index: u32, value: &T) -> Array<T>;
1284}
1285
1286// Tuples as a typed array variant
1287#[wasm_bindgen]
1288extern "C" {
1289    #[wasm_bindgen(extends = Object, js_name = Array, is_type_of = Array::is_array, no_upcast, typescript_type = "Array<any>")]
1290    #[derive(Clone, Debug)]
1291    pub type ArrayTuple<T: JsTuple = (JsValue,)>;
1292
1293    /// Creates a new JS array typed as a 1-tuple.
1294    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1295    pub fn new1<T1>(t1: &T1) -> ArrayTuple<(T1,)>;
1296
1297    /// Creates a new JS array typed as a 2-tuple.
1298    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1299    pub fn new2<T1, T2>(t1: &T1, t2: &T2) -> ArrayTuple<(T1, T2)>;
1300
1301    /// Creates a new JS array typed as a 3-tuple.
1302    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1303    pub fn new3<T1, T2, T3>(t1: &T1, t2: &T2, t3: &T3) -> ArrayTuple<(T1, T2, T3)>;
1304
1305    /// Creates a new JS array typed as a 4-tuple.
1306    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1307    pub fn new4<T1, T2, T3, T4>(t1: &T1, t2: &T2, t3: &T3, t4: &T4)
1308        -> ArrayTuple<(T1, T2, T3, T4)>;
1309
1310    /// Creates a new JS array typed as a 5-tuple.
1311    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1312    pub fn new5<T1, T2, T3, T4, T5>(
1313        t1: &T1,
1314        t2: &T2,
1315        t3: &T3,
1316        t4: &T4,
1317        t5: &T5,
1318    ) -> ArrayTuple<(T1, T2, T3, T4, T5)>;
1319
1320    /// Creates a new JS array typed as a 6-tuple.
1321    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1322    pub fn new6<T1, T2, T3, T4, T5, T6>(
1323        t1: &T1,
1324        t2: &T2,
1325        t3: &T3,
1326        t4: &T4,
1327        t5: &T5,
1328        t6: &T6,
1329    ) -> ArrayTuple<(T1, T2, T3, T4, T5, T6)>;
1330
1331    /// Creates a new JS array typed as a 7-tuple.
1332    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1333    pub fn new7<T1, T2, T3, T4, T5, T6, T7>(
1334        t1: &T1,
1335        t2: &T2,
1336        t3: &T3,
1337        t4: &T4,
1338        t5: &T5,
1339        t6: &T6,
1340        t7: &T7,
1341    ) -> ArrayTuple<(T1, T2, T3, T4, T5, T6, T7)>;
1342
1343    /// Creates a new JS array typed as a 8-tuple.
1344    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1345    pub fn new8<T1, T2, T3, T4, T5, T6, T7, T8>(
1346        t1: &T1,
1347        t2: &T2,
1348        t3: &T3,
1349        t4: &T4,
1350        t5: &T5,
1351        t6: &T6,
1352        t7: &T7,
1353        t8: &T8,
1354    ) -> ArrayTuple<(T1, T2, T3, T4, T5, T6, T7, T8)>;
1355
1356    /// Gets the 1st item
1357    #[wasm_bindgen(
1358        method,
1359        js_class = Array,
1360        getter,
1361        js_name = "0"
1362    )]
1363    pub fn get0<T: JsTuple1 = (JsValue,)>(this: &ArrayTuple<T>) -> <T as JsTuple1>::T1;
1364
1365    /// Gets the 2nd item
1366    #[wasm_bindgen(
1367        method,
1368        js_class = Array,
1369        getter,
1370        js_name = "1"
1371    )]
1372    pub fn get1<T: JsTuple2 = (JsValue, JsValue)>(this: &ArrayTuple<T>) -> <T as JsTuple2>::T2;
1373
1374    /// Gets the 3rd item
1375    #[wasm_bindgen(
1376        method,
1377        js_class = Array,
1378        getter,
1379        js_name = "2"
1380    )]
1381    pub fn get2<T: JsTuple3 = (JsValue, JsValue, JsValue)>(
1382        this: &ArrayTuple<T>,
1383    ) -> <T as JsTuple3>::T3;
1384
1385    /// Gets the 4th item
1386    #[wasm_bindgen(
1387        method,
1388        js_class = Array,
1389        getter,
1390        js_name = "3"
1391    )]
1392    pub fn get3<T: JsTuple4 = (JsValue, JsValue, JsValue, JsValue)>(
1393        this: &ArrayTuple<T>,
1394    ) -> <T as JsTuple4>::T4;
1395
1396    /// Gets the 5th item
1397    #[wasm_bindgen(
1398        method,
1399        js_class = Array,
1400        getter,
1401        js_name = "4"
1402    )]
1403    pub fn get4<T: JsTuple5 = (JsValue, JsValue, JsValue, JsValue, JsValue)>(
1404        this: &ArrayTuple<T>,
1405    ) -> <T as JsTuple5>::T5;
1406
1407    /// Gets the 6th item
1408    #[wasm_bindgen(
1409        method,
1410        js_class = Array,
1411        getter,
1412        js_name = "5"
1413    )]
1414    pub fn get5<T: JsTuple6 = (JsValue, JsValue, JsValue, JsValue, JsValue, JsValue)>(
1415        this: &ArrayTuple<T>,
1416    ) -> <T as JsTuple6>::T6;
1417
1418    /// Gets the 7th item
1419    #[wasm_bindgen(
1420        method,
1421        js_class = Array,
1422        getter,
1423        js_name = "6"
1424    )]
1425    pub fn get6<
1426        T: JsTuple7 = (
1427            JsValue,
1428            JsValue,
1429            JsValue,
1430            JsValue,
1431            JsValue,
1432            JsValue,
1433            JsValue,
1434        ),
1435    >(
1436        this: &ArrayTuple<T>,
1437    ) -> <T as JsTuple7>::T7;
1438
1439    /// Gets the 8th item
1440    #[wasm_bindgen(
1441        method,
1442        js_class = Array,
1443        getter,
1444        js_name = "7"
1445    )]
1446    pub fn get7<
1447        T: JsTuple8 = (
1448            JsValue,
1449            JsValue,
1450            JsValue,
1451            JsValue,
1452            JsValue,
1453            JsValue,
1454            JsValue,
1455            JsValue,
1456        ),
1457    >(
1458        this: &ArrayTuple<T>,
1459    ) -> <T as JsTuple8>::T8;
1460
1461    /// Sets the 1st item
1462    #[wasm_bindgen(
1463        method,
1464        js_class = Array,
1465        setter,
1466        js_name = "0"
1467    )]
1468    pub fn set0<T: JsTuple1 = (JsValue,)>(this: &ArrayTuple<T>, value: &<T as JsTuple1>::T1);
1469
1470    /// Sets the 2nd item
1471    #[wasm_bindgen(
1472        method,
1473        js_class = Array,
1474        setter,
1475        js_name = "1"
1476    )]
1477    pub fn set1<T: JsTuple2 = (JsValue, JsValue)>(
1478        this: &ArrayTuple<T>,
1479        value: &<T as JsTuple2>::T2,
1480    );
1481
1482    /// Sets the 3rd item
1483    #[wasm_bindgen(
1484        method,
1485        js_class = Array,
1486        setter,
1487        js_name = "2"
1488    )]
1489    pub fn set2<T: JsTuple3 = (JsValue, JsValue, JsValue)>(
1490        this: &ArrayTuple<T>,
1491        value: &<T as JsTuple3>::T3,
1492    );
1493
1494    /// Sets the 4th item
1495    #[wasm_bindgen(
1496        method,
1497        js_class = Array,
1498        setter,
1499        js_name = "3"
1500    )]
1501    pub fn set3<T: JsTuple4 = (JsValue, JsValue, JsValue, JsValue)>(
1502        this: &ArrayTuple<T>,
1503        value: &<T as JsTuple4>::T4,
1504    );
1505
1506    /// Sets the 5th item
1507    #[wasm_bindgen(
1508        method,
1509        js_class = Array,
1510        setter,
1511        js_name = "4"
1512    )]
1513    pub fn set4<T: JsTuple5 = (JsValue, JsValue, JsValue, JsValue, JsValue)>(
1514        this: &ArrayTuple<T>,
1515        value: &<T as JsTuple5>::T5,
1516    );
1517
1518    /// Sets the 6th item
1519    #[wasm_bindgen(
1520        method,
1521        js_class = Array,
1522        setter,
1523        js_name = "5"
1524    )]
1525    pub fn set5<T: JsTuple6 = (JsValue, JsValue, JsValue, JsValue, JsValue, JsValue)>(
1526        this: &ArrayTuple<T>,
1527        value: &<T as JsTuple6>::T6,
1528    );
1529
1530    /// Sets the 7th item
1531    #[wasm_bindgen(
1532        method,
1533        js_class = Array,
1534        setter,
1535        js_name = "6"
1536    )]
1537    pub fn set6<
1538        T: JsTuple7 = (
1539            JsValue,
1540            JsValue,
1541            JsValue,
1542            JsValue,
1543            JsValue,
1544            JsValue,
1545            JsValue,
1546        ),
1547    >(
1548        this: &ArrayTuple<T>,
1549        value: &<T as JsTuple7>::T7,
1550    );
1551
1552    /// Sets the 8th item
1553    #[wasm_bindgen(
1554        method,
1555        js_class = Array,
1556        setter,
1557        js_name = "7"
1558    )]
1559    pub fn set7<
1560        T: JsTuple8 = (
1561            JsValue,
1562            JsValue,
1563            JsValue,
1564            JsValue,
1565            JsValue,
1566            JsValue,
1567            JsValue,
1568            JsValue,
1569        ),
1570    >(
1571        this: &ArrayTuple<T>,
1572        value: &<T as JsTuple8>::T8,
1573    );
1574}
1575
1576/// Base trait for tuple types.
1577pub trait JsTuple {
1578    const ARITY: usize;
1579}
1580
1581macro_rules! impl_tuple_traits {
1582    // Base case: first trait has no parent (besides JsTuple)
1583    ($name:ident $ty:tt) => {
1584        pub trait $name: JsTuple {
1585            type $ty;
1586        }
1587    };
1588
1589    // Recursive case: define trait with parent, then recurse
1590    ($name:ident $ty:tt $($rest_name:ident $rest_ty:tt)+) => {
1591        pub trait $name: JsTuple {
1592            type $ty;
1593        }
1594
1595        impl_tuple_traits!(@with_parent $name $($rest_name $rest_ty)+);
1596    };
1597
1598    // Internal: traits that have a parent
1599    (@with_parent $trait:ident $name:ident $ty:tt) => {
1600        pub trait $name: $trait {
1601            type $ty;
1602        }
1603    };
1604
1605    (@with_parent $trait:ident $name:ident $ty:tt $($rest_name:ident $rest_ty:tt)+) => {
1606        pub trait $name: $trait {
1607            type $ty;
1608        }
1609
1610        impl_tuple_traits!(@with_parent $name $($rest_name $rest_ty)+);
1611    };
1612}
1613
1614macro_rules! impl_parent_traits {
1615    ([$($types:tt),+] [] []) => {};
1616
1617    ([$($types:tt),+] [$trait:ident $($rest_traits:ident)*] [$ty:tt $($rest_tys:tt)*]) => {
1618        impl<$($types),+> $trait for ($($types),+,) {
1619            type $ty = $ty;
1620        }
1621
1622        impl_parent_traits!([$($types),+] [$($rest_traits)*] [$($rest_tys)*]);
1623    };
1624}
1625
1626// Define the trait hierarchy once
1627impl_tuple_traits!(
1628    JsTuple1 T1
1629    JsTuple2 T2
1630    JsTuple3 T3
1631    JsTuple4 T4
1632    JsTuple5 T5
1633    JsTuple6 T6
1634    JsTuple7 T7
1635    JsTuple8 T8
1636);
1637
1638impl<T: JsTuple> ArrayTuple<T> {
1639    /// Get the static arity of the ArrayTuple type.
1640    #[allow(clippy::len_without_is_empty)]
1641    pub fn len(&self) -> usize {
1642        <T as JsTuple>::ARITY
1643    }
1644}
1645
1646macro_rules! impl_tuple {
1647    ($arity:literal [$($traits:ident)*] [$($T:tt)+] [$($vars:tt)+] $new:ident $last:ident $last_ty:tt) => {
1648        impl<$($T),+> JsTuple for ($($T),+,) {
1649            const ARITY: usize = $arity;
1650        }
1651
1652        impl_parent_traits!([$($T),+] [$($traits)*] [$($T)*]);
1653
1654        impl<$($T: JsGeneric),+> From<($($T,)+)> for ArrayTuple<($($T),+,)> {
1655            fn from(($($vars,)+): ($($T,)+)) -> Self {
1656                $(let $vars: JsValue = $vars.upcast_into();)+
1657                Array::of(&[$($vars),+]).unchecked_into()
1658            }
1659        }
1660
1661        impl<$($T: JsGeneric + Default),+> Default for ArrayTuple<($($T),+,)> {
1662            fn default() -> Self {
1663                (
1664                    $($T::default(),)+
1665                ).into()
1666            }
1667        }
1668
1669        impl<$($T: JsGeneric),+> ArrayTuple<($($T),+,)> {
1670            /// Get the first element of the ArrayTuple
1671            pub fn first(&self) -> T1 {
1672                self.get0()
1673            }
1674
1675            /// Get the last element of the ArrayTuple
1676            pub fn last(&self) -> $last_ty {
1677                self.$last()
1678            }
1679
1680            /// Convert the ArrayTuple into its corresponding Rust tuple.
1681            pub fn into_tuple(self) -> ($($T,)+) {
1682                ($(self.$vars(),)+)
1683            }
1684
1685            /// Deprecated alias for [`ArrayTuple::into_tuple`].
1686            #[deprecated(note = "renamed to `into_tuple`")]
1687            pub fn into_parts(self) -> ($($T,)+) {
1688                self.into_tuple()
1689            }
1690
1691            /// Create a new ArrayTuple from the corresponding parts.
1692            ///
1693            /// # Example
1694            ///
1695            /// ```
1696            /// use js_sys::{ArrayTuple, JsString};
1697            ///
1698            /// let tuple = ArrayTuple::<JsString, JsString>::new(&"a".into(), &"b".into());
1699            /// ```
1700            ///
1701            /// Note: You must specify the T using `::<...>` syntax on `ArrayTuple`.
1702            /// Alternatively, use `new1`, `new2`, etc. for type inference from the left-hand side.
1703            pub fn new($($vars: &$T),+) -> ArrayTuple<($($T),+,)> {
1704                ArrayTuple::$new($($vars),+)
1705            }
1706        }
1707    };
1708}
1709
1710// Implement for each tuple size
1711impl_tuple!(1 [JsTuple1] [T1] [get0] new1 get0 T1);
1712impl_tuple!(2 [JsTuple1 JsTuple2] [T1 T2] [get0 get1] new2 get1 T2);
1713impl_tuple!(3 [JsTuple1 JsTuple2 JsTuple3] [T1 T2 T3] [get0 get1 get2] new3 get2 T3);
1714impl_tuple!(4 [JsTuple1 JsTuple2 JsTuple3 JsTuple4] [T1 T2 T3 T4] [get0 get1 get2 get3] new4 get3 T4);
1715impl_tuple!(5 [JsTuple1 JsTuple2 JsTuple3 JsTuple4 JsTuple5] [T1 T2 T3 T4 T5] [get0 get1 get2 get3 get4] new5 get4 T5);
1716impl_tuple!(6 [JsTuple1 JsTuple2 JsTuple3 JsTuple4 JsTuple5 JsTuple6] [T1 T2 T3 T4 T5 T6] [get0 get1 get2 get3 get4 get5] new6 get5 T6);
1717impl_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);
1718impl_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);
1719
1720// Macro to generate structural covariance impls for each arity
1721macro_rules! impl_tuple_covariance {
1722    ([$($T:ident)+] [$($Target:ident)+] [$($Ts:ident)+]) => {
1723        // ArrayTuple -> Array
1724        // Allows (T1, T2, ...) to be used where (Target) is expected
1725        // when all T1, T2, ... are covariant to Target
1726        impl<$($T,)+ Target> UpcastFrom<ArrayTuple<($($T,)+)>> for Array<Target>
1727        where
1728            $(Target: UpcastFrom<$T>,)+
1729        {
1730        }
1731        impl<$($T,)+ Target> UpcastFrom<ArrayTuple<($($T,)+)>> for JsOption<Array<Target>>
1732        where
1733            $(Target: UpcastFrom<$T>,)+
1734        {}
1735        // Array<T> -> ArrayTuple<T, ...>
1736        impl<T> UpcastFrom<Array<T>> for ArrayTuple<($($Ts,)+)> {}
1737        impl<T: JsGeneric> UpcastFrom<Array<T>> for ArrayTuple<($(JsOption<$Ts>,)+)> {}
1738    };
1739}
1740
1741impl_tuple_covariance!([T1][Target1][T]);
1742impl_tuple_covariance!([T1 T2] [Target1 Target2] [T T]);
1743impl_tuple_covariance!([T1 T2 T3] [Target1 Target2 Target3] [T T T]);
1744impl_tuple_covariance!([T1 T2 T3 T4] [Target1 Target2 Target3 Target4] [T T T T]);
1745impl_tuple_covariance!([T1 T2 T3 T4 T5] [Target1 Target2 Target3 Target4 Target5] [T T T T T]);
1746impl_tuple_covariance!([T1 T2 T3 T4 T5 T6] [Target1 Target2 Target3 Target4 Target5 Target6] [T T T T T T]);
1747impl_tuple_covariance!([T1 T2 T3 T4 T5 T6 T7] [Target1 Target2 Target3 Target4 Target5 Target6 Target7] [T T T T T T T]);
1748impl_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]);
1749
1750// Tuple casting is implemented in core
1751impl<T: JsTuple, U: JsTuple> UpcastFrom<ArrayTuple<T>> for ArrayTuple<U> where U: UpcastFrom<T> {}
1752impl<T: JsTuple> UpcastFrom<ArrayTuple<T>> for JsValue {}
1753impl<T: JsTuple> UpcastFrom<ArrayTuple<T>> for JsOption<JsValue> {}
1754
1755/// Iterator returned by `Array::into_iter`
1756#[derive(Debug, Clone)]
1757pub struct ArrayIntoIter<T: JsGeneric = JsValue> {
1758    range: core::ops::Range<u32>,
1759    array: Array<T>,
1760}
1761
1762#[cfg(not(js_sys_unstable_apis))]
1763impl<T: JsGeneric> core::iter::Iterator for ArrayIntoIter<T> {
1764    type Item = T;
1765
1766    fn next(&mut self) -> Option<Self::Item> {
1767        let index = self.range.next()?;
1768        Some(self.array.get(index))
1769    }
1770
1771    #[inline]
1772    fn size_hint(&self) -> (usize, Option<usize>) {
1773        self.range.size_hint()
1774    }
1775
1776    #[inline]
1777    fn count(self) -> usize
1778    where
1779        Self: Sized,
1780    {
1781        self.range.count()
1782    }
1783
1784    #[inline]
1785    fn last(self) -> Option<Self::Item>
1786    where
1787        Self: Sized,
1788    {
1789        let Self { range, array } = self;
1790        range.last().map(|index| array.get(index))
1791    }
1792
1793    #[inline]
1794    fn nth(&mut self, n: usize) -> Option<Self::Item> {
1795        self.range.nth(n).map(|index| self.array.get(index))
1796    }
1797}
1798
1799#[cfg(js_sys_unstable_apis)]
1800impl<T: JsGeneric> core::iter::Iterator for ArrayIntoIter<T> {
1801    type Item = T;
1802
1803    fn next(&mut self) -> Option<Self::Item> {
1804        let index = self.range.next()?;
1805        self.array.get(index)
1806    }
1807
1808    #[inline]
1809    fn size_hint(&self) -> (usize, Option<usize>) {
1810        self.range.size_hint()
1811    }
1812
1813    #[inline]
1814    fn count(self) -> usize
1815    where
1816        Self: Sized,
1817    {
1818        self.range.count()
1819    }
1820
1821    #[inline]
1822    fn last(self) -> Option<Self::Item>
1823    where
1824        Self: Sized,
1825    {
1826        let Self { range, array } = self;
1827        range.last().and_then(|index| array.get(index))
1828    }
1829
1830    #[inline]
1831    fn nth(&mut self, n: usize) -> Option<Self::Item> {
1832        self.range.nth(n).and_then(|index| self.array.get(index))
1833    }
1834}
1835
1836#[cfg(not(js_sys_unstable_apis))]
1837impl<T: JsGeneric> core::iter::DoubleEndedIterator for ArrayIntoIter<T> {
1838    fn next_back(&mut self) -> Option<Self::Item> {
1839        let index = self.range.next_back()?;
1840        Some(self.array.get(index))
1841    }
1842
1843    fn nth_back(&mut self, n: usize) -> Option<Self::Item> {
1844        self.range.nth_back(n).map(|index| self.array.get(index))
1845    }
1846}
1847
1848#[cfg(js_sys_unstable_apis)]
1849impl<T: JsGeneric> core::iter::DoubleEndedIterator for ArrayIntoIter<T> {
1850    fn next_back(&mut self) -> Option<Self::Item> {
1851        let index = self.range.next_back()?;
1852        self.array.get(index)
1853    }
1854
1855    fn nth_back(&mut self, n: usize) -> Option<Self::Item> {
1856        self.range
1857            .nth_back(n)
1858            .and_then(|index| self.array.get(index))
1859    }
1860}
1861
1862impl<T: JsGeneric> core::iter::FusedIterator for ArrayIntoIter<T> {}
1863
1864impl<T: JsGeneric> core::iter::ExactSizeIterator for ArrayIntoIter<T> {}
1865
1866/// Iterator returned by `Array::iter`
1867#[derive(Debug, Clone)]
1868pub struct ArrayIter<'a, T: JsGeneric = JsValue> {
1869    range: core::ops::Range<u32>,
1870    array: &'a Array<T>,
1871}
1872
1873impl<T: JsGeneric> core::iter::Iterator for ArrayIter<'_, T> {
1874    type Item = T;
1875
1876    fn next(&mut self) -> Option<Self::Item> {
1877        let index = self.range.next()?;
1878        Some(self.array.get_unchecked(index))
1879    }
1880
1881    #[inline]
1882    fn size_hint(&self) -> (usize, Option<usize>) {
1883        self.range.size_hint()
1884    }
1885
1886    #[inline]
1887    fn count(self) -> usize
1888    where
1889        Self: Sized,
1890    {
1891        self.range.count()
1892    }
1893
1894    #[inline]
1895    fn last(self) -> Option<Self::Item>
1896    where
1897        Self: Sized,
1898    {
1899        let Self { range, array } = self;
1900        range.last().map(|index| array.get_unchecked(index))
1901    }
1902
1903    #[inline]
1904    fn nth(&mut self, n: usize) -> Option<Self::Item> {
1905        self.range
1906            .nth(n)
1907            .map(|index| self.array.get_unchecked(index))
1908    }
1909}
1910
1911impl<T: JsGeneric> core::iter::DoubleEndedIterator for ArrayIter<'_, T> {
1912    fn next_back(&mut self) -> Option<Self::Item> {
1913        let index = self.range.next_back()?;
1914        Some(self.array.get_unchecked(index))
1915    }
1916
1917    fn nth_back(&mut self, n: usize) -> Option<Self::Item> {
1918        self.range
1919            .nth_back(n)
1920            .map(|index| self.array.get_unchecked(index))
1921    }
1922}
1923
1924impl<T: JsGeneric> core::iter::FusedIterator for ArrayIter<'_, T> {}
1925
1926impl<T: JsGeneric> core::iter::ExactSizeIterator for ArrayIter<'_, T> {}
1927
1928impl<T: JsGeneric> Array<T> {
1929    /// Returns an iterator over the values of the JS array.
1930    pub fn iter(&self) -> ArrayIter<'_, T> {
1931        ArrayIter {
1932            range: 0..self.length(),
1933            array: self,
1934        }
1935    }
1936}
1937
1938impl<T: JsGeneric> core::iter::IntoIterator for Array<T> {
1939    type Item = T;
1940    type IntoIter = ArrayIntoIter<T>;
1941
1942    fn into_iter(self) -> Self::IntoIter {
1943        ArrayIntoIter {
1944            range: 0..self.length(),
1945            array: self,
1946        }
1947    }
1948}
1949
1950// `FromIterator` / `Extend` for `Array` (= `Array<JsValue>` via the default
1951// type parameter) preserve the long-standing stable behaviour: any iterator
1952// of items convertible to `&JsValue` collects into an erased `Array<JsValue>`.
1953//
1954// Typed collection (where the element type is inferred from the iterator
1955// item via [`IntoJsGeneric`]) is exposed as the inherent constructor
1956// [`Array::from_iter_typed`] rather than a second `FromIterator` impl. A
1957// blanket `impl<A: IntoJsGeneric> FromIterator<A> for Array<A::JsCanon>`
1958// would overlap with the stable `AsRef<JsValue>` impl on `Array<JsValue>`
1959// (since `JsValue: IntoJsGeneric` with `JsCanon = JsValue`), so the two
1960// cannot coexist as `FromIterator` impls without coherence violations.
1961//
1962// TODO(next major): deprecate this `FromIterator`/`Extend` pair in favour
1963// of a single `IntoJsGeneric`-based impl, and rename `from_iter_typed` to
1964// take its place. That migration is source-breaking for callers relying on
1965// `.collect::<Array>()` implicit erasure of typed items, so it is deferred.
1966
1967impl<A> core::iter::FromIterator<A> for Array
1968where
1969    A: AsRef<JsValue>,
1970{
1971    fn from_iter<I>(iter: I) -> Array
1972    where
1973        I: IntoIterator<Item = A>,
1974    {
1975        let mut out = Array::new();
1976        out.extend(iter);
1977        out
1978    }
1979}
1980
1981impl<A> core::iter::Extend<A> for Array
1982where
1983    A: AsRef<JsValue>,
1984{
1985    fn extend<I>(&mut self, iter: I)
1986    where
1987        I: IntoIterator<Item = A>,
1988    {
1989        for value in iter {
1990            self.push(value.as_ref());
1991        }
1992    }
1993}
1994
1995impl<T: JsGeneric> Array<T> {
1996    /// Collect an iterator into a typed `Array<T>`, projecting each item
1997    /// through its canonical [`JsGeneric`] via [`IntoJsGeneric`].
1998    ///
1999    /// This is the typed counterpart to the stable
2000    /// `impl FromIterator<A> for Array where A: AsRef<JsValue>`, which always
2001    /// produces an erased `Array<JsValue>`. Use `from_iter_typed` when you
2002    /// want the element type inferred from the iterator item:
2003    ///
2004    /// ```ignore
2005    /// use js_sys::{Array, Number};
2006    ///
2007    /// let arr = Array::from_iter_typed((0..10).map(Number::from));
2008    /// // arr: Array<Number>
2009    /// ```
2010    ///
2011    /// Reference iteration (`Item = &U`) is supported transparently via the
2012    /// `&U: IntoJsGeneric` blanket in `wasm-bindgen` core.
2013    //
2014    // TODO(next major): replace the stable `FromIterator` impl above with
2015    // this behaviour and remove `from_iter_typed`.
2016    pub fn from_iter_typed<A, I>(iter: I) -> Array<T>
2017    where
2018        A: IntoJsGeneric<JsCanon = T>,
2019        I: IntoIterator<Item = A>,
2020    {
2021        let mut out = Array::<T>::new_typed();
2022        out.extend_typed(iter);
2023        out
2024    }
2025
2026    /// Extend a typed `Array<T>` with an iterator of items convertible to
2027    /// `T` via [`IntoJsGeneric`]. Companion to [`Array::from_iter_typed`].
2028    //
2029    // TODO(next major): replace the stable `Extend` impl above with this
2030    // behaviour and remove `extend_typed`.
2031    pub fn extend_typed<A, I>(&mut self, iter: I)
2032    where
2033        A: IntoJsGeneric<JsCanon = T>,
2034        I: IntoIterator<Item = A>,
2035    {
2036        for value in iter {
2037            self.push(&value.to_js());
2038        }
2039    }
2040}
2041
2042impl Default for Array<JsValue> {
2043    fn default() -> Self {
2044        Self::new()
2045    }
2046}
2047
2048impl<T> Iterable for Array<T> {
2049    type Item = T;
2050}
2051
2052impl<T: JsTuple> Iterable for ArrayTuple<T> {
2053    type Item = JsValue;
2054}
2055
2056// ArrayBufferOptions
2057#[wasm_bindgen]
2058extern "C" {
2059    #[wasm_bindgen(extends = Object, typescript_type = "ArrayBufferOptions")]
2060    #[derive(Clone, Debug, PartialEq, Eq)]
2061    pub type ArrayBufferOptions;
2062
2063    /// The maximum size, in bytes, that the array buffer can be resized to.
2064    #[wasm_bindgen(method, setter, js_name = maxByteLength)]
2065    pub fn set_max_byte_length(this: &ArrayBufferOptions, max_byte_length: usize);
2066
2067    /// The maximum size, in bytes, that the array buffer can be resized to.
2068    #[wasm_bindgen(method, getter, js_name = maxByteLength)]
2069    pub fn get_max_byte_length(this: &ArrayBufferOptions) -> usize;
2070}
2071
2072impl ArrayBufferOptions {
2073    #[cfg(not(js_sys_unstable_apis))]
2074    pub fn new(max_byte_length: usize) -> ArrayBufferOptions {
2075        let options = JsCast::unchecked_into::<ArrayBufferOptions>(Object::new());
2076        options.set_max_byte_length(max_byte_length);
2077        options
2078    }
2079
2080    #[cfg(js_sys_unstable_apis)]
2081    pub fn new(max_byte_length: usize) -> ArrayBufferOptions {
2082        let options = JsCast::unchecked_into::<ArrayBufferOptions>(Object::<JsValue>::new());
2083        options.set_max_byte_length(max_byte_length);
2084        options
2085    }
2086}
2087
2088// ArrayBuffer
2089#[wasm_bindgen]
2090extern "C" {
2091    #[wasm_bindgen(extends = Object, typescript_type = "ArrayBuffer")]
2092    #[derive(Clone, Debug, PartialEq, Eq)]
2093    pub type 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    #[cfg(not(js_sys_unstable_apis))]
2104    #[wasm_bindgen(constructor)]
2105    pub fn new(length: u32) -> ArrayBuffer;
2106
2107    /// The `ArrayBuffer` object is used to represent a generic,
2108    /// fixed-length raw binary data buffer. You cannot directly
2109    /// manipulate the contents of an `ArrayBuffer`; instead, you
2110    /// create one of the typed array objects or a `DataView` object
2111    /// which represents the buffer in a specific format, and use that
2112    /// to read and write the contents of the buffer.
2113    ///
2114    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)
2115    #[cfg(js_sys_unstable_apis)]
2116    #[wasm_bindgen(constructor)]
2117    pub fn new(length: usize) -> ArrayBuffer;
2118
2119    /// The `ArrayBuffer` object is used to represent a generic,
2120    /// fixed-length raw binary data buffer. You cannot directly
2121    /// manipulate the contents of an `ArrayBuffer`; instead, you
2122    /// create one of the typed array objects or a `DataView` object
2123    /// which represents the buffer in a specific format, and use that
2124    /// to read and write the contents of the buffer.
2125    ///
2126    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)
2127    #[wasm_bindgen(constructor)]
2128    pub fn new_with_options(length: usize, options: &ArrayBufferOptions) -> ArrayBuffer;
2129
2130    /// The `byteLength` property of an object which is an instance of type ArrayBuffer
2131    /// it's an accessor property whose set accessor function is undefined,
2132    /// meaning that you can only read this property.
2133    /// The value is established when the array is constructed and cannot be changed.
2134    /// This property returns 0 if this ArrayBuffer has been detached.
2135    ///
2136    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/byteLength)
2137    #[cfg(not(js_sys_unstable_apis))]
2138    #[wasm_bindgen(method, getter, js_name = byteLength)]
2139    pub fn byte_length(this: &ArrayBuffer) -> u32;
2140
2141    /// The `byteLength` property of an object which is an instance of type ArrayBuffer
2142    /// it's an accessor property whose set accessor function is undefined,
2143    /// meaning that you can only read this property.
2144    /// The value is established when the array is constructed and cannot be changed.
2145    /// This property returns 0 if this ArrayBuffer has been detached.
2146    ///
2147    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/byteLength)
2148    #[cfg(js_sys_unstable_apis)]
2149    #[wasm_bindgen(method, getter, js_name = byteLength)]
2150    pub fn byte_length(this: &ArrayBuffer) -> usize;
2151
2152    /// The `detached` accessor property of `ArrayBuffer` instances returns a boolean indicating
2153    /// whether or not this buffer has been detached (transferred).
2154    ///
2155    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/detached)
2156    #[wasm_bindgen(method, getter)]
2157    pub fn detached(this: &ArrayBuffer) -> bool;
2158
2159    /// The `isView()` method returns true if arg is one of the `ArrayBuffer`
2160    /// views, such as typed array objects or a DataView; false otherwise.
2161    ///
2162    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView)
2163    #[wasm_bindgen(static_method_of = ArrayBuffer, js_name = isView)]
2164    pub fn is_view(value: &JsValue) -> bool;
2165
2166    /// The `maxByteLength` accessor property of ArrayBuffer instances returns the maximum
2167    /// length (in bytes) that this array buffer can be resized to.
2168    ///
2169    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/maxByteLength)
2170    #[wasm_bindgen(method, getter, js_name = maxByteLength)]
2171    pub fn max_byte_length(this: &ArrayBuffer) -> usize;
2172
2173    /// The `resizable` accessor property of `ArrayBuffer` instances returns whether this array buffer
2174    /// can be resized or not.
2175    ///
2176    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/resizable)
2177    #[wasm_bindgen(method, getter)]
2178    pub fn resizable(this: &ArrayBuffer) -> bool;
2179
2180    /// The `resize()` method of ArrayBuffer instances resizes the ArrayBuffer to the
2181    /// specified size, in bytes.
2182    ///
2183    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/resize)
2184    #[wasm_bindgen(method, catch)]
2185    pub fn resize(this: &ArrayBuffer, new_len: usize) -> Result<(), JsValue>;
2186
2187    /// The `slice()` method returns a new `ArrayBuffer` whose contents
2188    /// are a copy of this `ArrayBuffer`'s bytes from begin, inclusive,
2189    /// up to end, exclusive.
2190    ///
2191    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice)
2192    #[cfg(not(js_sys_unstable_apis))]
2193    #[wasm_bindgen(method)]
2194    pub fn slice(this: &ArrayBuffer, begin: u32) -> ArrayBuffer;
2195
2196    /// The `slice()` method returns a new `ArrayBuffer` whose contents
2197    /// are a copy of this `ArrayBuffer`'s bytes from begin, inclusive,
2198    /// up to end, exclusive. Negative indices count from the end.
2199    ///
2200    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice)
2201    #[cfg(js_sys_unstable_apis)]
2202    #[wasm_bindgen(method)]
2203    pub fn slice(this: &ArrayBuffer, begin: isize, end: isize) -> ArrayBuffer;
2204
2205    /// The `slice()` method returns a new `ArrayBuffer` whose contents
2206    /// are a copy of this `ArrayBuffer`'s bytes from begin, inclusive,
2207    /// up to end, exclusive.
2208    ///
2209    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice)
2210    #[cfg(not(js_sys_unstable_apis))]
2211    #[wasm_bindgen(method, js_name = slice)]
2212    pub fn slice_from(this: &ArrayBuffer, begin: isize) -> ArrayBuffer;
2213
2214    /// The `slice()` method returns a new `ArrayBuffer` whose contents
2215    /// are a copy of this `ArrayBuffer`'s bytes from begin to the end.
2216    /// Negative indices count from the end.
2217    ///
2218    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice)
2219    #[cfg(js_sys_unstable_apis)]
2220    #[wasm_bindgen(method, js_name = slice)]
2221    pub fn slice_from(this: &ArrayBuffer, begin: isize) -> ArrayBuffer;
2222
2223    // Next major: deprecate
2224    /// Like `slice()` but with the `end` argument.
2225    ///
2226    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice)
2227    #[wasm_bindgen(method, js_name = slice)]
2228    pub fn slice_with_end(this: &ArrayBuffer, begin: u32, end: u32) -> ArrayBuffer;
2229
2230    /// The `transfer()` method of ArrayBuffer instances creates a new `ArrayBuffer`
2231    /// 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/transfer)
2234    #[wasm_bindgen(method, catch)]
2235    pub fn transfer(this: &ArrayBuffer) -> Result<ArrayBuffer, JsValue>;
2236
2237    /// The `transfer()` method of `ArrayBuffer` instances creates a new `ArrayBuffer`
2238    /// with the same byte content as this buffer, then detaches this buffer.
2239    ///
2240    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/transfer)
2241    #[wasm_bindgen(method, catch, js_name = transfer)]
2242    pub fn transfer_with_length(
2243        this: &ArrayBuffer,
2244        new_byte_length: usize,
2245    ) -> Result<ArrayBuffer, JsValue>;
2246
2247    /// The `transferToFixedLength()` method of `ArrayBuffer` instances creates a new non-resizable
2248    /// ArrayBuffer with the same byte content as this buffer, then detaches this buffer.
2249    ///
2250    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/transferToFixedLength)
2251    #[wasm_bindgen(method, catch, js_name = transferToFixedLength)]
2252    pub fn transfer_to_fixed_length(this: &ArrayBuffer) -> Result<ArrayBuffer, JsValue>;
2253
2254    /// The `transferToFixedLength()` method of `ArrayBuffer` instances creates a new non-resizable
2255    /// `ArrayBuffer` with the same byte content as this buffer, then detaches this buffer.
2256    ///
2257    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/transferToFixedLength)
2258    #[wasm_bindgen(method, catch, js_name = transferToFixedLength)]
2259    pub fn transfer_to_fixed_length_with_length(
2260        this: &ArrayBuffer,
2261        new_byte_length: usize,
2262    ) -> Result<ArrayBuffer, JsValue>;
2263}
2264
2265impl UpcastFrom<&[u8]> for ArrayBuffer {}
2266
2267// SharedArrayBuffer
2268#[wasm_bindgen]
2269extern "C" {
2270    #[wasm_bindgen(extends = Object, typescript_type = "SharedArrayBuffer")]
2271    #[derive(Clone, Debug)]
2272    pub type SharedArrayBuffer;
2273
2274    /// The `SharedArrayBuffer` object is used to represent a generic,
2275    /// fixed-length raw binary data buffer, similar to the `ArrayBuffer`
2276    /// object, but in a way that they can be used to create views
2277    /// on shared memory. Unlike an `ArrayBuffer`, a `SharedArrayBuffer`
2278    /// cannot become detached.
2279    ///
2280    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer)
2281    #[cfg(not(js_sys_unstable_apis))]
2282    #[wasm_bindgen(constructor)]
2283    pub fn new(length: u32) -> SharedArrayBuffer;
2284
2285    /// The `SharedArrayBuffer` object is used to represent a generic,
2286    /// fixed-length raw binary data buffer, similar to the `ArrayBuffer`
2287    /// object, but in a way that they can be used to create views
2288    /// on shared memory. Unlike an `ArrayBuffer`, a `SharedArrayBuffer`
2289    /// cannot become detached.
2290    ///
2291    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer)
2292    #[cfg(js_sys_unstable_apis)]
2293    #[wasm_bindgen(constructor)]
2294    pub fn new(length: usize) -> SharedArrayBuffer;
2295
2296    /// The `SharedArrayBuffer` object is used to represent a generic,
2297    /// fixed-length raw binary data buffer, similar to the `ArrayBuffer`
2298    /// object, but in a way that they can be used to create views
2299    /// on shared memory. Unlike an `ArrayBuffer`, a `SharedArrayBuffer`
2300    /// cannot become detached.
2301    ///
2302    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer)
2303    #[wasm_bindgen(constructor)]
2304    pub fn new_with_options(length: usize, options: &ArrayBufferOptions) -> SharedArrayBuffer;
2305
2306    /// The `byteLength` accessor property represents the length of
2307    /// an `SharedArrayBuffer` in bytes. This is established when
2308    /// the `SharedArrayBuffer` is constructed and cannot be changed.
2309    ///
2310    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/byteLength)
2311    #[cfg(not(js_sys_unstable_apis))]
2312    #[wasm_bindgen(method, getter, js_name = byteLength)]
2313    pub fn byte_length(this: &SharedArrayBuffer) -> u32;
2314
2315    /// The `byteLength` accessor property represents the length of
2316    /// an `SharedArrayBuffer` in bytes. This is established when
2317    /// the `SharedArrayBuffer` is constructed and cannot be changed.
2318    ///
2319    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/byteLength)
2320    #[cfg(js_sys_unstable_apis)]
2321    #[wasm_bindgen(method, getter, js_name = byteLength)]
2322    pub fn byte_length(this: &SharedArrayBuffer) -> usize;
2323
2324    /// The `growable` accessor property of `SharedArrayBuffer` instances returns whether
2325    /// this `SharedArrayBuffer` can be grown or not.
2326    ///
2327    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/growable)
2328    #[wasm_bindgen(method, getter)]
2329    pub fn growable(this: &SharedArrayBuffer) -> bool;
2330
2331    /// The `grow()` method of `SharedArrayBuffer` instances grows the
2332    /// `SharedArrayBuffer` to the specified size, in bytes.
2333    ///
2334    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/grow)
2335    #[wasm_bindgen(method, catch)]
2336    pub fn grow(this: &SharedArrayBuffer, new_byte_length: usize) -> Result<(), JsValue>;
2337
2338    /// The `maxByteLength` accessor property of `SharedArrayBuffer` instances returns the maximum
2339    /// length (in bytes) that this `SharedArrayBuffer` can be resized to.
2340    ///
2341    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/maxByteLength)
2342    #[wasm_bindgen(method, getter, js_name = maxByteLength)]
2343    pub fn max_byte_length(this: &SharedArrayBuffer) -> usize;
2344
2345    /// The `slice()` method returns a new `SharedArrayBuffer` whose contents
2346    /// are a copy of this `SharedArrayBuffer`'s bytes from begin, inclusive,
2347    /// up to end, exclusive.
2348    ///
2349    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice)
2350    #[cfg(not(js_sys_unstable_apis))]
2351    #[wasm_bindgen(method)]
2352    pub fn slice(this: &SharedArrayBuffer, begin: u32) -> SharedArrayBuffer;
2353
2354    /// The `slice()` method returns a new `SharedArrayBuffer` whose contents
2355    /// are a copy of this `SharedArrayBuffer`'s bytes from begin, inclusive,
2356    /// up to end, exclusive. Negative indices count from the end.
2357    ///
2358    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice)
2359    #[cfg(js_sys_unstable_apis)]
2360    #[wasm_bindgen(method)]
2361    pub fn slice(this: &SharedArrayBuffer, begin: isize, end: isize) -> SharedArrayBuffer;
2362
2363    /// The `slice()` method returns a new `SharedArrayBuffer` whose contents
2364    /// are a copy of this `SharedArrayBuffer`'s bytes from begin, inclusive,
2365    /// up to end, exclusive.
2366    ///
2367    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice)
2368    #[cfg(not(js_sys_unstable_apis))]
2369    #[wasm_bindgen(method)]
2370    pub fn slice_from(this: &SharedArrayBuffer, begin: isize) -> SharedArrayBuffer;
2371
2372    /// The `slice()` method returns a new `SharedArrayBuffer` whose contents
2373    /// are a copy of this `SharedArrayBuffer`'s bytes from begin to end.
2374    /// Negative indices count from the end.
2375    ///
2376    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice)
2377    #[cfg(js_sys_unstable_apis)]
2378    #[wasm_bindgen(method)]
2379    pub fn slice_from(this: &SharedArrayBuffer, begin: isize) -> SharedArrayBuffer;
2380
2381    // Next major: deprecate
2382    /// Like `slice()` but with the `end` argument.
2383    ///
2384    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice)
2385    #[wasm_bindgen(method, js_name = slice)]
2386    pub fn slice_with_end(this: &SharedArrayBuffer, begin: u32, end: u32) -> SharedArrayBuffer;
2387}
2388
2389// Array Iterator
2390#[wasm_bindgen]
2391extern "C" {
2392    /// The `keys()` method returns a new Array Iterator object that contains the
2393    /// keys for each index in the array.
2394    ///
2395    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/keys)
2396    #[wasm_bindgen(method)]
2397    pub fn keys<T>(this: &Array<T>) -> Iterator<T>;
2398
2399    /// The `entries()` method returns a new Array Iterator object that contains
2400    /// the key/value pairs for each index in the array.
2401    ///
2402    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries)
2403    #[cfg(not(js_sys_unstable_apis))]
2404    #[wasm_bindgen(method)]
2405    #[deprecated(note = "recommended to use `Array::entries_typed` instead for typing")]
2406    #[allow(deprecated)]
2407    pub fn entries<T>(this: &Array<T>) -> Iterator<T>;
2408
2409    /// The `entries()` method returns a new Array Iterator object that contains
2410    /// the key/value pairs for each index in the array.
2411    ///
2412    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries)
2413    #[cfg(js_sys_unstable_apis)]
2414    #[wasm_bindgen(method)]
2415    pub fn entries<T: JsGeneric>(this: &Array<T>) -> Iterator<ArrayTuple<(Number, T)>>;
2416
2417    // Next major: deprecate
2418    /// The `entries()` method returns a new Array Iterator object that contains
2419    /// the key/value pairs for each index in the array.
2420    ///
2421    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries)
2422    #[wasm_bindgen(method, js_name = entries)]
2423    pub fn entries_typed<T: JsGeneric>(this: &Array<T>) -> Iterator<ArrayTuple<(Number, T)>>;
2424
2425    /// The `values()` method returns a new Array Iterator object that
2426    /// contains the values for each index in the array.
2427    ///
2428    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/values)
2429    #[wasm_bindgen(method)]
2430    pub fn values<T>(this: &Array<T>) -> Iterator<T>;
2431}
2432
2433pub trait TypedArray: JsGeneric {}
2434
2435// Next major: use usize/isize for indices
2436/// The `Atomics` object provides atomic operations as static methods.
2437/// They are used with `SharedArrayBuffer` objects.
2438///
2439/// The Atomic operations are installed on an `Atomics` module. Unlike
2440/// the other global objects, `Atomics` is not a constructor. You cannot
2441/// use it with a new operator or invoke the `Atomics` object as a
2442/// function. All properties and methods of `Atomics` are static
2443/// (as is the case with the Math object, for example).
2444/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics)
2445#[allow(non_snake_case)]
2446pub mod Atomics {
2447    use super::*;
2448
2449    #[wasm_bindgen]
2450    extern "C" {
2451        /// The static `Atomics.add()` method adds a given value at a given
2452        /// position in the array and returns the old value at that position.
2453        /// This atomic operation guarantees that no other write happens
2454        /// until the modified value is written back.
2455        ///
2456        /// You should use `add_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2457        ///
2458        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/add)
2459        #[wasm_bindgen(js_namespace = Atomics, catch)]
2460        pub fn add<T: TypedArray = Int32Array>(
2461            typed_array: &T,
2462            index: u32,
2463            value: i32,
2464        ) -> Result<i32, JsValue>;
2465
2466        /// The static `Atomics.add()` method adds a given value at a given
2467        /// position in the array and returns the old value at that position.
2468        /// This atomic operation guarantees that no other write happens
2469        /// until the modified value is written back.
2470        ///
2471        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2472        ///
2473        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/add)
2474        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = add)]
2475        pub fn add_bigint<T: TypedArray = Int32Array>(
2476            typed_array: &T,
2477            index: u32,
2478            value: i64,
2479        ) -> Result<i64, JsValue>;
2480
2481        /// The static `Atomics.and()` method computes a bitwise AND with a given
2482        /// value at a given position in the array, and returns the old value
2483        /// at that position.
2484        /// This atomic operation guarantees that no other write happens
2485        /// until the modified value is written back.
2486        ///
2487        /// You should use `and_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2488        ///
2489        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/and)
2490        #[wasm_bindgen(js_namespace = Atomics, catch)]
2491        pub fn and<T: TypedArray = Int32Array>(
2492            typed_array: &T,
2493            index: u32,
2494            value: i32,
2495        ) -> Result<i32, JsValue>;
2496
2497        /// The static `Atomics.and()` method computes a bitwise AND with a given
2498        /// value at a given position in the array, and returns the old value
2499        /// at that position.
2500        /// This atomic operation guarantees that no other write happens
2501        /// until the modified value is written back.
2502        ///
2503        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2504        ///
2505        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/and)
2506        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = and)]
2507        pub fn and_bigint<T: TypedArray = Int32Array>(
2508            typed_array: &T,
2509            index: u32,
2510            value: i64,
2511        ) -> Result<i64, JsValue>;
2512
2513        /// The static `Atomics.compareExchange()` method exchanges a given
2514        /// replacement value at a given position in the array, if a given expected
2515        /// value equals the old value. It returns the old value at that position
2516        /// whether it was equal to the expected value or not.
2517        /// This atomic operation guarantees that no other write happens
2518        /// until the modified value is written back.
2519        ///
2520        /// You should use `compare_exchange_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2521        ///
2522        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/compareExchange)
2523        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = compareExchange)]
2524        pub fn compare_exchange<T: TypedArray = Int32Array>(
2525            typed_array: &T,
2526            index: u32,
2527            expected_value: i32,
2528            replacement_value: i32,
2529        ) -> Result<i32, JsValue>;
2530
2531        /// The static `Atomics.compareExchange()` method exchanges a given
2532        /// replacement value at a given position in the array, if a given expected
2533        /// value equals the old value. It returns the old value at that position
2534        /// whether it was equal to the expected value or not.
2535        /// This atomic operation guarantees that no other write happens
2536        /// until the modified value is written back.
2537        ///
2538        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2539        ///
2540        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/compareExchange)
2541        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = compareExchange)]
2542        pub fn compare_exchange_bigint<T: TypedArray = Int32Array>(
2543            typed_array: &T,
2544            index: u32,
2545            expected_value: i64,
2546            replacement_value: i64,
2547        ) -> Result<i64, JsValue>;
2548
2549        /// The static `Atomics.exchange()` method stores a given value at a given
2550        /// position in the array and returns the old value at that position.
2551        /// This atomic operation guarantees that no other write happens
2552        /// until the modified value is written back.
2553        ///
2554        /// You should use `exchange_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2555        ///
2556        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/exchange)
2557        #[wasm_bindgen(js_namespace = Atomics, catch)]
2558        pub fn exchange<T: TypedArray = Int32Array>(
2559            typed_array: &T,
2560            index: u32,
2561            value: i32,
2562        ) -> Result<i32, JsValue>;
2563
2564        /// The static `Atomics.exchange()` method stores a given value at a given
2565        /// position in the array and returns the old value at that position.
2566        /// This atomic operation guarantees that no other write happens
2567        /// until the modified value is written back.
2568        ///
2569        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2570        ///
2571        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/exchange)
2572        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = exchange)]
2573        pub fn exchange_bigint<T: TypedArray = Int32Array>(
2574            typed_array: &T,
2575            index: u32,
2576            value: i64,
2577        ) -> Result<i64, JsValue>;
2578
2579        /// The static `Atomics.isLockFree()` method is used to determine
2580        /// whether to use locks or atomic operations. It returns true,
2581        /// if the given size is one of the `BYTES_PER_ELEMENT` property
2582        /// of integer `TypedArray` types.
2583        ///
2584        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/isLockFree)
2585        #[wasm_bindgen(js_namespace = Atomics, js_name = isLockFree)]
2586        pub fn is_lock_free(size: u32) -> bool;
2587
2588        /// The static `Atomics.load()` method returns a value at a given
2589        /// position in the array.
2590        ///
2591        /// You should use `load_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2592        ///
2593        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/load)
2594        #[wasm_bindgen(js_namespace = Atomics, catch)]
2595        pub fn load<T: TypedArray = Int32Array>(
2596            typed_array: &T,
2597            index: u32,
2598        ) -> Result<i32, JsValue>;
2599
2600        /// The static `Atomics.load()` method returns a value at a given
2601        /// position in the array.
2602        ///
2603        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2604        ///
2605        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/load)
2606        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = load)]
2607        pub fn load_bigint<T: TypedArray = Int32Array>(
2608            typed_array: &T,
2609            index: i64,
2610        ) -> Result<i64, JsValue>;
2611
2612        /// The static `Atomics.notify()` method notifies up some agents that
2613        /// are sleeping in the wait queue.
2614        /// Note: This operation works with a shared `Int32Array` only.
2615        /// If `count` is not provided, notifies all the agents in the queue.
2616        ///
2617        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/notify)
2618        #[wasm_bindgen(js_namespace = Atomics, catch)]
2619        pub fn notify(typed_array: &Int32Array, index: u32) -> Result<u32, JsValue>;
2620
2621        /// The static `Atomics.notify()` method notifies up some agents that
2622        /// are sleeping in the wait queue.
2623        /// Note: This operation works with a shared `Int32Array` only.
2624        /// If `count` is not provided, notifies all the agents in the queue.
2625        ///
2626        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/notify)
2627        #[wasm_bindgen(js_namespace = Atomics, catch)]
2628        pub fn notify_bigint(typed_array: &BigInt64Array, index: u32) -> Result<u32, JsValue>;
2629
2630        /// Notifies up to `count` agents in the wait queue.
2631        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = notify)]
2632        pub fn notify_with_count(
2633            typed_array: &Int32Array,
2634            index: u32,
2635            count: u32,
2636        ) -> Result<u32, JsValue>;
2637
2638        /// Notifies up to `count` agents in the wait queue.
2639        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = notify)]
2640        pub fn notify_bigint_with_count(
2641            typed_array: &BigInt64Array,
2642            index: u32,
2643            count: u32,
2644        ) -> Result<u32, JsValue>;
2645
2646        /// The static `Atomics.or()` method computes a bitwise OR with a given value
2647        /// at a given position in the array, and returns the old value at that position.
2648        /// This atomic operation guarantees that no other write happens
2649        /// until the modified value is written back.
2650        ///
2651        /// You should use `or_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2652        ///
2653        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/or)
2654        #[wasm_bindgen(js_namespace = Atomics, catch)]
2655        pub fn or<T: TypedArray = Int32Array>(
2656            typed_array: &T,
2657            index: u32,
2658            value: i32,
2659        ) -> Result<i32, JsValue>;
2660
2661        /// The static `Atomics.or()` method computes a bitwise OR with a given value
2662        /// at a given position in the array, and returns the old value at that position.
2663        /// This atomic operation guarantees that no other write happens
2664        /// until the modified value is written back.
2665        ///
2666        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2667        ///
2668        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/or)
2669        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = or)]
2670        pub fn or_bigint<T: TypedArray = Int32Array>(
2671            typed_array: &T,
2672            index: u32,
2673            value: i64,
2674        ) -> Result<i64, JsValue>;
2675
2676        /// The static `Atomics.pause()` static method provides a micro-wait primitive that hints to the CPU
2677        /// that the caller is spinning while waiting on access to a shared resource. This allows the system
2678        /// to reduce the resources allocated to the core (such as power) or thread, without yielding the
2679        /// current thread.
2680        ///
2681        /// `pause()` has no observable behavior other than timing. The exact behavior is dependent on the CPU
2682        /// architecture and the operating system. For example, in Intel x86, it may be a pause instruction as
2683        /// per Intel's optimization manual. It could be a no-op in certain platforms.
2684        ///
2685        /// This method is used 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/xor)
2688        #[wasm_bindgen(js_namespace = Atomics)]
2689        pub fn pause();
2690
2691        /// The static `Atomics.pause()` static method provides a micro-wait primitive that hints to the CPU
2692        /// that the caller is spinning while waiting on access to a shared resource. This allows the system
2693        /// to reduce the resources allocated to the core (such as power) or thread, without yielding the
2694        /// current thread.
2695        ///
2696        /// `pause()` has no observable behavior other than timing. The exact behavior is dependent on the CPU
2697        /// architecture and the operating system. For example, in Intel x86, it may be a pause instruction as
2698        /// per Intel's optimization manual. It could be a no-op in certain platforms.
2699        ///
2700        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2701        ///
2702        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/xor)
2703        #[wasm_bindgen(js_namespace = Atomics)]
2704        pub fn pause_with_hint(duration_hint: u32);
2705
2706        /// The static `Atomics.store()` method stores a given value at the given
2707        /// position in the array and returns that value.
2708        ///
2709        /// You should use `store_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2710        ///
2711        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/store)
2712        #[wasm_bindgen(js_namespace = Atomics, catch)]
2713        pub fn store<T: TypedArray = Int32Array>(
2714            typed_array: &T,
2715            index: u32,
2716            value: i32,
2717        ) -> Result<i32, JsValue>;
2718
2719        /// The static `Atomics.store()` method stores a given value at the given
2720        /// position in the array and returns that value.
2721        ///
2722        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2723        ///
2724        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/store)
2725        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = store)]
2726        pub fn store_bigint<T: TypedArray = Int32Array>(
2727            typed_array: &T,
2728            index: u32,
2729            value: i64,
2730        ) -> Result<i64, JsValue>;
2731
2732        /// The static `Atomics.sub()` method subtracts a given value at a
2733        /// given position in the array and returns the old value at that position.
2734        /// This atomic operation guarantees that no other write happens
2735        /// until the modified value is written back.
2736        ///
2737        /// You should use `sub_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2738        ///
2739        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/sub)
2740        #[wasm_bindgen(js_namespace = Atomics, catch)]
2741        pub fn sub<T: TypedArray = Int32Array>(
2742            typed_array: &T,
2743            index: u32,
2744            value: i32,
2745        ) -> Result<i32, JsValue>;
2746
2747        /// The static `Atomics.sub()` method subtracts a given value at a
2748        /// given position in the array and returns the old value at that position.
2749        /// This atomic operation guarantees that no other write happens
2750        /// until the modified value is written back.
2751        ///
2752        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2753        ///
2754        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/sub)
2755        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = sub)]
2756        pub fn sub_bigint<T: TypedArray = Int32Array>(
2757            typed_array: &T,
2758            index: u32,
2759            value: i64,
2760        ) -> Result<i64, JsValue>;
2761
2762        /// The static `Atomics.wait()` method verifies that a given
2763        /// position in an `Int32Array` still contains a given value
2764        /// and if so sleeps, awaiting a wakeup or a timeout.
2765        /// It returns a string which is either "ok", "not-equal", or "timed-out".
2766        /// Note: This operation only works with a shared `Int32Array`
2767        /// and may not be allowed on the main thread.
2768        ///
2769        /// You should use `wait_bigint` to operate on a `BigInt64Array`.
2770        ///
2771        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait)
2772        #[wasm_bindgen(js_namespace = Atomics, catch)]
2773        pub fn wait(typed_array: &Int32Array, index: u32, value: i32) -> Result<JsString, JsValue>;
2774
2775        /// The static `Atomics.wait()` method verifies that a given
2776        /// position in an `BigInt64Array` still contains a given value
2777        /// and if so sleeps, awaiting a wakeup or a timeout.
2778        /// It returns a string which is either "ok", "not-equal", or "timed-out".
2779        /// Note: This operation only works with a shared `BigInt64Array`
2780        /// and may not be allowed on the main thread.
2781        ///
2782        /// You should use `wait` to operate on a `Int32Array`.
2783        ///
2784        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait)
2785        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = wait)]
2786        pub fn wait_bigint(
2787            typed_array: &BigInt64Array,
2788            index: u32,
2789            value: i64,
2790        ) -> Result<JsString, JsValue>;
2791
2792        /// Like `wait()`, but with timeout
2793        ///
2794        /// You should use `wait_with_timeout_bigint` to operate on a `BigInt64Array`.
2795        ///
2796        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait)
2797        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = wait)]
2798        pub fn wait_with_timeout(
2799            typed_array: &Int32Array,
2800            index: u32,
2801            value: i32,
2802            timeout: f64,
2803        ) -> Result<JsString, JsValue>;
2804
2805        /// Like `wait()`, but with timeout
2806        ///
2807        /// You should use `wait_with_timeout` to operate on a `Int32Array`.
2808        ///
2809        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait)
2810        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = wait)]
2811        pub fn wait_with_timeout_bigint(
2812            typed_array: &BigInt64Array,
2813            index: u32,
2814            value: i64,
2815            timeout: f64,
2816        ) -> Result<JsString, JsValue>;
2817
2818        /// The static `Atomics.waitAsync()` method verifies that a given position in an
2819        /// `Int32Array` still contains a given value and if so sleeps, awaiting a
2820        /// wakeup or a timeout. It returns an object with two properties. The first
2821        /// property `async` is a boolean which if true indicates that the second
2822        /// property `value` is a promise. If `async` is false then value is a string
2823        /// whether equal to either "not-equal" or "timed-out".
2824        /// Note: This operation only works with a shared `Int32Array` and may be used
2825        /// on the main thread.
2826        ///
2827        /// You should use `wait_async_bigint` to operate on a `BigInt64Array`.
2828        ///
2829        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/waitAsync)
2830        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = waitAsync)]
2831        pub fn wait_async(
2832            typed_array: &Int32Array,
2833            index: u32,
2834            value: i32,
2835        ) -> Result<Object, JsValue>;
2836
2837        /// The static `Atomics.waitAsync()` method verifies that a given position in an
2838        /// `Int32Array` still contains a given value and if so sleeps, awaiting a
2839        /// wakeup or a timeout. It returns an object with two properties. The first
2840        /// property `async` is a boolean which if true indicates that the second
2841        /// property `value` is a promise. If `async` is false then value is a string
2842        /// whether equal to either "not-equal" or "timed-out".
2843        /// Note: This operation only works with a shared `BigInt64Array` and may be used
2844        /// on the main thread.
2845        ///
2846        /// You should use `wait_async` to operate on a `Int32Array`.
2847        ///
2848        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/waitAsync)
2849        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = waitAsync)]
2850        pub fn wait_async_bigint(
2851            typed_array: &BigInt64Array,
2852            index: u32,
2853            value: i64,
2854        ) -> Result<Object, JsValue>;
2855
2856        /// Like `waitAsync()`, but with timeout
2857        ///
2858        /// You should use `wait_async_with_timeout_bigint` to operate on a `BigInt64Array`.
2859        ///
2860        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/waitAsync)
2861        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = waitAsync)]
2862        pub fn wait_async_with_timeout(
2863            typed_array: &Int32Array,
2864            index: u32,
2865            value: i32,
2866            timeout: f64,
2867        ) -> Result<Object, JsValue>;
2868
2869        /// Like `waitAsync()`, but with timeout
2870        ///
2871        /// You should use `wait_async_with_timeout` to operate on a `Int32Array`.
2872        ///
2873        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/waitAsync)
2874        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = waitAsync)]
2875        pub fn wait_async_with_timeout_bigint(
2876            typed_array: &BigInt64Array,
2877            index: u32,
2878            value: i64,
2879            timeout: f64,
2880        ) -> Result<Object, JsValue>;
2881
2882        /// The static `Atomics.xor()` method computes a bitwise XOR
2883        /// with a given value at a given position in the array,
2884        /// and returns the old value at that position.
2885        /// This atomic operation guarantees that no other write happens
2886        /// until the modified value is written back.
2887        ///
2888        /// You should use `xor_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2889        ///
2890        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/xor)
2891        #[wasm_bindgen(js_namespace = Atomics, catch)]
2892        pub fn xor<T: TypedArray = Int32Array>(
2893            typed_array: &T,
2894            index: u32,
2895            value: i32,
2896        ) -> Result<i32, JsValue>;
2897
2898        /// The static `Atomics.xor()` method computes a bitwise XOR
2899        /// with a given value at a given position in the array,
2900        /// and returns the old value at that position.
2901        /// This atomic operation guarantees that no other write happens
2902        /// until the modified value is written back.
2903        ///
2904        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2905        ///
2906        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/xor)
2907        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = xor)]
2908        pub fn xor_bigint<T: TypedArray = Int32Array>(
2909            typed_array: &T,
2910            index: u32,
2911            value: i64,
2912        ) -> Result<i64, JsValue>;
2913    }
2914}
2915
2916// BigInt
2917#[wasm_bindgen]
2918extern "C" {
2919    #[wasm_bindgen(extends = Object, is_type_of = |v| v.is_bigint(), typescript_type = "bigint")]
2920    #[derive(Clone, PartialEq, Eq)]
2921    pub type BigInt;
2922
2923    #[wasm_bindgen(catch, js_name = BigInt)]
2924    fn new_bigint(value: &JsValue) -> Result<BigInt, Error>;
2925
2926    #[wasm_bindgen(js_name = BigInt)]
2927    fn new_bigint_unchecked(value: &JsValue) -> BigInt;
2928
2929    /// Clamps a BigInt value to a signed integer value, and returns that value.
2930    ///
2931    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/asIntN)
2932    #[wasm_bindgen(static_method_of = BigInt, js_name = asIntN)]
2933    pub fn as_int_n(bits: f64, bigint: &BigInt) -> BigInt;
2934
2935    /// Clamps a BigInt value to an unsigned integer value, and returns that value.
2936    ///
2937    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/asUintN)
2938    #[wasm_bindgen(static_method_of = BigInt, js_name = asUintN)]
2939    pub fn as_uint_n(bits: f64, bigint: &BigInt) -> BigInt;
2940
2941    /// 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.
2942    ///
2943    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/toLocaleString)
2944    #[cfg(not(js_sys_unstable_apis))]
2945    #[wasm_bindgen(method, js_name = toLocaleString)]
2946    pub fn to_locale_string(this: &BigInt, locales: &JsValue, options: &JsValue) -> JsString;
2947
2948    /// 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.
2949    ///
2950    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/toLocaleString)
2951    #[cfg(js_sys_unstable_apis)]
2952    #[wasm_bindgen(method, js_name = toLocaleString)]
2953    pub fn to_locale_string(
2954        this: &BigInt,
2955        locales: &[JsString],
2956        options: &Intl::NumberFormatOptions,
2957    ) -> JsString;
2958
2959    // Next major: deprecate
2960    /// 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.
2961    ///
2962    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/toString)
2963    #[wasm_bindgen(catch, method, js_name = toString)]
2964    pub fn to_string(this: &BigInt, radix: u8) -> Result<JsString, RangeError>;
2965
2966    /// Returns a string representing this BigInt value in the specified radix (base).
2967    ///
2968    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/toString)
2969    #[cfg(js_sys_unstable_apis)]
2970    #[wasm_bindgen(catch, method, js_name = toString)]
2971    pub fn to_string_with_radix(this: &BigInt, radix: u8) -> Result<JsString, RangeError>;
2972
2973    #[wasm_bindgen(method, js_name = toString)]
2974    fn to_string_unchecked(this: &BigInt, radix: u8) -> String;
2975
2976    /// Returns this BigInt value. Overrides the [`Object.prototype.valueOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf) method.
2977    ///
2978    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/valueOf)
2979    #[wasm_bindgen(method, js_name = valueOf)]
2980    pub fn value_of(this: &BigInt, radix: u8) -> BigInt;
2981}
2982
2983impl BigInt {
2984    /// Creates a new BigInt value.
2985    ///
2986    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/BigInt)
2987    #[inline]
2988    pub fn new(value: &JsValue) -> Result<BigInt, Error> {
2989        new_bigint(value)
2990    }
2991
2992    /// Applies the binary `/` JS operator on two `BigInt`s, catching and returning any `RangeError` thrown.
2993    ///
2994    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Division)
2995    pub fn checked_div(&self, rhs: &Self) -> Result<Self, RangeError> {
2996        let result = JsValue::as_ref(self).checked_div(JsValue::as_ref(rhs));
2997
2998        if result.is_instance_of::<RangeError>() {
2999            Err(result.unchecked_into())
3000        } else {
3001            Ok(result.unchecked_into())
3002        }
3003    }
3004
3005    /// Applies the binary `**` JS operator on the two `BigInt`s.
3006    ///
3007    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Exponentiation)
3008    #[inline]
3009    pub fn pow(&self, rhs: &Self) -> Self {
3010        JsValue::as_ref(self)
3011            .pow(JsValue::as_ref(rhs))
3012            .unchecked_into()
3013    }
3014
3015    /// Returns a tuple of this [`BigInt`]'s absolute value along with a
3016    /// [`bool`] indicating whether the [`BigInt`] was negative.
3017    fn abs(&self) -> (Self, bool) {
3018        if self < &BigInt::from(0) {
3019            (-self, true)
3020        } else {
3021            (self.clone(), false)
3022        }
3023    }
3024}
3025
3026macro_rules! bigint_from {
3027    ($($x:ident)*) => ($(
3028        impl From<$x> for BigInt {
3029            #[inline]
3030            fn from(x: $x) -> BigInt {
3031                new_bigint_unchecked(&JsValue::from(x))
3032            }
3033        }
3034
3035        impl PartialEq<$x> for BigInt {
3036            #[inline]
3037            fn eq(&self, other: &$x) -> bool {
3038                JsValue::from(self) == JsValue::from(BigInt::from(*other))
3039            }
3040        }
3041    )*)
3042}
3043bigint_from!(i8 u8 i16 u16 i32 u32 isize usize);
3044
3045macro_rules! bigint_from_big {
3046    ($($x:ident)*) => ($(
3047        impl From<$x> for BigInt {
3048            #[inline]
3049            fn from(x: $x) -> BigInt {
3050                JsValue::from(x).unchecked_into()
3051            }
3052        }
3053
3054        impl PartialEq<$x> for BigInt {
3055            #[inline]
3056            fn eq(&self, other: &$x) -> bool {
3057                self == &BigInt::from(*other)
3058            }
3059        }
3060
3061        impl TryFrom<BigInt> for $x {
3062            type Error = BigInt;
3063
3064            #[inline]
3065            fn try_from(x: BigInt) -> Result<Self, BigInt> {
3066                Self::try_from(JsValue::from(x)).map_err(JsCast::unchecked_into)
3067            }
3068        }
3069    )*)
3070}
3071bigint_from_big!(i64 u64 i128 u128);
3072
3073impl PartialEq<Number> for BigInt {
3074    #[inline]
3075    fn eq(&self, other: &Number) -> bool {
3076        JsValue::as_ref(self).loose_eq(JsValue::as_ref(other))
3077    }
3078}
3079
3080impl Not for &BigInt {
3081    type Output = BigInt;
3082
3083    #[inline]
3084    fn not(self) -> Self::Output {
3085        JsValue::as_ref(self).bit_not().unchecked_into()
3086    }
3087}
3088
3089forward_deref_unop!(impl Not, not for BigInt);
3090forward_js_unop!(impl Neg, neg for BigInt);
3091forward_js_binop!(impl BitAnd, bitand for BigInt);
3092forward_js_binop!(impl BitOr, bitor for BigInt);
3093forward_js_binop!(impl BitXor, bitxor for BigInt);
3094forward_js_binop!(impl Shl, shl for BigInt);
3095forward_js_binop!(impl Shr, shr for BigInt);
3096forward_js_binop!(impl Add, add for BigInt);
3097forward_js_binop!(impl Sub, sub for BigInt);
3098forward_js_binop!(impl Div, div for BigInt);
3099forward_js_binop!(impl Mul, mul for BigInt);
3100forward_js_binop!(impl Rem, rem for BigInt);
3101sum_product!(BigInt);
3102
3103partialord_ord!(BigInt);
3104
3105impl Default for BigInt {
3106    fn default() -> Self {
3107        BigInt::from(i32::default())
3108    }
3109}
3110
3111impl FromStr for BigInt {
3112    type Err = Error;
3113
3114    #[inline]
3115    fn from_str(s: &str) -> Result<Self, Self::Err> {
3116        BigInt::new(&s.into())
3117    }
3118}
3119
3120impl fmt::Debug for BigInt {
3121    #[inline]
3122    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3123        fmt::Display::fmt(self, f)
3124    }
3125}
3126
3127impl fmt::Display 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, "", &abs.to_string_unchecked(10))
3132    }
3133}
3134
3135impl fmt::Binary for BigInt {
3136    #[inline]
3137    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3138        let (abs, is_neg) = self.abs();
3139        f.pad_integral(!is_neg, "0b", &abs.to_string_unchecked(2))
3140    }
3141}
3142
3143impl fmt::Octal for BigInt {
3144    #[inline]
3145    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3146        let (abs, is_neg) = self.abs();
3147        f.pad_integral(!is_neg, "0o", &abs.to_string_unchecked(8))
3148    }
3149}
3150
3151impl fmt::LowerHex for BigInt {
3152    #[inline]
3153    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3154        let (abs, is_neg) = self.abs();
3155        f.pad_integral(!is_neg, "0x", &abs.to_string_unchecked(16))
3156    }
3157}
3158
3159impl fmt::UpperHex for BigInt {
3160    #[inline]
3161    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3162        let (abs, is_neg) = self.abs();
3163        let mut s: String = abs.to_string_unchecked(16);
3164        s.make_ascii_uppercase();
3165        f.pad_integral(!is_neg, "0x", &s)
3166    }
3167}
3168
3169// Boolean
3170#[wasm_bindgen]
3171extern "C" {
3172    #[wasm_bindgen(extends = Object, is_type_of = |v| v.as_bool().is_some(), typescript_type = "boolean")]
3173    #[derive(Clone, PartialEq, Eq)]
3174    pub type Boolean;
3175
3176    /// The `Boolean()` constructor creates an object wrapper for a boolean value.
3177    ///
3178    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
3179    #[cfg(not(js_sys_unstable_apis))]
3180    #[wasm_bindgen(constructor)]
3181    #[deprecated(note = "recommended to use `Boolean::from` instead")]
3182    #[allow(deprecated)]
3183    pub fn new(value: &JsValue) -> Boolean;
3184
3185    /// The `valueOf()` method returns the primitive value of a `Boolean` object.
3186    ///
3187    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/valueOf)
3188    #[wasm_bindgen(method, js_name = valueOf)]
3189    pub fn value_of(this: &Boolean) -> bool;
3190}
3191
3192impl UpcastFrom<bool> for Boolean {}
3193impl UpcastFrom<Boolean> for bool {}
3194
3195impl Boolean {
3196    /// Typed Boolean true constant.
3197    pub const TRUE: Boolean = Self {
3198        obj: Object {
3199            obj: JsValue::TRUE,
3200            generics: PhantomData,
3201        },
3202    };
3203
3204    /// Typed Boolean false constant.
3205    pub const FALSE: Boolean = Self {
3206        obj: Object {
3207            obj: JsValue::FALSE,
3208            generics: PhantomData,
3209        },
3210    };
3211}
3212
3213impl From<bool> for Boolean {
3214    #[inline]
3215    fn from(b: bool) -> Boolean {
3216        Boolean::unchecked_from_js(JsValue::from(b))
3217    }
3218}
3219
3220impl From<Boolean> for bool {
3221    #[inline]
3222    fn from(b: Boolean) -> bool {
3223        b.value_of()
3224    }
3225}
3226
3227impl PartialEq<bool> for Boolean {
3228    #[inline]
3229    fn eq(&self, other: &bool) -> bool {
3230        self.value_of() == *other
3231    }
3232}
3233
3234impl fmt::Debug for Boolean {
3235    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
3236        fmt::Debug::fmt(&self.value_of(), f)
3237    }
3238}
3239
3240impl fmt::Display for Boolean {
3241    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
3242        fmt::Display::fmt(&self.value_of(), f)
3243    }
3244}
3245
3246impl Default for Boolean {
3247    fn default() -> Self {
3248        Self::from(bool::default())
3249    }
3250}
3251
3252impl Not for &Boolean {
3253    type Output = Boolean;
3254
3255    #[inline]
3256    fn not(self) -> Self::Output {
3257        (!JsValue::as_ref(self)).into()
3258    }
3259}
3260
3261forward_deref_unop!(impl Not, not for Boolean);
3262
3263partialord_ord!(Boolean);
3264
3265// DataView
3266#[wasm_bindgen]
3267extern "C" {
3268    #[wasm_bindgen(extends = Object, typescript_type = "DataView")]
3269    #[derive(Clone, Debug, PartialEq, Eq)]
3270    pub type DataView;
3271
3272    /// The `DataView` view provides a low-level interface for reading and
3273    /// writing multiple number types in an `ArrayBuffer` irrespective of the
3274    /// platform's endianness.
3275    ///
3276    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView)
3277    #[wasm_bindgen(constructor)]
3278    pub fn new(buffer: &ArrayBuffer, byteOffset: usize, byteLength: usize) -> DataView;
3279
3280    /// The `DataView` view provides a low-level interface for reading and
3281    /// writing multiple number types in an `ArrayBuffer` irrespective of the
3282    /// platform's endianness.
3283    ///
3284    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView)
3285    #[wasm_bindgen(constructor)]
3286    pub fn new_with_shared_array_buffer(
3287        buffer: &SharedArrayBuffer,
3288        byteOffset: usize,
3289        byteLength: usize,
3290    ) -> DataView;
3291
3292    /// The ArrayBuffer referenced by this view. Fixed at construction time and thus read only.
3293    ///
3294    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/buffer)
3295    #[wasm_bindgen(method, getter)]
3296    pub fn buffer(this: &DataView) -> ArrayBuffer;
3297
3298    /// The length (in bytes) of this view from the start of its ArrayBuffer.
3299    /// Fixed at construction time and thus read only.
3300    ///
3301    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteLength)
3302    #[wasm_bindgen(method, getter, js_name = byteLength)]
3303    pub fn byte_length(this: &DataView) -> usize;
3304
3305    /// The offset (in bytes) of this view from the start of its ArrayBuffer.
3306    /// Fixed at construction time and thus read only.
3307    ///
3308    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteOffset)
3309    #[wasm_bindgen(method, getter, js_name = byteOffset)]
3310    pub fn byte_offset(this: &DataView) -> usize;
3311
3312    /// The `getInt8()` method gets a signed 8-bit integer (byte) at the
3313    /// specified byte offset from the start of the DataView.
3314    ///
3315    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt8)
3316    #[wasm_bindgen(method, js_name = getInt8)]
3317    pub fn get_int8(this: &DataView, byte_offset: usize) -> i8;
3318
3319    /// The `getUint8()` method gets a unsigned 8-bit integer (byte) at the specified
3320    /// byte offset from the start of the DataView.
3321    ///
3322    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint8)
3323    #[wasm_bindgen(method, js_name = getUint8)]
3324    pub fn get_uint8(this: &DataView, byte_offset: usize) -> u8;
3325
3326    /// The `getInt16()` method gets a signed 16-bit integer (short) at the specified
3327    /// byte offset from the start of the DataView.
3328    ///
3329    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt16)
3330    #[wasm_bindgen(method, js_name = getInt16)]
3331    pub fn get_int16(this: &DataView, byte_offset: usize) -> i16;
3332
3333    /// The `getInt16()` method gets a signed 16-bit integer (short) at the specified
3334    /// byte offset from the start of the DataView.
3335    ///
3336    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt16)
3337    #[wasm_bindgen(method, js_name = getInt16)]
3338    pub fn get_int16_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> i16;
3339
3340    /// The `getUint16()` method gets an unsigned 16-bit integer (unsigned short) at the specified
3341    /// byte offset from the start of the view.
3342    ///
3343    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint16)
3344    #[wasm_bindgen(method, js_name = getUint16)]
3345    pub fn get_uint16(this: &DataView, byte_offset: usize) -> u16;
3346
3347    /// The `getUint16()` method gets an unsigned 16-bit integer (unsigned short) at the specified
3348    /// byte offset from the start of the view.
3349    ///
3350    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint16)
3351    #[wasm_bindgen(method, js_name = getUint16)]
3352    pub fn get_uint16_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> u16;
3353
3354    /// The `getInt32()` method gets a signed 32-bit integer (long) at the specified
3355    /// byte offset from the start of the DataView.
3356    ///
3357    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt32)
3358    #[wasm_bindgen(method, js_name = getInt32)]
3359    pub fn get_int32(this: &DataView, byte_offset: usize) -> i32;
3360
3361    /// The `getInt32()` method gets a signed 32-bit integer (long) at the specified
3362    /// byte offset from the start of the DataView.
3363    ///
3364    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt32)
3365    #[wasm_bindgen(method, js_name = getInt32)]
3366    pub fn get_int32_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> i32;
3367
3368    /// The `getUint32()` method gets an unsigned 32-bit integer (unsigned long) at the specified
3369    /// byte offset from the start of the view.
3370    ///
3371    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint32)
3372    #[wasm_bindgen(method, js_name = getUint32)]
3373    pub fn get_uint32(this: &DataView, byte_offset: usize) -> u32;
3374
3375    /// The `getUint32()` method gets an unsigned 32-bit integer (unsigned long) at the specified
3376    /// byte offset from the start of the view.
3377    ///
3378    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint32)
3379    #[wasm_bindgen(method, js_name = getUint32)]
3380    pub fn get_uint32_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> u32;
3381
3382    /// The `getFloat32()` method gets a signed 32-bit float (float) at the specified
3383    /// byte offset from the start of the DataView.
3384    ///
3385    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat32)
3386    #[wasm_bindgen(method, js_name = getFloat32)]
3387    pub fn get_float32(this: &DataView, byte_offset: usize) -> f32;
3388
3389    /// The `getFloat32()` method gets a signed 32-bit float (float) at the specified
3390    /// byte offset from the start of the DataView.
3391    ///
3392    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat32)
3393    #[wasm_bindgen(method, js_name = getFloat32)]
3394    pub fn get_float32_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> f32;
3395
3396    /// The `getFloat16()` method gets a signed 16-bit float at the specified
3397    /// byte offset from the start of the DataView as an `f32`.
3398    ///
3399    /// The unsuffixed `get_float16` name is reserved for a future native
3400    /// `f16` binding once Rust stabilizes the type.
3401    ///
3402    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat16)
3403    #[wasm_bindgen(method, js_name = getFloat16)]
3404    pub fn get_float16_as_f32(this: &DataView, byte_offset: usize) -> f32;
3405
3406    /// The `getFloat16()` method gets a signed 16-bit float at the specified
3407    /// byte offset from the start of the DataView as an `f32`.
3408    ///
3409    /// The unsuffixed `get_float16_endian` name is reserved for a future
3410    /// native `f16` binding once Rust stabilizes the type.
3411    ///
3412    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat16)
3413    #[wasm_bindgen(method, js_name = getFloat16)]
3414    pub fn get_float16_endian_as_f32(
3415        this: &DataView,
3416        byte_offset: usize,
3417        little_endian: bool,
3418    ) -> f32;
3419
3420    /// The `getFloat64()` method gets a signed 64-bit float (double) at the specified
3421    /// byte offset from the start of the DataView.
3422    ///
3423    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat64)
3424    #[wasm_bindgen(method, js_name = getFloat64)]
3425    pub fn get_float64(this: &DataView, byte_offset: usize) -> f64;
3426
3427    /// The `getFloat64()` method gets a signed 64-bit float (double) at the specified
3428    /// byte offset from the start of the DataView.
3429    ///
3430    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat64)
3431    #[wasm_bindgen(method, js_name = getFloat64)]
3432    pub fn get_float64_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> f64;
3433
3434    /// The `setInt8()` method stores a signed 8-bit integer (byte) value at the
3435    /// specified byte offset from the start of the DataView.
3436    ///
3437    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt8)
3438    #[wasm_bindgen(method, js_name = setInt8)]
3439    pub fn set_int8(this: &DataView, byte_offset: usize, value: i8);
3440
3441    /// The `setUint8()` method stores an unsigned 8-bit integer (byte) value at the
3442    /// specified byte offset from the start of the DataView.
3443    ///
3444    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint8)
3445    #[wasm_bindgen(method, js_name = setUint8)]
3446    pub fn set_uint8(this: &DataView, byte_offset: usize, value: u8);
3447
3448    /// The `setInt16()` method stores a signed 16-bit integer (short) value at the
3449    /// specified byte offset from the start of the DataView.
3450    ///
3451    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt16)
3452    #[wasm_bindgen(method, js_name = setInt16)]
3453    pub fn set_int16(this: &DataView, byte_offset: usize, value: i16);
3454
3455    /// The `setInt16()` method stores a signed 16-bit integer (short) value at the
3456    /// specified byte offset from the start of the DataView.
3457    ///
3458    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt16)
3459    #[wasm_bindgen(method, js_name = setInt16)]
3460    pub fn set_int16_endian(this: &DataView, byte_offset: usize, value: i16, little_endian: bool);
3461
3462    /// The `setUint16()` method stores an unsigned 16-bit integer (unsigned short) value at the
3463    /// specified byte offset from the start of the DataView.
3464    ///
3465    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint16)
3466    #[wasm_bindgen(method, js_name = setUint16)]
3467    pub fn set_uint16(this: &DataView, byte_offset: usize, value: u16);
3468
3469    /// The `setUint16()` method stores an unsigned 16-bit integer (unsigned short) value at the
3470    /// specified byte offset from the start of the DataView.
3471    ///
3472    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint16)
3473    #[wasm_bindgen(method, js_name = setUint16)]
3474    pub fn set_uint16_endian(this: &DataView, byte_offset: usize, value: u16, little_endian: bool);
3475
3476    /// The `setInt32()` method stores a signed 32-bit integer (long) value at the
3477    /// specified byte offset from the start of the DataView.
3478    ///
3479    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt32)
3480    #[wasm_bindgen(method, js_name = setInt32)]
3481    pub fn set_int32(this: &DataView, byte_offset: usize, value: i32);
3482
3483    /// The `setInt32()` method stores a signed 32-bit integer (long) value at the
3484    /// specified byte offset from the start of the DataView.
3485    ///
3486    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt32)
3487    #[wasm_bindgen(method, js_name = setInt32)]
3488    pub fn set_int32_endian(this: &DataView, byte_offset: usize, value: i32, little_endian: bool);
3489
3490    /// The `setUint32()` method stores an unsigned 32-bit integer (unsigned long) value at the
3491    /// specified byte offset from the start of the DataView.
3492    ///
3493    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint32)
3494    #[wasm_bindgen(method, js_name = setUint32)]
3495    pub fn set_uint32(this: &DataView, byte_offset: usize, value: u32);
3496
3497    /// The `setUint32()` method stores an unsigned 32-bit integer (unsigned long) value at the
3498    /// specified byte offset from the start of the DataView.
3499    ///
3500    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint32)
3501    #[wasm_bindgen(method, js_name = setUint32)]
3502    pub fn set_uint32_endian(this: &DataView, byte_offset: usize, value: u32, little_endian: bool);
3503
3504    /// The `setFloat32()` method stores a signed 32-bit float (float) value at the
3505    /// specified byte offset from the start of the DataView.
3506    ///
3507    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat32)
3508    #[wasm_bindgen(method, js_name = setFloat32)]
3509    pub fn set_float32(this: &DataView, byte_offset: usize, value: f32);
3510
3511    /// The `setFloat32()` method stores a signed 32-bit float (float) value at the
3512    /// specified byte offset from the start of the DataView.
3513    ///
3514    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat32)
3515    #[wasm_bindgen(method, js_name = setFloat32)]
3516    pub fn set_float32_endian(this: &DataView, byte_offset: usize, value: f32, little_endian: bool);
3517
3518    /// The `setFloat16()` method stores a signed 16-bit float value from an
3519    /// `f32` at the specified byte offset from the start of the DataView.
3520    ///
3521    /// The unsuffixed `set_float16` name is reserved for a future native
3522    /// `f16` binding once Rust stabilizes the type.
3523    ///
3524    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat16)
3525    #[wasm_bindgen(method, js_name = setFloat16)]
3526    pub fn set_float16_from_f32(this: &DataView, byte_offset: usize, value: f32);
3527
3528    /// The `setFloat16()` method stores a signed 16-bit float value from an
3529    /// `f32` at the specified byte offset from the start of the DataView.
3530    ///
3531    /// The unsuffixed `set_float16_endian` name is reserved for a future
3532    /// native `f16` binding once Rust stabilizes the type.
3533    ///
3534    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat16)
3535    #[wasm_bindgen(method, js_name = setFloat16)]
3536    pub fn set_float16_endian_from_f32(
3537        this: &DataView,
3538        byte_offset: usize,
3539        value: f32,
3540        little_endian: bool,
3541    );
3542
3543    /// The `setFloat64()` method stores a signed 64-bit float (double) value at the
3544    /// specified byte offset from the start of the DataView.
3545    ///
3546    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat64)
3547    #[wasm_bindgen(method, js_name = setFloat64)]
3548    pub fn set_float64(this: &DataView, byte_offset: usize, value: f64);
3549
3550    /// The `setFloat64()` method stores a signed 64-bit float (double) value at the
3551    /// specified byte offset from the start of the DataView.
3552    ///
3553    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat64)
3554    #[wasm_bindgen(method, js_name = setFloat64)]
3555    pub fn set_float64_endian(this: &DataView, byte_offset: usize, value: f64, little_endian: bool);
3556}
3557
3558// Error
3559#[wasm_bindgen]
3560extern "C" {
3561    #[wasm_bindgen(extends = Object, typescript_type = "Error")]
3562    #[derive(Clone, Debug, PartialEq, Eq)]
3563    pub type Error;
3564
3565    /// The Error constructor creates an error object.
3566    /// Instances of Error objects are thrown when runtime errors occur.
3567    /// The Error object can also be used as a base object for user-defined exceptions.
3568    /// See below for standard built-in error types.
3569    ///
3570    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)
3571    #[wasm_bindgen(constructor)]
3572    pub fn new(message: &str) -> Error;
3573    #[wasm_bindgen(constructor)]
3574    pub fn new_with_options(message: &str, options: &Object) -> Error;
3575
3576    /// The cause property is the underlying cause of the error.
3577    /// Usually this is used to add context to re-thrown errors.
3578    ///
3579    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#differentiate_between_similar_errors)
3580    #[wasm_bindgen(method, getter)]
3581    pub fn cause(this: &Error) -> JsValue;
3582    #[wasm_bindgen(method, setter)]
3583    pub fn set_cause(this: &Error, cause: &JsValue);
3584
3585    /// The message property is a human-readable description of the error.
3586    ///
3587    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/message)
3588    #[wasm_bindgen(method, getter)]
3589    pub fn message(this: &Error) -> JsString;
3590    #[wasm_bindgen(method, setter)]
3591    pub fn set_message(this: &Error, message: &str);
3592
3593    /// The name property represents a name for the type of error. The initial value is "Error".
3594    ///
3595    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name)
3596    #[wasm_bindgen(method, getter)]
3597    pub fn name(this: &Error) -> JsString;
3598    #[wasm_bindgen(method, setter)]
3599    pub fn set_name(this: &Error, name: &str);
3600
3601    /// The `toString()` method returns a string representing the specified Error object
3602    ///
3603    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/toString)
3604    #[cfg(not(js_sys_unstable_apis))]
3605    #[wasm_bindgen(method, js_name = toString)]
3606    pub fn to_string(this: &Error) -> JsString;
3607
3608    /// The `Error.stackTraceLimit` property controls the number of stack
3609    /// frames collected by a stack trace.
3610    ///
3611    /// This is a non-standard V8/Node.js API.
3612    ///
3613    /// [V8 documentation](https://v8.dev/docs/stack-trace-api#stack-trace-collection-for-custom-exceptions)
3614    #[wasm_bindgen(static_method_of = Error, getter, js_name = stackTraceLimit)]
3615    pub fn stack_trace_limit() -> JsValue;
3616
3617    /// Set `Error.stackTraceLimit` to control the number of stack frames
3618    /// collected by a stack trace.
3619    ///
3620    /// This is a non-standard V8/Node.js API.
3621    ///
3622    /// [V8 documentation](https://v8.dev/docs/stack-trace-api#stack-trace-collection-for-custom-exceptions)
3623    #[wasm_bindgen(static_method_of = Error, setter, js_name = stackTraceLimit)]
3624    pub fn set_stack_trace_limit(value: &JsValue);
3625}
3626
3627partialord_ord!(JsString);
3628
3629// EvalError
3630#[wasm_bindgen]
3631extern "C" {
3632    #[wasm_bindgen(extends = Object, extends = Error, typescript_type = "EvalError")]
3633    #[derive(Clone, Debug, PartialEq, Eq)]
3634    pub type EvalError;
3635
3636    /// The `EvalError` object indicates an error regarding the global eval() function. This
3637    /// exception is not thrown by JavaScript anymore, however the EvalError object remains for
3638    /// compatibility.
3639    ///
3640    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError)
3641    #[wasm_bindgen(constructor)]
3642    pub fn new(message: &str) -> EvalError;
3643}
3644
3645#[wasm_bindgen]
3646extern "C" {
3647    #[wasm_bindgen(extends = Object, is_type_of = JsValue::is_function, no_upcast, typescript_type = "Function")]
3648    #[derive(Clone, Debug, PartialEq, Eq)]
3649    /// `Function` represents any generic Function in JS, by treating all arguments as `JsValue`.
3650    ///
3651    /// It takes a generic parameter of phantom type `fn (Arg1, ..., Argn) -> Ret` which
3652    /// is used to type the JS function. For example, `Function<fn () -> Number>` represents
3653    /// a function taking no arguments that returns a number.
3654    ///
3655    /// The 8 generic argument parameters (`Arg1` through `Arg8`) are the argument
3656    /// types. Arguments not provided enable strict arity checking at compile time.
3657    ///
3658    /// A void function is represented by `fn (Arg) -> Undefined`, and **not** the `()` unit
3659    /// type. This is because generics must be based on JS values in the JS generic type system.
3660    ///
3661    /// _The default without any parameters is as a void function - no arguments, `Undefined` return._
3662    ///
3663    /// _The default generic for `Function` is `fn (JsValue, JsValue, ...) -> JsValue`,
3664    /// representing any function, since all functions safely upcast into this function._
3665    ///
3666    /// ### Arity Enforcement
3667    ///
3668    /// It is not possible to use `call4` or `bind4` on a function that does not have
3669    /// at least 4 arguments — the compiler will reject this because only arguments that
3670    /// are not `None` support the trait bound for `ErasableGeneric`.
3671    ///
3672    /// ### Examples
3673    ///
3674    /// ```ignore
3675    /// // A function taking no args, returning Number
3676    /// let f: Function<Number> = get_some_fn();
3677    ///
3678    /// // A function taking (String, Number) and returning Boolean
3679    /// let f: Function<Boolean, String, Number> = get_some_fn();
3680    ///
3681    /// ### Upcasting
3682    ///
3683    /// To pass a typed `Function` where a different generic Function is expected, `upcast()` may be used
3684    /// to convert into any generic `Function` at zero cost with type-safety.
3685    ///
3686    /// MDN documentation (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
3687    pub type Function<
3688        T: JsFunction = fn(
3689            JsValue,
3690            JsValue,
3691            JsValue,
3692            JsValue,
3693            JsValue,
3694            JsValue,
3695            JsValue,
3696            JsValue,
3697        ) -> JsValue,
3698    >;
3699}
3700
3701#[wasm_bindgen]
3702extern "C" {
3703    /// The `Function` constructor creates a new `Function` object. Calling the
3704    /// constructor directly can create functions dynamically, but suffers from
3705    /// security and similar (but far less significant) performance issues
3706    /// similar to `eval`. However, unlike `eval`, the `Function` constructor
3707    /// allows executing code in the global scope, prompting better programming
3708    /// habits and allowing for more efficient code minification.
3709    ///
3710    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
3711    #[cfg(all(feature = "unsafe-eval", not(js_sys_unstable_apis)))]
3712    #[wasm_bindgen(constructor)]
3713    pub fn new_with_args(args: &str, body: &str) -> Function;
3714
3715    /// The `Function` constructor creates a new `Function` object. Calling the
3716    /// constructor directly can create functions dynamically, but suffers from
3717    /// security and similar (but far less significant) performance issues
3718    /// similar to `eval`. However, unlike `eval`, the `Function` constructor
3719    /// allows executing code in the global scope, prompting better programming
3720    /// habits and allowing for more efficient code minification.
3721    ///
3722    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
3723    #[cfg(all(feature = "unsafe-eval", js_sys_unstable_apis))]
3724    #[wasm_bindgen(constructor)]
3725    pub fn new_with_args<T: JsFunction = fn() -> JsValue>(args: &str, body: &str) -> Function<T>;
3726
3727    // Next major: deprecate
3728    /// The `Function` constructor creates a new `Function` object. Calling the
3729    /// constructor directly can create functions dynamically, but suffers from
3730    /// security and similar (but far less significant) performance issues
3731    /// similar to `eval`. However, unlike `eval`, the `Function` constructor
3732    /// allows executing code in the global scope, prompting better programming
3733    /// habits and allowing for more efficient code minification.
3734    ///
3735    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
3736    #[cfg(feature = "unsafe-eval")]
3737    #[wasm_bindgen(constructor)]
3738    pub fn new_with_args_typed<T: JsFunction = fn() -> JsValue>(
3739        args: &str,
3740        body: &str,
3741    ) -> Function<T>;
3742
3743    /// The `Function` constructor creates a new `Function` object. Calling the
3744    /// constructor directly can create functions dynamically, but suffers from
3745    /// security and similar (but far less significant) performance issues
3746    /// similar to `eval`. However, unlike `eval`, the `Function` constructor
3747    /// allows executing code in the global scope, prompting better programming
3748    /// habits and allowing for more efficient code minification.
3749    ///
3750    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
3751    #[cfg(all(feature = "unsafe-eval", not(js_sys_unstable_apis)))]
3752    #[wasm_bindgen(constructor)]
3753    pub fn new_no_args(body: &str) -> Function;
3754
3755    /// The `Function` constructor creates a new `Function` object. Calling the
3756    /// constructor directly can create functions dynamically, but suffers from
3757    /// security and similar (but far less significant) performance issues
3758    /// similar to `eval`. However, unlike `eval`, the `Function` constructor
3759    /// allows executing code in the global scope, prompting better programming
3760    /// habits and allowing for more efficient code minification.
3761    ///
3762    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
3763    #[cfg(all(feature = "unsafe-eval", js_sys_unstable_apis))]
3764    #[wasm_bindgen(constructor)]
3765    pub fn new_no_args<T: JsFunction = fn() -> JsValue>(body: &str) -> Function<T>;
3766
3767    // Next major: deprecate
3768    /// The `Function` constructor creates a new `Function` object.
3769    ///
3770    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
3771    #[cfg(feature = "unsafe-eval")]
3772    #[wasm_bindgen(constructor)]
3773    pub fn new_no_args_typed<T: JsFunction = fn() -> JsValue>(body: &str) -> Function<T>;
3774
3775    /// The `apply()` method calls a function with a given this value, and arguments provided as an array
3776    /// (or an array-like object).
3777    ///
3778    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply)
3779    #[wasm_bindgen(method, catch)]
3780    pub fn apply<T: JsFunction = fn() -> JsValue>(
3781        this: &Function<T>,
3782        context: &JsValue,
3783        args: &Array,
3784    ) -> Result<<T as JsFunction>::Ret, JsValue>;
3785
3786    // Next major: Deprecate, and separately provide provide impl
3787    /// The `call()` method calls a function with a given this value and
3788    /// arguments provided individually.
3789    ///
3790    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
3791    ///
3792    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
3793    #[wasm_bindgen(method, catch, js_name = call)]
3794    pub fn call0<Ret: JsGeneric, F: JsFunction<Ret = Ret> = fn() -> JsValue>(
3795        this: &Function<F>,
3796        context: &JsValue,
3797    ) -> Result<Ret, JsValue>;
3798
3799    // Next major: Deprecate, and separately provide provide impl
3800    /// The `call()` method calls a function with a given this value and
3801    /// arguments provided individually.
3802    ///
3803    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
3804    ///
3805    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
3806    #[wasm_bindgen(method, catch, js_name = call)]
3807    pub fn call1<
3808        Ret: JsGeneric,
3809        Arg1: JsGeneric,
3810        F: JsFunction<Ret = Ret> + JsFunction1<Arg1 = Arg1> = fn(JsValue) -> JsValue,
3811    >(
3812        this: &Function<F>,
3813        context: &JsValue,
3814        arg1: &Arg1,
3815    ) -> Result<Ret, JsValue>;
3816
3817    // Next major: Deprecate, and separately provide provide impl
3818    /// The `call()` method calls a function with a given this value and
3819    /// arguments provided individually.
3820    ///
3821    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
3822    ///
3823    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
3824    #[wasm_bindgen(method, catch, js_name = call)]
3825    pub fn call2<
3826        Ret: JsGeneric,
3827        Arg1: JsGeneric,
3828        Arg2: JsGeneric,
3829        F: JsFunction<Ret = Ret> + JsFunction1<Arg1 = Arg1> + JsFunction2<Arg2 = Arg2> = fn(
3830            JsValue,
3831            JsValue,
3832        ) -> JsValue,
3833    >(
3834        this: &Function<F>,
3835        context: &JsValue,
3836        arg1: &Arg1,
3837        arg2: &Arg2,
3838    ) -> Result<Ret, JsValue>;
3839
3840    // Next major: Deprecate, and separately provide provide impl
3841    /// The `call()` method calls a function with a given this value and
3842    /// arguments provided individually.
3843    ///
3844    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
3845    ///
3846    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
3847    #[wasm_bindgen(method, catch, js_name = call)]
3848    pub fn call3<
3849        Ret: JsGeneric,
3850        Arg1: JsGeneric,
3851        Arg2: JsGeneric,
3852        Arg3: JsGeneric,
3853        F: JsFunction<Ret = Ret> + JsFunction3<Arg1 = Arg1, Arg2 = Arg2, Arg3 = Arg3> = fn(
3854            JsValue,
3855            JsValue,
3856            JsValue,
3857        ) -> JsValue,
3858    >(
3859        this: &Function<F>,
3860        context: &JsValue,
3861        arg1: &Arg1,
3862        arg2: &Arg2,
3863        arg3: &Arg3,
3864    ) -> Result<Ret, JsValue>;
3865
3866    // Next major: Deprecate, and separately provide provide impl
3867    /// The `call()` method calls a function with a given this value and
3868    /// arguments provided individually.
3869    ///
3870    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
3871    ///
3872    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
3873    #[wasm_bindgen(method, catch, js_name = call)]
3874    pub fn call4<
3875        Ret: JsGeneric,
3876        Arg1: JsGeneric,
3877        Arg2: JsGeneric,
3878        Arg3: JsGeneric,
3879        Arg4: JsGeneric,
3880        F: JsFunction<Ret = Ret> + JsFunction4<Arg1 = Arg1, Arg2 = Arg2, Arg3 = Arg3, Arg4 = Arg4> = fn(
3881            JsValue,
3882            JsValue,
3883            JsValue,
3884            JsValue,
3885        ) -> JsValue,
3886    >(
3887        this: &Function<F>,
3888        context: &JsValue,
3889        arg1: &Arg1,
3890        arg2: &Arg2,
3891        arg3: &Arg3,
3892        arg4: &Arg4,
3893    ) -> Result<Ret, JsValue>;
3894
3895    // Next major: Deprecate, and separately provide provide impl
3896    /// The `call()` method calls a function with a given this value and
3897    /// arguments provided individually.
3898    ///
3899    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
3900    ///
3901    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
3902    #[wasm_bindgen(method, catch, js_name = call)]
3903    pub fn call5<
3904        Ret: JsGeneric,
3905        Arg1: JsGeneric,
3906        Arg2: JsGeneric,
3907        Arg3: JsGeneric,
3908        Arg4: JsGeneric,
3909        Arg5: JsGeneric,
3910        F: JsFunction<Ret = Ret>
3911            + JsFunction5<Arg1 = Arg1, Arg2 = Arg2, Arg3 = Arg3, Arg4 = Arg4, Arg5 = Arg5> = fn(
3912            JsValue,
3913            JsValue,
3914            JsValue,
3915            JsValue,
3916            JsValue,
3917        ) -> JsValue,
3918    >(
3919        this: &Function<F>,
3920        context: &JsValue,
3921        arg1: &Arg1,
3922        arg2: &Arg2,
3923        arg3: &Arg3,
3924        arg4: &Arg4,
3925        arg5: &Arg5,
3926    ) -> Result<Ret, JsValue>;
3927
3928    // Next major: Deprecate, and separately provide provide impl
3929    /// The `call()` method calls a function with a given this value and
3930    /// arguments provided individually.
3931    ///
3932    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
3933    ///
3934    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
3935    #[wasm_bindgen(method, catch, js_name = call)]
3936    pub fn call6<
3937        Ret: JsGeneric,
3938        Arg1: JsGeneric,
3939        Arg2: JsGeneric,
3940        Arg3: JsGeneric,
3941        Arg4: JsGeneric,
3942        Arg5: JsGeneric,
3943        Arg6: JsGeneric,
3944        F: JsFunction<Ret = Ret>
3945            + JsFunction6<
3946                Arg1 = Arg1,
3947                Arg2 = Arg2,
3948                Arg3 = Arg3,
3949                Arg4 = Arg4,
3950                Arg5 = Arg5,
3951                Arg6 = Arg6,
3952            > = fn(JsValue, JsValue, JsValue, JsValue, JsValue, JsValue) -> JsValue,
3953    >(
3954        this: &Function<F>,
3955        context: &JsValue,
3956        arg1: &Arg1,
3957        arg2: &Arg2,
3958        arg3: &Arg3,
3959        arg4: &Arg4,
3960        arg5: &Arg5,
3961        arg6: &Arg6,
3962    ) -> Result<Ret, JsValue>;
3963
3964    // Next major: Deprecate, and separately provide provide impl
3965    /// The `call()` method calls a function with a given this value and
3966    /// arguments provided individually.
3967    ///
3968    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
3969    ///
3970    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
3971    #[wasm_bindgen(method, catch, js_name = call)]
3972    pub fn call7<
3973        Ret: JsGeneric,
3974        Arg1: JsGeneric,
3975        Arg2: JsGeneric,
3976        Arg3: JsGeneric,
3977        Arg4: JsGeneric,
3978        Arg5: JsGeneric,
3979        Arg6: JsGeneric,
3980        Arg7: JsGeneric,
3981        F: JsFunction<Ret = Ret>
3982            + JsFunction7<
3983                Arg1 = Arg1,
3984                Arg2 = Arg2,
3985                Arg3 = Arg3,
3986                Arg4 = Arg4,
3987                Arg5 = Arg5,
3988                Arg6 = Arg6,
3989                Arg7 = Arg7,
3990            > = fn(
3991            JsValue,
3992            JsValue,
3993            JsValue,
3994            JsValue,
3995            JsValue,
3996            JsValue,
3997            JsValue,
3998        ) -> JsValue,
3999    >(
4000        this: &Function<F>,
4001        context: &JsValue,
4002        arg1: &Arg1,
4003        arg2: &Arg2,
4004        arg3: &Arg3,
4005        arg4: &Arg4,
4006        arg5: &Arg5,
4007        arg6: &Arg6,
4008        arg7: &Arg7,
4009    ) -> Result<Ret, JsValue>;
4010
4011    // Next major: Deprecate, and separately provide provide impl
4012    /// The `call()` method calls a function with a given this value and
4013    /// arguments provided individually.
4014    ///
4015    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
4016    ///
4017    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
4018    #[wasm_bindgen(method, catch, js_name = call)]
4019    pub fn call8<
4020        Ret: JsGeneric,
4021        Arg1: JsGeneric,
4022        Arg2: JsGeneric,
4023        Arg3: JsGeneric,
4024        Arg4: JsGeneric,
4025        Arg5: JsGeneric,
4026        Arg6: JsGeneric,
4027        Arg7: JsGeneric,
4028        Arg8: JsGeneric,
4029        F: JsFunction8<
4030            Ret = Ret,
4031            Arg1 = Arg1,
4032            Arg2 = Arg2,
4033            Arg3 = Arg3,
4034            Arg4 = Arg4,
4035            Arg5 = Arg5,
4036            Arg6 = Arg6,
4037            Arg7 = Arg7,
4038            Arg8 = Arg8,
4039        > = fn(
4040            JsValue,
4041            JsValue,
4042            JsValue,
4043            JsValue,
4044            JsValue,
4045            JsValue,
4046            JsValue,
4047            JsValue,
4048        ) -> JsValue,
4049    >(
4050        this: &Function<F>,
4051        context: &JsValue,
4052        arg1: &Arg1,
4053        arg2: &Arg2,
4054        arg3: &Arg3,
4055        arg4: &Arg4,
4056        arg5: &Arg5,
4057        arg6: &Arg6,
4058        arg7: &Arg7,
4059        arg8: &Arg8,
4060    ) -> Result<Ret, JsValue>;
4061
4062    /// The `call()` method calls a function with a given this value and
4063    /// arguments provided individually.
4064    ///
4065    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
4066    ///
4067    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
4068    #[deprecated]
4069    #[allow(deprecated)]
4070    #[wasm_bindgen(method, catch, js_name = call)]
4071    pub fn call9<
4072        Ret: JsGeneric,
4073        Arg1: JsGeneric,
4074        Arg2: JsGeneric,
4075        Arg3: JsGeneric,
4076        Arg4: JsGeneric,
4077        Arg5: JsGeneric,
4078        Arg6: JsGeneric,
4079        Arg7: JsGeneric,
4080        Arg8: JsGeneric,
4081        F: JsFunction8<
4082            Ret = Ret,
4083            Arg1 = Arg1,
4084            Arg2 = Arg2,
4085            Arg3 = Arg3,
4086            Arg4 = Arg4,
4087            Arg5 = Arg5,
4088            Arg6 = Arg6,
4089            Arg7 = Arg7,
4090            Arg8 = Arg8,
4091        > = fn(
4092            JsValue,
4093            JsValue,
4094            JsValue,
4095            JsValue,
4096            JsValue,
4097            JsValue,
4098            JsValue,
4099            JsValue,
4100        ) -> JsValue,
4101    >(
4102        this: &Function<F>,
4103        context: &JsValue,
4104        arg1: &Arg1,
4105        arg2: &Arg2,
4106        arg3: &Arg3,
4107        arg4: &Arg4,
4108        arg5: &Arg5,
4109        arg6: &Arg6,
4110        arg7: &Arg7,
4111        arg8: &Arg8,
4112        arg9: &JsValue,
4113    ) -> Result<Ret, JsValue>;
4114
4115    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4116    /// with a given sequence of arguments preceding any provided when the new function is called.
4117    ///
4118    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4119    #[cfg(not(js_sys_unstable_apis))]
4120    #[deprecated(note = "Use `Function::bind0` instead.")]
4121    #[allow(deprecated)]
4122    #[wasm_bindgen(method, js_name = bind)]
4123    pub fn bind<T: JsFunction = fn() -> JsValue>(
4124        this: &Function<T>,
4125        context: &JsValue,
4126    ) -> Function<T>;
4127
4128    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4129    /// with a given sequence of arguments preceding any provided when the new function is called.
4130    ///
4131    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4132    ///
4133    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4134    #[wasm_bindgen(method, js_name = bind)]
4135    pub fn bind0<T: JsFunction = fn() -> JsValue>(
4136        this: &Function<T>,
4137        context: &JsValue,
4138    ) -> Function<T>;
4139
4140    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4141    /// with a given sequence of arguments preceding any provided when the new function is called.
4142    ///
4143    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4144    ///
4145    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4146    #[wasm_bindgen(method, js_name = bind)]
4147    pub fn bind1<
4148        Ret: JsGeneric,
4149        Arg1: JsGeneric,
4150        F: JsFunction1<Ret = Ret, Arg1 = Arg1> = fn(JsValue) -> JsValue,
4151    >(
4152        this: &Function<F>,
4153        context: &JsValue,
4154        arg1: &Arg1,
4155    ) -> Function<<F as JsFunction1>::Bind1>;
4156
4157    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4158    /// with a given sequence of arguments preceding any provided when the new function is called.
4159    ///
4160    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4161    ///
4162    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4163    #[wasm_bindgen(method, js_name = bind)]
4164    pub fn bind2<
4165        Ret: JsGeneric,
4166        Arg1: JsGeneric,
4167        Arg2: JsGeneric,
4168        F: JsFunction2<Ret = Ret, Arg1 = Arg1, Arg2 = Arg2> = fn(JsValue, JsValue) -> JsValue,
4169    >(
4170        this: &Function<F>,
4171        context: &JsValue,
4172        arg1: &Arg1,
4173        arg2: &Arg2,
4174    ) -> Function<<F as JsFunction2>::Bind2>;
4175
4176    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4177    /// with a given sequence of arguments preceding any provided when the new function is called.
4178    ///
4179    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4180    ///
4181    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4182    #[wasm_bindgen(method, js_name = bind)]
4183    pub fn bind3<
4184        Ret: JsGeneric,
4185        Arg1: JsGeneric,
4186        Arg2: JsGeneric,
4187        Arg3: JsGeneric,
4188        F: JsFunction3<Ret = Ret, Arg1 = Arg1, Arg2 = Arg2, Arg3 = Arg3> = fn(
4189            JsValue,
4190            JsValue,
4191            JsValue,
4192        ) -> JsValue,
4193    >(
4194        this: &Function<F>,
4195        context: &JsValue,
4196        arg1: &Arg1,
4197        arg2: &Arg2,
4198        arg3: &Arg3,
4199    ) -> Function<<F as JsFunction3>::Bind3>;
4200
4201    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4202    /// with a given sequence of arguments preceding any provided when the new function is called.
4203    ///
4204    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4205    ///
4206    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4207    #[wasm_bindgen(method, js_name = bind)]
4208    pub fn bind4<
4209        Ret: JsGeneric,
4210        Arg1: JsGeneric,
4211        Arg2: JsGeneric,
4212        Arg3: JsGeneric,
4213        Arg4: JsGeneric,
4214        F: JsFunction4<Ret = Ret, Arg1 = Arg1, Arg2 = Arg2, Arg3 = Arg3, Arg4 = Arg4> = fn(
4215            JsValue,
4216            JsValue,
4217            JsValue,
4218            JsValue,
4219        ) -> JsValue,
4220    >(
4221        this: &Function<F>,
4222        context: &JsValue,
4223        arg1: &Arg1,
4224        arg2: &Arg2,
4225        arg3: &Arg3,
4226        arg4: &Arg4,
4227    ) -> Function<<F as JsFunction4>::Bind4>;
4228
4229    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4230    /// with a given sequence of arguments preceding any provided when the new function is called.
4231    ///
4232    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4233    ///
4234    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4235    #[wasm_bindgen(method, js_name = bind)]
4236    pub fn bind5<
4237        Ret: JsGeneric,
4238        Arg1: JsGeneric,
4239        Arg2: JsGeneric,
4240        Arg3: JsGeneric,
4241        Arg4: JsGeneric,
4242        Arg5: JsGeneric,
4243        F: JsFunction5<Ret = Ret, Arg1 = Arg1, Arg2 = Arg2, Arg3 = Arg3, Arg4 = Arg4, Arg5 = Arg5> = fn(
4244            JsValue,
4245            JsValue,
4246            JsValue,
4247            JsValue,
4248            JsValue,
4249        ) -> JsValue,
4250    >(
4251        this: &Function<F>,
4252        context: &JsValue,
4253        arg1: &Arg1,
4254        arg2: &Arg2,
4255        arg3: &Arg3,
4256        arg4: &Arg4,
4257        arg5: &Arg5,
4258    ) -> Function<<F as JsFunction5>::Bind5>;
4259
4260    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4261    /// with a given sequence of arguments preceding any provided when the new function is called.
4262    ///
4263    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4264    ///
4265    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4266    #[wasm_bindgen(method, js_name = bind)]
4267    pub fn bind6<
4268        Ret: JsGeneric,
4269        Arg1: JsGeneric,
4270        Arg2: JsGeneric,
4271        Arg3: JsGeneric,
4272        Arg4: JsGeneric,
4273        Arg5: JsGeneric,
4274        Arg6: JsGeneric,
4275        F: JsFunction6<
4276            Ret = Ret,
4277            Arg1 = Arg1,
4278            Arg2 = Arg2,
4279            Arg3 = Arg3,
4280            Arg4 = Arg4,
4281            Arg5 = Arg5,
4282            Arg6 = Arg6,
4283        > = fn(JsValue, JsValue, JsValue, JsValue, JsValue, JsValue) -> JsValue,
4284    >(
4285        this: &Function<F>,
4286        context: &JsValue,
4287        arg1: &Arg1,
4288        arg2: &Arg2,
4289        arg3: &Arg3,
4290        arg4: &Arg4,
4291        arg5: &Arg5,
4292        arg6: &Arg6,
4293    ) -> Function<<F as JsFunction6>::Bind6>;
4294
4295    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4296    /// with a given sequence of arguments preceding any provided when the new function is called.
4297    ///
4298    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4299    ///
4300    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4301    #[wasm_bindgen(method, js_name = bind)]
4302    pub fn bind7<
4303        Ret: JsGeneric,
4304        Arg1: JsGeneric,
4305        Arg2: JsGeneric,
4306        Arg3: JsGeneric,
4307        Arg4: JsGeneric,
4308        Arg5: JsGeneric,
4309        Arg6: JsGeneric,
4310        Arg7: JsGeneric,
4311        F: JsFunction7<
4312            Ret = Ret,
4313            Arg1 = Arg1,
4314            Arg2 = Arg2,
4315            Arg3 = Arg3,
4316            Arg4 = Arg4,
4317            Arg5 = Arg5,
4318            Arg6 = Arg6,
4319            Arg7 = Arg7,
4320        > = fn(
4321            JsValue,
4322            JsValue,
4323            JsValue,
4324            JsValue,
4325            JsValue,
4326            JsValue,
4327            JsValue,
4328        ) -> JsValue,
4329    >(
4330        this: &Function<F>,
4331        context: &JsValue,
4332        arg1: &Arg1,
4333        arg2: &Arg2,
4334        arg3: &Arg3,
4335        arg4: &Arg4,
4336        arg5: &Arg5,
4337        arg6: &Arg6,
4338        arg7: &Arg7,
4339    ) -> Function<<F as JsFunction7>::Bind7>;
4340
4341    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4342    /// with a given sequence of arguments preceding any provided when the new function is called.
4343    ///
4344    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4345    ///
4346    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4347    #[wasm_bindgen(method, js_name = bind)]
4348    pub fn bind8<
4349        Ret: JsGeneric,
4350        Arg1: JsGeneric,
4351        Arg2: JsGeneric,
4352        Arg3: JsGeneric,
4353        Arg4: JsGeneric,
4354        Arg5: JsGeneric,
4355        Arg6: JsGeneric,
4356        Arg7: JsGeneric,
4357        Arg8: JsGeneric,
4358        F: JsFunction8<
4359            Ret = Ret,
4360            Arg1 = Arg1,
4361            Arg2 = Arg2,
4362            Arg3 = Arg3,
4363            Arg4 = Arg4,
4364            Arg5 = Arg5,
4365            Arg6 = Arg6,
4366            Arg7 = Arg7,
4367            Arg8 = Arg8,
4368        > = fn(
4369            JsValue,
4370            JsValue,
4371            JsValue,
4372            JsValue,
4373            JsValue,
4374            JsValue,
4375            JsValue,
4376            JsValue,
4377        ) -> JsValue,
4378    >(
4379        this: &Function<F>,
4380        context: &JsValue,
4381        arg1: &Arg1,
4382        arg2: &Arg2,
4383        arg3: &Arg3,
4384        arg4: &Arg4,
4385        arg5: &Arg5,
4386        arg6: &Arg6,
4387        arg7: &Arg7,
4388        arg8: &Arg8,
4389    ) -> Function<<F as JsFunction8>::Bind8>;
4390
4391    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4392    /// with a given sequence of arguments preceding any provided when the new function is called.
4393    ///
4394    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4395    ///
4396    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4397    #[deprecated]
4398    #[allow(deprecated)]
4399    #[wasm_bindgen(method, js_name = bind)]
4400    pub fn bind9<
4401        Ret: JsGeneric,
4402        Arg1: JsGeneric,
4403        Arg2: JsGeneric,
4404        Arg3: JsGeneric,
4405        Arg4: JsGeneric,
4406        Arg5: JsGeneric,
4407        Arg6: JsGeneric,
4408        Arg7: JsGeneric,
4409        Arg8: JsGeneric,
4410        F: JsFunction8<
4411            Ret = Ret,
4412            Arg1 = Arg1,
4413            Arg2 = Arg2,
4414            Arg3 = Arg3,
4415            Arg4 = Arg4,
4416            Arg5 = Arg5,
4417            Arg6 = Arg6,
4418            Arg7 = Arg7,
4419            Arg8 = Arg8,
4420        > = fn(
4421            JsValue,
4422            JsValue,
4423            JsValue,
4424            JsValue,
4425            JsValue,
4426            JsValue,
4427            JsValue,
4428            JsValue,
4429        ) -> JsValue,
4430    >(
4431        this: &Function<F>,
4432        context: &JsValue,
4433        arg1: &Arg1,
4434        arg2: &Arg2,
4435        arg3: &Arg3,
4436        arg4: &Arg4,
4437        arg5: &Arg5,
4438        arg6: &Arg6,
4439        arg7: &Arg7,
4440        arg8: &Arg8,
4441        arg9: &JsValue,
4442    ) -> Function<fn() -> Ret>;
4443
4444    /// The length property indicates the number of arguments expected by the function.
4445    ///
4446    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length)
4447    #[wasm_bindgen(method, getter)]
4448    pub fn length<T: JsFunction = fn() -> JsValue>(this: &Function<T>) -> u32;
4449
4450    /// A Function object's read-only name property indicates the function's
4451    /// name as specified when it was created or "anonymous" for functions
4452    /// created anonymously.
4453    ///
4454    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name)
4455    #[wasm_bindgen(method, getter)]
4456    pub fn name<T: JsFunction = fn() -> JsValue>(this: &Function<T>) -> JsString;
4457
4458    /// The `toString()` method returns a string representing the source code of the function.
4459    ///
4460    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toString)
4461    #[cfg(not(js_sys_unstable_apis))]
4462    #[wasm_bindgen(method, js_name = toString)]
4463    pub fn to_string<T: JsFunction = fn() -> JsValue>(this: &Function<T>) -> JsString;
4464}
4465
4466// Basic UpcastFrom impls for Function<T>
4467impl<T: JsFunction> UpcastFrom<Function<T>> for JsValue {}
4468impl<T: JsFunction> UpcastFrom<Function<T>> for JsOption<JsValue> {}
4469impl<T: JsFunction> UpcastFrom<Function<T>> for Object {}
4470impl<T: JsFunction> UpcastFrom<Function<T>> for JsOption<Object> {}
4471
4472// Blanket trait for Function upcast
4473// Function<T> upcasts to Function<U> when the underlying fn type T upcasts to U.
4474// The fn signature UpcastFrom impls already encode correct variance (covariant return, contravariant args).
4475impl<T: JsFunction, U: JsFunction> UpcastFrom<Function<T>> for Function<U> where U: UpcastFrom<T> {}
4476
4477// len() method for Function<T> using JsFunction::ARITY
4478impl<T: JsFunction> Function<T> {
4479    /// Get the static arity of this function type.
4480    #[allow(clippy::len_without_is_empty)]
4481    pub fn len(&self) -> usize {
4482        T::ARITY
4483    }
4484
4485    /// Returns true if this is a zero-argument function.
4486    pub fn is_empty(&self) -> bool {
4487        T::ARITY == 0
4488    }
4489}
4490
4491// Base traits for function signature types.
4492pub trait JsFunction {
4493    type Ret: JsGeneric;
4494    const ARITY: usize;
4495}
4496
4497pub trait JsFunction1: JsFunction {
4498    type Arg1: JsGeneric;
4499    type Bind1: JsFunction;
4500}
4501pub trait JsFunction2: JsFunction1 {
4502    type Arg2: JsGeneric;
4503    type Bind2: JsFunction;
4504}
4505pub trait JsFunction3: JsFunction2 {
4506    type Arg3: JsGeneric;
4507    type Bind3: JsFunction;
4508}
4509pub trait JsFunction4: JsFunction3 {
4510    type Arg4: JsGeneric;
4511    type Bind4: JsFunction;
4512}
4513pub trait JsFunction5: JsFunction4 {
4514    type Arg5: JsGeneric;
4515    type Bind5: JsFunction;
4516}
4517pub trait JsFunction6: JsFunction5 {
4518    type Arg6: JsGeneric;
4519    type Bind6: JsFunction;
4520}
4521pub trait JsFunction7: JsFunction6 {
4522    type Arg7: JsGeneric;
4523    type Bind7: JsFunction;
4524}
4525pub trait JsFunction8: JsFunction7 {
4526    type Arg8: JsGeneric;
4527    type Bind8: JsFunction;
4528}
4529
4530// Manual impl for fn() -> R
4531impl<Ret: JsGeneric> JsFunction for fn() -> Ret {
4532    type Ret = Ret;
4533    const ARITY: usize = 0;
4534}
4535
4536macro_rules! impl_fn {
4537    () => {
4538        impl_fn!(@impl 1 [Arg1] [
4539            JsFunction1 Arg1 Bind1 {fn() -> Ret}
4540        ]);
4541        impl_fn!(@impl 2 [Arg1 Arg2] [
4542            JsFunction1 Arg1 Bind1 {fn(Arg2) -> Ret}
4543            JsFunction2 Arg2 Bind2 {fn() -> Ret}
4544        ]);
4545        impl_fn!(@impl 3 [Arg1 Arg2 Arg3] [
4546            JsFunction1 Arg1 Bind1 {fn(Arg2, Arg3) -> Ret}
4547            JsFunction2 Arg2 Bind2 {fn(Arg3) -> Ret}
4548            JsFunction3 Arg3 Bind3 {fn() -> Ret}
4549        ]);
4550        impl_fn!(@impl 4 [Arg1 Arg2 Arg3 Arg4] [
4551            JsFunction1 Arg1 Bind1 {fn(Arg2, Arg3, Arg4) -> Ret}
4552            JsFunction2 Arg2 Bind2 {fn(Arg3, Arg4) -> Ret}
4553            JsFunction3 Arg3 Bind3 {fn(Arg4) -> Ret}
4554            JsFunction4 Arg4 Bind4 {fn() -> Ret}
4555        ]);
4556        impl_fn!(@impl 5 [Arg1 Arg2 Arg3 Arg4 Arg5] [
4557            JsFunction1 Arg1 Bind1 {fn(Arg2, Arg3, Arg4, Arg5) -> Ret}
4558            JsFunction2 Arg2 Bind2 {fn(Arg3, Arg4, Arg5) -> Ret}
4559            JsFunction3 Arg3 Bind3 {fn(Arg4, Arg5) -> Ret}
4560            JsFunction4 Arg4 Bind4 {fn(Arg5) -> Ret}
4561            JsFunction5 Arg5 Bind5 {fn() -> Ret}
4562        ]);
4563        impl_fn!(@impl 6 [Arg1 Arg2 Arg3 Arg4 Arg5 Arg6] [
4564            JsFunction1 Arg1 Bind1 {fn(Arg2, Arg3, Arg4, Arg5, Arg6) -> Ret}
4565            JsFunction2 Arg2 Bind2 {fn(Arg3, Arg4, Arg5, Arg6) -> Ret}
4566            JsFunction3 Arg3 Bind3 {fn(Arg4, Arg5, Arg6) -> Ret}
4567            JsFunction4 Arg4 Bind4 {fn(Arg5, Arg6) -> Ret}
4568            JsFunction5 Arg5 Bind5 {fn(Arg6) -> Ret}
4569            JsFunction6 Arg6 Bind6 {fn() -> Ret}
4570        ]);
4571        impl_fn!(@impl 7 [Arg1 Arg2 Arg3 Arg4 Arg5 Arg6 Arg7] [
4572            JsFunction1 Arg1 Bind1 {fn(Arg2, Arg3, Arg4, Arg5, Arg6, Arg7) -> Ret}
4573            JsFunction2 Arg2 Bind2 {fn(Arg3, Arg4, Arg5, Arg6, Arg7) -> Ret}
4574            JsFunction3 Arg3 Bind3 {fn(Arg4, Arg5, Arg6, Arg7) -> Ret}
4575            JsFunction4 Arg4 Bind4 {fn(Arg5, Arg6, Arg7) -> Ret}
4576            JsFunction5 Arg5 Bind5 {fn(Arg6, Arg7) -> Ret}
4577            JsFunction6 Arg6 Bind6 {fn(Arg7) -> Ret}
4578            JsFunction7 Arg7 Bind7 {fn() -> Ret}
4579        ]);
4580        impl_fn!(@impl 8 [Arg1 Arg2 Arg3 Arg4 Arg5 Arg6 Arg7 Arg8] [
4581            JsFunction1 Arg1 Bind1 {fn(Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8) -> Ret}
4582            JsFunction2 Arg2 Bind2 {fn(Arg3, Arg4, Arg5, Arg6, Arg7, Arg8) -> Ret}
4583            JsFunction3 Arg3 Bind3 {fn(Arg4, Arg5, Arg6, Arg7, Arg8) -> Ret}
4584            JsFunction4 Arg4 Bind4 {fn(Arg5, Arg6, Arg7, Arg8) -> Ret}
4585            JsFunction5 Arg5 Bind5 {fn(Arg6, Arg7, Arg8) -> Ret}
4586            JsFunction6 Arg6 Bind6 {fn(Arg7, Arg8) -> Ret}
4587            JsFunction7 Arg7 Bind7 {fn(Arg8) -> Ret}
4588            JsFunction8 Arg8 Bind8 {fn() -> Ret}
4589        ]);
4590    };
4591
4592    (@impl $arity:literal [$($A:ident)+] [$($trait:ident $arg:ident $bind:ident {$bind_ty:ty})+]) => {
4593        impl<Ret: JsGeneric $(, $A: JsGeneric)+> JsFunction for fn($($A),+) -> Ret {
4594            type Ret = Ret;
4595            const ARITY: usize = $arity;
4596        }
4597
4598        impl_fn!(@traits [$($A)+] [$($trait $arg $bind {$bind_ty})+]);
4599    };
4600
4601    (@traits [$($A:ident)+] []) => {};
4602
4603    (@traits [$($A:ident)+] [$trait:ident $arg:ident $bind:ident {$bind_ty:ty} $($rest:tt)*]) => {
4604        impl<Ret: JsGeneric $(, $A: JsGeneric)+> $trait for fn($($A),+) -> Ret {
4605            type $arg = $arg;
4606            type $bind = $bind_ty;
4607        }
4608
4609        impl_fn!(@traits [$($A)+] [$($rest)*]);
4610    };
4611}
4612
4613impl_fn!();
4614
4615/// Trait for argument tuples that can call or bind a `Function<T>`.
4616pub trait JsArgs<T: JsFunction> {
4617    type BindOutput;
4618    fn apply_call(self, func: &Function<T>, context: &JsValue) -> Result<T::Ret, JsValue>;
4619    fn apply_bind(self, func: &Function<T>, context: &JsValue) -> Self::BindOutput;
4620}
4621
4622// Manual impl for 0-arg
4623impl<Ret: JsGeneric, F: JsFunction<Ret = Ret>> JsArgs<F> for () {
4624    type BindOutput = Function<F>;
4625
4626    #[inline]
4627    fn apply_call(self, func: &Function<F>, context: &JsValue) -> Result<Ret, JsValue> {
4628        func.call0(context)
4629    }
4630
4631    #[inline]
4632    fn apply_bind(self, func: &Function<F>, context: &JsValue) -> Self::BindOutput {
4633        func.bind0(context)
4634    }
4635}
4636
4637macro_rules! impl_js_args {
4638    ($arity:literal $trait:ident $bind_output:ident [$($A:ident)+] [$($idx:tt)+] $call:ident $bind:ident) => {
4639        impl<Ret: JsGeneric, $($A: JsGeneric,)+ F: $trait<Ret = Ret, $($A = $A,)*>> JsArgs<F> for ($(&$A,)+)
4640        {
4641            type BindOutput = Function<<F as $trait>::$bind_output>;
4642
4643            #[inline]
4644            fn apply_call(self, func: &Function<F>, context: &JsValue) -> Result<Ret, JsValue> {
4645                func.$call(context, $(self.$idx),+)
4646            }
4647
4648            #[inline]
4649            fn apply_bind(self, func: &Function<F>, context: &JsValue) -> Self::BindOutput {
4650                func.$bind(context, $(self.$idx),+)
4651            }
4652        }
4653    };
4654}
4655
4656impl_js_args!(1 JsFunction1 Bind1 [Arg1] [0] call1 bind1);
4657impl_js_args!(2 JsFunction2 Bind2 [Arg1 Arg2] [0 1] call2 bind2);
4658impl_js_args!(3 JsFunction3 Bind3 [Arg1 Arg2 Arg3] [0 1 2] call3 bind3);
4659impl_js_args!(4 JsFunction4 Bind4 [Arg1 Arg2 Arg3 Arg4] [0 1 2 3] call4 bind4);
4660impl_js_args!(5 JsFunction5 Bind5 [Arg1 Arg2 Arg3 Arg4 Arg5] [0 1 2 3 4] call5 bind5);
4661impl_js_args!(6 JsFunction6 Bind6 [Arg1 Arg2 Arg3 Arg4 Arg5 Arg6] [0 1 2 3 4 5] call6 bind6);
4662impl_js_args!(7 JsFunction7 Bind7 [Arg1 Arg2 Arg3 Arg4 Arg5 Arg6 Arg7] [0 1 2 3 4 5 6] call7 bind7);
4663impl_js_args!(8 JsFunction8 Bind8 [Arg1 Arg2 Arg3 Arg4 Arg5 Arg6 Arg7 Arg8] [0 1 2 3 4 5 6 7] call8 bind8);
4664
4665impl<T: JsFunction> Function<T> {
4666    /// The `call()` method calls a function with a given `this` value and
4667    /// arguments provided as a tuple.
4668    ///
4669    /// This method accepts a tuple of references matching the function's
4670    /// argument types.
4671    ///
4672    /// # Example
4673    ///
4674    /// ```ignore
4675    /// // 0-arg function
4676    /// let f: Function<fn() -> Number> = get_fn();
4677    /// let result = f.call(&JsValue::NULL, ())?;
4678    ///
4679    /// // 1-arg function (note trailing comma for 1-tuple)
4680    /// let f: Function<fn(JsString) -> Number> = get_fn();
4681    /// let result = f.call(&JsValue::NULL, (&name,))?;
4682    ///
4683    /// // 2-arg function
4684    /// let f: Function<fn(JsString, Boolean) -> Number> = get_fn();
4685    /// let result = f.call(&JsValue::NULL, (&name, &flag))?;
4686    /// ```
4687    ///
4688    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
4689    #[inline]
4690    pub fn call<Args: JsArgs<T>>(&self, context: &JsValue, args: Args) -> Result<T::Ret, JsValue> {
4691        args.apply_call(self, context)
4692    }
4693
4694    /// The `bind()` method creates a new function that, when called, has its
4695    /// `this` keyword set to the provided value, with a given sequence of
4696    /// arguments preceding any provided when the new function is called.
4697    ///
4698    /// This method accepts a tuple of references to bind.
4699    ///
4700    /// # Example
4701    ///
4702    /// ```ignore
4703    /// let f: Function<fn(JsString, Boolean) -> Number> = get_fn();
4704    ///
4705    /// // Bind no args - same signature
4706    /// let bound: Function<fn(JsString, Boolean) -> Number> = f.bind(&ctx, ());
4707    ///
4708    /// // Bind one arg (use 1-tuple of references)
4709    /// let bound: Function<fn(Boolean) -> Number> = f.bind(&ctx, (&my_string,));
4710    ///
4711    /// // Bind two args - becomes 0-arg function
4712    /// let bound: Function<fn() -> Number> = f.bind(&ctx, (&my_string, &my_bool));
4713    /// ```
4714    ///
4715    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4716    #[inline]
4717    pub fn bindn<Args: JsArgs<T>>(&self, context: &JsValue, args: Args) -> Args::BindOutput {
4718        args.apply_bind(self, context)
4719    }
4720
4721    /// The `bind()` method creates a new function that, when called, has its
4722    /// `this` keyword set to the provided value, with a given sequence of
4723    /// arguments preceding any provided when the new function is called.
4724    ///
4725    /// This method accepts a tuple of references to bind.
4726    ///
4727    /// # Example
4728    ///
4729    /// ```ignore
4730    /// let f: Function<fn(JsString, Boolean) -> Number> = get_fn();
4731    ///
4732    /// // Bind no args - same signature
4733    /// let bound: Function<fn(JsString, Boolean) -> Number> = f.bind(&ctx, ());
4734    ///
4735    /// // Bind one arg (use 1-tuple of references)
4736    /// let bound: Function<fn(Boolean) -> Number> = f.bind(&ctx, (&my_string,));
4737    ///
4738    /// // Bind two args - becomes 0-arg function
4739    /// let bound: Function<fn() -> Number> = f.bind(&ctx, (&my_string, &my_bool));
4740    /// ```
4741    ///
4742    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4743    #[cfg(js_sys_unstable_apis)]
4744    #[inline]
4745    pub fn bind<Args: JsArgs<T>>(&self, context: &JsValue, args: Args) -> Args::BindOutput {
4746        args.apply_bind(self, context)
4747    }
4748}
4749
4750pub trait FunctionIntoClosure: JsFunction {
4751    type ClosureTypeMut: WasmClosure + ?Sized;
4752}
4753
4754macro_rules! impl_function_into_closure {
4755    ( $(($($var:ident)*))* ) => {$(
4756        impl<$($var: FromWasmAbi + JsGeneric,)* R: IntoWasmAbi + JsGeneric> FunctionIntoClosure for fn($($var),*) -> R {
4757            type ClosureTypeMut = dyn FnMut($($var),*) -> R;
4758        }
4759    )*};
4760}
4761
4762impl_function_into_closure! {
4763    ()
4764    (A)
4765    (A B)
4766    (A B C)
4767    (A B C D)
4768    (A B C D E)
4769    (A B C D E F)
4770    (A B C D E F G)
4771    (A B C D E F G H)
4772}
4773
4774impl<F: JsFunction> Function<F> {
4775    /// Convert a borrowed `ScopedClosure` into a typed JavaScript Function reference.
4776    ///
4777    /// The conversion is a direct type-safe conversion and upcast of a
4778    /// closure into its corresponding typed JavaScript Function,
4779    /// based on covariance and contravariance [`Upcast`] trait hierarchy.
4780    ///
4781    /// For transferring ownership to JS, use [`Function::from_closure`].
4782    #[inline]
4783    pub fn closure_ref<'a, C>(closure: &'a ScopedClosure<'_, C>) -> &'a Self
4784    where
4785        F: FunctionIntoClosure,
4786        C: WasmClosure + ?Sized,
4787        <F as FunctionIntoClosure>::ClosureTypeMut: UpcastFrom<<C as WasmClosure>::AsMut>,
4788    {
4789        closure.as_js_value().unchecked_ref()
4790    }
4791
4792    /// Convert a Rust closure into a typed JavaScript Function.
4793    ///
4794    /// This function releases ownership of the closure to JS, and provides
4795    /// an owned function handle for the same closure.
4796    ///
4797    /// The conversion is a direct type-safe conversion and upcast of a
4798    /// closure into its corresponding typed JavaScript Function,
4799    /// based on covariance and contravariance [`Upcast`] trait hierarchy.
4800    ///
4801    /// This method is only supported for static closures which do not have
4802    /// borrowed lifetime data, and thus can be released into JS.
4803    ///
4804    /// For borrowed closures, which cannot cede ownership to JS,
4805    /// instead use [`Function::closure_ref`].
4806    #[inline]
4807    pub fn from_closure<C>(closure: ScopedClosure<'static, C>) -> Self
4808    where
4809        F: FunctionIntoClosure,
4810        C: WasmClosure + ?Sized,
4811        <F as FunctionIntoClosure>::ClosureTypeMut: UpcastFrom<<C as WasmClosure>::AsMut>,
4812    {
4813        closure.into_js_value().unchecked_into()
4814    }
4815}
4816
4817#[cfg(not(js_sys_unstable_apis))]
4818impl Function {
4819    /// Returns the `Function` value of this JS value if it's an instance of a
4820    /// function.
4821    ///
4822    /// If this JS value is not an instance of a function then this returns
4823    /// `None`.
4824    #[deprecated(note = "recommended to use dyn_ref instead which is now equivalent")]
4825    pub fn try_from(val: &JsValue) -> Option<&Function> {
4826        val.dyn_ref()
4827    }
4828}
4829
4830#[cfg(feature = "unsafe-eval")]
4831impl Default for Function {
4832    fn default() -> Self {
4833        Self::new_no_args("")
4834    }
4835}
4836
4837// Generator
4838#[wasm_bindgen]
4839extern "C" {
4840    #[wasm_bindgen(extends = Object, typescript_type = "Generator<any, any, any>")]
4841    #[derive(Clone, Debug, PartialEq, Eq)]
4842    pub type Generator<T = JsValue>;
4843
4844    /// The `next()` method returns an object with two properties done and value.
4845    /// You can also provide a parameter to the next method to send a value to the generator.
4846    ///
4847    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/next)
4848    #[cfg(not(js_sys_unstable_apis))]
4849    #[wasm_bindgen(method, catch)]
4850    pub fn next<T>(this: &Generator<T>, value: &T) -> Result<JsValue, JsValue>;
4851
4852    /// The `next()` method returns an object with two properties done and value.
4853    /// You can also provide a parameter to the next method to send a value to the generator.
4854    ///
4855    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/next)
4856    #[cfg(js_sys_unstable_apis)]
4857    #[wasm_bindgen(method, catch, js_name = next)]
4858    pub fn next<T: FromWasmAbi>(this: &Generator<T>, value: &T)
4859        -> Result<IteratorNext<T>, JsValue>;
4860
4861    // Next major: deprecate
4862    /// The `next()` method returns an object with two properties done and value.
4863    /// You can also provide a parameter to the next method to send a value to the generator.
4864    ///
4865    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/next)
4866    #[wasm_bindgen(method, catch)]
4867    pub fn next_iterator<T: FromWasmAbi>(
4868        this: &Generator<T>,
4869        value: &T,
4870    ) -> Result<IteratorNext<T>, JsValue>;
4871
4872    /// The `return()` method returns the given value and finishes the generator.
4873    ///
4874    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/return)
4875    #[cfg(not(js_sys_unstable_apis))]
4876    #[wasm_bindgen(method, js_name = "return")]
4877    pub fn return_<T>(this: &Generator<T>, value: &T) -> JsValue;
4878
4879    /// The `return()` method returns the given value and finishes the generator.
4880    ///
4881    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/return)
4882    #[cfg(js_sys_unstable_apis)]
4883    #[wasm_bindgen(method, catch, js_name = "return")]
4884    pub fn return_<T: FromWasmAbi>(
4885        this: &Generator<T>,
4886        value: &T,
4887    ) -> Result<IteratorNext<T>, JsValue>;
4888
4889    // Next major: deprecate
4890    /// The `return()` method returns the given value and finishes the generator.
4891    ///
4892    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/return)
4893    #[wasm_bindgen(method, catch, js_name = "return")]
4894    pub fn try_return<T: FromWasmAbi>(
4895        this: &Generator<T>,
4896        value: &T,
4897    ) -> Result<IteratorNext<T>, JsValue>;
4898
4899    /// The `throw()` method resumes the execution of a generator by throwing an error into it
4900    /// and returns an object with two properties done and value.
4901    ///
4902    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/throw)
4903    #[cfg(not(js_sys_unstable_apis))]
4904    #[wasm_bindgen(method, catch)]
4905    pub fn throw<T>(this: &Generator<T>, error: &Error) -> Result<JsValue, JsValue>;
4906
4907    /// The `throw()` method resumes the execution of a generator by throwing an error into it
4908    /// and returns an object with two properties done and value.
4909    ///
4910    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/throw)
4911    #[cfg(js_sys_unstable_apis)]
4912    #[wasm_bindgen(method, catch, js_name = throw)]
4913    pub fn throw<T: FromWasmAbi>(
4914        this: &Generator<T>,
4915        error: &JsValue,
4916    ) -> Result<IteratorNext<T>, JsValue>;
4917
4918    // Next major: deprecate
4919    /// The `throw()` method resumes the execution of a generator by throwing an error into it
4920    /// and returns an object with two properties done and value.
4921    ///
4922    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/throw)
4923    #[wasm_bindgen(method, catch, js_name = throw)]
4924    pub fn throw_value<T: FromWasmAbi>(
4925        this: &Generator<T>,
4926        error: &JsValue,
4927    ) -> Result<IteratorNext<T>, JsValue>;
4928}
4929
4930impl<T: FromWasmAbi> Iterable for Generator<T> {
4931    type Item = T;
4932}
4933
4934// AsyncGenerator
4935#[wasm_bindgen]
4936extern "C" {
4937    #[wasm_bindgen(extends = Object, typescript_type = "AsyncGenerator<any, any, any>")]
4938    #[derive(Clone, Debug, PartialEq, Eq)]
4939    pub type AsyncGenerator<T = JsValue>;
4940
4941    /// The `next()` method returns an object with two properties done and value.
4942    /// You can also provide a parameter to the next method to send a value to the generator.
4943    ///
4944    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncGenerator/next)
4945    #[wasm_bindgen(method, catch)]
4946    pub fn next<T>(
4947        this: &AsyncGenerator<T>,
4948        value: &T,
4949    ) -> Result<Promise<IteratorNext<T>>, JsValue>;
4950
4951    /// The `return()` method returns the given value and finishes the generator.
4952    ///
4953    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncGenerator/return)
4954    #[wasm_bindgen(method, js_name = "return", catch)]
4955    pub fn return_<T>(
4956        this: &AsyncGenerator<T>,
4957        value: &T,
4958    ) -> Result<Promise<IteratorNext<T>>, JsValue>;
4959
4960    /// The `throw()` method resumes the execution of a generator by throwing an error into it
4961    /// and returns an object with two properties done and value.
4962    ///
4963    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncGenerator/throw)
4964    #[wasm_bindgen(method, catch)]
4965    pub fn throw<T>(
4966        this: &AsyncGenerator<T>,
4967        error: &JsValue,
4968    ) -> Result<Promise<IteratorNext<T>>, JsValue>;
4969}
4970
4971impl<T: FromWasmAbi> AsyncIterable for AsyncGenerator<T> {
4972    type Item = T;
4973}
4974
4975// Map
4976#[wasm_bindgen]
4977extern "C" {
4978    #[wasm_bindgen(extends = Object, typescript_type = "Map<any, any>")]
4979    #[derive(Clone, Debug, PartialEq, Eq)]
4980    pub type Map<K = JsValue, V = JsValue>;
4981
4982    /// The Map object holds key-value pairs. Any value (both objects and
4983    /// primitive values) maybe used as either a key or a value.
4984    ///
4985    /// **Note:** Consider using [`Map::new_typed`] for typing support.
4986    ///
4987    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
4988    #[cfg(not(js_sys_unstable_apis))]
4989    #[wasm_bindgen(constructor)]
4990    pub fn new() -> Map;
4991
4992    /// The Map object holds key-value pairs. Any value (both objects and
4993    /// primitive values) maybe used as either a key or a value.
4994    ///
4995    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
4996    #[cfg(js_sys_unstable_apis)]
4997    #[wasm_bindgen(constructor)]
4998    pub fn new<K, V>() -> Map<K, V>;
4999
5000    // Next major: deprecate
5001    /// The Map object holds key-value pairs. Any value (both objects and
5002    /// primitive values) maybe used as either a key or a value.
5003    ///
5004    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
5005    #[wasm_bindgen(constructor)]
5006    pub fn new_typed<K, V>() -> Map<K, V>;
5007
5008    /// The Map object holds key-value pairs. Any value (both objects and
5009    /// primitive values) maybe used as either a key or a value.
5010    ///
5011    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
5012    #[wasm_bindgen(constructor, js_name = new)]
5013    pub fn new_from_entries<K, V, I: Iterable<Item = ArrayTuple<(K, V)>>>(entries: &I)
5014        -> Map<K, V>;
5015
5016    /// The `clear()` method removes all elements from a Map object.
5017    ///
5018    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/clear)
5019    #[wasm_bindgen(method)]
5020    pub fn clear<K, V>(this: &Map<K, V>);
5021
5022    /// The `delete()` method removes the specified element from a Map object.
5023    ///
5024    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/delete)
5025    #[wasm_bindgen(method)]
5026    pub fn delete<K, V>(this: &Map<K, V>, key: &K) -> bool;
5027
5028    /// The `forEach()` method executes a provided function once per each
5029    /// key/value pair in the Map object, in insertion order.
5030    /// Note that in Javascript land the `Key` and `Value` are reversed compared to normal expectations:
5031    /// # Examples
5032    /// ```
5033    /// let js_map = Map::new();
5034    /// js_map.for_each(&mut |value, key| {
5035    ///     // Do something here...
5036    /// })
5037    /// ```
5038    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach)
5039    #[wasm_bindgen(method, js_name = forEach)]
5040    pub fn for_each<K, V>(this: &Map<K, V>, callback: &mut dyn FnMut(V, K));
5041
5042    /// The `forEach()` method executes a provided function once per each
5043    /// key/value pair in the Map object, in insertion order. _(Fallible variation)_
5044    /// Note that in Javascript land the `Key` and `Value` are reversed compared to normal expectations:
5045    /// # Examples
5046    /// ```
5047    /// let js_map = Map::new();
5048    /// js_map.for_each(&mut |value, key| {
5049    ///     // Do something here...
5050    /// })
5051    /// ```
5052    ///
5053    /// **Note:** Consider using [`Map::try_for_each`] if the callback might throw an error.
5054    ///
5055    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach)
5056    #[wasm_bindgen(method, js_name = forEach, catch)]
5057    pub fn try_for_each<K, V>(
5058        this: &Map<K, V>,
5059        callback: &mut dyn FnMut(V, K) -> Result<(), JsError>,
5060    ) -> Result<(), JsValue>;
5061
5062    /// The `get()` method returns a specified element from a Map object.
5063    /// Returns `undefined` if the key is not found.
5064    ///
5065    /// **Note:** Consider using [`Map::get_checked`] to get an `Option<V>` instead.
5066    ///
5067    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get)
5068    #[cfg(not(js_sys_unstable_apis))]
5069    #[wasm_bindgen(method)]
5070    pub fn get<K, V>(this: &Map<K, V>, key: &K) -> V;
5071
5072    /// The `get()` method returns a specified element from a Map object.
5073    /// Returns `None` if the key is not found.
5074    ///
5075    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get)
5076    #[cfg(js_sys_unstable_apis)]
5077    #[wasm_bindgen(method)]
5078    pub fn get<K, V>(this: &Map<K, V>, key: &K) -> Option<V>;
5079
5080    /// The `get()` method returns a specified element from a Map object.
5081    /// Returns `None` if the key is not found.
5082    ///
5083    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get)
5084    #[wasm_bindgen(method, js_name = get)]
5085    pub fn get_checked<K, V>(this: &Map<K, V>, key: &K) -> Option<V>;
5086
5087    /// The `has()` method returns a boolean indicating whether an element with
5088    /// the specified key exists or not.
5089    ///
5090    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has)
5091    #[wasm_bindgen(method)]
5092    pub fn has<K, V>(this: &Map<K, V>, key: &K) -> bool;
5093
5094    /// The `set()` method adds or updates an element with a specified key
5095    /// and value to a Map object.
5096    ///
5097    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/set)
5098    #[wasm_bindgen(method)]
5099    pub fn set<K, V>(this: &Map<K, V>, key: &K, value: &V) -> Map<K, V>;
5100
5101    /// The value of size is an integer representing how many entries
5102    /// the Map object has. A set accessor function for size is undefined;
5103    /// you can not change this property.
5104    ///
5105    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/size)
5106    #[wasm_bindgen(method, getter)]
5107    pub fn size<K, V>(this: &Map<K, V>) -> u32;
5108}
5109
5110impl Default for Map<JsValue, JsValue> {
5111    fn default() -> Self {
5112        Self::new()
5113    }
5114}
5115
5116// Map Iterator
5117#[wasm_bindgen]
5118extern "C" {
5119    /// The `entries()` method returns a new Iterator object that contains
5120    /// the [key, value] pairs for each element in the Map object in
5121    /// insertion order.
5122    ///
5123    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/entries)
5124    #[cfg(not(js_sys_unstable_apis))]
5125    #[wasm_bindgen(method)]
5126    pub fn entries<K, V: FromWasmAbi>(this: &Map<K, V>) -> Iterator;
5127
5128    /// The `entries()` method returns a new Iterator object that contains
5129    /// the [key, value] pairs for each element in the Map object in
5130    /// insertion order.
5131    ///
5132    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/entries)
5133    #[cfg(js_sys_unstable_apis)]
5134    #[wasm_bindgen(method, js_name = entries)]
5135    pub fn entries<K: JsGeneric, V: FromWasmAbi + JsGeneric>(
5136        this: &Map<K, V>,
5137    ) -> Iterator<ArrayTuple<(K, V)>>;
5138
5139    // Next major: deprecate
5140    /// The `entries()` method returns a new Iterator object that contains
5141    /// the [key, value] pairs for each element in the Map object in
5142    /// insertion order.
5143    ///
5144    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/entries)
5145    #[wasm_bindgen(method, js_name = entries)]
5146    pub fn entries_typed<K: JsGeneric, V: FromWasmAbi + JsGeneric>(
5147        this: &Map<K, V>,
5148    ) -> Iterator<ArrayTuple<(K, V)>>;
5149
5150    /// The `keys()` method returns a new Iterator object that contains the
5151    /// keys for each element in the Map object in insertion order.
5152    ///
5153    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/keys)
5154    #[wasm_bindgen(method)]
5155    pub fn keys<K: FromWasmAbi, V: FromWasmAbi>(this: &Map<K, V>) -> Iterator<K>;
5156
5157    /// The `values()` method returns a new Iterator object that contains the
5158    /// values for each element in the Map object in insertion order.
5159    ///
5160    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/values)
5161    #[wasm_bindgen(method)]
5162    pub fn values<K, V: FromWasmAbi>(this: &Map<K, V>) -> Iterator<V>;
5163}
5164
5165impl<K, V> Iterable for Map<K, V> {
5166    type Item = ArrayTuple<(K, V)>;
5167}
5168
5169// Iterator
5170#[wasm_bindgen]
5171extern "C" {
5172    /// Any object that conforms to the JS iterator protocol. For example,
5173    /// something returned by `myArray[Symbol.iterator]()`.
5174    ///
5175    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols)
5176    #[derive(Clone, Debug)]
5177    #[wasm_bindgen(is_type_of = Iterator::looks_like_iterator, typescript_type = "Iterator<any>")]
5178    pub type Iterator<T = JsValue>;
5179
5180    /// The `next()` method always has to return an object with appropriate
5181    /// properties including done and value. If a non-object value gets returned
5182    /// (such as false or undefined), a TypeError ("iterator.next() returned a
5183    /// non-object value") will be thrown.
5184    #[wasm_bindgen(catch, method)]
5185    pub fn next<T: FromWasmAbi>(this: &Iterator<T>) -> Result<IteratorNext<T>, JsValue>;
5186}
5187
5188impl<T> UpcastFrom<Iterator<T>> for Object {}
5189
5190impl Iterator {
5191    fn looks_like_iterator(it: &JsValue) -> bool {
5192        #[wasm_bindgen]
5193        extern "C" {
5194            #[derive(Clone, Debug)]
5195            type MaybeIterator;
5196
5197            #[wasm_bindgen(method, getter)]
5198            fn next(this: &MaybeIterator) -> JsValue;
5199        }
5200
5201        if !it.is_object() {
5202            return false;
5203        }
5204
5205        let it = it.unchecked_ref::<MaybeIterator>();
5206
5207        it.next().is_function()
5208    }
5209}
5210
5211// iterators in JS are themselves iterable
5212impl<T> Iterable for Iterator<T> {
5213    type Item = T;
5214}
5215
5216// Async Iterator
5217#[wasm_bindgen]
5218extern "C" {
5219    /// Any object that conforms to the JS async iterator protocol. For example,
5220    /// something returned by `myObject[Symbol.asyncIterator]()`.
5221    ///
5222    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of)
5223    #[derive(Clone, Debug)]
5224    #[wasm_bindgen(is_type_of = Iterator::looks_like_iterator, typescript_type = "AsyncIterator<any>")]
5225    pub type AsyncIterator<T = JsValue>;
5226
5227    /// The `next()` method always has to return a Promise which resolves to an object
5228    /// with appropriate properties including done and value. If a non-object value
5229    /// gets returned (such as false or undefined), a TypeError ("iterator.next()
5230    /// returned a non-object value") will be thrown.
5231    #[cfg(not(js_sys_unstable_apis))]
5232    #[wasm_bindgen(catch, method)]
5233    pub fn next<T>(this: &AsyncIterator<T>) -> Result<Promise, JsValue>;
5234
5235    /// The `next()` method always has to return a Promise which resolves to an object
5236    /// with appropriate properties including done and value. If a non-object value
5237    /// gets returned (such as false or undefined), a TypeError ("iterator.next()
5238    /// returned a non-object value") will be thrown.
5239    #[cfg(js_sys_unstable_apis)]
5240    #[wasm_bindgen(catch, method, js_name = next)]
5241    pub fn next<T: FromWasmAbi>(
5242        this: &AsyncIterator<T>,
5243    ) -> Result<Promise<IteratorNext<T>>, JsValue>;
5244
5245    // Next major: deprecate
5246    /// The `next()` method always has to return a Promise which resolves to an object
5247    /// with appropriate properties including done and value. If a non-object value
5248    /// gets returned (such as false or undefined), a TypeError ("iterator.next()
5249    /// returned a non-object value") will be thrown.
5250    #[wasm_bindgen(catch, method, js_name = next)]
5251    pub fn next_iterator<T: FromWasmAbi>(
5252        this: &AsyncIterator<T>,
5253    ) -> Result<Promise<IteratorNext<T>>, JsValue>;
5254}
5255
5256impl<T> UpcastFrom<AsyncIterator<T>> for Object {}
5257
5258// iterators in JS are themselves iterable
5259impl<T> AsyncIterable for AsyncIterator<T> {
5260    type Item = T;
5261}
5262
5263/// An iterator over the JS `Symbol.iterator` iteration protocol.
5264///
5265/// Use the `IntoIterator for &js_sys::Iterator` implementation to create this.
5266pub struct Iter<'a, T = JsValue> {
5267    js: &'a Iterator<T>,
5268    state: IterState,
5269}
5270
5271/// An iterator over the JS `Symbol.iterator` iteration protocol.
5272///
5273/// Use the `IntoIterator for js_sys::Iterator` implementation to create this.
5274pub struct IntoIter<T = JsValue> {
5275    js: Iterator<T>,
5276    state: IterState,
5277}
5278
5279struct IterState {
5280    done: bool,
5281}
5282
5283impl<'a, T: FromWasmAbi + JsGeneric> IntoIterator for &'a Iterator<T> {
5284    type Item = Result<T, JsValue>;
5285    type IntoIter = Iter<'a, T>;
5286
5287    fn into_iter(self) -> Iter<'a, T> {
5288        Iter {
5289            js: self,
5290            state: IterState::new(),
5291        }
5292    }
5293}
5294
5295impl<T: FromWasmAbi + JsGeneric> core::iter::Iterator for Iter<'_, T> {
5296    type Item = Result<T, JsValue>;
5297
5298    fn next(&mut self) -> Option<Self::Item> {
5299        self.state.next(self.js)
5300    }
5301}
5302
5303impl<T: FromWasmAbi + JsGeneric> IntoIterator for Iterator<T> {
5304    type Item = Result<T, JsValue>;
5305    type IntoIter = IntoIter<T>;
5306
5307    fn into_iter(self) -> IntoIter<T> {
5308        IntoIter {
5309            js: self,
5310            state: IterState::new(),
5311        }
5312    }
5313}
5314
5315impl<T: FromWasmAbi + JsGeneric> core::iter::Iterator for IntoIter<T> {
5316    type Item = Result<T, JsValue>;
5317
5318    fn next(&mut self) -> Option<Self::Item> {
5319        self.state.next(&self.js)
5320    }
5321}
5322
5323impl IterState {
5324    fn new() -> IterState {
5325        IterState { done: false }
5326    }
5327
5328    fn next<T: FromWasmAbi + JsGeneric>(&mut self, js: &Iterator<T>) -> Option<Result<T, JsValue>> {
5329        if self.done {
5330            return None;
5331        }
5332        let next = match js.next() {
5333            Ok(val) => val,
5334            Err(e) => {
5335                self.done = true;
5336                return Some(Err(e));
5337            }
5338        };
5339        if next.done() {
5340            self.done = true;
5341            None
5342        } else {
5343            Some(Ok(next.value()))
5344        }
5345    }
5346}
5347
5348/// Create an iterator over `val` using the JS iteration protocol and
5349/// `Symbol.iterator`.
5350// #[cfg(not(js_sys_unstable_apis))]
5351pub fn try_iter(val: &JsValue) -> Result<Option<IntoIter<JsValue>>, JsValue> {
5352    let iter_sym = Symbol::iterator();
5353
5354    let iter_fn = Reflect::get_symbol::<Object>(val.unchecked_ref(), iter_sym.as_ref())?;
5355    let iter_fn: Function = match iter_fn.dyn_into() {
5356        Ok(iter_fn) => iter_fn,
5357        Err(_) => return Ok(None),
5358    };
5359
5360    let it: Iterator = match iter_fn.call0(val)?.dyn_into() {
5361        Ok(it) => it,
5362        Err(_) => return Ok(None),
5363    };
5364
5365    Ok(Some(it.into_iter()))
5366}
5367
5368/// Trait for JavaScript types that implement the iterable protocol via `Symbol.iterator`.
5369///
5370/// Types implementing this trait can be iterated over using JavaScript's iteration
5371/// protocol. The `Item` associated type specifies the type of values yielded.
5372///
5373/// ## Built-in Iterables
5374///
5375/// Many `js-sys` collection types implement `Iterable` out of the box:
5376///
5377/// ```ignore
5378/// use js_sys::{Array, Map, Set};
5379///
5380/// // Array<T> yields T
5381/// let arr: Array<Number> = get_numbers();
5382/// for value in arr.iter() {
5383///     let num: Number = value?;
5384/// }
5385///
5386/// // Map<K, V> yields Array (key-value pairs)
5387/// let map: Map<JsString, Number> = get_map();
5388/// for entry in map.iter() {
5389///     let pair: Array = entry?;
5390/// }
5391///
5392/// // Set<T> yields T
5393/// let set: Set<JsString> = get_set();
5394/// for value in set.iter() {
5395///     let s: JsString = value?;
5396/// }
5397/// ```
5398///
5399/// ## Typing Foreign Iterators
5400///
5401/// If you have a JavaScript value that implements the iterator protocol (has a `next()`
5402/// method) but isn't a built-in type, you can use [`JsCast`] to cast it to [`Iterator<T>`]:
5403///
5404/// ```ignore
5405/// use js_sys::Iterator;
5406/// use wasm_bindgen::JsCast;
5407///
5408/// // For a value you know implements the iterator protocol
5409/// fn process_iterator(js_iter: JsValue) {
5410///     // Checked cast - returns None if not an iterator
5411///     if let Some(iter) = js_iter.dyn_ref::<Iterator<Number>>() {
5412///         for value in iter.into_iter() {
5413///             let num: Number = value.unwrap();
5414///             // ...
5415///         }
5416///     }
5417/// }
5418///
5419/// // Or with unchecked cast when you're certain of the type
5420/// fn process_known_iterator(js_iter: JsValue) {
5421///     let iter: &Iterator<JsString> = js_iter.unchecked_ref();
5422///     for value in iter.into_iter() {
5423///         let s: JsString = value.unwrap();
5424///         // ...
5425///     }
5426/// }
5427/// ```
5428///
5429/// ## Using with `JsValue`
5430///
5431/// For dynamic or unknown iterables, use [`try_iter`] which returns an untyped iterator:
5432///
5433/// ```ignore
5434/// fn iterate_unknown(val: &JsValue) -> Result<(), JsValue> {
5435///     if let Some(iter) = js_sys::try_iter(val)? {
5436///         for item in iter {
5437///             let value: JsValue = item?;
5438///             // Handle dynamically...
5439///         }
5440///     }
5441///     Ok(())
5442/// }
5443/// ```
5444///
5445/// [`JsCast`]: wasm_bindgen::JsCast
5446/// [`Iterator<T>`]: Iterator
5447/// [`try_iter`]: crate::try_iter
5448pub trait Iterable {
5449    /// The type of values yielded by this iterable.
5450    type Item;
5451}
5452
5453impl<T: Iterable> Iterable for &T {
5454    type Item = T::Item;
5455}
5456
5457/// Trait for types known to implement the iterator protocol on Symbol.asyncIterator
5458pub trait AsyncIterable {
5459    type Item;
5460}
5461
5462impl<T: AsyncIterable> AsyncIterable for &T {
5463    type Item = T::Item;
5464}
5465
5466impl AsyncIterable for JsValue {
5467    type Item = JsValue;
5468}
5469
5470// IteratorNext
5471#[wasm_bindgen]
5472extern "C" {
5473    /// The result of calling `next()` on a JS iterator.
5474    ///
5475    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols)
5476    #[wasm_bindgen(extends = Object, typescript_type = "IteratorResult<any>")]
5477    #[derive(Clone, Debug, PartialEq, Eq)]
5478    pub type IteratorNext<T = JsValue>;
5479
5480    /// Has the value `true` if the iterator is past the end of the iterated
5481    /// sequence. In this case value optionally specifies the return value of
5482    /// the iterator.
5483    ///
5484    /// Has the value `false` if the iterator was able to produce the next value
5485    /// in the sequence. This is equivalent of not specifying the done property
5486    /// altogether.
5487    #[wasm_bindgen(method, getter)]
5488    pub fn done<T>(this: &IteratorNext<T>) -> bool;
5489
5490    /// Any JavaScript value returned by the iterator. Can be omitted when done
5491    /// is true.
5492    #[wasm_bindgen(method, getter)]
5493    pub fn value<T>(this: &IteratorNext<T>) -> T;
5494}
5495
5496#[allow(non_snake_case)]
5497pub mod Math {
5498    use super::*;
5499
5500    // Math
5501    #[wasm_bindgen]
5502    extern "C" {
5503        /// The `Math.abs()` function returns the absolute value of a number, that is
5504        /// Math.abs(x) = |x|
5505        ///
5506        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs)
5507        #[wasm_bindgen(js_namespace = Math)]
5508        pub fn abs(x: f64) -> f64;
5509
5510        /// The `Math.acos()` function returns the arccosine (in radians) of a
5511        /// number, that is ∀x∊[-1;1]
5512        /// Math.acos(x) = arccos(x) = the unique y∊[0;π] such that cos(y)=x
5513        ///
5514        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acos)
5515        #[wasm_bindgen(js_namespace = Math)]
5516        pub fn acos(x: f64) -> f64;
5517
5518        /// The `Math.acosh()` function returns the hyperbolic arc-cosine of a
5519        /// number, that is ∀x ≥ 1
5520        /// Math.acosh(x) = arcosh(x) = the unique y ≥ 0 such that cosh(y) = x
5521        ///
5522        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acosh)
5523        #[wasm_bindgen(js_namespace = Math)]
5524        pub fn acosh(x: f64) -> f64;
5525
5526        /// The `Math.asin()` function returns the arcsine (in radians) of a
5527        /// number, that is ∀x ∊ [-1;1]
5528        /// Math.asin(x) = arcsin(x) = the unique y∊[-π2;π2] such that sin(y) = x
5529        ///
5530        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asin)
5531        #[wasm_bindgen(js_namespace = Math)]
5532        pub fn asin(x: f64) -> f64;
5533
5534        /// The `Math.asinh()` function returns the hyperbolic arcsine of a
5535        /// number, that is Math.asinh(x) = arsinh(x) = the unique y such that sinh(y) = x
5536        ///
5537        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asinh)
5538        #[wasm_bindgen(js_namespace = Math)]
5539        pub fn asinh(x: f64) -> f64;
5540
5541        /// The `Math.atan()` function returns the arctangent (in radians) of a
5542        /// number, that is Math.atan(x) = arctan(x) = the unique y ∊ [-π2;π2]such that
5543        /// tan(y) = x
5544        #[wasm_bindgen(js_namespace = Math)]
5545        pub fn atan(x: f64) -> f64;
5546
5547        /// The `Math.atan2()` function returns the arctangent of the quotient of
5548        /// its arguments.
5549        ///
5550        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan2)
5551        #[wasm_bindgen(js_namespace = Math)]
5552        pub fn atan2(y: f64, x: f64) -> f64;
5553
5554        /// The `Math.atanh()` function returns the hyperbolic arctangent of a number,
5555        /// that is ∀x ∊ (-1,1), Math.atanh(x) = arctanh(x) = the unique y such that
5556        /// tanh(y) = x
5557        ///
5558        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atanh)
5559        #[wasm_bindgen(js_namespace = Math)]
5560        pub fn atanh(x: f64) -> f64;
5561
5562        /// The `Math.cbrt() `function returns the cube root of a number, that is
5563        /// Math.cbrt(x) = ∛x = the unique y such that y^3 = x
5564        ///
5565        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt)
5566        #[wasm_bindgen(js_namespace = Math)]
5567        pub fn cbrt(x: f64) -> f64;
5568
5569        /// The `Math.ceil()` function returns the smallest integer greater than
5570        /// or equal to a given number.
5571        ///
5572        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil)
5573        #[wasm_bindgen(js_namespace = Math)]
5574        pub fn ceil(x: f64) -> f64;
5575
5576        /// The `Math.clz32()` function returns the number of leading zero bits in
5577        /// the 32-bit binary representation of a number.
5578        ///
5579        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32)
5580        #[wasm_bindgen(js_namespace = Math)]
5581        pub fn clz32(x: i32) -> u32;
5582
5583        /// The `Math.cos()` static function returns the cosine of the specified angle,
5584        /// which must be specified in radians. This value is length(adjacent)/length(hypotenuse).
5585        ///
5586        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cos)
5587        #[wasm_bindgen(js_namespace = Math)]
5588        pub fn cos(x: f64) -> f64;
5589
5590        /// The `Math.cosh()` function returns the hyperbolic cosine of a number,
5591        /// that can be expressed using the constant e.
5592        ///
5593        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cosh)
5594        #[wasm_bindgen(js_namespace = Math)]
5595        pub fn cosh(x: f64) -> f64;
5596
5597        /// The `Math.exp()` function returns e^x, where x is the argument, and e is Euler's number
5598        /// (also known as Napier's constant), the base of the natural logarithms.
5599        ///
5600        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/exp)
5601        #[wasm_bindgen(js_namespace = Math)]
5602        pub fn exp(x: f64) -> f64;
5603
5604        /// The `Math.expm1()` function returns e^x - 1, where x is the argument, and e the base of the
5605        /// natural logarithms.
5606        ///
5607        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/expm1)
5608        #[wasm_bindgen(js_namespace = Math)]
5609        pub fn expm1(x: f64) -> f64;
5610
5611        /// The `Math.floor()` function returns the largest integer less than or
5612        /// equal to a given number.
5613        ///
5614        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor)
5615        #[wasm_bindgen(js_namespace = Math)]
5616        pub fn floor(x: f64) -> f64;
5617
5618        /// The `Math.fround()` function returns the nearest 32-bit single precision float representation
5619        /// of a Number.
5620        ///
5621        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround)
5622        #[wasm_bindgen(js_namespace = Math)]
5623        pub fn fround(x: f64) -> f32;
5624
5625        /// The `Math.hypot()` function returns the square root of the sum of squares of its arguments.
5626        ///
5627        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot)
5628        #[wasm_bindgen(js_namespace = Math)]
5629        pub fn hypot(x: f64, y: f64) -> f64;
5630
5631        /// The `Math.imul()` function returns the result of the C-like 32-bit multiplication of the
5632        /// two parameters.
5633        ///
5634        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul)
5635        #[wasm_bindgen(js_namespace = Math)]
5636        pub fn imul(x: i32, y: i32) -> i32;
5637
5638        /// The `Math.log()` function returns the natural logarithm (base e) of a number.
5639        /// The JavaScript `Math.log()` function is equivalent to ln(x) in mathematics.
5640        ///
5641        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log)
5642        #[wasm_bindgen(js_namespace = Math)]
5643        pub fn log(x: f64) -> f64;
5644
5645        /// The `Math.log10()` function returns the base 10 logarithm of a number.
5646        ///
5647        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log10)
5648        #[wasm_bindgen(js_namespace = Math)]
5649        pub fn log10(x: f64) -> f64;
5650
5651        /// The `Math.log1p()` function returns the natural logarithm (base e) of 1 + a number.
5652        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log1p)
5653        #[wasm_bindgen(js_namespace = Math)]
5654        pub fn log1p(x: f64) -> f64;
5655
5656        /// The `Math.log2()` function returns the base 2 logarithm of a number.
5657        ///
5658        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log2)
5659        #[wasm_bindgen(js_namespace = Math)]
5660        pub fn log2(x: f64) -> f64;
5661
5662        /// The `Math.max()` function returns the largest of two numbers.
5663        ///
5664        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max)
5665        #[wasm_bindgen(js_namespace = Math)]
5666        pub fn max(x: f64, y: f64) -> f64;
5667
5668        /// The static function `Math.min()` returns the lowest-valued number passed into it.
5669        ///
5670        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min)
5671        #[wasm_bindgen(js_namespace = Math)]
5672        pub fn min(x: f64, y: f64) -> f64;
5673
5674        /// The `Math.pow()` function returns the base to the exponent power, that is, base^exponent.
5675        ///
5676        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow)
5677        #[wasm_bindgen(js_namespace = Math)]
5678        pub fn pow(base: f64, exponent: f64) -> f64;
5679
5680        /// The `Math.random()` function returns a floating-point, pseudo-random number
5681        /// in the range 0–1 (inclusive of 0, but not 1) with approximately uniform distribution
5682        /// over that range — which you can then scale to your desired range.
5683        /// The implementation selects the initial seed to the random number generation algorithm;
5684        /// it cannot be chosen or reset by the user.
5685        ///
5686        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random)
5687        #[wasm_bindgen(js_namespace = Math)]
5688        pub fn random() -> f64;
5689
5690        /// The `Math.round()` function returns the value of a number rounded to the nearest integer.
5691        ///
5692        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round)
5693        #[wasm_bindgen(js_namespace = Math)]
5694        pub fn round(x: f64) -> f64;
5695
5696        /// The `Math.sign()` function returns the sign of a number, indicating whether the number is
5697        /// positive, negative or zero.
5698        ///
5699        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign)
5700        #[wasm_bindgen(js_namespace = Math)]
5701        pub fn sign(x: f64) -> f64;
5702
5703        /// The `Math.sin()` function returns the sine of a number.
5704        ///
5705        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sin)
5706        #[wasm_bindgen(js_namespace = Math)]
5707        pub fn sin(x: f64) -> f64;
5708
5709        /// The `Math.sinh()` function returns the hyperbolic sine of a number, that can be expressed
5710        /// using the constant e: Math.sinh(x) = (e^x - e^-x)/2
5711        ///
5712        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sinh)
5713        #[wasm_bindgen(js_namespace = Math)]
5714        pub fn sinh(x: f64) -> f64;
5715
5716        /// The `Math.sqrt()` function returns the square root of a number, that is
5717        /// ∀x ≥ 0, Math.sqrt(x) = √x = the unique y ≥ 0 such that y^2 = x
5718        ///
5719        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sqrt)
5720        #[wasm_bindgen(js_namespace = Math)]
5721        pub fn sqrt(x: f64) -> f64;
5722
5723        /// The `Math.tan()` function returns the tangent of a number.
5724        ///
5725        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tan)
5726        #[wasm_bindgen(js_namespace = Math)]
5727        pub fn tan(x: f64) -> f64;
5728
5729        /// The `Math.tanh()` function returns the hyperbolic tangent of a number, that is
5730        /// tanh x = sinh x / cosh x = (e^x - e^-x)/(e^x + e^-x) = (e^2x - 1)/(e^2x + 1)
5731        ///
5732        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tanh)
5733        #[wasm_bindgen(js_namespace = Math)]
5734        pub fn tanh(x: f64) -> f64;
5735
5736        /// The `Math.trunc()` function returns the integer part of a number by removing any fractional
5737        /// digits.
5738        ///
5739        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc)
5740        #[wasm_bindgen(js_namespace = Math)]
5741        pub fn trunc(x: f64) -> f64;
5742
5743        /// The `Math.PI` property represents the ratio of the circumference of a circle to its diameter,
5744        /// approximately 3.14159.
5745        ///
5746        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/PI)
5747        #[wasm_bindgen(thread_local_v2, js_namespace = Math)]
5748        pub static PI: f64;
5749    }
5750}
5751
5752// Number.
5753#[wasm_bindgen]
5754extern "C" {
5755    #[wasm_bindgen(extends = Object, is_type_of = |v| v.as_f64().is_some(), typescript_type = "number")]
5756    #[derive(Clone, PartialEq)]
5757    pub type Number;
5758
5759    /// The `Number.isFinite()` method determines whether the passed value is a finite number.
5760    ///
5761    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite)
5762    #[wasm_bindgen(static_method_of = Number, js_name = isFinite)]
5763    pub fn is_finite(value: &JsValue) -> bool;
5764
5765    /// The `Number.isInteger()` method determines whether the passed value is an integer.
5766    ///
5767    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger)
5768    #[wasm_bindgen(static_method_of = Number, js_name = isInteger)]
5769    pub fn is_integer(value: &JsValue) -> bool;
5770
5771    /// The `Number.isNaN()` method determines whether the passed value is `NaN` and its type is Number.
5772    /// It is a more robust version of the original, global isNaN().
5773    ///
5774    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN)
5775    #[wasm_bindgen(static_method_of = Number, js_name = isNaN)]
5776    pub fn is_nan(value: &JsValue) -> bool;
5777
5778    /// The `Number.isSafeInteger()` method determines whether the provided value is a number
5779    /// that is a safe integer.
5780    ///
5781    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger)
5782    #[wasm_bindgen(static_method_of = Number, js_name = isSafeInteger)]
5783    pub fn is_safe_integer(value: &JsValue) -> bool;
5784
5785    /// The `Number` JavaScript object is a wrapper object allowing
5786    /// you to work with numerical values. A `Number` object is
5787    /// created using the `Number()` constructor.
5788    ///
5789    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)
5790    #[cfg(not(js_sys_unstable_apis))]
5791    #[wasm_bindgen(constructor)]
5792    #[deprecated(note = "recommended to use `Number::from` instead")]
5793    #[allow(deprecated)]
5794    pub fn new(value: &JsValue) -> Number;
5795
5796    #[wasm_bindgen(constructor)]
5797    fn new_from_str(value: &str) -> Number;
5798
5799    /// The `Number.parseInt()` method parses a string argument and returns an
5800    /// integer of the specified radix or base.
5801    ///
5802    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseInt)
5803    #[wasm_bindgen(static_method_of = Number, js_name = parseInt)]
5804    pub fn parse_int(text: &str, radix: u8) -> f64;
5805
5806    /// The `Number.parseFloat()` method parses a string argument and returns a
5807    /// floating point number.
5808    ///
5809    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseFloat)
5810    #[wasm_bindgen(static_method_of = Number, js_name = parseFloat)]
5811    pub fn parse_float(text: &str) -> f64;
5812
5813    /// The `toLocaleString()` method returns a string with a language sensitive
5814    /// representation of this number.
5815    ///
5816    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString)
5817    #[cfg(not(js_sys_unstable_apis))]
5818    #[wasm_bindgen(method, js_name = toLocaleString)]
5819    pub fn to_locale_string(this: &Number, locale: &str) -> JsString;
5820
5821    /// The `toLocaleString()` method returns a string with a language sensitive
5822    /// representation of this number.
5823    ///
5824    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString)
5825    #[cfg(js_sys_unstable_apis)]
5826    #[wasm_bindgen(method, js_name = toLocaleString)]
5827    pub fn to_locale_string(
5828        this: &Number,
5829        locales: &[JsString],
5830        options: &Intl::NumberFormatOptions,
5831    ) -> JsString;
5832
5833    /// The `toPrecision()` method returns a string representing the Number
5834    /// object to the specified precision.
5835    ///
5836    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision)
5837    #[wasm_bindgen(catch, method, js_name = toPrecision)]
5838    pub fn to_precision(this: &Number, precision: u8) -> Result<JsString, JsValue>;
5839
5840    /// The `toFixed()` method returns a string representing the Number
5841    /// object using fixed-point notation.
5842    ///
5843    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed)
5844    #[wasm_bindgen(catch, method, js_name = toFixed)]
5845    pub fn to_fixed(this: &Number, digits: u8) -> Result<JsString, JsValue>;
5846
5847    /// The `toExponential()` method returns a string representing the Number
5848    /// object in exponential notation.
5849    ///
5850    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential)
5851    #[wasm_bindgen(catch, method, js_name = toExponential)]
5852    pub fn to_exponential(this: &Number, fraction_digits: u8) -> Result<JsString, JsValue>;
5853
5854    /// The `toString()` method returns a string representing the
5855    /// specified Number object.
5856    ///
5857    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString)
5858    #[cfg(not(js_sys_unstable_apis))]
5859    #[deprecated(note = "Use `Number::to_string_with_radix` instead.")]
5860    #[allow(deprecated)]
5861    #[wasm_bindgen(catch, method, js_name = toString)]
5862    pub fn to_string(this: &Number, radix: u8) -> Result<JsString, JsValue>;
5863
5864    /// The `toString()` method returns a string representing the
5865    /// specified Number object.
5866    ///
5867    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString)
5868    #[wasm_bindgen(catch, method, js_name = toString)]
5869    pub fn to_string_with_radix(this: &Number, radix: u8) -> Result<JsString, JsValue>;
5870
5871    /// The `valueOf()` method returns the wrapped primitive value of
5872    /// a Number object.
5873    ///
5874    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/valueOf)
5875    #[wasm_bindgen(method, js_name = valueOf)]
5876    pub fn value_of(this: &Number) -> f64;
5877}
5878
5879impl Number {
5880    /// The smallest interval between two representable numbers.
5881    ///
5882    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON)
5883    pub const EPSILON: f64 = f64::EPSILON;
5884    /// The maximum safe integer in JavaScript (2^53 - 1).
5885    ///
5886    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)
5887    pub const MAX_SAFE_INTEGER: f64 = 9007199254740991.0;
5888    /// The largest positive representable number.
5889    ///
5890    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE)
5891    pub const MAX_VALUE: f64 = f64::MAX;
5892    /// The minimum safe integer in JavaScript (-(2^53 - 1)).
5893    ///
5894    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER)
5895    pub const MIN_SAFE_INTEGER: f64 = -9007199254740991.0;
5896    /// The smallest positive representable number—that is, the positive number closest to zero
5897    /// (without actually being zero).
5898    ///
5899    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_VALUE)
5900    // Cannot use f64::MIN_POSITIVE since that is the smallest **normal** positive number.
5901    pub const MIN_VALUE: f64 = 5E-324;
5902    /// Special "Not a Number" value.
5903    ///
5904    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NaN)
5905    pub const NAN: f64 = f64::NAN;
5906    /// Special value representing negative infinity. Returned on overflow.
5907    ///
5908    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY)
5909    pub const NEGATIVE_INFINITY: f64 = f64::NEG_INFINITY;
5910    /// Special value representing infinity. Returned on overflow.
5911    ///
5912    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY)
5913    pub const POSITIVE_INFINITY: f64 = f64::INFINITY;
5914
5915    /// Applies the binary `**` JS operator on the two `Number`s.
5916    ///
5917    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Exponentiation)
5918    #[inline]
5919    pub fn pow(&self, rhs: &Self) -> Self {
5920        JsValue::as_ref(self)
5921            .pow(JsValue::as_ref(rhs))
5922            .unchecked_into()
5923    }
5924
5925    /// Applies the binary `>>>` JS operator on the two `Number`s.
5926    ///
5927    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Unsigned_right_shift)
5928    #[inline]
5929    pub fn unsigned_shr(&self, rhs: &Self) -> Self {
5930        Number::from(JsValue::as_ref(self).unsigned_shr(JsValue::as_ref(rhs)))
5931    }
5932}
5933
5934macro_rules! number_from {
5935    ($($x:ident)*) => ($(
5936        impl From<$x> for Number {
5937            #[inline]
5938            fn from(x: $x) -> Number {
5939                Number::unchecked_from_js(JsValue::from(x))
5940            }
5941        }
5942
5943        impl PartialEq<$x> for Number {
5944            #[inline]
5945            fn eq(&self, other: &$x) -> bool {
5946                self.value_of() == f64::from(*other)
5947            }
5948        }
5949
5950        impl UpcastFrom<$x> for Number {}
5951    )*)
5952}
5953number_from!(i8 u8 i16 u16 i32 u32 f32 f64);
5954
5955// The only guarantee for a JS number
5956impl UpcastFrom<Number> for f64 {}
5957
5958/// The error type returned when a checked integral type conversion fails.
5959#[derive(Debug, Copy, Clone, PartialEq, Eq)]
5960pub struct TryFromIntError(());
5961
5962impl fmt::Display for TryFromIntError {
5963    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
5964        fmt.write_str("out of range integral type conversion attempted")
5965    }
5966}
5967
5968#[cfg(feature = "std")]
5969impl std::error::Error for TryFromIntError {}
5970
5971macro_rules! number_try_from {
5972    ($($x:ident)*) => ($(
5973        impl TryFrom<$x> for Number {
5974            type Error = TryFromIntError;
5975
5976            #[inline]
5977            fn try_from(x: $x) -> Result<Number, Self::Error> {
5978                let x_f64 = x as f64;
5979                if (Number::MIN_SAFE_INTEGER..=Number::MAX_SAFE_INTEGER).contains(&x_f64) {
5980                    Ok(Number::from(x_f64))
5981                } else {
5982                    Err(TryFromIntError(()))
5983                }
5984            }
5985        }
5986    )*)
5987}
5988number_try_from!(i64 u64 i128 u128);
5989
5990impl From<&Number> for f64 {
5991    #[inline]
5992    fn from(n: &Number) -> f64 {
5993        n.value_of()
5994    }
5995}
5996
5997impl From<Number> for f64 {
5998    #[inline]
5999    fn from(n: Number) -> f64 {
6000        <f64 as From<&'_ Number>>::from(&n)
6001    }
6002}
6003
6004impl fmt::Debug for Number {
6005    #[inline]
6006    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
6007        fmt::Debug::fmt(&self.value_of(), f)
6008    }
6009}
6010
6011impl fmt::Display for Number {
6012    #[inline]
6013    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
6014        fmt::Display::fmt(&self.value_of(), f)
6015    }
6016}
6017
6018impl Default for Number {
6019    fn default() -> Self {
6020        Self::from(f64::default())
6021    }
6022}
6023
6024impl PartialEq<BigInt> for Number {
6025    #[inline]
6026    fn eq(&self, other: &BigInt) -> bool {
6027        JsValue::as_ref(self).loose_eq(JsValue::as_ref(other))
6028    }
6029}
6030
6031impl Not for &Number {
6032    type Output = BigInt;
6033
6034    #[inline]
6035    fn not(self) -> Self::Output {
6036        JsValue::as_ref(self).bit_not().unchecked_into()
6037    }
6038}
6039
6040forward_deref_unop!(impl Not, not for Number);
6041forward_js_unop!(impl Neg, neg for Number);
6042forward_js_binop!(impl BitAnd, bitand for Number);
6043forward_js_binop!(impl BitOr, bitor for Number);
6044forward_js_binop!(impl BitXor, bitxor for Number);
6045forward_js_binop!(impl Shl, shl for Number);
6046forward_js_binop!(impl Shr, shr for Number);
6047forward_js_binop!(impl Add, add for Number);
6048forward_js_binop!(impl Sub, sub for Number);
6049forward_js_binop!(impl Div, div for Number);
6050forward_js_binop!(impl Mul, mul for Number);
6051forward_js_binop!(impl Rem, rem for Number);
6052
6053sum_product!(Number);
6054
6055impl PartialOrd for Number {
6056    #[inline]
6057    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
6058        if Number::is_nan(self) || Number::is_nan(other) {
6059            None
6060        } else if self == other {
6061            Some(Ordering::Equal)
6062        } else if self.lt(other) {
6063            Some(Ordering::Less)
6064        } else {
6065            Some(Ordering::Greater)
6066        }
6067    }
6068
6069    #[inline]
6070    fn lt(&self, other: &Self) -> bool {
6071        JsValue::as_ref(self).lt(JsValue::as_ref(other))
6072    }
6073
6074    #[inline]
6075    fn le(&self, other: &Self) -> bool {
6076        JsValue::as_ref(self).le(JsValue::as_ref(other))
6077    }
6078
6079    #[inline]
6080    fn ge(&self, other: &Self) -> bool {
6081        JsValue::as_ref(self).ge(JsValue::as_ref(other))
6082    }
6083
6084    #[inline]
6085    fn gt(&self, other: &Self) -> bool {
6086        JsValue::as_ref(self).gt(JsValue::as_ref(other))
6087    }
6088}
6089
6090#[cfg(not(js_sys_unstable_apis))]
6091impl FromStr for Number {
6092    type Err = Infallible;
6093
6094    #[allow(deprecated)]
6095    #[inline]
6096    fn from_str(s: &str) -> Result<Self, Self::Err> {
6097        Ok(Number::new_from_str(s))
6098    }
6099}
6100
6101// Date.
6102#[wasm_bindgen]
6103extern "C" {
6104    #[wasm_bindgen(extends = Object, typescript_type = "Date")]
6105    #[derive(Clone, Debug, PartialEq, Eq)]
6106    pub type Date;
6107
6108    /// The `getDate()` method returns the day of the month for the
6109    /// specified date according to local time.
6110    ///
6111    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDate)
6112    #[wasm_bindgen(method, js_name = getDate)]
6113    pub fn get_date(this: &Date) -> u32;
6114
6115    /// The `getDay()` method returns the day of the week for the specified date according to local time,
6116    /// where 0 represents Sunday. For the day of the month see getDate().
6117    ///
6118    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay)
6119    #[wasm_bindgen(method, js_name = getDay)]
6120    pub fn get_day(this: &Date) -> u32;
6121
6122    /// The `getFullYear()` method returns the year of the specified date according to local time.
6123    ///
6124    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getFullYear)
6125    #[wasm_bindgen(method, js_name = getFullYear)]
6126    pub fn get_full_year(this: &Date) -> u32;
6127
6128    /// The `getHours()` method returns the hour for the specified date, according to local time.
6129    ///
6130    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getHours)
6131    #[wasm_bindgen(method, js_name = getHours)]
6132    pub fn get_hours(this: &Date) -> u32;
6133
6134    /// The `getMilliseconds()` method returns the milliseconds in the specified date according to local time.
6135    ///
6136    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMilliseconds)
6137    #[wasm_bindgen(method, js_name = getMilliseconds)]
6138    pub fn get_milliseconds(this: &Date) -> u32;
6139
6140    /// The `getMinutes()` method returns the minutes in the specified date according to local time.
6141    ///
6142    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMinutes)
6143    #[wasm_bindgen(method, js_name = getMinutes)]
6144    pub fn get_minutes(this: &Date) -> u32;
6145
6146    /// The `getMonth()` method returns the month in the specified date according to local time,
6147    /// as a zero-based value (where zero indicates the first month of the year).
6148    ///
6149    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMonth)
6150    #[wasm_bindgen(method, js_name = getMonth)]
6151    pub fn get_month(this: &Date) -> u32;
6152
6153    /// The `getSeconds()` method returns the seconds in the specified date according to local time.
6154    ///
6155    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getSeconds)
6156    #[wasm_bindgen(method, js_name = getSeconds)]
6157    pub fn get_seconds(this: &Date) -> u32;
6158
6159    /// The `getTime()` method returns the numeric value corresponding to the time for the specified date
6160    /// according to universal time.
6161    ///
6162    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime)
6163    #[wasm_bindgen(method, js_name = getTime)]
6164    pub fn get_time(this: &Date) -> f64;
6165
6166    /// The `getTimezoneOffset()` method returns the time zone difference, in minutes,
6167    /// from current locale (host system settings) to UTC.
6168    ///
6169    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset)
6170    #[wasm_bindgen(method, js_name = getTimezoneOffset)]
6171    pub fn get_timezone_offset(this: &Date) -> f64;
6172
6173    /// The `getUTCDate()` method returns the day (date) of the month in the specified date
6174    /// according to universal time.
6175    ///
6176    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDate)
6177    #[wasm_bindgen(method, js_name = getUTCDate)]
6178    pub fn get_utc_date(this: &Date) -> u32;
6179
6180    /// The `getUTCDay()` method returns the day of the week in the specified date according to universal time,
6181    /// where 0 represents Sunday.
6182    ///
6183    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDay)
6184    #[wasm_bindgen(method, js_name = getUTCDay)]
6185    pub fn get_utc_day(this: &Date) -> u32;
6186
6187    /// The `getUTCFullYear()` method returns the year in the specified date according to universal time.
6188    ///
6189    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCFullYear)
6190    #[wasm_bindgen(method, js_name = getUTCFullYear)]
6191    pub fn get_utc_full_year(this: &Date) -> u32;
6192
6193    /// The `getUTCHours()` method returns the hours in the specified date according to universal time.
6194    ///
6195    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCHours)
6196    #[wasm_bindgen(method, js_name = getUTCHours)]
6197    pub fn get_utc_hours(this: &Date) -> u32;
6198
6199    /// The `getUTCMilliseconds()` method returns the milliseconds in the specified date
6200    /// according to universal time.
6201    ///
6202    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMilliseconds)
6203    #[wasm_bindgen(method, js_name = getUTCMilliseconds)]
6204    pub fn get_utc_milliseconds(this: &Date) -> u32;
6205
6206    /// The `getUTCMinutes()` method returns the minutes in the specified date according to universal time.
6207    ///
6208    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMinutes)
6209    #[wasm_bindgen(method, js_name = getUTCMinutes)]
6210    pub fn get_utc_minutes(this: &Date) -> u32;
6211
6212    /// The `getUTCMonth()` returns the month of the specified date according to universal time,
6213    /// as a zero-based value (where zero indicates the first month of the year).
6214    ///
6215    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMonth)
6216    #[wasm_bindgen(method, js_name = getUTCMonth)]
6217    pub fn get_utc_month(this: &Date) -> u32;
6218
6219    /// The `getUTCSeconds()` method returns the seconds in the specified date according to universal time.
6220    ///
6221    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCSeconds)
6222    #[wasm_bindgen(method, js_name = getUTCSeconds)]
6223    pub fn get_utc_seconds(this: &Date) -> u32;
6224
6225    /// Creates a JavaScript `Date` instance that represents
6226    /// a single moment in time. `Date` objects are based on a time value that is
6227    /// the number of milliseconds since 1 January 1970 UTC.
6228    ///
6229    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6230    #[wasm_bindgen(constructor)]
6231    pub fn new(init: &JsValue) -> Date;
6232
6233    /// Creates a JavaScript `Date` instance that represents the current moment in
6234    /// time.
6235    ///
6236    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6237    #[wasm_bindgen(constructor)]
6238    pub fn new_0() -> Date;
6239
6240    /// Creates a JavaScript `Date` instance that represents
6241    /// a single moment in time. `Date` objects are based on a time value that is
6242    /// the number of milliseconds since 1 January 1970 UTC.
6243    ///
6244    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6245    #[wasm_bindgen(constructor)]
6246    pub fn new_with_year_month(year: u32, month: i32) -> Date;
6247
6248    /// Creates a JavaScript `Date` instance that represents
6249    /// a single moment in time. `Date` objects are based on a time value that is
6250    /// the number of milliseconds since 1 January 1970 UTC.
6251    ///
6252    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6253    #[wasm_bindgen(constructor)]
6254    pub fn new_with_year_month_day(year: u32, month: i32, day: i32) -> Date;
6255
6256    /// Creates a JavaScript `Date` instance that represents
6257    /// a single moment in time. `Date` objects are based on a time value that is
6258    /// the number of milliseconds since 1 January 1970 UTC.
6259    ///
6260    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6261    #[wasm_bindgen(constructor)]
6262    pub fn new_with_year_month_day_hr(year: u32, month: i32, day: i32, hr: i32) -> Date;
6263
6264    /// Creates a JavaScript `Date` instance that represents
6265    /// a single moment in time. `Date` objects are based on a time value that is
6266    /// the number of milliseconds since 1 January 1970 UTC.
6267    ///
6268    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6269    #[wasm_bindgen(constructor)]
6270    pub fn new_with_year_month_day_hr_min(
6271        year: u32,
6272        month: i32,
6273        day: i32,
6274        hr: i32,
6275        min: i32,
6276    ) -> Date;
6277
6278    /// Creates a JavaScript `Date` instance that represents
6279    /// a single moment in time. `Date` objects are based on a time value that is
6280    /// the number of milliseconds since 1 January 1970 UTC.
6281    ///
6282    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6283    #[wasm_bindgen(constructor)]
6284    pub fn new_with_year_month_day_hr_min_sec(
6285        year: u32,
6286        month: i32,
6287        day: i32,
6288        hr: i32,
6289        min: i32,
6290        sec: i32,
6291    ) -> Date;
6292
6293    /// Creates a JavaScript `Date` instance that represents
6294    /// a single moment in time. `Date` objects are based on a time value that is
6295    /// the number of milliseconds since 1 January 1970 UTC.
6296    ///
6297    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6298    #[wasm_bindgen(constructor)]
6299    pub fn new_with_year_month_day_hr_min_sec_milli(
6300        year: u32,
6301        month: i32,
6302        day: i32,
6303        hr: i32,
6304        min: i32,
6305        sec: i32,
6306        milli: i32,
6307    ) -> Date;
6308
6309    /// The `Date.now()` method returns the number of milliseconds
6310    /// elapsed since January 1, 1970 00:00:00 UTC.
6311    ///
6312    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now)
6313    #[wasm_bindgen(static_method_of = Date)]
6314    pub fn now() -> f64;
6315
6316    /// The `Date.parse()` method parses a string representation of a date, and returns the number of milliseconds
6317    /// since January 1, 1970, 00:00:00 UTC or `NaN` if the string is unrecognized or, in some cases,
6318    /// contains illegal date values (e.g. 2015-02-31).
6319    ///
6320    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse)
6321    #[wasm_bindgen(static_method_of = Date)]
6322    pub fn parse(date: &str) -> f64;
6323
6324    /// The `setDate()` method sets the day of the Date object relative to the beginning of the currently set month.
6325    ///
6326    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setDate)
6327    #[wasm_bindgen(method, js_name = setDate)]
6328    pub fn set_date(this: &Date, day: u32) -> f64;
6329
6330    /// The `setFullYear()` method sets the full year for a specified date according to local time.
6331    /// Returns new timestamp.
6332    ///
6333    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear)
6334    #[wasm_bindgen(method, js_name = setFullYear)]
6335    pub fn set_full_year(this: &Date, year: u32) -> f64;
6336
6337    /// The `setFullYear()` method sets the full year for a specified date according to local time.
6338    /// Returns new timestamp.
6339    ///
6340    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear)
6341    #[wasm_bindgen(method, js_name = setFullYear)]
6342    pub fn set_full_year_with_month(this: &Date, year: u32, month: i32) -> f64;
6343
6344    /// The `setFullYear()` method sets the full year for a specified date according to local time.
6345    /// Returns new timestamp.
6346    ///
6347    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear)
6348    #[wasm_bindgen(method, js_name = setFullYear)]
6349    pub fn set_full_year_with_month_date(this: &Date, year: u32, month: i32, date: i32) -> f64;
6350
6351    /// The `setHours()` method sets the hours for a specified date according to local time,
6352    /// and returns the number of milliseconds since January 1, 1970 00:00:00 UTC until the time represented
6353    /// by the updated Date instance.
6354    ///
6355    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setHours)
6356    #[wasm_bindgen(method, js_name = setHours)]
6357    pub fn set_hours(this: &Date, hours: u32) -> f64;
6358
6359    /// The `setMilliseconds()` method sets the milliseconds for a specified date according to local time.
6360    ///
6361    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMilliseconds)
6362    #[wasm_bindgen(method, js_name = setMilliseconds)]
6363    pub fn set_milliseconds(this: &Date, milliseconds: u32) -> f64;
6364
6365    /// The `setMinutes()` method sets the minutes for a specified date according to local time.
6366    ///
6367    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMinutes)
6368    #[wasm_bindgen(method, js_name = setMinutes)]
6369    pub fn set_minutes(this: &Date, minutes: u32) -> f64;
6370
6371    /// The `setMonth()` method sets the month for a specified date according to the currently set year.
6372    ///
6373    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMonth)
6374    #[wasm_bindgen(method, js_name = setMonth)]
6375    pub fn set_month(this: &Date, month: u32) -> f64;
6376
6377    /// The `setSeconds()` method sets the seconds for a specified date according to local time.
6378    ///
6379    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setSeconds)
6380    #[wasm_bindgen(method, js_name = setSeconds)]
6381    pub fn set_seconds(this: &Date, seconds: u32) -> f64;
6382
6383    /// The `setTime()` method sets the Date object to the time represented by a number of milliseconds
6384    /// since January 1, 1970, 00:00:00 UTC.
6385    ///
6386    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setTime)
6387    #[wasm_bindgen(method, js_name = setTime)]
6388    pub fn set_time(this: &Date, time: f64) -> f64;
6389
6390    /// The `setUTCDate()` method sets the day of the month for a specified date
6391    /// according to universal time.
6392    ///
6393    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCDate)
6394    #[wasm_bindgen(method, js_name = setUTCDate)]
6395    pub fn set_utc_date(this: &Date, day: u32) -> f64;
6396
6397    /// The `setUTCFullYear()` method sets the full year for a specified date according to universal time.
6398    ///
6399    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear)
6400    #[wasm_bindgen(method, js_name = setUTCFullYear)]
6401    pub fn set_utc_full_year(this: &Date, year: u32) -> f64;
6402
6403    /// The `setUTCFullYear()` method sets the full year for a specified date according to universal time.
6404    ///
6405    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear)
6406    #[wasm_bindgen(method, js_name = setUTCFullYear)]
6407    pub fn set_utc_full_year_with_month(this: &Date, year: u32, month: i32) -> f64;
6408
6409    /// The `setUTCFullYear()` method sets the full year for a specified date according to universal time.
6410    ///
6411    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear)
6412    #[wasm_bindgen(method, js_name = setUTCFullYear)]
6413    pub fn set_utc_full_year_with_month_date(this: &Date, year: u32, month: i32, date: i32) -> f64;
6414
6415    /// The `setUTCHours()` method sets the hour for a specified date according to universal time,
6416    /// and returns the number of milliseconds since  January 1, 1970 00:00:00 UTC until the time
6417    /// represented by the updated Date instance.
6418    ///
6419    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCHours)
6420    #[wasm_bindgen(method, js_name = setUTCHours)]
6421    pub fn set_utc_hours(this: &Date, hours: u32) -> f64;
6422
6423    /// The `setUTCMilliseconds()` method sets the milliseconds for a specified date
6424    /// according to universal time.
6425    ///
6426    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMilliseconds)
6427    #[wasm_bindgen(method, js_name = setUTCMilliseconds)]
6428    pub fn set_utc_milliseconds(this: &Date, milliseconds: u32) -> f64;
6429
6430    /// The `setUTCMinutes()` method sets the minutes for a specified date according to universal time.
6431    ///
6432    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMinutes)
6433    #[wasm_bindgen(method, js_name = setUTCMinutes)]
6434    pub fn set_utc_minutes(this: &Date, minutes: u32) -> f64;
6435
6436    /// The `setUTCMonth()` method sets the month for a specified date according to universal time.
6437    ///
6438    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMonth)
6439    #[wasm_bindgen(method, js_name = setUTCMonth)]
6440    pub fn set_utc_month(this: &Date, month: u32) -> f64;
6441
6442    /// The `setUTCSeconds()` method sets the seconds for a specified date according to universal time.
6443    ///
6444    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCSeconds)
6445    #[wasm_bindgen(method, js_name = setUTCSeconds)]
6446    pub fn set_utc_seconds(this: &Date, seconds: u32) -> f64;
6447
6448    /// The `toDateString()` method returns the date portion of a Date object
6449    /// in human readable form in American English.
6450    ///
6451    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toDateString)
6452    #[wasm_bindgen(method, js_name = toDateString)]
6453    pub fn to_date_string(this: &Date) -> JsString;
6454
6455    /// The `toISOString()` method returns a string in simplified extended ISO format (ISO
6456    /// 8601), which is always 24 or 27 characters long (YYYY-MM-DDTHH:mm:ss.sssZ or
6457    /// ±YYYYYY-MM-DDTHH:mm:ss.sssZ, respectively). The timezone is always zero UTC offset,
6458    /// as denoted by the suffix "Z"
6459    ///
6460    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
6461    #[wasm_bindgen(method, js_name = toISOString)]
6462    pub fn to_iso_string(this: &Date) -> JsString;
6463
6464    /// The `toJSON()` method returns a string representation of the Date object.
6465    ///
6466    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toJSON)
6467    #[wasm_bindgen(method, js_name = toJSON)]
6468    pub fn to_json(this: &Date) -> JsString;
6469
6470    /// The `toLocaleDateString()` method returns a string with a language sensitive
6471    /// representation of the date portion of this date. The new locales and options
6472    /// arguments let applications specify the language whose formatting conventions
6473    /// should be used and allow to customize the behavior of the function.
6474    /// In older implementations, which ignore the locales and options arguments,
6475    /// 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/toLocaleDateString)
6479    #[cfg(not(js_sys_unstable_apis))]
6480    #[wasm_bindgen(method, js_name = toLocaleDateString)]
6481    pub fn to_locale_date_string(this: &Date, locale: &str, options: &JsValue) -> JsString;
6482
6483    /// The `toLocaleDateString()` method returns a string with a language sensitive
6484    /// representation of the date portion of this date.
6485    ///
6486    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString)
6487    #[cfg(js_sys_unstable_apis)]
6488    #[wasm_bindgen(method, js_name = toLocaleDateString)]
6489    pub fn to_locale_date_string(
6490        this: &Date,
6491        locales: &[JsString],
6492        options: &Intl::DateTimeFormatOptions,
6493    ) -> JsString;
6494
6495    /// The `toLocaleString()` method returns a string with a language sensitive
6496    /// representation of this date. The new locales and options arguments
6497    /// let applications specify the language whose formatting conventions
6498    /// should be used and customize the behavior of the function.
6499    /// In older implementations, which ignore the locales
6500    /// and options arguments, the locale used and the form of the string
6501    /// returned are entirely implementation dependent.
6502    ///
6503    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString)
6504    #[cfg(not(js_sys_unstable_apis))]
6505    #[wasm_bindgen(method, js_name = toLocaleString)]
6506    pub fn to_locale_string(this: &Date, locale: &str, options: &JsValue) -> JsString;
6507
6508    /// The `toLocaleString()` method returns a string with a language sensitive
6509    /// representation of this date.
6510    ///
6511    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString)
6512    #[cfg(js_sys_unstable_apis)]
6513    #[wasm_bindgen(method, js_name = toLocaleString)]
6514    pub fn to_locale_string(
6515        this: &Date,
6516        locales: &[JsString],
6517        options: &Intl::DateTimeFormatOptions,
6518    ) -> JsString;
6519
6520    /// The `toLocaleTimeString()` method returns a string with a language sensitive
6521    /// representation of the time portion of this date. The new locales and options
6522    /// arguments let applications specify the language whose formatting conventions should be
6523    /// used and customize the behavior of the function. In older implementations, which ignore
6524    /// the locales and options arguments, the locale used and the form of the string
6525    /// returned are entirely implementation dependent.
6526    ///
6527    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString)
6528    #[cfg(not(js_sys_unstable_apis))]
6529    #[wasm_bindgen(method, js_name = toLocaleTimeString)]
6530    pub fn to_locale_time_string(this: &Date, locale: &str) -> JsString;
6531
6532    /// The `toLocaleTimeString()` method returns a string with a language sensitive
6533    /// representation of the time portion of this date.
6534    ///
6535    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString)
6536    #[cfg(js_sys_unstable_apis)]
6537    #[wasm_bindgen(method, js_name = toLocaleTimeString)]
6538    pub fn to_locale_time_string(
6539        this: &Date,
6540        locales: &[JsString],
6541        options: &Intl::DateTimeFormatOptions,
6542    ) -> JsString;
6543
6544    #[cfg(not(js_sys_unstable_apis))]
6545    #[wasm_bindgen(method, js_name = toLocaleTimeString)]
6546    pub fn to_locale_time_string_with_options(
6547        this: &Date,
6548        locale: &str,
6549        options: &JsValue,
6550    ) -> JsString;
6551
6552    /// The `toString()` method returns a string representing
6553    /// the specified Date object.
6554    ///
6555    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toString)
6556    #[cfg(not(js_sys_unstable_apis))]
6557    #[wasm_bindgen(method, js_name = toString)]
6558    pub fn to_string(this: &Date) -> JsString;
6559
6560    /// The `toTimeString()` method returns the time portion of a Date object in human
6561    /// readable form in American English.
6562    ///
6563    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toTimeString)
6564    #[wasm_bindgen(method, js_name = toTimeString)]
6565    pub fn to_time_string(this: &Date) -> JsString;
6566
6567    /// The `toUTCString()` method converts a date to a string,
6568    /// using the UTC time zone.
6569    ///
6570    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString)
6571    #[wasm_bindgen(method, js_name = toUTCString)]
6572    pub fn to_utc_string(this: &Date) -> JsString;
6573
6574    /// The `Date.UTC()` method accepts the same parameters as the
6575    /// longest form of the constructor, and returns the number of
6576    /// milliseconds in a `Date` object since January 1, 1970,
6577    /// 00:00:00, universal time.
6578    ///
6579    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC)
6580    #[wasm_bindgen(static_method_of = Date, js_name = UTC)]
6581    pub fn utc(year: f64, month: f64) -> f64;
6582
6583    /// The `valueOf()` method  returns the primitive value of
6584    /// a Date object.
6585    ///
6586    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/valueOf)
6587    #[wasm_bindgen(method, js_name = valueOf)]
6588    pub fn value_of(this: &Date) -> f64;
6589
6590    /// The `toTemporalInstant()` method converts a legacy `Date` object to a
6591    /// `Temporal.Instant` object representing the same moment in time.
6592    ///
6593    /// This method is added by the Temporal proposal to facilitate migration
6594    /// from legacy `Date` to the new Temporal API.
6595    ///
6596    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toTemporalInstant)
6597    #[cfg(js_sys_unstable_apis)]
6598    #[wasm_bindgen(method, js_name = toTemporalInstant)]
6599    pub fn to_temporal_instant(this: &Date) -> Temporal::Instant;
6600}
6601
6602// Property Descriptor.
6603#[wasm_bindgen]
6604extern "C" {
6605    #[wasm_bindgen(extends = Object)]
6606    #[derive(Clone, Debug)]
6607    pub type PropertyDescriptor<T = JsValue>;
6608
6609    #[wasm_bindgen(method, getter = writable)]
6610    pub fn get_writable<T>(this: &PropertyDescriptor<T>) -> Option<bool>;
6611
6612    #[wasm_bindgen(method, setter = writable)]
6613    pub fn set_writable<T>(this: &PropertyDescriptor<T>, writable: bool);
6614
6615    #[wasm_bindgen(method, getter = enumerable)]
6616    pub fn get_enumerable<T>(this: &PropertyDescriptor<T>) -> Option<bool>;
6617
6618    #[wasm_bindgen(method, setter = enumerable)]
6619    pub fn set_enumerable<T>(this: &PropertyDescriptor<T>, enumerable: bool);
6620
6621    #[wasm_bindgen(method, getter = configurable)]
6622    pub fn get_configurable<T>(this: &PropertyDescriptor<T>) -> Option<bool>;
6623
6624    #[wasm_bindgen(method, setter = configurable)]
6625    pub fn set_configurable<T>(this: &PropertyDescriptor<T>, configurable: bool);
6626
6627    #[wasm_bindgen(method, getter = get)]
6628    pub fn get_get<T: JsGeneric>(this: &PropertyDescriptor<T>) -> Option<Function<fn() -> T>>;
6629
6630    #[wasm_bindgen(method, setter = get)]
6631    pub fn set_get<T: JsGeneric>(this: &PropertyDescriptor<T>, get: Function<fn() -> T>);
6632
6633    #[wasm_bindgen(method, getter = set)]
6634    pub fn get_set<T: JsGeneric>(
6635        this: &PropertyDescriptor<T>,
6636    ) -> Option<Function<fn(T) -> JsValue>>;
6637
6638    #[wasm_bindgen(method, setter = set)]
6639    pub fn set_set<T: JsGeneric>(this: &PropertyDescriptor<T>, set: Function<fn(T) -> JsValue>);
6640
6641    #[wasm_bindgen(method, getter = value)]
6642    pub fn get_value<T>(this: &PropertyDescriptor<T>) -> Option<T>;
6643
6644    #[wasm_bindgen(method, setter = value)]
6645    pub fn set_value<T>(this: &PropertyDescriptor<T>, value: &T);
6646}
6647
6648impl PropertyDescriptor {
6649    #[cfg(not(js_sys_unstable_apis))]
6650    pub fn new<T>() -> PropertyDescriptor<T> {
6651        JsCast::unchecked_into(Object::new())
6652    }
6653
6654    #[cfg(js_sys_unstable_apis)]
6655    pub fn new<T>() -> PropertyDescriptor<T> {
6656        JsCast::unchecked_into(Object::<JsValue>::new())
6657    }
6658
6659    #[cfg(not(js_sys_unstable_apis))]
6660    pub fn new_value<T: JsGeneric>(value: &T) -> PropertyDescriptor<T> {
6661        let desc: PropertyDescriptor<T> = JsCast::unchecked_into(Object::new());
6662        desc.set_value(value);
6663        desc
6664    }
6665
6666    #[cfg(js_sys_unstable_apis)]
6667    pub fn new_value<T: JsGeneric>(value: &T) -> PropertyDescriptor<T> {
6668        let desc: PropertyDescriptor<T> = JsCast::unchecked_into(Object::<JsValue>::new());
6669        desc.set_value(value);
6670        desc
6671    }
6672}
6673
6674impl Default for PropertyDescriptor {
6675    fn default() -> Self {
6676        PropertyDescriptor::new()
6677    }
6678}
6679
6680// Object.
6681#[wasm_bindgen]
6682extern "C" {
6683    #[wasm_bindgen(typescript_type = "object")]
6684    #[derive(Clone, Debug)]
6685    pub type Object<T = JsValue>;
6686
6687    // Next major: deprecate
6688    /// The `Object.assign()` method is used to copy the values of all enumerable
6689    /// own properties from one or more source objects to a target object. It
6690    /// will return the target object.
6691    ///
6692    /// **Note:** Consider using [`Object::try_assign`] to support error handling.
6693    ///
6694    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
6695    #[wasm_bindgen(static_method_of = Object)]
6696    pub fn assign<T>(target: &Object<T>, source: &Object<T>) -> Object<T>;
6697
6698    // Next major: deprecate
6699    /// The `Object.assign()` method is used to copy the values of all enumerable
6700    /// own properties from one or more source objects to a target object. It
6701    /// will return the target object.
6702    ///
6703    /// **Note:** Consider using [`Object::try_assign`] to support error handling.
6704    ///
6705    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
6706    #[wasm_bindgen(static_method_of = Object, js_name = assign, catch)]
6707    pub fn try_assign<T>(target: &Object<T>, source: &Object<T>) -> Result<Object<T>, JsValue>;
6708
6709    /// The `Object.assign()` method is used to copy the values of all enumerable
6710    /// own properties from one or more source objects to a target object. It
6711    /// will return the target object.
6712    ///
6713    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
6714    #[cfg(not(js_sys_unstable_apis))]
6715    #[wasm_bindgen(static_method_of = Object, js_name = assign)]
6716    #[deprecated(note = "use `assign_many` for arbitrary assign arguments instead")]
6717    #[allow(deprecated)]
6718    pub fn assign2<T>(target: &Object<T>, source1: &Object<T>, source2: &Object<T>) -> Object<T>;
6719
6720    /// The `Object.assign()` method is used to copy the values of all enumerable
6721    /// own properties from one or more source objects to a target object. It
6722    /// will return the target object.
6723    ///
6724    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
6725    #[cfg(not(js_sys_unstable_apis))]
6726    #[wasm_bindgen(static_method_of = Object, js_name = assign)]
6727    #[deprecated(note = "use `assign_many` for arbitrary assign arguments instead")]
6728    #[allow(deprecated)]
6729    pub fn assign3<T>(
6730        target: &Object<T>,
6731        source1: &Object<T>,
6732        source2: &Object<T>,
6733        source3: &Object<T>,
6734    ) -> Object<T>;
6735
6736    /// The `Object.assign()` method is used to copy the values of all enumerable
6737    /// own properties from one or more source objects to a target object. It
6738    /// will return the target object.
6739    ///
6740    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
6741    #[wasm_bindgen(static_method_of = Object, js_name = assign, catch, variadic)]
6742    pub fn assign_many<T>(target: &Object<T>, sources: &[Object<T>]) -> Result<Object<T>, JsValue>;
6743
6744    /// The constructor property returns a reference to the `Object` constructor
6745    /// function that created the instance object.
6746    ///
6747    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor)
6748    #[wasm_bindgen(method, getter)]
6749    pub fn constructor<T>(this: &Object<T>) -> Function;
6750
6751    /// The `Object.create()` method creates a new object, using an existing
6752    /// object to provide the newly created object's prototype.
6753    ///
6754    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create)
6755    #[wasm_bindgen(static_method_of = Object)]
6756    pub fn create<T>(prototype: &Object<T>) -> Object<T>;
6757
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    /// **Note:** Consider using [`Object::define_property_str`] to support typing and error handling.
6763    ///
6764    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty)
6765    #[cfg(not(js_sys_unstable_apis))]
6766    #[wasm_bindgen(static_method_of = Object, js_name = defineProperty)]
6767    pub fn define_property<T>(obj: &Object<T>, prop: &JsValue, descriptor: &Object) -> Object<T>;
6768
6769    /// The static method `Object.defineProperty()` defines a new
6770    /// property directly on an object, or modifies an existing
6771    /// property on an object, and returns the object.
6772    ///
6773    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty)
6774    #[cfg(js_sys_unstable_apis)]
6775    #[wasm_bindgen(static_method_of = Object, js_name = defineProperty, catch)]
6776    pub fn define_property<T>(
6777        obj: &Object<T>,
6778        prop: &JsString,
6779        descriptor: &PropertyDescriptor<T>,
6780    ) -> Result<Object<T>, JsValue>;
6781
6782    // Next major: deprecate
6783    /// The static method `Object.defineProperty()` defines a new
6784    /// property directly on an object, or modifies an existing
6785    /// property on an object, and returns the object.
6786    ///
6787    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty)
6788    #[wasm_bindgen(static_method_of = Object, js_name = defineProperty, catch)]
6789    pub fn define_property_str<T>(
6790        obj: &Object<T>,
6791        prop: &JsString,
6792        descriptor: &PropertyDescriptor<T>,
6793    ) -> Result<Object<T>, JsValue>;
6794
6795    /// The static method `Object.defineProperty()` defines a new
6796    /// property directly on an object, or modifies an existing
6797    /// property on an object, and returns the object.
6798    ///
6799    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty)
6800    #[wasm_bindgen(static_method_of = Object, js_name = defineProperty, catch)]
6801    pub fn define_property_symbol<T>(
6802        obj: &Object<T>,
6803        prop: &Symbol,
6804        descriptor: &PropertyDescriptor<JsValue>,
6805    ) -> Result<Object<T>, JsValue>;
6806
6807    /// The `Object.defineProperties()` method defines new or modifies
6808    /// existing properties directly on an object, returning the
6809    /// object.
6810    ///
6811    /// **Note:** Consider using [`Object::try_define_properties`] to support typing and error handling.
6812    ///
6813    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties)
6814    #[wasm_bindgen(static_method_of = Object, js_name = defineProperties)]
6815    pub fn define_properties<T>(obj: &Object<T>, props: &Object) -> Object<T>;
6816
6817    /// The `Object.defineProperties()` method defines new or modifies
6818    /// existing properties directly on an object, returning the
6819    /// object.
6820    ///
6821    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties)
6822    #[cfg(js_sys_unstable_apis)]
6823    #[wasm_bindgen(static_method_of = Object, js_name = defineProperties, catch)]
6824    pub fn try_define_properties<T>(
6825        obj: &Object<T>,
6826        props: &Object<PropertyDescriptor<T>>,
6827    ) -> Result<Object<T>, JsValue>;
6828
6829    /// The `Object.entries()` method returns an array of a given
6830    /// object's own enumerable property [key, value] pairs, in the
6831    /// same order as that provided by a for...in loop (the difference
6832    /// being that a for-in loop enumerates properties in the
6833    /// prototype chain as well).
6834    ///
6835    /// **Note:** Consider using [`Object::entries_typed`] to support typing and error handling.
6836    ///
6837    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries)
6838    #[cfg(not(js_sys_unstable_apis))]
6839    #[wasm_bindgen(static_method_of = Object)]
6840    pub fn entries(object: &Object) -> Array;
6841
6842    /// The `Object.entries()` method returns an array of a given
6843    /// object's own enumerable property [key, value] pairs, in the
6844    /// same order as that provided by a for...in loop (the difference
6845    /// being that a for-in loop enumerates properties in the
6846    /// prototype chain as well).
6847    ///
6848    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries)
6849    #[cfg(js_sys_unstable_apis)]
6850    #[wasm_bindgen(static_method_of = Object, js_name = entries, catch)]
6851    pub fn entries<T: JsGeneric>(
6852        object: &Object<T>,
6853    ) -> Result<Array<ArrayTuple<(JsString, T)>>, JsValue>;
6854
6855    // Next major: deprecate
6856    /// The `Object.entries()` method returns an array of a given
6857    /// object's own enumerable property [key, value] pairs, in the
6858    /// same order as that provided by a for...in loop (the difference
6859    /// being that a for-in loop enumerates properties in the
6860    /// prototype chain as well).
6861    ///
6862    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries)
6863    #[wasm_bindgen(static_method_of = Object, js_name = entries, catch)]
6864    pub fn entries_typed<T: JsGeneric>(
6865        object: &Object<T>,
6866    ) -> Result<Array<ArrayTuple<(JsString, T)>>, JsValue>;
6867
6868    /// The `Object.freeze()` method freezes an object: that is, prevents new
6869    /// properties from being added to it; prevents existing properties from
6870    /// being removed; and prevents existing properties, or their enumerability,
6871    /// configurability, or writability, from being changed, it also prevents
6872    /// the prototype from being changed. The method returns the passed object.
6873    ///
6874    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze)
6875    #[wasm_bindgen(static_method_of = Object)]
6876    pub fn freeze<T>(value: &Object<T>) -> Object<T>;
6877
6878    /// The `Object.fromEntries()` method transforms a list of key-value pairs
6879    /// into an object.
6880    ///
6881    /// **Note:** Consider using [`Object::from_entries_typed`] to support typing and error handling.
6882    ///
6883    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries)
6884    #[cfg(not(js_sys_unstable_apis))]
6885    #[wasm_bindgen(static_method_of = Object, catch, js_name = fromEntries)]
6886    pub fn from_entries(entries: &JsValue) -> Result<Object, JsValue>;
6887
6888    /// The `Object.fromEntries()` method transforms a list of key-value pairs
6889    /// into an object.
6890    ///
6891    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries)
6892    #[cfg(js_sys_unstable_apis)]
6893    #[wasm_bindgen(static_method_of = Object, catch, js_name = fromEntries)]
6894    pub fn from_entries<T: JsGeneric, I: Iterable<Item = ArrayTuple<(JsString, T)>>>(
6895        entries: &I,
6896    ) -> Result<Object<T>, JsValue>;
6897
6898    // Next major: deprecate
6899    /// The `Object.fromEntries()` method transforms a list of key-value pairs
6900    /// into an object.
6901    ///
6902    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries)
6903    #[wasm_bindgen(static_method_of = Object, catch, js_name = fromEntries)]
6904    pub fn from_entries_typed<T: JsGeneric, I: Iterable<Item = ArrayTuple<(JsString, T)>>>(
6905        entries: &I,
6906    ) -> Result<Object<T>, JsValue>;
6907
6908    /// The `Object.getOwnPropertyDescriptor()` method returns a
6909    /// property descriptor for an own property (that is, one directly
6910    /// present on an object and not in the object's prototype chain)
6911    /// of a given object.
6912    ///
6913    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor)
6914    #[cfg(not(js_sys_unstable_apis))]
6915    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptor)]
6916    pub fn get_own_property_descriptor<T>(obj: &Object<T>, prop: &JsValue) -> JsValue;
6917
6918    /// The `Object.getOwnPropertyDescriptor()` method returns a
6919    /// property descriptor for an own property (that is, one directly
6920    /// present on an object and not in the object's prototype chain)
6921    /// of a given object.
6922    ///
6923    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor)
6924    #[cfg(js_sys_unstable_apis)]
6925    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptor, catch)]
6926    pub fn get_own_property_descriptor<T>(
6927        obj: &Object<T>,
6928        prop: &JsString,
6929    ) -> Result<PropertyDescriptor<T>, JsValue>;
6930
6931    // Next major: deprecate
6932    /// The `Object.getOwnPropertyDescriptor()` method returns a
6933    /// property descriptor for an own property (that is, one directly
6934    /// present on an object and not in the object's prototype chain)
6935    /// of a given object.
6936    ///
6937    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor)
6938    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptor, catch)]
6939    pub fn get_own_property_descriptor_str<T>(
6940        obj: &Object<T>,
6941        prop: &JsString,
6942    ) -> Result<PropertyDescriptor<T>, JsValue>;
6943
6944    /// The `Object.getOwnPropertyDescriptor()` method returns a
6945    /// property descriptor for an own property (that is, one directly
6946    /// present on an object and not in the object's prototype chain)
6947    /// of a given object.
6948    ///
6949    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor)
6950    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptor, catch)]
6951    pub fn get_own_property_descriptor_symbol<T>(
6952        obj: &Object<T>,
6953        prop: &Symbol,
6954    ) -> Result<PropertyDescriptor<JsValue>, JsValue>;
6955
6956    /// The `Object.getOwnPropertyDescriptors()` method returns all own
6957    /// property descriptors of a given object.
6958    ///
6959    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors)
6960    #[cfg(not(js_sys_unstable_apis))]
6961    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptors)]
6962    pub fn get_own_property_descriptors<T>(obj: &Object<T>) -> JsValue;
6963
6964    /// The `Object.getOwnPropertyDescriptors()` method returns all own
6965    /// property descriptors of a given object.
6966    ///
6967    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors)
6968    #[cfg(js_sys_unstable_apis)]
6969    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptors, catch)]
6970    pub fn get_own_property_descriptors<T>(
6971        obj: &Object<T>,
6972    ) -> Result<Object<PropertyDescriptor<T>>, JsValue>;
6973
6974    /// The `Object.getOwnPropertyNames()` method returns an array of
6975    /// all properties (including non-enumerable properties except for
6976    /// those which use Symbol) found directly upon a given object.
6977    ///
6978    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames)
6979    #[cfg(not(js_sys_unstable_apis))]
6980    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyNames)]
6981    pub fn get_own_property_names<T>(obj: &Object<T>) -> Array;
6982
6983    /// The `Object.getOwnPropertyNames()` method returns an array of
6984    /// all properties (including non-enumerable properties except for
6985    /// those which use Symbol) found directly upon a given object.
6986    ///
6987    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames)
6988    #[cfg(js_sys_unstable_apis)]
6989    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyNames, catch)]
6990    pub fn get_own_property_names<T>(obj: &Object<T>) -> Result<Array<JsString>, JsValue>;
6991
6992    /// The `Object.getOwnPropertySymbols()` method returns an array of
6993    /// all symbol properties found directly upon a given object.
6994    ///
6995    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols)
6996    #[cfg(not(js_sys_unstable_apis))]
6997    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertySymbols)]
6998    pub fn get_own_property_symbols<T>(obj: &Object<T>) -> Array;
6999
7000    /// The `Object.getOwnPropertySymbols()` method returns an array of
7001    /// all symbol properties found directly upon a given object.
7002    ///
7003    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols)
7004    #[cfg(js_sys_unstable_apis)]
7005    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertySymbols, catch)]
7006    pub fn get_own_property_symbols<T>(obj: &Object<T>) -> Result<Array<Symbol>, JsValue>;
7007
7008    /// The `Object.getPrototypeOf()` method returns the prototype
7009    /// (i.e. the value of the internal [[Prototype]] property) of the
7010    /// specified object.
7011    ///
7012    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf)
7013    #[wasm_bindgen(static_method_of = Object, js_name = getPrototypeOf)]
7014    pub fn get_prototype_of(obj: &JsValue) -> Object;
7015
7016    /// The `hasOwnProperty()` method returns a boolean indicating whether the
7017    /// object has the specified property as its own property (as opposed to
7018    /// inheriting it).
7019    ///
7020    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty)
7021    #[deprecated(note = "Use `Object::hasOwn` instead.")]
7022    #[allow(deprecated)]
7023    #[wasm_bindgen(method, js_name = hasOwnProperty)]
7024    pub fn has_own_property<T>(this: &Object<T>, property: &JsValue) -> bool;
7025
7026    /// The `Object.hasOwn()` method returns a boolean indicating whether the
7027    /// object passed in has the specified property as its own property (as
7028    /// opposed to inheriting it).
7029    ///
7030    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn)
7031    #[cfg(not(js_sys_unstable_apis))]
7032    #[wasm_bindgen(static_method_of = Object, js_name = hasOwn)]
7033    pub fn has_own<T>(instance: &Object<T>, property: &JsValue) -> bool;
7034
7035    /// The `Object.hasOwn()` method returns a boolean indicating whether the
7036    /// object passed in has the specified property as its own property (as
7037    /// opposed to inheriting it).
7038    ///
7039    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn)
7040    #[cfg(js_sys_unstable_apis)]
7041    #[wasm_bindgen(static_method_of = Object, js_name = hasOwn, catch)]
7042    pub fn has_own<T>(instance: &Object<T>, property: &JsString) -> Result<bool, JsValue>;
7043
7044    // Next major: deprecate
7045    /// The `Object.hasOwn()` method returns a boolean indicating whether the
7046    /// object passed in has the specified property as its own property (as
7047    /// opposed to inheriting it).
7048    ///
7049    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn)
7050    #[wasm_bindgen(static_method_of = Object, js_name = hasOwn, catch)]
7051    pub fn has_own_str<T>(instance: &Object<T>, property: &JsString) -> Result<bool, JsValue>;
7052
7053    /// The `Object.hasOwn()` method returns a boolean indicating whether the
7054    /// object passed in has the specified property as its own property (as
7055    /// opposed to inheriting it).
7056    ///
7057    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn)
7058    #[wasm_bindgen(static_method_of = Object, js_name = hasOwn, catch)]
7059    pub fn has_own_symbol<T>(instance: &Object<T>, property: &Symbol) -> Result<bool, JsValue>;
7060
7061    /// The `Object.is()` method determines whether two values are the same value.
7062    ///
7063    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is)
7064    #[wasm_bindgen(static_method_of = Object)]
7065    pub fn is(value1: &JsValue, value_2: &JsValue) -> bool;
7066
7067    /// The `Object.isExtensible()` method determines if an object is extensible
7068    /// (whether it can have new properties added to it).
7069    ///
7070    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible)
7071    #[wasm_bindgen(static_method_of = Object, js_name = isExtensible)]
7072    pub fn is_extensible<T>(object: &Object<T>) -> bool;
7073
7074    /// The `Object.isFrozen()` determines if an object is frozen.
7075    ///
7076    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen)
7077    #[wasm_bindgen(static_method_of = Object, js_name = isFrozen)]
7078    pub fn is_frozen<T>(object: &Object<T>) -> bool;
7079
7080    /// The `Object.isSealed()` method determines if an object is sealed.
7081    ///
7082    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isSealed)
7083    #[wasm_bindgen(static_method_of = Object, js_name = isSealed)]
7084    pub fn is_sealed<T>(object: &Object<T>) -> bool;
7085
7086    /// The `isPrototypeOf()` method checks if an object exists in another
7087    /// object's prototype chain.
7088    ///
7089    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf)
7090    #[wasm_bindgen(method, js_name = isPrototypeOf)]
7091    pub fn is_prototype_of<T>(this: &Object<T>, value: &JsValue) -> bool;
7092
7093    /// The `Object.keys()` method returns an array of a given object's property
7094    /// names, in the same order as we get with a normal loop.
7095    ///
7096    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys)
7097    #[cfg(not(js_sys_unstable_apis))]
7098    #[wasm_bindgen(static_method_of = Object)]
7099    pub fn keys<T>(object: &Object<T>) -> Array;
7100
7101    /// The `Object.keys()` method returns an array of a given object's property
7102    /// names, in the same order as we get with a normal loop.
7103    ///
7104    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys)
7105    #[cfg(js_sys_unstable_apis)]
7106    #[wasm_bindgen(static_method_of = Object)]
7107    pub fn keys<T>(object: &Object<T>) -> Array<JsString>;
7108
7109    /// The [`Object`] constructor creates an object wrapper.
7110    ///
7111    /// **Note:** Consider using [`Object::new_typed`] for typed object records.
7112    ///
7113    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
7114    #[wasm_bindgen(constructor)]
7115    pub fn new() -> Object;
7116
7117    // Next major: deprecate
7118    /// The [`Object`] constructor creates an object wrapper.
7119    ///
7120    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
7121    #[wasm_bindgen(constructor)]
7122    pub fn new_typed<T>() -> Object<T>;
7123
7124    /// The `Object.preventExtensions()` method prevents new properties from
7125    /// ever being added to an object (i.e. prevents future extensions to the
7126    /// object).
7127    ///
7128    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions)
7129    #[wasm_bindgen(static_method_of = Object, js_name = preventExtensions)]
7130    pub fn prevent_extensions<T>(object: &Object<T>);
7131
7132    /// The `propertyIsEnumerable()` method returns a Boolean indicating
7133    /// whether the specified property is enumerable.
7134    ///
7135    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable)
7136    #[wasm_bindgen(method, js_name = propertyIsEnumerable)]
7137    pub fn property_is_enumerable<T>(this: &Object<T>, property: &JsValue) -> bool;
7138
7139    /// The `Object.seal()` method seals an object, preventing new properties
7140    /// from being added to it and marking all existing properties as
7141    /// non-configurable.  Values of present properties can still be changed as
7142    /// long as they are writable.
7143    ///
7144    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal)
7145    #[wasm_bindgen(static_method_of = Object)]
7146    pub fn seal<T>(value: &Object<T>) -> Object<T>;
7147
7148    /// The `Object.setPrototypeOf()` method sets the prototype (i.e., the
7149    /// internal `[[Prototype]]` property) of a specified object to another
7150    /// object or `null`.
7151    ///
7152    /// **Note:** Consider using [`Object::try_set_prototype_of`] to support errors.
7153    ///
7154    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf)
7155    #[wasm_bindgen(static_method_of = Object, js_name = setPrototypeOf)]
7156    pub fn set_prototype_of<T>(object: &Object<T>, prototype: &Object) -> Object<T>;
7157
7158    /// The `Object.setPrototypeOf()` method sets the prototype (i.e., the
7159    /// internal `[[Prototype]]` property) of a specified object to another
7160    /// object or `null`.
7161    ///
7162    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf)
7163    #[wasm_bindgen(static_method_of = Object, js_name = setPrototypeOf, catch)]
7164    pub fn try_set_prototype_of<T>(
7165        object: &Object<T>,
7166        prototype: &Object,
7167    ) -> Result<Object<T>, JsValue>;
7168
7169    /// The `toLocaleString()` method returns a string representing the object.
7170    /// This method is meant to be overridden by derived objects for
7171    /// locale-specific purposes.
7172    ///
7173    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toLocaleString)
7174    #[wasm_bindgen(method, js_name = toLocaleString)]
7175    pub fn to_locale_string<T>(this: &Object<T>) -> JsString;
7176
7177    // Next major: deprecate
7178    /// The `toString()` method returns a string representing the object.
7179    ///
7180    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString)
7181    #[wasm_bindgen(method, js_name = toString)]
7182    pub fn to_string<T>(this: &Object<T>) -> JsString;
7183
7184    /// The `toString()` method returns a string representing the object.
7185    ///
7186    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString)
7187    #[wasm_bindgen(method, js_name = toString)]
7188    pub fn to_js_string<T>(this: &Object<T>) -> JsString;
7189
7190    /// The `valueOf()` method returns the primitive value of the
7191    /// specified object.
7192    ///
7193    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf)
7194    #[wasm_bindgen(method, js_name = valueOf)]
7195    pub fn value_of<T>(this: &Object<T>) -> Object;
7196
7197    /// The `Object.values()` method returns an array of a given object's own
7198    /// enumerable property values, in the same order as that provided by a
7199    /// `for...in` loop (the difference being that a for-in loop enumerates
7200    /// properties in the prototype chain as well).
7201    ///
7202    /// **Note:** Consider using [`Object::try_values`] to support errors.
7203    ///
7204    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values)
7205    #[cfg(not(js_sys_unstable_apis))]
7206    #[wasm_bindgen(static_method_of = Object)]
7207    pub fn values<T>(object: &Object<T>) -> Array<T>;
7208
7209    /// The `Object.values()` method returns an array of a given object's own
7210    /// enumerable property values, in the same order as that provided by a
7211    /// `for...in` loop (the difference being that a for-in loop enumerates
7212    /// properties in the prototype chain as well).
7213    ///
7214    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values)
7215    #[cfg(js_sys_unstable_apis)]
7216    #[wasm_bindgen(static_method_of = Object, catch, js_name = values)]
7217    pub fn values<T>(object: &Object<T>) -> Result<Array<T>, JsValue>;
7218
7219    // Next major: deprecate
7220    /// The `Object.values()` method returns an array of a given object's own
7221    /// enumerable property values, in the same order as that provided by a
7222    /// `for...in` loop (the difference being that a for-in loop enumerates
7223    /// properties in the prototype chain as well).
7224    ///
7225    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values)
7226    #[cfg(not(js_sys_unstable_apis))]
7227    #[wasm_bindgen(static_method_of = Object, catch, js_name = values)]
7228    pub fn try_values<T>(object: &Object<T>) -> Result<Array<T>, JsValue>;
7229}
7230
7231impl Object {
7232    /// Returns the `Object` value of this JS value if it's an instance of an
7233    /// object.
7234    ///
7235    /// If this JS value is not an instance of an object then this returns
7236    /// `None`.
7237    pub fn try_from(val: &JsValue) -> Option<&Object> {
7238        if val.is_object() {
7239            Some(val.unchecked_ref())
7240        } else {
7241            None
7242        }
7243    }
7244}
7245
7246impl PartialEq for Object {
7247    #[inline]
7248    fn eq(&self, other: &Object) -> bool {
7249        Object::is(self.as_ref(), other.as_ref())
7250    }
7251}
7252
7253impl Eq for Object {}
7254
7255impl Default for Object<JsValue> {
7256    fn default() -> Self {
7257        Self::new()
7258    }
7259}
7260
7261// Proxy
7262#[wasm_bindgen]
7263extern "C" {
7264    #[wasm_bindgen(typescript_type = "ProxyConstructor")]
7265    #[derive(Clone, Debug)]
7266    pub type Proxy;
7267
7268    /// The [`Proxy`] object is used to define custom behavior for fundamental
7269    /// operations (e.g. property lookup, assignment, enumeration, function
7270    /// invocation, etc).
7271    ///
7272    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy)
7273    #[wasm_bindgen(constructor)]
7274    pub fn new(target: &JsValue, handler: &Object) -> Proxy;
7275
7276    /// The `Proxy.revocable()` method is used to create a revocable [`Proxy`]
7277    /// object.
7278    ///
7279    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/revocable)
7280    #[wasm_bindgen(static_method_of = Proxy)]
7281    pub fn revocable(target: &JsValue, handler: &Object) -> Object;
7282}
7283
7284// RangeError
7285#[wasm_bindgen]
7286extern "C" {
7287    /// The `RangeError` object indicates an error when a value is not in the set
7288    /// or range of allowed values.
7289    ///
7290    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError)
7291    #[wasm_bindgen(extends = Error, extends = Object, typescript_type = "RangeError")]
7292    #[derive(Clone, Debug, PartialEq, Eq)]
7293    pub type RangeError;
7294
7295    /// The `RangeError` object indicates an error when a value is not in the set
7296    /// or range of allowed values.
7297    ///
7298    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError)
7299    #[wasm_bindgen(constructor)]
7300    pub fn new(message: &str) -> RangeError;
7301}
7302
7303// ReferenceError
7304#[wasm_bindgen]
7305extern "C" {
7306    /// The `ReferenceError` object represents an error when a non-existent
7307    /// variable is referenced.
7308    ///
7309    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError)
7310    #[wasm_bindgen(extends = Error, extends = Object, typescript_type = "ReferenceError")]
7311    #[derive(Clone, Debug, PartialEq, Eq)]
7312    pub type ReferenceError;
7313
7314    /// The `ReferenceError` object represents an error when a non-existent
7315    /// variable is referenced.
7316    ///
7317    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError)
7318    #[wasm_bindgen(constructor)]
7319    pub fn new(message: &str) -> ReferenceError;
7320}
7321
7322#[allow(non_snake_case)]
7323pub mod Reflect {
7324    use super::*;
7325
7326    // Reflect
7327    #[wasm_bindgen]
7328    extern "C" {
7329        /// The static `Reflect.apply()` method calls a target function with
7330        /// arguments as specified.
7331        ///
7332        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/apply)
7333        #[wasm_bindgen(js_namespace = Reflect, catch)]
7334        pub fn apply<T: JsFunction = fn() -> JsValue>(
7335            target: &Function<T>,
7336            this_argument: &JsValue,
7337            arguments_list: &Array,
7338        ) -> Result<<T as JsFunction>::Ret, JsValue>;
7339
7340        /// The static `Reflect.construct()` method acts like the new operator, but
7341        /// as a function.  It is equivalent to calling `new target(...args)`. It
7342        /// gives also the added option to specify a different prototype.
7343        ///
7344        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct)
7345        #[cfg(not(js_sys_unstable_apis))]
7346        #[wasm_bindgen(js_namespace = Reflect, catch)]
7347        pub fn construct<T: JsFunction = fn() -> JsValue>(
7348            target: &Function<T>,
7349            arguments_list: &Array,
7350        ) -> Result<JsValue, JsValue>;
7351
7352        /// The static `Reflect.construct()` method acts like the new operator, but
7353        /// as a function.  It is equivalent to calling `new target(...args)`. It
7354        /// gives also the added option to specify a different prototype.
7355        ///
7356        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct)
7357        #[cfg(js_sys_unstable_apis)]
7358        #[wasm_bindgen(js_namespace = Reflect, catch)]
7359        pub fn construct<T: JsFunction = fn() -> JsValue>(
7360            target: &Function<T>,
7361            arguments_list: &ArrayTuple, // DOTO: <A1, A2, A3, A4, A5, A6, A7, A8>,
7362        ) -> Result<JsValue, JsValue>;
7363
7364        /// The static `Reflect.construct()` method acts like the new operator, but
7365        /// as a function.  It is equivalent to calling `new target(...args)`. It
7366        /// gives also the added option to specify a different prototype.
7367        ///
7368        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct)
7369        #[wasm_bindgen(js_namespace = Reflect, js_name = construct, catch)]
7370        pub fn construct_with_new_target(
7371            target: &Function,
7372            arguments_list: &Array,
7373            new_target: &Function,
7374        ) -> Result<JsValue, JsValue>;
7375
7376        /// The static `Reflect.defineProperty()` method is like
7377        /// `Object.defineProperty()` but returns a `Boolean`.
7378        ///
7379        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty)
7380        #[cfg(not(js_sys_unstable_apis))]
7381        #[wasm_bindgen(js_namespace = Reflect, js_name = defineProperty, catch)]
7382        pub fn define_property<T>(
7383            target: &Object<T>,
7384            property_key: &JsValue,
7385            attributes: &Object,
7386        ) -> Result<bool, JsValue>;
7387
7388        /// The static `Reflect.defineProperty()` method is like
7389        /// `Object.defineProperty()` but returns a `Boolean`.
7390        ///
7391        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty)
7392        #[cfg(js_sys_unstable_apis)]
7393        #[wasm_bindgen(js_namespace = Reflect, js_name = defineProperty, catch)]
7394        pub fn define_property<T>(
7395            target: &Object<T>,
7396            property_key: &JsValue,
7397            attributes: &PropertyDescriptor<T>,
7398        ) -> Result<bool, JsValue>;
7399
7400        /// The static `Reflect.defineProperty()` method is like
7401        /// `Object.defineProperty()` but returns a `Boolean`.
7402        ///
7403        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty)
7404        #[wasm_bindgen(js_namespace = Reflect, js_name = defineProperty, catch)]
7405        pub fn define_property_str<T>(
7406            target: &Object<T>,
7407            property_key: &JsString,
7408            attributes: &PropertyDescriptor<T>,
7409        ) -> Result<bool, JsValue>;
7410
7411        /// The static `Reflect.deleteProperty()` method allows to delete
7412        /// properties.  It is like the `delete` operator as a function.
7413        ///
7414        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/deleteProperty)
7415        #[wasm_bindgen(js_namespace = Reflect, js_name = deleteProperty, catch)]
7416        pub fn delete_property<T>(target: &Object<T>, key: &JsValue) -> Result<bool, JsValue>;
7417
7418        /// The static `Reflect.deleteProperty()` method allows to delete
7419        /// properties.  It is like the `delete` operator as a function.
7420        ///
7421        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/deleteProperty)
7422        #[wasm_bindgen(js_namespace = Reflect, js_name = deleteProperty, catch)]
7423        pub fn delete_property_str<T>(target: &Object<T>, key: &JsString) -> Result<bool, JsValue>;
7424
7425        /// The static `Reflect.get()` method works like getting a property from
7426        /// an object (`target[propertyKey]`) as a function.
7427        ///
7428        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get)
7429        #[cfg(not(js_sys_unstable_apis))]
7430        #[wasm_bindgen(js_namespace = Reflect, catch)]
7431        pub fn get(target: &JsValue, key: &JsValue) -> Result<JsValue, JsValue>;
7432
7433        /// The static `Reflect.get()` method works like getting a property from
7434        /// an object (`target[propertyKey]`) as a function.
7435        ///
7436        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get)
7437        #[cfg(js_sys_unstable_apis)]
7438        #[wasm_bindgen(js_namespace = Reflect, catch)]
7439        pub fn get<T>(target: &Object<T>, key: &JsString) -> Result<Option<T>, JsValue>;
7440
7441        /// The static `Reflect.get()` method works like getting a property from
7442        /// an object (`target[propertyKey]`) as a function.
7443        ///
7444        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get)
7445        #[wasm_bindgen(js_namespace = Reflect, js_name = get, catch)]
7446        pub fn get_str<T>(target: &Object<T>, key: &JsString) -> Result<Option<T>, JsValue>;
7447
7448        /// The static `Reflect.get()` method works like getting a property from
7449        /// an object (`target[propertyKey]`) as a function.
7450        ///
7451        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get)
7452        #[wasm_bindgen(js_namespace = Reflect, js_name = get, catch)]
7453        pub fn get_symbol<T>(target: &Object<T>, key: &Symbol) -> Result<JsValue, JsValue>;
7454
7455        /// The same as [`get`](fn.get.html)
7456        /// except the key is an `f64`, which is slightly faster.
7457        #[wasm_bindgen(js_namespace = Reflect, js_name = get, catch)]
7458        pub fn get_f64(target: &JsValue, key: f64) -> Result<JsValue, JsValue>;
7459
7460        /// The same as [`get`](fn.get.html)
7461        /// except the key is a `u32`, which is slightly faster.
7462        #[wasm_bindgen(js_namespace = Reflect, js_name = get, catch)]
7463        pub fn get_u32(target: &JsValue, key: u32) -> Result<JsValue, JsValue>;
7464
7465        /// The static `Reflect.getOwnPropertyDescriptor()` method is similar to
7466        /// `Object.getOwnPropertyDescriptor()`. It returns a property descriptor
7467        /// of the given property if it exists on the object, `undefined` otherwise.
7468        ///
7469        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getOwnPropertyDescriptor)
7470        #[wasm_bindgen(js_namespace = Reflect, js_name = getOwnPropertyDescriptor, catch)]
7471        pub fn get_own_property_descriptor<T>(
7472            target: &Object<T>,
7473            property_key: &JsValue,
7474        ) -> Result<JsValue, JsValue>;
7475
7476        /// The static `Reflect.getOwnPropertyDescriptor()` method is similar to
7477        /// `Object.getOwnPropertyDescriptor()`. It returns a property descriptor
7478        /// of the given property if it exists on the object, `undefined` otherwise.
7479        ///
7480        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getOwnPropertyDescriptor)
7481        #[wasm_bindgen(js_namespace = Reflect, js_name = getOwnPropertyDescriptor, catch)]
7482        pub fn get_own_property_descriptor_str<T>(
7483            target: &Object<T>,
7484            property_key: &JsString,
7485        ) -> Result<PropertyDescriptor<T>, JsValue>;
7486
7487        /// The static `Reflect.getPrototypeOf()` method is almost the same
7488        /// method as `Object.getPrototypeOf()`. It returns the prototype
7489        /// (i.e. the value of the internal `[[Prototype]]` property) of
7490        /// the specified object.
7491        ///
7492        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getPrototypeOf)
7493        #[cfg(not(js_sys_unstable_apis))]
7494        #[wasm_bindgen(js_namespace = Reflect, js_name = getPrototypeOf, catch)]
7495        pub fn get_prototype_of(target: &JsValue) -> Result<Object, JsValue>;
7496
7497        /// The static `Reflect.getPrototypeOf()` method is almost the same
7498        /// method as `Object.getPrototypeOf()`. It returns the prototype
7499        /// (i.e. the value of the internal `[[Prototype]]` property) of
7500        /// the specified object.
7501        ///
7502        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getPrototypeOf)
7503        #[cfg(js_sys_unstable_apis)]
7504        #[wasm_bindgen(js_namespace = Reflect, js_name = getPrototypeOf, catch)]
7505        pub fn get_prototype_of(target: &Object) -> Result<Object, JsValue>;
7506
7507        /// The static `Reflect.has()` method works like the in operator as a
7508        /// function.
7509        ///
7510        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has)
7511        #[cfg(not(js_sys_unstable_apis))]
7512        #[wasm_bindgen(js_namespace = Reflect, catch)]
7513        pub fn has(target: &JsValue, property_key: &JsValue) -> Result<bool, JsValue>;
7514
7515        /// The static `Reflect.has()` method works like the in operator as a
7516        /// function.
7517        ///
7518        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has)
7519        #[cfg(js_sys_unstable_apis)]
7520        #[wasm_bindgen(js_namespace = Reflect, catch)]
7521        pub fn has(target: &JsValue, property_key: &Symbol) -> Result<bool, JsValue>;
7522
7523        // Next major: deprecate
7524        /// The static `Reflect.has()` method works like the in operator as a
7525        /// function.
7526        ///
7527        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has)
7528        #[wasm_bindgen(js_namespace = Reflect, js_name = has, catch)]
7529        pub fn has_str<T>(target: &Object<T>, property_key: &JsString) -> Result<bool, JsValue>;
7530
7531        /// The static `Reflect.has()` method works like the in operator as a
7532        /// function.
7533        ///
7534        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has)
7535        #[wasm_bindgen(js_namespace = Reflect, js_name = has, catch)]
7536        pub fn has_symbol<T>(target: &Object<T>, property_key: &Symbol) -> Result<bool, JsValue>;
7537
7538        /// The static `Reflect.isExtensible()` method determines if an object is
7539        /// extensible (whether it can have new properties added to it). It is
7540        /// similar to `Object.isExtensible()`, but with some differences.
7541        ///
7542        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/isExtensible)
7543        #[wasm_bindgen(js_namespace = Reflect, js_name = isExtensible, catch)]
7544        pub fn is_extensible<T>(target: &Object<T>) -> Result<bool, JsValue>;
7545
7546        /// The static `Reflect.ownKeys()` method returns an array of the
7547        /// target object's own property keys.
7548        ///
7549        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/ownKeys)
7550        #[wasm_bindgen(js_namespace = Reflect, js_name = ownKeys, catch)]
7551        pub fn own_keys(target: &JsValue) -> Result<Array, JsValue>;
7552
7553        /// The static `Reflect.preventExtensions()` method prevents new
7554        /// properties from ever being added to an object (i.e. prevents
7555        /// future extensions to the object). It is similar to
7556        /// `Object.preventExtensions()`, but with some differences.
7557        ///
7558        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/preventExtensions)
7559        #[wasm_bindgen(js_namespace = Reflect, js_name = preventExtensions, catch)]
7560        pub fn prevent_extensions<T>(target: &Object<T>) -> Result<bool, JsValue>;
7561
7562        /// The static `Reflect.set()` method works like setting a
7563        /// property on an object.
7564        ///
7565        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
7566        #[cfg(not(js_sys_unstable_apis))]
7567        #[wasm_bindgen(js_namespace = Reflect, catch)]
7568        pub fn set(
7569            target: &JsValue,
7570            property_key: &JsValue,
7571            value: &JsValue,
7572        ) -> Result<bool, JsValue>;
7573
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        #[cfg(js_sys_unstable_apis)]
7579        #[wasm_bindgen(js_namespace = Reflect, catch)]
7580        pub fn set<T>(
7581            target: &Object<T>,
7582            property_key: &JsString,
7583            value: &T,
7584        ) -> Result<bool, JsValue>;
7585
7586        /// The static `Reflect.set()` method works like setting a
7587        /// property on an object.
7588        ///
7589        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
7590        #[cfg(js_sys_unstable_apis)]
7591        #[wasm_bindgen(js_namespace = Reflect, catch)]
7592        pub fn set_symbol<T>(
7593            target: &Object<T>,
7594            property_key: &Symbol,
7595            value: &JsValue,
7596        ) -> Result<bool, JsValue>;
7597
7598        // Next major: deprecate
7599        /// The static `Reflect.set()` method works like setting a
7600        /// property on an object.
7601        ///
7602        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
7603        #[wasm_bindgen(js_namespace = Reflect, js_name = set, catch)]
7604        pub fn set_str<T>(
7605            target: &Object<T>,
7606            property_key: &JsString,
7607            value: &T,
7608        ) -> Result<bool, JsValue>;
7609
7610        /// The same as [`set`](fn.set.html)
7611        /// except the key is an `f64`, which is slightly faster.
7612        #[wasm_bindgen(js_namespace = Reflect, js_name = set, catch)]
7613        pub fn set_f64(
7614            target: &JsValue,
7615            property_key: f64,
7616            value: &JsValue,
7617        ) -> Result<bool, JsValue>;
7618
7619        /// The same as [`set`](fn.set.html)
7620        /// except the key is a `u32`, which is slightly faster.
7621        #[wasm_bindgen(js_namespace = Reflect, js_name = set, catch)]
7622        pub fn set_u32(
7623            target: &JsValue,
7624            property_key: u32,
7625            value: &JsValue,
7626        ) -> Result<bool, JsValue>;
7627
7628        /// The static `Reflect.set()` method works like setting a
7629        /// property on an object.
7630        ///
7631        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
7632        #[wasm_bindgen(js_namespace = Reflect, js_name = set, catch)]
7633        pub fn set_with_receiver(
7634            target: &JsValue,
7635            property_key: &JsValue,
7636            value: &JsValue,
7637            receiver: &JsValue,
7638        ) -> Result<bool, JsValue>;
7639
7640        /// The static `Reflect.setPrototypeOf()` method is the same
7641        /// method as `Object.setPrototypeOf()`. It sets the prototype
7642        /// (i.e., the internal `[[Prototype]]` property) of a specified
7643        /// object to another object or to null.
7644        ///
7645        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/setPrototypeOf)
7646        #[wasm_bindgen(js_namespace = Reflect, js_name = setPrototypeOf, catch)]
7647        pub fn set_prototype_of<T>(
7648            target: &Object<T>,
7649            prototype: &JsValue,
7650        ) -> Result<bool, JsValue>;
7651    }
7652}
7653
7654// RegExp
7655#[wasm_bindgen]
7656extern "C" {
7657    #[wasm_bindgen(extends = Object, typescript_type = "RegExp")]
7658    #[derive(Clone, Debug, PartialEq, Eq)]
7659    pub type RegExp;
7660
7661    /// The `exec()` method executes a search for a match in a specified
7662    /// string. Returns a result array, or null.
7663    ///
7664    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec)
7665    #[cfg(not(js_sys_unstable_apis))]
7666    #[wasm_bindgen(method)]
7667    pub fn exec(this: &RegExp, text: &str) -> Option<Array<JsString>>;
7668
7669    /// The `exec()` method executes a search for a match in a specified
7670    /// string. Returns a result array, or null.
7671    ///
7672    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec)
7673    #[cfg(js_sys_unstable_apis)]
7674    #[wasm_bindgen(method)]
7675    pub fn exec(this: &RegExp, text: &str) -> Option<RegExpMatchArray>;
7676
7677    /// The flags property returns a string consisting of the flags of
7678    /// the current regular expression object.
7679    ///
7680    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/flags)
7681    #[wasm_bindgen(method, getter)]
7682    pub fn flags(this: &RegExp) -> JsString;
7683
7684    /// The global property indicates whether or not the "g" flag is
7685    /// used with the regular expression. global is a read-only
7686    /// property of an individual regular expression instance.
7687    ///
7688    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/global)
7689    #[wasm_bindgen(method, getter)]
7690    pub fn global(this: &RegExp) -> bool;
7691
7692    /// The ignoreCase property indicates whether or not the "i" flag
7693    /// is used with the regular expression. ignoreCase is a read-only
7694    /// property of an individual regular expression instance.
7695    ///
7696    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/ignoreCase)
7697    #[wasm_bindgen(method, getter, js_name = ignoreCase)]
7698    pub fn ignore_case(this: &RegExp) -> bool;
7699
7700    /// The non-standard input property is a static property of
7701    /// regular expressions that contains the string against which a
7702    /// regular expression is matched. RegExp.$_ is an alias for this
7703    /// property.
7704    ///
7705    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/input)
7706    #[wasm_bindgen(static_method_of = RegExp, getter)]
7707    pub fn input() -> JsString;
7708
7709    /// The lastIndex is a read/write integer property of regular expression
7710    /// instances that specifies the index at which to start the next match.
7711    ///
7712    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex)
7713    #[wasm_bindgen(structural, getter = lastIndex, method)]
7714    pub fn last_index(this: &RegExp) -> u32;
7715
7716    /// The lastIndex is a read/write integer property of regular expression
7717    /// instances that specifies the index at which to start the next match.
7718    ///
7719    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex)
7720    #[wasm_bindgen(structural, setter = lastIndex, method)]
7721    pub fn set_last_index(this: &RegExp, index: u32);
7722
7723    /// The non-standard lastMatch property is a static and read-only
7724    /// property of regular expressions that contains the last matched
7725    /// characters. `RegExp.$&` is an alias for this property.
7726    ///
7727    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastMatch)
7728    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = lastMatch)]
7729    pub fn last_match() -> JsString;
7730
7731    /// The non-standard lastParen property is a static and read-only
7732    /// property of regular expressions that contains the last
7733    /// parenthesized substring match, if any. `RegExp.$+` is an alias
7734    /// for this property.
7735    ///
7736    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastParen)
7737    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = lastParen)]
7738    pub fn last_paren() -> JsString;
7739
7740    /// The non-standard leftContext property is a static and
7741    /// read-only property of regular expressions that contains the
7742    /// substring preceding the most recent match. `RegExp.$`` is an
7743    /// alias for this property.
7744    ///
7745    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/leftContext)
7746    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = leftContext)]
7747    pub fn left_context() -> JsString;
7748
7749    /// The multiline property indicates whether or not the "m" flag
7750    /// is used with the regular expression. multiline is a read-only
7751    /// property of an individual regular expression instance.
7752    ///
7753    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/multiline)
7754    #[wasm_bindgen(method, getter)]
7755    pub fn multiline(this: &RegExp) -> bool;
7756
7757    /// The non-standard $1, $2, $3, $4, $5, $6, $7, $8, $9 properties
7758    /// are static and read-only properties of regular expressions
7759    /// that contain parenthesized substring matches.
7760    ///
7761    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/n)
7762    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$1")]
7763    pub fn n1() -> JsString;
7764    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$2")]
7765    pub fn n2() -> JsString;
7766    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$3")]
7767    pub fn n3() -> JsString;
7768    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$4")]
7769    pub fn n4() -> JsString;
7770    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$5")]
7771    pub fn n5() -> JsString;
7772    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$6")]
7773    pub fn n6() -> JsString;
7774    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$7")]
7775    pub fn n7() -> JsString;
7776    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$8")]
7777    pub fn n8() -> JsString;
7778    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$9")]
7779    pub fn n9() -> JsString;
7780
7781    /// The `RegExp` constructor creates a regular expression object for matching text with a pattern.
7782    ///
7783    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp)
7784    #[wasm_bindgen(constructor)]
7785    pub fn new(pattern: &str, flags: &str) -> RegExp;
7786    #[wasm_bindgen(constructor)]
7787    pub fn new_regexp(pattern: &RegExp, flags: &str) -> RegExp;
7788
7789    /// The non-standard rightContext property is a static and
7790    /// read-only property of regular expressions that contains the
7791    /// substring following the most recent match. `RegExp.$'` is an
7792    /// alias for this property.
7793    ///
7794    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/rightContext)
7795    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = rightContext)]
7796    pub fn right_context() -> JsString;
7797
7798    /// The source property returns a String containing the source
7799    /// text of the regexp object, and it doesn't contain the two
7800    /// forward slashes on both sides and any flags.
7801    ///
7802    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/source)
7803    #[wasm_bindgen(method, getter)]
7804    pub fn source(this: &RegExp) -> JsString;
7805
7806    /// The sticky property reflects whether or not the search is
7807    /// sticky (searches in strings only from the index indicated by
7808    /// the lastIndex property of this regular expression). sticky is
7809    /// a read-only property of an individual regular expression
7810    /// object.
7811    ///
7812    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/sticky)
7813    #[wasm_bindgen(method, getter)]
7814    pub fn sticky(this: &RegExp) -> bool;
7815
7816    /// The `test()` method executes a search for a match between a
7817    /// regular expression and a specified string. Returns true or
7818    /// false.
7819    ///
7820    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)
7821    #[wasm_bindgen(method)]
7822    pub fn test(this: &RegExp, text: &str) -> bool;
7823
7824    /// The `toString()` method returns a string representing the
7825    /// regular expression.
7826    ///
7827    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/toString)
7828    #[cfg(not(js_sys_unstable_apis))]
7829    #[wasm_bindgen(method, js_name = toString)]
7830    pub fn to_string(this: &RegExp) -> JsString;
7831
7832    /// The unicode property indicates whether or not the "u" flag is
7833    /// used with a regular expression. unicode is a read-only
7834    /// property of an individual regular expression instance.
7835    ///
7836    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode)
7837    #[wasm_bindgen(method, getter)]
7838    pub fn unicode(this: &RegExp) -> bool;
7839}
7840
7841// RegExpMatchArray
7842#[wasm_bindgen]
7843extern "C" {
7844    /// The result array from `RegExp.exec()` or `String.matchAll()`.
7845    ///
7846    /// This is an array of strings with additional properties `index`, `input`, and `groups`.
7847    ///
7848    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec#return_value)
7849    #[wasm_bindgen(extends = Object, extends = Array, typescript_type = "RegExpMatchArray")]
7850    #[derive(Clone, Debug, PartialEq, Eq)]
7851    pub type RegExpMatchArray;
7852
7853    /// The 0-based index of the match in the string.
7854    #[wasm_bindgen(method, getter)]
7855    pub fn index(this: &RegExpMatchArray) -> u32;
7856
7857    /// The original string that was matched against.
7858    #[wasm_bindgen(method, getter)]
7859    pub fn input(this: &RegExpMatchArray) -> JsString;
7860
7861    /// An object of named capturing groups whose keys are the names and valuestype Array
7862    /// are the capturing groups, or `undefined` if no named capturing groups were defined.
7863    #[wasm_bindgen(method, getter)]
7864    pub fn groups(this: &RegExpMatchArray) -> Option<Object>;
7865
7866    /// The number of elements in the match array (full match + capture groups).
7867    #[wasm_bindgen(method, getter)]
7868    pub fn length(this: &RegExpMatchArray) -> u32;
7869
7870    /// Gets the matched string or capture group at the given index.
7871    /// Index 0 is the full match, indices 1+ are capture groups.
7872    #[wasm_bindgen(method, indexing_getter)]
7873    pub fn get(this: &RegExpMatchArray, index: u32) -> Option<JsString>;
7874}
7875
7876// Set
7877#[wasm_bindgen]
7878extern "C" {
7879    #[wasm_bindgen(extends = Object, typescript_type = "Set<any>")]
7880    #[derive(Clone, Debug, PartialEq, Eq)]
7881    pub type Set<T = JsValue>;
7882
7883    /// The [`Set`] object lets you store unique values of any type, whether
7884    /// primitive values or object references.
7885    ///
7886    /// **Note:** Consider using [`Set::new_typed`] to support typing.
7887    ///
7888    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
7889    #[cfg(not(js_sys_unstable_apis))]
7890    #[wasm_bindgen(constructor)]
7891    pub fn new(init: &JsValue) -> Set;
7892
7893    /// The [`Set`] object lets you store unique values of any type, whether
7894    /// primitive values or object references.
7895    ///
7896    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
7897    #[cfg(js_sys_unstable_apis)]
7898    #[wasm_bindgen(constructor)]
7899    pub fn new<T>() -> Set<T>;
7900
7901    // Next major: deprecate
7902    /// The [`Set`] object lets you store unique values of any type, whether
7903    /// primitive values or object references.
7904    ///
7905    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
7906    #[wasm_bindgen(constructor)]
7907    pub fn new_typed<T>() -> Set<T>;
7908
7909    /// The [`Set`] object lets you store unique values of any type, whether
7910    /// primitive values or object references.
7911    ///
7912    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
7913    #[wasm_bindgen(constructor, js_name = new)]
7914    pub fn new_empty<T>() -> Set<T>;
7915
7916    /// The [`Set`] object lets you store unique values of any type, whether
7917    /// primitive values or object references.
7918    ///
7919    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
7920    #[wasm_bindgen(constructor, js_name = new)]
7921    pub fn new_from_items<T>(items: &[T]) -> Set<T>;
7922
7923    /// The [`Set`] object lets you store unique values of any type, whether
7924    /// primitive values or object references.
7925    ///
7926    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
7927    #[wasm_bindgen(constructor, js_name = new, catch)]
7928    pub fn new_from_iterable<T, I: Iterable<Item = T>>(iterable: I) -> Result<Set<T>, JsValue>;
7929
7930    /// The `add()` method appends a new element with a specified value to the
7931    /// end of a [`Set`] object.
7932    ///
7933    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/add)
7934    #[wasm_bindgen(method)]
7935    pub fn add<T>(this: &Set<T>, value: &T) -> Set<T>;
7936
7937    /// The `clear()` method removes all elements from a [`Set`] object.
7938    ///
7939    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/clear)
7940    #[wasm_bindgen(method)]
7941    pub fn clear<T>(this: &Set<T>);
7942
7943    /// The `delete()` method removes the specified element from a [`Set`]
7944    /// object.
7945    ///
7946    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/delete)
7947    #[wasm_bindgen(method)]
7948    pub fn delete<T>(this: &Set<T>, value: &T) -> bool;
7949
7950    /// The `forEach()` method executes a provided function once for each value
7951    /// in the Set object, in insertion order.
7952    ///
7953    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/forEach)
7954    #[cfg(not(js_sys_unstable_apis))]
7955    #[wasm_bindgen(method, js_name = forEach)]
7956    pub fn for_each<T>(this: &Set<T>, callback: &mut dyn FnMut(T, T, Set<T>));
7957
7958    /// The `forEach()` method executes a provided function once for each value
7959    /// in the Set object, in insertion order.
7960    ///
7961    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/forEach)
7962    #[cfg(js_sys_unstable_apis)]
7963    #[wasm_bindgen(method, js_name = forEach)]
7964    pub fn for_each<T>(this: &Set<T>, callback: &mut dyn FnMut(T));
7965
7966    /// The `forEach()` method executes a provided function once for each value
7967    /// in the Set object, in insertion order.
7968    ///
7969    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/forEach)
7970    #[wasm_bindgen(method, js_name = forEach, catch)]
7971    pub fn try_for_each<T>(
7972        this: &Set<T>,
7973        callback: &mut dyn FnMut(T) -> Result<(), JsError>,
7974    ) -> Result<(), JsValue>;
7975
7976    /// The `has()` method returns a boolean indicating whether an element with
7977    /// the specified value exists in a [`Set`] object or not.
7978    ///
7979    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/has)
7980    #[wasm_bindgen(method)]
7981    pub fn has<T>(this: &Set<T>, value: &T) -> bool;
7982
7983    /// The size accessor property returns the number of elements in a [`Set`]
7984    /// object.
7985    ///
7986    /// [MDN documentation](https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Set/size)
7987    #[wasm_bindgen(method, getter)]
7988    pub fn size<T>(this: &Set<T>) -> u32;
7989
7990    /// The `union()` method returns a new set containing elements which are in
7991    /// either or both of this set and the given set.
7992    ///
7993    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/union)
7994    #[wasm_bindgen(method)]
7995    pub fn union<T>(this: &Set<T>, other: &Set<T>) -> Set<T>;
7996
7997    /// The `intersection()` method returns a new set containing elements which are
7998    /// in both this set and the given set.
7999    ///
8000    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/intersection)
8001    #[wasm_bindgen(method)]
8002    pub fn intersection<T>(this: &Set<T>, other: &Set<T>) -> Set<T>;
8003
8004    /// The `difference()` method returns a new set containing elements which are
8005    /// in this set but not in the given set.
8006    ///
8007    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/difference)
8008    #[wasm_bindgen(method)]
8009    pub fn difference<T>(this: &Set<T>, other: &Set<T>) -> Set<T>;
8010
8011    /// The `symmetricDifference()` method returns a new set containing elements
8012    /// which are in either this set or the given set, but not in both.
8013    ///
8014    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/symmetricDifference)
8015    #[wasm_bindgen(method, js_name = symmetricDifference)]
8016    pub fn symmetric_difference<T>(this: &Set<T>, other: &Set<T>) -> Set<T>;
8017
8018    /// The `isSubsetOf()` method returns a boolean indicating whether all elements
8019    /// of this set are in the given set.
8020    ///
8021    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/isSubsetOf)
8022    #[wasm_bindgen(method, js_name = isSubsetOf)]
8023    pub fn is_subset_of<T>(this: &Set<T>, other: &Set<T>) -> bool;
8024
8025    /// The `isSupersetOf()` method returns a boolean indicating whether all elements
8026    /// of the given set are in this set.
8027    ///
8028    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/isSupersetOf)
8029    #[wasm_bindgen(method, js_name = isSupersetOf)]
8030    pub fn is_superset_of<T>(this: &Set<T>, other: &Set<T>) -> bool;
8031
8032    /// The `isDisjointFrom()` method returns a boolean indicating whether this set
8033    /// has no elements in common with the given set.
8034    ///
8035    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/isDisjointFrom)
8036    #[wasm_bindgen(method, js_name = isDisjointFrom)]
8037    pub fn is_disjoint_from<T>(this: &Set<T>, other: &Set<T>) -> bool;
8038}
8039
8040impl Default for Set<JsValue> {
8041    fn default() -> Self {
8042        Self::new_typed()
8043    }
8044}
8045
8046impl<T> Iterable for Set<T> {
8047    type Item = T;
8048}
8049
8050// SetIterator
8051#[wasm_bindgen]
8052extern "C" {
8053    /// The `entries()` method returns a new Iterator object that contains an
8054    /// array of [value, value] for each element in the Set object, in insertion
8055    /// order. For Set objects there is no key like in Map objects. However, to
8056    /// keep the API similar to the Map object, each entry has the same value
8057    /// for its key and value here, so that an array [value, value] is returned.
8058    ///
8059    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/entries)
8060    #[cfg(not(js_sys_unstable_apis))]
8061    #[wasm_bindgen(method)]
8062    pub fn entries<T>(set: &Set<T>) -> Iterator;
8063
8064    /// The `entries()` method returns a new Iterator object that contains an
8065    /// array of [value, value] for each element in the Set object, in insertion
8066    /// order. For Set objects there is no key like in Map objects. However, to
8067    /// keep the API similar to the Map object, each entry has the same value
8068    /// for its key and value here, so that an array [value, value] is returned.
8069    ///
8070    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/entries)
8071    #[cfg(js_sys_unstable_apis)]
8072    #[wasm_bindgen(method, js_name = entries)]
8073    pub fn entries<T: JsGeneric>(set: &Set<T>) -> Iterator<ArrayTuple<(T, T)>>;
8074
8075    // Next major: deprecate
8076    /// The `entries()` method returns a new Iterator object that contains an
8077    /// array of [value, value] for each element in the Set object, in insertion
8078    /// order. For Set objects there is no key like in Map objects. However, to
8079    /// keep the API similar to the Map object, each entry has the same value
8080    /// for its key and value here, so that an array [value, value] is returned.
8081    ///
8082    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/entries)
8083    #[wasm_bindgen(method, js_name = entries)]
8084    pub fn entries_typed<T: JsGeneric>(set: &Set<T>) -> Iterator<ArrayTuple<(T, T)>>;
8085
8086    /// The `keys()` method is an alias for this method (for similarity with
8087    /// Map objects); it behaves exactly the same and returns values
8088    /// of Set elements.
8089    ///
8090    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/values)
8091    #[wasm_bindgen(method)]
8092    pub fn keys<T>(set: &Set<T>) -> Iterator<T>;
8093
8094    /// The `values()` method returns a new Iterator object that contains the
8095    /// values for each element in the Set object in insertion order.
8096    ///
8097    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/values)
8098    #[wasm_bindgen(method)]
8099    pub fn values<T>(set: &Set<T>) -> Iterator<T>;
8100}
8101
8102// SyntaxError
8103#[wasm_bindgen]
8104extern "C" {
8105    /// A `SyntaxError` is thrown when the JavaScript engine encounters tokens or
8106    /// token order that does not conform to the syntax of the language when
8107    /// parsing code.
8108    ///
8109    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError)
8110    #[wasm_bindgen(extends = Error, extends = Object, typescript_type = "SyntaxError")]
8111    #[derive(Clone, Debug, PartialEq, Eq)]
8112    pub type SyntaxError;
8113
8114    /// A `SyntaxError` is thrown when the JavaScript engine encounters tokens or
8115    /// token order that does not conform to the syntax of the language when
8116    /// parsing code.
8117    ///
8118    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError)
8119    #[wasm_bindgen(constructor)]
8120    pub fn new(message: &str) -> SyntaxError;
8121}
8122
8123// TypeError
8124#[wasm_bindgen]
8125extern "C" {
8126    /// The `TypeError` object represents an error when a value is not of the
8127    /// expected type.
8128    ///
8129    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError)
8130    #[wasm_bindgen(extends = Error, extends = Object, typescript_type = "TypeError")]
8131    #[derive(Clone, Debug, PartialEq, Eq)]
8132    pub type TypeError;
8133
8134    /// The `TypeError` object represents an error when a value is not of the
8135    /// expected type.
8136    ///
8137    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError)
8138    #[wasm_bindgen(constructor)]
8139    pub fn new(message: &str) -> TypeError;
8140}
8141
8142// URIError
8143#[wasm_bindgen]
8144extern "C" {
8145    /// The `URIError` object represents an error when a global URI handling
8146    /// function was used in a wrong way.
8147    ///
8148    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError)
8149    #[wasm_bindgen(extends = Error, extends = Object, js_name = URIError, typescript_type = "URIError")]
8150    #[derive(Clone, Debug, PartialEq, Eq)]
8151    pub type UriError;
8152
8153    /// The `URIError` object represents an error when a global URI handling
8154    /// function was used in a wrong way.
8155    ///
8156    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError)
8157    #[wasm_bindgen(constructor, js_class = "URIError")]
8158    pub fn new(message: &str) -> UriError;
8159}
8160
8161// WeakMap
8162#[wasm_bindgen]
8163extern "C" {
8164    #[wasm_bindgen(extends = Object, typescript_type = "WeakMap<object, any>")]
8165    #[derive(Clone, Debug, PartialEq, Eq)]
8166    pub type WeakMap<K = Object, V = JsValue>;
8167
8168    /// The [`WeakMap`] object is a collection of key/value pairs in which the
8169    /// keys are weakly referenced.  The keys must be objects and the values can
8170    /// be arbitrary values.
8171    ///
8172    /// **Note:** Consider using [`WeakMap::new_typed`] to support typing.
8173    ///
8174    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap)
8175    #[cfg(not(js_sys_unstable_apis))]
8176    #[wasm_bindgen(constructor)]
8177    pub fn new() -> WeakMap;
8178
8179    /// The [`WeakMap`] object is a collection of key/value pairs in which the
8180    /// keys are weakly referenced.  The keys must be objects and the values can
8181    /// be arbitrary values.
8182    ///
8183    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap)
8184    #[cfg(js_sys_unstable_apis)]
8185    #[wasm_bindgen(constructor)]
8186    pub fn new<K: JsGeneric = Object, V: JsGeneric = Object>() -> WeakMap<K, V>;
8187
8188    // Next major: deprecate
8189    /// The [`WeakMap`] object is a collection of key/value pairs in which the
8190    /// keys are weakly referenced.  The keys must be objects and the values can
8191    /// be arbitrary values.
8192    ///
8193    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap)
8194    #[wasm_bindgen(constructor)]
8195    pub fn new_typed<K: JsGeneric = Object, V: JsGeneric = Object>() -> WeakMap<K, V>;
8196
8197    /// The `set()` method sets the value for the key in the [`WeakMap`] object.
8198    /// Returns the [`WeakMap`] object.
8199    ///
8200    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/set)
8201    #[wasm_bindgen(method, js_class = "WeakMap")]
8202    pub fn set<K, V>(this: &WeakMap<K, V>, key: &K, value: &V) -> WeakMap<K, V>;
8203
8204    /// The `get()` method returns a specified by key element
8205    /// from a [`WeakMap`] object. Returns `undefined` if the key is not found.
8206    ///
8207    /// **Note:** Consider using [`WeakMap::get_checked`] to get an `Option<V>` instead.
8208    ///
8209    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/get)
8210    #[cfg(not(js_sys_unstable_apis))]
8211    #[wasm_bindgen(method)]
8212    pub fn get<K, V>(this: &WeakMap<K, V>, key: &K) -> V;
8213
8214    /// The `get()` method returns a specified by key element
8215    /// from a [`WeakMap`] object. Returns `None` if the key is not found.
8216    ///
8217    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/get)
8218    #[cfg(js_sys_unstable_apis)]
8219    #[wasm_bindgen(method)]
8220    pub fn get<K, V>(this: &WeakMap<K, V>, key: &K) -> Option<V>;
8221
8222    /// The `get()` method returns a specified by key element
8223    /// from a [`WeakMap`] object. Returns `None` if the key is not found.
8224    ///
8225    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/get)
8226    #[wasm_bindgen(method, js_name = get)]
8227    pub fn get_checked<K, V>(this: &WeakMap<K, V>, key: &K) -> Option<V>;
8228
8229    /// The `has()` method returns a boolean indicating whether an element with
8230    /// the specified key exists in the [`WeakMap`] object or not.
8231    ///
8232    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/has)
8233    #[wasm_bindgen(method)]
8234    pub fn has<K, V>(this: &WeakMap<K, V>, key: &K) -> bool;
8235
8236    /// The `delete()` method removes the specified element from a [`WeakMap`]
8237    /// object.
8238    ///
8239    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/delete)
8240    #[wasm_bindgen(method)]
8241    pub fn delete<K, V>(this: &WeakMap<K, V>, key: &K) -> bool;
8242}
8243
8244impl Default for WeakMap {
8245    fn default() -> Self {
8246        Self::new()
8247    }
8248}
8249
8250// WeakSet
8251#[wasm_bindgen]
8252extern "C" {
8253    #[wasm_bindgen(extends = Object, typescript_type = "WeakSet<object>")]
8254    #[derive(Clone, Debug, PartialEq, Eq)]
8255    pub type WeakSet<T = Object>;
8256
8257    /// The `WeakSet` object lets you store weakly held objects in a collection.
8258    ///
8259    /// **Note:** Consider using [`WeakSet::new_typed`] for typed sets.
8260    ///
8261    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet)
8262    #[cfg(not(js_sys_unstable_apis))]
8263    #[wasm_bindgen(constructor)]
8264    pub fn new() -> WeakSet;
8265
8266    /// The `WeakSet` object lets you store weakly held objects in a collection.
8267    ///
8268    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet)
8269    #[cfg(js_sys_unstable_apis)]
8270    #[wasm_bindgen(constructor)]
8271    pub fn new<T = Object>() -> WeakSet<T>;
8272
8273    // Next major: deprecate
8274    /// The `WeakSet` object lets you store weakly held objects in a collection.
8275    ///
8276    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet)
8277    #[wasm_bindgen(constructor)]
8278    pub fn new_typed<T = Object>() -> WeakSet<T>;
8279
8280    /// The `has()` method returns a boolean indicating whether an object exists
8281    /// in a WeakSet or not.
8282    ///
8283    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/has)
8284    #[wasm_bindgen(method)]
8285    pub fn has<T>(this: &WeakSet<T>, value: &T) -> bool;
8286
8287    /// The `add()` method appends a new object to the end of a WeakSet object.
8288    ///
8289    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/add)
8290    #[wasm_bindgen(method)]
8291    pub fn add<T>(this: &WeakSet<T>, value: &T) -> WeakSet<T>;
8292
8293    /// The `delete()` method removes the specified element from a WeakSet
8294    /// object.
8295    ///
8296    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/delete)
8297    #[wasm_bindgen(method)]
8298    pub fn delete<T>(this: &WeakSet<T>, value: &T) -> bool;
8299}
8300
8301impl Default for WeakSet {
8302    fn default() -> Self {
8303        Self::new()
8304    }
8305}
8306
8307// WeakRef
8308#[wasm_bindgen]
8309extern "C" {
8310    #[wasm_bindgen(extends = Object, typescript_type = "WeakRef<object>")]
8311    #[derive(Clone, Debug, PartialEq, Eq)]
8312    pub type WeakRef<T = Object>;
8313
8314    /// The `WeakRef` object contains a weak reference to an object. A weak
8315    /// reference to an object is a reference that does not prevent the object
8316    /// from being reclaimed by the garbage collector.
8317    ///
8318    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakRef)
8319    #[wasm_bindgen(constructor)]
8320    pub fn new<T = Object>(target: &T) -> WeakRef<T>;
8321
8322    /// Returns the `Object` this `WeakRef` points to, or `None` if the
8323    /// object has been garbage collected.
8324    ///
8325    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakRef/deref)
8326    #[wasm_bindgen(method)]
8327    pub fn deref<T>(this: &WeakRef<T>) -> Option<T>;
8328}
8329
8330#[cfg(js_sys_unstable_apis)]
8331#[allow(non_snake_case)]
8332pub mod Temporal;
8333
8334#[allow(non_snake_case)]
8335pub mod WebAssembly {
8336    use super::*;
8337
8338    // WebAssembly
8339    #[wasm_bindgen]
8340    extern "C" {
8341        /// The `WebAssembly.compile()` function compiles a `WebAssembly.Module`
8342        /// from WebAssembly binary code.  This function is useful if it is
8343        /// necessary to a compile a module before it can be instantiated
8344        /// (otherwise, the `WebAssembly.instantiate()` function should be used).
8345        ///
8346        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compile)
8347        #[cfg(not(js_sys_unstable_apis))]
8348        #[wasm_bindgen(js_namespace = WebAssembly)]
8349        pub fn compile(buffer_source: &JsValue) -> Promise<JsValue>;
8350
8351        /// The `WebAssembly.compile()` function compiles a `WebAssembly.Module`
8352        /// from WebAssembly binary code.  This function is useful if it is
8353        /// necessary to a compile a module before it can be instantiated
8354        /// (otherwise, the `WebAssembly.instantiate()` function should be used).
8355        ///
8356        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compile)
8357        #[cfg(js_sys_unstable_apis)]
8358        #[wasm_bindgen(js_namespace = WebAssembly)]
8359        pub fn compile(buffer_source: &JsValue) -> Promise<Module>;
8360
8361        /// The `WebAssembly.compileStreaming()` function compiles a
8362        /// `WebAssembly.Module` module directly from a streamed underlying
8363        /// source. This function is useful if it is necessary to a compile a
8364        /// module before it can be instantiated (otherwise, the
8365        /// `WebAssembly.instantiateStreaming()` function should be used).
8366        ///
8367        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming)
8368        #[cfg(not(js_sys_unstable_apis))]
8369        #[wasm_bindgen(js_namespace = WebAssembly, js_name = compileStreaming)]
8370        pub fn compile_streaming(response: &Promise) -> Promise<JsValue>;
8371
8372        /// The `WebAssembly.compileStreaming()` function compiles a
8373        /// `WebAssembly.Module` module directly from a streamed underlying
8374        /// source. This function is useful if it is necessary to a compile a
8375        /// module before it can be instantiated (otherwise, the
8376        /// `WebAssembly.instantiateStreaming()` function should be used).
8377        ///
8378        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming)
8379        #[cfg(js_sys_unstable_apis)]
8380        #[wasm_bindgen(js_namespace = WebAssembly, js_name = compileStreaming)]
8381        pub fn compile_streaming(response: &Promise) -> Promise<Module>;
8382
8383        /// The `WebAssembly.instantiate()` function allows you to compile and
8384        /// instantiate WebAssembly code.
8385        ///
8386        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate)
8387        #[cfg(not(js_sys_unstable_apis))]
8388        #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiate)]
8389        pub fn instantiate_buffer(buffer: &[u8], imports: &Object) -> Promise<JsValue>;
8390
8391        /// The `WebAssembly.instantiate()` function allows you to compile and
8392        /// instantiate WebAssembly code.
8393        ///
8394        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate)
8395        #[cfg(js_sys_unstable_apis)]
8396        #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiate)]
8397        pub fn instantiate_buffer(buffer: &[u8], imports: &Object) -> Promise<Instance>;
8398
8399        /// The `WebAssembly.instantiate()` function allows you to compile and
8400        /// instantiate WebAssembly code.
8401        ///
8402        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate)
8403        #[cfg(not(js_sys_unstable_apis))]
8404        #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiate)]
8405        pub fn instantiate_module(module: &Module, imports: &Object) -> Promise<JsValue>;
8406
8407        /// The `WebAssembly.instantiate()` function allows you to compile and
8408        /// instantiate WebAssembly code.
8409        ///
8410        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate)
8411        #[cfg(js_sys_unstable_apis)]
8412        #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiate)]
8413        pub fn instantiate_module(module: &Module, imports: &Object) -> Promise<Instance>;
8414
8415        /// The `WebAssembly.instantiateStreaming()` function compiles and
8416        /// instantiates a WebAssembly module directly from a streamed
8417        /// underlying source. This is the most efficient, optimized way to load
8418        /// Wasm code.
8419        ///
8420        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming)
8421        #[cfg(not(js_sys_unstable_apis))]
8422        #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiateStreaming)]
8423        pub fn instantiate_streaming(response: &JsValue, imports: &Object) -> Promise<JsValue>;
8424
8425        /// The `WebAssembly.instantiateStreaming()` function compiles and
8426        /// instantiates a WebAssembly module directly from a streamed
8427        /// underlying source. This is the most efficient, optimized way to load
8428        /// Wasm code.
8429        ///
8430        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming)
8431        #[cfg(js_sys_unstable_apis)]
8432        #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiateStreaming)]
8433        pub fn instantiate_streaming(response: &JsValue, imports: &Object) -> Promise<Instance>;
8434
8435        /// The `WebAssembly.validate()` function validates a given typed
8436        /// array of WebAssembly binary code, returning whether the bytes
8437        /// form a valid Wasm module (`true`) or not (`false`).
8438        ///
8439        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/validate)
8440        #[wasm_bindgen(js_namespace = WebAssembly, catch)]
8441        pub fn validate(buffer_source: &JsValue) -> Result<bool, JsValue>;
8442    }
8443
8444    // WebAssembly.CompileError
8445    #[wasm_bindgen]
8446    extern "C" {
8447        /// The `WebAssembly.CompileError()` constructor creates a new
8448        /// WebAssembly `CompileError` object, which indicates an error during
8449        /// WebAssembly decoding or validation.
8450        ///
8451        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError)
8452        #[wasm_bindgen(extends = Error, js_namespace = WebAssembly, typescript_type = "WebAssembly.CompileError")]
8453        #[derive(Clone, Debug, PartialEq, Eq)]
8454        pub type CompileError;
8455
8456        /// The `WebAssembly.CompileError()` constructor creates a new
8457        /// WebAssembly `CompileError` object, which indicates an error during
8458        /// WebAssembly decoding or validation.
8459        ///
8460        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError)
8461        #[wasm_bindgen(constructor, js_namespace = WebAssembly)]
8462        pub fn new(message: &str) -> CompileError;
8463    }
8464
8465    // WebAssembly.Instance
8466    #[wasm_bindgen]
8467    extern "C" {
8468        /// A `WebAssembly.Instance` object is a stateful, executable instance
8469        /// of a `WebAssembly.Module`. Instance objects contain all the exported
8470        /// WebAssembly functions that allow calling into WebAssembly code from
8471        /// JavaScript.
8472        ///
8473        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance)
8474        #[wasm_bindgen(extends = Object, js_namespace = WebAssembly, typescript_type = "WebAssembly.Instance")]
8475        #[derive(Clone, Debug, PartialEq, Eq)]
8476        pub type Instance;
8477
8478        /// The `WebAssembly.Instance()` constructor function can be called to
8479        /// synchronously instantiate a given `WebAssembly.Module`
8480        /// object. However, the primary way to get an `Instance` is through the
8481        /// asynchronous `WebAssembly.instantiateStreaming()` function.
8482        ///
8483        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance)
8484        #[wasm_bindgen(catch, constructor, js_namespace = WebAssembly)]
8485        pub fn new(module: &Module, imports: &Object) -> Result<Instance, JsValue>;
8486
8487        /// The `exports` readonly property of the `WebAssembly.Instance` object
8488        /// prototype returns an object containing as its members all the
8489        /// functions exported from the WebAssembly module instance, to allow
8490        /// them to be accessed and used by JavaScript.
8491        ///
8492        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/exports)
8493        #[wasm_bindgen(getter, method, js_namespace = WebAssembly)]
8494        pub fn exports(this: &Instance) -> Object;
8495    }
8496
8497    // WebAssembly.LinkError
8498    #[wasm_bindgen]
8499    extern "C" {
8500        /// The `WebAssembly.LinkError()` constructor creates a new WebAssembly
8501        /// LinkError object, which indicates an error during module
8502        /// instantiation (besides traps from the start function).
8503        ///
8504        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError)
8505        #[wasm_bindgen(extends = Error, js_namespace = WebAssembly, typescript_type = "WebAssembly.LinkError")]
8506        #[derive(Clone, Debug, PartialEq, Eq)]
8507        pub type LinkError;
8508
8509        /// The `WebAssembly.LinkError()` constructor creates a new WebAssembly
8510        /// LinkError object, which indicates an error during module
8511        /// instantiation (besides traps from the start function).
8512        ///
8513        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError)
8514        #[wasm_bindgen(constructor, js_namespace = WebAssembly)]
8515        pub fn new(message: &str) -> LinkError;
8516    }
8517
8518    // WebAssembly.RuntimeError
8519    #[wasm_bindgen]
8520    extern "C" {
8521        /// The `WebAssembly.RuntimeError()` constructor creates a new WebAssembly
8522        /// `RuntimeError` object — the type that is thrown whenever WebAssembly
8523        /// specifies a trap.
8524        ///
8525        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError)
8526        #[wasm_bindgen(extends = Error, js_namespace = WebAssembly, typescript_type = "WebAssembly.RuntimeError")]
8527        #[derive(Clone, Debug, PartialEq, Eq)]
8528        pub type RuntimeError;
8529
8530        /// The `WebAssembly.RuntimeError()` constructor creates a new WebAssembly
8531        /// `RuntimeError` object — the type that is thrown whenever WebAssembly
8532        /// specifies a trap.
8533        ///
8534        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError)
8535        #[wasm_bindgen(constructor, js_namespace = WebAssembly)]
8536        pub fn new(message: &str) -> RuntimeError;
8537    }
8538
8539    // WebAssembly.Module
8540    #[wasm_bindgen]
8541    extern "C" {
8542        /// A `WebAssembly.Module` object contains stateless WebAssembly code
8543        /// that has already been compiled by the browser and can be
8544        /// efficiently shared with Workers, and instantiated multiple times.
8545        ///
8546        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module)
8547        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Module")]
8548        #[derive(Clone, Debug, PartialEq, Eq)]
8549        pub type Module;
8550
8551        /// A `WebAssembly.Module` object contains stateless WebAssembly code
8552        /// that has already been compiled by the browser and can be
8553        /// efficiently shared with Workers, and instantiated multiple times.
8554        ///
8555        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module)
8556        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8557        pub fn new(buffer_source: &JsValue) -> Result<Module, JsValue>;
8558
8559        /// The `WebAssembly.customSections()` function returns a copy of the
8560        /// contents of all custom sections in the given module with the given
8561        /// string name.
8562        ///
8563        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/customSections)
8564        #[wasm_bindgen(static_method_of = Module, js_namespace = WebAssembly, js_name = customSections)]
8565        pub fn custom_sections(module: &Module, sectionName: &str) -> Array;
8566
8567        /// The `WebAssembly.exports()` function returns an array containing
8568        /// descriptions of all the declared exports of the given `Module`.
8569        ///
8570        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/exports)
8571        #[wasm_bindgen(static_method_of = Module, js_namespace = WebAssembly)]
8572        pub fn exports(module: &Module) -> Array;
8573
8574        /// The `WebAssembly.imports()` function returns an array containing
8575        /// descriptions of all the declared imports of the given `Module`.
8576        ///
8577        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/imports)
8578        #[wasm_bindgen(static_method_of = Module, js_namespace = WebAssembly)]
8579        pub fn imports(module: &Module) -> Array;
8580    }
8581
8582    // WebAssembly.Table
8583    #[wasm_bindgen]
8584    extern "C" {
8585        /// The `WebAssembly.Table()` constructor creates a new `Table` object
8586        /// of the given size and element type.
8587        ///
8588        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table)
8589        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Table")]
8590        #[derive(Clone, Debug, PartialEq, Eq)]
8591        pub type Table;
8592
8593        /// The `WebAssembly.Table()` constructor creates a new `Table` object
8594        /// of the given size and element type.
8595        ///
8596        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table)
8597        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8598        pub fn new(table_descriptor: &Object) -> Result<Table, JsValue>;
8599
8600        /// The `WebAssembly.Table()` constructor creates a new `Table` object
8601        /// of the given size and element type.
8602        ///
8603        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table)
8604        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8605        pub fn new_with_value(table_descriptor: &Object, value: JsValue) -> Result<Table, JsValue>;
8606
8607        /// The length prototype property of the `WebAssembly.Table` object
8608        /// returns the length of the table, i.e. the number of elements in the
8609        /// table.
8610        ///
8611        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/length)
8612        #[wasm_bindgen(method, getter, js_namespace = WebAssembly)]
8613        pub fn length(this: &Table) -> u32;
8614
8615        /// The `get()` prototype method of the `WebAssembly.Table()` object
8616        /// retrieves a function reference stored at a given index.
8617        ///
8618        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/get)
8619        #[wasm_bindgen(method, catch, js_namespace = WebAssembly)]
8620        pub fn get(this: &Table, index: u32) -> Result<Function, JsValue>;
8621
8622        /// The `get()` prototype method of the `WebAssembly.Table()` object
8623        /// retrieves a function reference stored at a given index.
8624        ///
8625        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/get)
8626        #[wasm_bindgen(method, catch, js_namespace = WebAssembly, js_name = get)]
8627        pub fn get_raw(this: &Table, index: u32) -> Result<JsValue, JsValue>;
8628
8629        /// The `grow()` prototype method of the `WebAssembly.Table` object
8630        /// increases the size of the `Table` instance by a specified number of
8631        /// elements.
8632        ///
8633        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/grow)
8634        #[wasm_bindgen(method, catch, js_namespace = WebAssembly)]
8635        pub fn grow(this: &Table, additional_capacity: u32) -> Result<u32, JsValue>;
8636
8637        /// The `grow()` prototype method of the `WebAssembly.Table` object
8638        /// increases the size of the `Table` instance by a specified number of
8639        /// elements.
8640        ///
8641        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/grow)
8642        #[wasm_bindgen(method, catch, js_namespace = WebAssembly, js_name = grow)]
8643        pub fn grow_with_value(
8644            this: &Table,
8645            additional_capacity: u32,
8646            value: JsValue,
8647        ) -> Result<u32, JsValue>;
8648
8649        /// The `set()` prototype method of the `WebAssembly.Table` object mutates a
8650        /// reference stored at a given index to a different value.
8651        ///
8652        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/set)
8653        #[wasm_bindgen(method, catch, js_namespace = WebAssembly)]
8654        pub fn set(this: &Table, index: u32, function: &Function) -> Result<(), JsValue>;
8655
8656        /// The `set()` prototype method of the `WebAssembly.Table` object mutates a
8657        /// reference stored at a given index to a different value.
8658        ///
8659        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/set)
8660        #[wasm_bindgen(method, catch, js_namespace = WebAssembly, js_name = set)]
8661        pub fn set_raw(this: &Table, index: u32, value: &JsValue) -> Result<(), JsValue>;
8662    }
8663
8664    // WebAssembly.Tag
8665    #[wasm_bindgen]
8666    extern "C" {
8667        /// The `WebAssembly.Tag()` constructor creates a new `Tag` object
8668        ///
8669        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Tag)
8670        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Tag")]
8671        #[derive(Clone, Debug, PartialEq, Eq)]
8672        pub type Tag;
8673
8674        /// The `WebAssembly.Tag()` constructor creates a new `Tag` object
8675        ///
8676        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Tag)
8677        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8678        pub fn new(tag_descriptor: &Object) -> Result<Tag, JsValue>;
8679    }
8680
8681    // WebAssembly.Exception
8682    #[wasm_bindgen]
8683    extern "C" {
8684        /// The `WebAssembly.Exception()` constructor creates a new `Exception` object
8685        ///
8686        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Exception)
8687        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Exception")]
8688        #[derive(Clone, Debug, PartialEq, Eq)]
8689        pub type Exception;
8690
8691        /// The `WebAssembly.Exception()` constructor creates a new `Exception` object
8692        ///
8693        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Exception)
8694        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8695        pub fn new(tag: &Tag, payload: &Array) -> Result<Exception, JsValue>;
8696
8697        /// The `WebAssembly.Exception()` constructor creates a new `Exception` object
8698        ///
8699        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Exception)
8700        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8701        pub fn new_with_options(
8702            tag: &Tag,
8703            payload: &Array,
8704            options: &Object,
8705        ) -> Result<Exception, JsValue>;
8706
8707        /// The `is()` prototype method of the `WebAssembly.Exception` can be used to
8708        /// test if the Exception matches a given tag.
8709        ///
8710        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Exception/is)
8711        #[wasm_bindgen(method, js_namespace = WebAssembly)]
8712        pub fn is(this: &Exception, tag: &Tag) -> bool;
8713
8714        /// The `getArg()` prototype method of the `WebAssembly.Exception` can be used
8715        /// to get the value of a specified item in the exception's data arguments
8716        ///
8717        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Exception/getArg)
8718        #[wasm_bindgen(method, js_namespace = WebAssembly, js_name = getArg, catch)]
8719        pub fn get_arg(this: &Exception, tag: &Tag, index: u32) -> Result<JsValue, JsValue>;
8720    }
8721
8722    // WebAssembly.Global
8723    #[wasm_bindgen]
8724    extern "C" {
8725        /// The `WebAssembly.Global()` constructor creates a new `Global` object
8726        /// of the given type and value.
8727        ///
8728        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global)
8729        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Global")]
8730        #[derive(Clone, Debug, PartialEq, Eq)]
8731        pub type Global;
8732
8733        /// The `WebAssembly.Global()` constructor creates a new `Global` object
8734        /// of the given type and value.
8735        ///
8736        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global)
8737        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8738        pub fn new(global_descriptor: &Object, value: &JsValue) -> Result<Global, JsValue>;
8739
8740        /// The value prototype property of the `WebAssembly.Global` object
8741        /// returns the value of the global.
8742        ///
8743        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global)
8744        #[wasm_bindgen(method, getter, js_namespace = WebAssembly)]
8745        pub fn value(this: &Global) -> JsValue;
8746        #[wasm_bindgen(method, setter = value, js_namespace = WebAssembly)]
8747        pub fn set_value(this: &Global, value: &JsValue);
8748    }
8749
8750    // WebAssembly.Memory
8751    #[wasm_bindgen]
8752    extern "C" {
8753        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory)
8754        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Memory")]
8755        #[derive(Clone, Debug, PartialEq, Eq)]
8756        pub type Memory;
8757
8758        /// The `WebAssembly.Memory()` constructor creates a new `Memory` object
8759        /// which is a resizable `ArrayBuffer` that holds the raw bytes of
8760        /// memory accessed by a WebAssembly `Instance`.
8761        ///
8762        /// A memory created by JavaScript or in WebAssembly code will be
8763        /// accessible and mutable from both JavaScript and WebAssembly.
8764        ///
8765        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory)
8766        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8767        pub fn new(descriptor: &Object) -> Result<Memory, JsValue>;
8768
8769        /// An accessor property that returns the buffer contained in the
8770        /// memory.
8771        ///
8772        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/buffer)
8773        #[wasm_bindgen(method, getter, js_namespace = WebAssembly)]
8774        pub fn buffer(this: &Memory) -> JsValue;
8775
8776        /// The `grow()` prototype method of the `Memory` object increases the
8777        /// size of the memory instance by a specified number of WebAssembly
8778        /// pages.
8779        ///
8780        /// Takes the number of pages to grow (64KiB in size) and returns the
8781        /// previous size of memory, in pages.
8782        ///
8783        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/grow)
8784        #[wasm_bindgen(method, js_namespace = WebAssembly)]
8785        pub fn grow(this: &Memory, pages: u32) -> u32;
8786    }
8787}
8788
8789/// The `JSON` object contains methods for parsing [JavaScript Object
8790/// Notation (JSON)](https://json.org/) and converting values to JSON. It
8791/// can't be called or constructed, and aside from its two method
8792/// properties, it has no interesting functionality of its own.
8793#[allow(non_snake_case)]
8794pub mod JSON {
8795    use super::*;
8796
8797    // JSON
8798    #[wasm_bindgen]
8799    extern "C" {
8800        /// The `JSON.parse()` method parses a JSON string, constructing the
8801        /// JavaScript value or object described by the string.
8802        ///
8803        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse)
8804        #[wasm_bindgen(catch, js_namespace = JSON)]
8805        pub fn parse(text: &str) -> Result<JsValue, JsValue>;
8806
8807        /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
8808        ///
8809        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
8810        #[wasm_bindgen(catch, js_namespace = JSON)]
8811        pub fn stringify(obj: &JsValue) -> Result<JsString, JsValue>;
8812
8813        /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
8814        ///
8815        /// The `replacer` argument is a function that alters the behavior of the stringification
8816        /// process, or an array of String and Number objects that serve as a whitelist
8817        /// for selecting/filtering the properties of the value object to be included
8818        /// in the JSON string. If this value is null or not provided, all properties
8819        /// of the object are included in the resulting JSON string.
8820        ///
8821        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
8822        #[cfg(not(js_sys_unstable_apis))]
8823        #[wasm_bindgen(catch, js_namespace = JSON, js_name = stringify)]
8824        pub fn stringify_with_replacer(
8825            obj: &JsValue,
8826            replacer: &JsValue,
8827        ) -> Result<JsString, JsValue>;
8828
8829        /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
8830        ///
8831        /// The `replacer` argument is a function that alters the behavior of the stringification
8832        /// process, or an array of String and Number objects that serve as a whitelist
8833        /// for selecting/filtering the properties of the value object to be included
8834        /// in the JSON string. If this value is null or not provided, all properties
8835        /// of the object are included in the resulting JSON string.
8836        ///
8837        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
8838        #[cfg(js_sys_unstable_apis)]
8839        #[wasm_bindgen(catch, js_namespace = JSON, js_name = stringify)]
8840        pub fn stringify_with_replacer<'a>(
8841            obj: &JsValue,
8842            replacer: &mut dyn FnMut(JsString, JsValue) -> Result<Option<JsValue>, JsError>,
8843            space: Option<u32>,
8844        ) -> Result<JsString, JsValue>;
8845
8846        // Next major: deprecate
8847        /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
8848        ///
8849        /// The `replacer` argument is a function that alters the behavior of the stringification
8850        /// process, or an array of String and Number objects that serve as a whitelist
8851        /// for selecting/filtering the properties of the value object to be included
8852        /// in the JSON string. If this value is null or not provided, all properties
8853        /// of the object are included in the resulting JSON string.
8854        ///
8855        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
8856        #[wasm_bindgen(catch, js_namespace = JSON, js_name = stringify)]
8857        pub fn stringify_with_replacer_func<'a>(
8858            obj: &JsValue,
8859            replacer: &mut dyn FnMut(JsString, JsValue) -> Result<Option<JsValue>, JsError>,
8860            space: Option<u32>,
8861        ) -> Result<JsString, JsValue>;
8862
8863        /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
8864        ///
8865        /// The `replacer` argument is a function that alters the behavior of the stringification
8866        /// process, or an array of String and Number objects that serve as a whitelist
8867        /// for selecting/filtering the properties of the value object to be included
8868        /// in the JSON string. If this value is null or not provided, all properties
8869        /// of the object are included in the resulting JSON string.
8870        ///
8871        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
8872        #[wasm_bindgen(catch, js_namespace = JSON, js_name = stringify)]
8873        pub fn stringify_with_replacer_list(
8874            obj: &JsValue,
8875            replacer: Vec<String>,
8876            space: Option<u32>,
8877        ) -> Result<JsString, JsValue>;
8878
8879        // Next major: deprecate
8880        /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
8881        ///
8882        /// The `replacer` argument is a function that alters the behavior of the stringification
8883        /// process, or an array of String and Number objects that serve as a whitelist
8884        /// for selecting/filtering the properties of the value object to be included
8885        /// in the JSON string. If this value is null or not provided, all properties
8886        /// of the object are included in the resulting JSON string.
8887        ///
8888        /// The `space` argument is a String or Number object that's used to insert white space into
8889        /// the output JSON string for readability purposes. If this is a Number, it
8890        /// indicates the number of space characters to use as white space; this number
8891        /// is capped at 10 (if it is greater, the value is just 10). Values less than
8892        /// 1 indicate that no space should be used. If this is a String, the string
8893        /// (or the first 10 characters of the string, if it's longer than that) is
8894        /// used as white space. If this parameter is not provided (or is null), no
8895        /// white space is used.
8896        ///
8897        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
8898        #[wasm_bindgen(catch, js_namespace = JSON, js_name = stringify)]
8899        pub fn stringify_with_replacer_and_space(
8900            obj: &JsValue,
8901            replacer: &JsValue,
8902            space: &JsValue,
8903        ) -> Result<JsString, JsValue>;
8904    }
8905}
8906// JsString
8907#[wasm_bindgen]
8908extern "C" {
8909    #[wasm_bindgen(js_name = String, extends = Object, is_type_of = JsValue::is_string, typescript_type = "string")]
8910    #[derive(Clone, PartialEq, Eq)]
8911    pub type JsString;
8912
8913    /// The length property of a String object indicates the length of a string,
8914    /// in UTF-16 code units.
8915    ///
8916    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length)
8917    #[wasm_bindgen(method, getter)]
8918    pub fn length(this: &JsString) -> u32;
8919
8920    /// The 'at()' method returns a new string consisting of the single UTF-16
8921    /// code unit located at the specified offset into the string, counting from
8922    /// the end if it's negative.
8923    ///
8924    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/at)
8925    #[wasm_bindgen(method, js_class = "String")]
8926    pub fn at(this: &JsString, index: i32) -> Option<JsString>;
8927
8928    /// The String object's `charAt()` method returns a new string consisting of
8929    /// the single UTF-16 code unit located at the specified offset into the
8930    /// string.
8931    ///
8932    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt)
8933    #[wasm_bindgen(method, js_class = "String", js_name = charAt)]
8934    pub fn char_at(this: &JsString, index: u32) -> JsString;
8935
8936    /// The `charCodeAt()` method returns an integer between 0 and 65535
8937    /// representing the UTF-16 code unit at the given index (the UTF-16 code
8938    /// unit matches the Unicode code point for code points representable in a
8939    /// single UTF-16 code unit, but might also be the first code unit of a
8940    /// surrogate pair for code points not representable in a single UTF-16 code
8941    /// unit, e.g. Unicode code points > 0x10000).  If you want the entire code
8942    /// point value, use `codePointAt()`.
8943    ///
8944    /// Returns `NaN` if index is out of range.
8945    ///
8946    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt)
8947    #[wasm_bindgen(method, js_class = "String", js_name = charCodeAt)]
8948    pub fn char_code_at(this: &JsString, index: u32) -> f64;
8949
8950    /// The `codePointAt()` method returns a non-negative integer that is the
8951    /// Unicode code point value.
8952    ///
8953    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)
8954    #[cfg(not(js_sys_unstable_apis))]
8955    #[wasm_bindgen(method, js_class = "String", js_name = codePointAt)]
8956    pub fn code_point_at(this: &JsString, pos: u32) -> JsValue;
8957
8958    /// The `codePointAt()` method returns a non-negative integer that is the
8959    /// Unicode code point value.
8960    ///
8961    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)
8962    #[cfg(js_sys_unstable_apis)]
8963    #[wasm_bindgen(method, js_class = "String", js_name = codePointAt)]
8964    pub fn code_point_at(this: &JsString, pos: u32) -> Option<u32>;
8965
8966    // Next major: deprecate
8967    /// The `codePointAt()` method returns a non-negative integer that is the
8968    /// Unicode code point value.
8969    ///
8970    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)
8971    #[wasm_bindgen(method, js_class = "String", js_name = codePointAt)]
8972    pub fn try_code_point_at(this: &JsString, pos: u32) -> Option<u16>;
8973
8974    /// The `concat()` method concatenates the string arguments to the calling
8975    /// string and returns a new string.
8976    ///
8977    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat)
8978    #[cfg(not(js_sys_unstable_apis))]
8979    #[wasm_bindgen(method, js_class = "String")]
8980    pub fn concat(this: &JsString, string_2: &JsValue) -> JsString;
8981
8982    /// The `concat()` method concatenates the string arguments to the calling
8983    /// string and returns a new string.
8984    ///
8985    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat)
8986    #[cfg(js_sys_unstable_apis)]
8987    #[wasm_bindgen(method, js_class = "String")]
8988    pub fn concat(this: &JsString, string: &JsString) -> JsString;
8989
8990    /// The `concat()` method concatenates the string arguments to the calling
8991    /// string and returns a new string.
8992    ///
8993    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat)
8994    #[wasm_bindgen(method, js_class = "String")]
8995    pub fn concat_many(this: &JsString, strings: &[JsString]) -> JsString;
8996
8997    /// The `endsWith()` method determines whether a string ends with the characters of a
8998    /// specified string, returning true or false as appropriate.
8999    ///
9000    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith)
9001    #[cfg(not(js_sys_unstable_apis))]
9002    #[wasm_bindgen(method, js_class = "String", js_name = endsWith)]
9003    pub fn ends_with(this: &JsString, search_string: &str, length: i32) -> bool;
9004
9005    /// The `endsWith()` method determines whether a string ends with the characters of a
9006    /// specified string, returning true or false as appropriate.
9007    ///
9008    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith)
9009    #[cfg(js_sys_unstable_apis)]
9010    #[wasm_bindgen(method, js_class = "String", js_name = endsWith)]
9011    pub fn ends_with(this: &JsString, search_string: &str) -> bool;
9012
9013    /// The static `String.fromCharCode()` method returns a string created from
9014    /// the specified sequence of UTF-16 code units.
9015    ///
9016    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9017    ///
9018    /// # Notes
9019    ///
9020    /// There are a few bindings to `from_char_code` in `js-sys`: `from_char_code1`, `from_char_code2`, etc...
9021    /// with different arities.
9022    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode, variadic)]
9023    pub fn from_char_code(char_codes: &[u16]) -> JsString;
9024
9025    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9026    #[cfg(not(js_sys_unstable_apis))]
9027    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9028    pub fn from_char_code1(a: u32) -> JsString;
9029
9030    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9031    #[cfg(js_sys_unstable_apis)]
9032    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9033    pub fn from_char_code1(a: u16) -> JsString;
9034
9035    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9036    #[cfg(not(js_sys_unstable_apis))]
9037    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9038    pub fn from_char_code2(a: u32, b: u32) -> JsString;
9039
9040    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9041    #[cfg(js_sys_unstable_apis)]
9042    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9043    pub fn from_char_code2(a: u16, b: u16) -> JsString;
9044
9045    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9046    #[cfg(not(js_sys_unstable_apis))]
9047    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9048    pub fn from_char_code3(a: u32, b: u32, c: u32) -> JsString;
9049
9050    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9051    #[cfg(js_sys_unstable_apis)]
9052    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9053    pub fn from_char_code3(a: u16, b: u16, c: u16) -> JsString;
9054
9055    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9056    #[cfg(not(js_sys_unstable_apis))]
9057    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9058    pub fn from_char_code4(a: u32, b: u32, c: u32, d: u32) -> JsString;
9059
9060    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9061    #[cfg(js_sys_unstable_apis)]
9062    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9063    pub fn from_char_code4(a: u16, b: u16, c: u16, d: u16) -> JsString;
9064
9065    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9066    #[cfg(not(js_sys_unstable_apis))]
9067    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9068    pub fn from_char_code5(a: u32, b: u32, c: u32, d: u32, e: u32) -> JsString;
9069
9070    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9071    #[cfg(js_sys_unstable_apis)]
9072    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9073    pub fn from_char_code5(a: u16, b: u16, c: u16, d: u16, e: u16) -> JsString;
9074
9075    /// The static `String.fromCodePoint()` method returns a string created by
9076    /// using the specified sequence of code points.
9077    ///
9078    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
9079    ///
9080    /// # Exceptions
9081    ///
9082    /// A RangeError is thrown if an invalid Unicode code point is given
9083    ///
9084    /// # Notes
9085    ///
9086    /// There are a few bindings to `from_code_point` in `js-sys`: `from_code_point1`, `from_code_point2`, etc...
9087    /// with different arities.
9088    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint, variadic)]
9089    pub fn from_code_point(code_points: &[u32]) -> Result<JsString, JsValue>;
9090
9091    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
9092    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint)]
9093    pub fn from_code_point1(a: u32) -> Result<JsString, JsValue>;
9094
9095    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
9096    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint)]
9097    pub fn from_code_point2(a: u32, b: u32) -> Result<JsString, JsValue>;
9098
9099    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
9100    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint)]
9101    pub fn from_code_point3(a: u32, b: u32, c: u32) -> Result<JsString, JsValue>;
9102
9103    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
9104    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint)]
9105    pub fn from_code_point4(a: u32, b: u32, c: u32, d: u32) -> Result<JsString, JsValue>;
9106
9107    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
9108    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint)]
9109    pub fn from_code_point5(a: u32, b: u32, c: u32, d: u32, e: u32) -> Result<JsString, JsValue>;
9110
9111    /// The `includes()` method determines whether one string may be found
9112    /// within another string, returning true or false as appropriate.
9113    ///
9114    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes)
9115    #[wasm_bindgen(method, js_class = "String")]
9116    pub fn includes(this: &JsString, search_string: &str, position: i32) -> bool;
9117
9118    /// The `indexOf()` method returns the index within the calling String
9119    /// object of the first occurrence of the specified value, starting the
9120    /// search at fromIndex.  Returns -1 if the value is not found.
9121    ///
9122    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf)
9123    #[wasm_bindgen(method, js_class = "String", js_name = indexOf)]
9124    pub fn index_of(this: &JsString, search_value: &str, from_index: i32) -> i32;
9125
9126    /// The `lastIndexOf()` method returns the index within the calling String
9127    /// object of the last occurrence of the specified value, searching
9128    /// backwards from fromIndex.  Returns -1 if the value is not found.
9129    ///
9130    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf)
9131    #[wasm_bindgen(method, js_class = "String", js_name = lastIndexOf)]
9132    pub fn last_index_of(this: &JsString, search_value: &str, from_index: i32) -> i32;
9133
9134    /// The `localeCompare()` method returns a number indicating whether
9135    /// a reference string comes before or after or is the same as
9136    /// the given string in sort order.
9137    ///
9138    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare)
9139    #[cfg(not(js_sys_unstable_apis))]
9140    #[wasm_bindgen(method, js_class = "String", js_name = localeCompare)]
9141    pub fn locale_compare(
9142        this: &JsString,
9143        compare_string: &str,
9144        locales: &Array,
9145        options: &Object,
9146    ) -> i32;
9147
9148    /// The `localeCompare()` method returns a number indicating whether
9149    /// a reference string comes before or after or is the same as
9150    /// the given string in sort order.
9151    ///
9152    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare)
9153    #[cfg(js_sys_unstable_apis)]
9154    #[wasm_bindgen(method, js_class = "String", js_name = localeCompare)]
9155    pub fn locale_compare(
9156        this: &JsString,
9157        compare_string: &str,
9158        locales: &[JsString],
9159        options: &Intl::CollatorOptions,
9160    ) -> i32;
9161
9162    /// The `match()` method retrieves the matches when matching a string against a regular expression.
9163    ///
9164    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match)
9165    #[wasm_bindgen(method, js_class = "String", js_name = match)]
9166    pub fn match_(this: &JsString, pattern: &RegExp) -> Option<Object>;
9167
9168    /// The `match_all()` method is similar to `match()`, but gives an iterator of `exec()` arrays, which preserve capture groups.
9169    ///
9170    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/matchAll)
9171    #[cfg(not(js_sys_unstable_apis))]
9172    #[wasm_bindgen(method, js_class = "String", js_name = matchAll)]
9173    pub fn match_all(this: &JsString, pattern: &RegExp) -> Iterator;
9174
9175    /// The `match_all()` method is similar to `match()`, but gives an iterator of `exec()` arrays, which preserve capture groups.
9176    ///
9177    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/matchAll)
9178    #[cfg(js_sys_unstable_apis)]
9179    #[wasm_bindgen(method, js_class = "String", js_name = matchAll)]
9180    pub fn match_all(this: &JsString, pattern: &RegExp) -> Iterator<RegExpMatchArray>;
9181
9182    /// The `normalize()` method returns the Unicode Normalization Form
9183    /// of a given string (if the value isn't a string, it will be converted to one first).
9184    ///
9185    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
9186    #[wasm_bindgen(method, js_class = "String")]
9187    pub fn normalize(this: &JsString, form: &str) -> JsString;
9188
9189    /// The `padEnd()` method pads the current string with a given string
9190    /// (repeated, if needed) so that the resulting string reaches a given
9191    /// length. The padding is applied from the end (right) of the current
9192    /// string.
9193    ///
9194    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd)
9195    #[wasm_bindgen(method, js_class = "String", js_name = padEnd)]
9196    pub fn pad_end(this: &JsString, target_length: u32, pad_string: &str) -> JsString;
9197
9198    /// The `padStart()` method pads the current string with another string
9199    /// (repeated, if needed) so that the resulting string reaches the given
9200    /// length. The padding is applied from the start (left) of the current
9201    /// string.
9202    ///
9203    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart)
9204    #[wasm_bindgen(method, js_class = "String", js_name = padStart)]
9205    pub fn pad_start(this: &JsString, target_length: u32, pad_string: &str) -> JsString;
9206
9207    /// The `repeat()` method constructs and returns a new string which contains the specified
9208    /// number of copies of the string on which it was called, concatenated together.
9209    ///
9210    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat)
9211    #[wasm_bindgen(method, js_class = "String")]
9212    pub fn repeat(this: &JsString, count: i32) -> JsString;
9213
9214    /// The `replace()` method returns a new string with some or all matches of a pattern
9215    /// replaced by a replacement. The pattern can be a string or a RegExp, and
9216    /// the replacement can be a string or a function to be called for each match.
9217    ///
9218    /// Note: The original string will remain unchanged.
9219    ///
9220    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
9221    #[wasm_bindgen(method, js_class = "String")]
9222    pub fn replace(this: &JsString, pattern: &str, 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_with_function(
9228        this: &JsString,
9229        pattern: &str,
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_with_function(
9241        this: &JsString,
9242        pattern: &str,
9243        replacement: &Function<fn(JsString) -> JsString>,
9244    ) -> JsString;
9245
9246    #[wasm_bindgen(method, js_class = "String", js_name = replace)]
9247    pub fn replace_by_pattern(this: &JsString, pattern: &RegExp, replacement: &str) -> JsString;
9248
9249    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
9250    #[cfg(not(js_sys_unstable_apis))]
9251    #[wasm_bindgen(method, js_class = "String", js_name = replace)]
9252    pub fn replace_by_pattern_with_function(
9253        this: &JsString,
9254        pattern: &RegExp,
9255        replacement: &Function,
9256    ) -> JsString;
9257
9258    /// The replacer function signature is `(match, offset, string) -> replacement`
9259    /// for patterns without capture groups, or `(match, p1, p2, ..., pN, offset, string, groups) -> replacement`
9260    /// when capture groups are present.
9261    ///
9262    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
9263    #[cfg(js_sys_unstable_apis)]
9264    #[wasm_bindgen(method, js_class = "String", js_name = replace)]
9265    pub fn replace_by_pattern_with_function(
9266        this: &JsString,
9267        pattern: &RegExp,
9268        replacement: &Function<fn(JsString) -> JsString>,
9269    ) -> JsString;
9270
9271    /// The `replace_all()` method returns a new string with all matches of a pattern
9272    /// replaced by a replacement. The pattern can be a string or a global RegExp, and
9273    /// the replacement can be a string or a function to be called for each match.
9274    ///
9275    /// Note: The original string will remain unchanged.
9276    ///
9277    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll)
9278    #[wasm_bindgen(method, js_class = "String", js_name = replaceAll)]
9279    pub fn replace_all(this: &JsString, pattern: &str, replacement: &str) -> JsString;
9280
9281    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll)
9282    #[cfg(not(js_sys_unstable_apis))]
9283    #[wasm_bindgen(method, js_class = "String", js_name = replaceAll)]
9284    pub fn replace_all_with_function(
9285        this: &JsString,
9286        pattern: &str,
9287        replacement: &Function,
9288    ) -> JsString;
9289
9290    /// The replacer function signature is `(match, offset, string) -> replacement`
9291    /// for patterns without capture groups, or `(match, p1, p2, ..., pN, offset, string, groups) -> replacement`
9292    /// when capture groups are present.
9293    ///
9294    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll)
9295    #[cfg(js_sys_unstable_apis)]
9296    #[wasm_bindgen(method, js_class = "String", js_name = replaceAll)]
9297    pub fn replace_all_with_function(
9298        this: &JsString,
9299        pattern: &str,
9300        replacement: &Function<fn(JsString) -> JsString>,
9301    ) -> JsString;
9302
9303    #[wasm_bindgen(method, js_class = "String", js_name = replaceAll)]
9304    pub fn replace_all_by_pattern(this: &JsString, pattern: &RegExp, replacement: &str)
9305        -> JsString;
9306
9307    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll)
9308    #[cfg(not(js_sys_unstable_apis))]
9309    #[wasm_bindgen(method, js_class = "String", js_name = replaceAll)]
9310    pub fn replace_all_by_pattern_with_function(
9311        this: &JsString,
9312        pattern: &RegExp,
9313        replacement: &Function,
9314    ) -> JsString;
9315
9316    /// The replacer function signature is `(match, offset, string) -> replacement`
9317    /// for patterns without capture groups, or `(match, p1, p2, ..., pN, offset, string, groups) -> replacement`
9318    /// when capture groups are present.
9319    ///
9320    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll)
9321    #[cfg(js_sys_unstable_apis)]
9322    #[wasm_bindgen(method, js_class = "String", js_name = replaceAll)]
9323    pub fn replace_all_by_pattern_with_function(
9324        this: &JsString,
9325        pattern: &RegExp,
9326        replacement: &Function<fn(JsString) -> JsString>,
9327    ) -> JsString;
9328
9329    /// The `search()` method executes a search for a match between
9330    /// a regular expression and this String object.
9331    ///
9332    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/search)
9333    #[wasm_bindgen(method, js_class = "String")]
9334    pub fn search(this: &JsString, pattern: &RegExp) -> i32;
9335
9336    /// The `slice()` method extracts a section of a string and returns it as a
9337    /// new string, without modifying the original string.
9338    ///
9339    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice)
9340    #[wasm_bindgen(method, js_class = "String")]
9341    pub fn slice(this: &JsString, start: u32, end: u32) -> JsString;
9342
9343    /// The `split()` method splits a String object into an array of strings by separating the string
9344    /// into substrings, using a specified separator string to determine where to make each split.
9345    ///
9346    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
9347    #[wasm_bindgen(method, js_class = "String")]
9348    pub fn split(this: &JsString, separator: &str) -> Array;
9349
9350    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
9351    #[wasm_bindgen(method, js_class = "String", js_name = split)]
9352    pub fn split_limit(this: &JsString, separator: &str, limit: u32) -> Array;
9353
9354    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
9355    #[wasm_bindgen(method, js_class = "String", js_name = split)]
9356    pub fn split_by_pattern(this: &JsString, pattern: &RegExp) -> Array;
9357
9358    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
9359    #[wasm_bindgen(method, js_class = "String", js_name = split)]
9360    pub fn split_by_pattern_limit(this: &JsString, pattern: &RegExp, limit: u32) -> Array;
9361
9362    /// The `startsWith()` method determines whether a string begins with the
9363    /// characters of a specified string, returning true or false as
9364    /// appropriate.
9365    ///
9366    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith)
9367    #[wasm_bindgen(method, js_class = "String", js_name = startsWith)]
9368    pub fn starts_with(this: &JsString, search_string: &str, position: u32) -> bool;
9369
9370    /// The `substring()` method returns the part of the string between the
9371    /// start and end indexes, or to the end of the string.
9372    ///
9373    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring)
9374    #[wasm_bindgen(method, js_class = "String")]
9375    pub fn substring(this: &JsString, index_start: u32, index_end: u32) -> JsString;
9376
9377    /// The `substr()` method returns the part of a string between
9378    /// the start index and a number of characters after it.
9379    ///
9380    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr)
9381    #[wasm_bindgen(method, js_class = "String")]
9382    pub fn substr(this: &JsString, start: i32, length: i32) -> JsString;
9383
9384    /// The `toLocaleLowerCase()` method returns the calling string value converted to lower case,
9385    /// according to any locale-specific case mappings.
9386    ///
9387    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase)
9388    #[wasm_bindgen(method, js_class = "String", js_name = toLocaleLowerCase)]
9389    pub fn to_locale_lower_case(this: &JsString, locale: Option<&str>) -> JsString;
9390
9391    /// The `toLocaleUpperCase()` method returns the calling string value converted to upper case,
9392    /// according to any locale-specific case mappings.
9393    ///
9394    /// [MDN documentation](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase)
9395    #[wasm_bindgen(method, js_class = "String", js_name = toLocaleUpperCase)]
9396    pub fn to_locale_upper_case(this: &JsString, locale: Option<&str>) -> JsString;
9397
9398    /// The `toLowerCase()` method returns the calling string value
9399    /// converted to lower case.
9400    ///
9401    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase)
9402    #[wasm_bindgen(method, js_class = "String", js_name = toLowerCase)]
9403    pub fn to_lower_case(this: &JsString) -> JsString;
9404
9405    /// The `toString()` method returns a string representing the specified
9406    /// object.
9407    ///
9408    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toString)
9409    #[cfg(not(js_sys_unstable_apis))]
9410    #[wasm_bindgen(method, js_class = "String", js_name = toString)]
9411    pub fn to_string(this: &JsString) -> JsString;
9412
9413    /// The `toUpperCase()` method returns the calling string value converted to
9414    /// uppercase (the value will be converted to a string if it isn't one).
9415    ///
9416    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase)
9417    #[wasm_bindgen(method, js_class = "String", js_name = toUpperCase)]
9418    pub fn to_upper_case(this: &JsString) -> JsString;
9419
9420    /// The `trim()` method removes whitespace from both ends of a string.
9421    /// Whitespace in this context is all the whitespace characters (space, tab,
9422    /// no-break space, etc.) and all the line terminator characters (LF, CR,
9423    /// etc.).
9424    ///
9425    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim)
9426    #[wasm_bindgen(method, js_class = "String")]
9427    pub fn trim(this: &JsString) -> JsString;
9428
9429    /// The `trimEnd()` method removes whitespace from the end of a string.
9430    /// `trimRight()` is an alias of this method.
9431    ///
9432    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd)
9433    #[wasm_bindgen(method, js_class = "String", js_name = trimEnd)]
9434    pub fn trim_end(this: &JsString) -> JsString;
9435
9436    /// The `trimEnd()` method removes whitespace from the end of a string.
9437    /// `trimRight()` is an alias of this method.
9438    ///
9439    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd)
9440    #[wasm_bindgen(method, js_class = "String", js_name = trimRight)]
9441    pub fn trim_right(this: &JsString) -> JsString;
9442
9443    /// The `trimStart()` method removes whitespace from the beginning of a
9444    /// string. `trimLeft()` is an alias of this method.
9445    ///
9446    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart)
9447    #[wasm_bindgen(method, js_class = "String", js_name = trimStart)]
9448    pub fn trim_start(this: &JsString) -> JsString;
9449
9450    /// The `trimStart()` method removes whitespace from the beginning of a
9451    /// string. `trimLeft()` is an alias of this method.
9452    ///
9453    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart)
9454    #[wasm_bindgen(method, js_class = "String", js_name = trimLeft)]
9455    pub fn trim_left(this: &JsString) -> JsString;
9456
9457    /// The `valueOf()` method returns the primitive value of a `String` object.
9458    ///
9459    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/valueOf)
9460    #[wasm_bindgen(method, js_class = "String", js_name = valueOf)]
9461    pub fn value_of(this: &JsString) -> JsString;
9462
9463    /// The static `raw()` method is a tag function of template literals,
9464    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9465    ///
9466    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9467    #[wasm_bindgen(catch, variadic, static_method_of = JsString, js_class = "String")]
9468    pub fn raw(call_site: &Object, substitutions: &Array) -> 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_0(call_site: &Object) -> Result<JsString, JsValue>;
9476
9477    /// The static `raw()` method is a tag function of template literals,
9478    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9479    ///
9480    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9481    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
9482    pub fn raw_1(call_site: &Object, substitutions_1: &str) -> Result<JsString, JsValue>;
9483
9484    /// The static `raw()` method is a tag function of template literals,
9485    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9486    ///
9487    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9488    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
9489    pub fn raw_2(
9490        call_site: &Object,
9491        substitutions1: &str,
9492        substitutions2: &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_3(
9501        call_site: &Object,
9502        substitutions1: &str,
9503        substitutions2: &str,
9504        substitutions3: &str,
9505    ) -> Result<JsString, JsValue>;
9506
9507    /// The static `raw()` method is a tag function of template literals,
9508    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9509    ///
9510    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9511    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
9512    pub fn raw_4(
9513        call_site: &Object,
9514        substitutions1: &str,
9515        substitutions2: &str,
9516        substitutions3: &str,
9517        substitutions4: &str,
9518    ) -> Result<JsString, JsValue>;
9519
9520    /// The static `raw()` method is a tag function of template literals,
9521    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9522    ///
9523    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9524    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
9525    pub fn raw_5(
9526        call_site: &Object,
9527        substitutions1: &str,
9528        substitutions2: &str,
9529        substitutions3: &str,
9530        substitutions4: &str,
9531        substitutions5: &str,
9532    ) -> Result<JsString, JsValue>;
9533
9534    /// The static `raw()` method is a tag function of template literals,
9535    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9536    ///
9537    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9538    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
9539    pub fn raw_6(
9540        call_site: &Object,
9541        substitutions1: &str,
9542        substitutions2: &str,
9543        substitutions3: &str,
9544        substitutions4: &str,
9545        substitutions5: &str,
9546        substitutions6: &str,
9547    ) -> Result<JsString, JsValue>;
9548
9549    /// The static `raw()` method is a tag function of template literals,
9550    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9551    ///
9552    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9553    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
9554    pub fn raw_7(
9555        call_site: &Object,
9556        substitutions1: &str,
9557        substitutions2: &str,
9558        substitutions3: &str,
9559        substitutions4: &str,
9560        substitutions5: &str,
9561        substitutions6: &str,
9562        substitutions7: &str,
9563    ) -> Result<JsString, JsValue>;
9564}
9565
9566// These upcasts are non-castable due to the constraints on the function
9567// but the UpcastFrom covariance must still extend through closure types.
9568// (impl UpcastFrom really just means CovariantGeneric relation)
9569impl UpcastFrom<String> for JsString {}
9570impl UpcastFrom<JsString> for String {}
9571
9572impl UpcastFrom<&str> for JsString {}
9573impl UpcastFrom<JsString> for &str {}
9574
9575impl UpcastFrom<char> for JsString {}
9576impl UpcastFrom<JsString> for char {}
9577
9578impl JsString {
9579    /// Returns the `JsString` value of this JS value if it's an instance of a
9580    /// string.
9581    ///
9582    /// If this JS value is not an instance of a string then this returns
9583    /// `None`.
9584    #[cfg(not(js_sys_unstable_apis))]
9585    #[deprecated(note = "recommended to use dyn_ref instead which is now equivalent")]
9586    pub fn try_from(val: &JsValue) -> Option<&JsString> {
9587        val.dyn_ref()
9588    }
9589
9590    /// Returns whether this string is a valid UTF-16 string.
9591    ///
9592    /// This is useful for learning whether `String::from(..)` will return a
9593    /// lossless representation of the JS string. If this string contains
9594    /// unpaired surrogates then `String::from` will succeed but it will be a
9595    /// lossy representation of the JS string because unpaired surrogates will
9596    /// become replacement characters.
9597    ///
9598    /// If this function returns `false` then to get a lossless representation
9599    /// of the string you'll need to manually use the `iter` method (or the
9600    /// `char_code_at` accessor) to view the raw character codes.
9601    ///
9602    /// For more information, see the documentation on [JS strings vs Rust
9603    /// strings][docs]
9604    ///
9605    /// [docs]: https://wasm-bindgen.github.io/wasm-bindgen/reference/types/str.html
9606    pub fn is_valid_utf16(&self) -> bool {
9607        core::char::decode_utf16(self.iter()).all(|i| i.is_ok())
9608    }
9609
9610    /// Returns an iterator over the `u16` character codes that make up this JS
9611    /// string.
9612    ///
9613    /// This method will call `char_code_at` for each code in this JS string,
9614    /// returning an iterator of the codes in sequence.
9615    pub fn iter(
9616        &self,
9617    ) -> impl ExactSizeIterator<Item = u16> + DoubleEndedIterator<Item = u16> + '_ {
9618        (0..self.length()).map(move |i| self.char_code_at(i) as u16)
9619    }
9620
9621    /// If this string consists of a single Unicode code point, then this method
9622    /// converts it into a Rust `char` without doing any allocations.
9623    ///
9624    /// If this JS value is not a valid UTF-8 or consists of more than a single
9625    /// codepoint, then this returns `None`.
9626    ///
9627    /// Note that a single Unicode code point might be represented as more than
9628    /// one code unit on the JavaScript side. For example, a JavaScript string
9629    /// `"\uD801\uDC37"` is actually a single Unicode code point U+10437 which
9630    /// corresponds to a character '𐐷'.
9631    pub fn as_char(&self) -> Option<char> {
9632        let len = self.length();
9633
9634        if len == 0 || len > 2 {
9635            return None;
9636        }
9637
9638        #[cfg(not(js_sys_unstable_apis))]
9639        let cp = self.code_point_at(0).as_f64().unwrap_throw() as u32;
9640        #[cfg(js_sys_unstable_apis)]
9641        let cp = self.code_point_at(0)?;
9642
9643        let c = core::char::from_u32(cp)?;
9644
9645        if c.len_utf16() as u32 == len {
9646            Some(c)
9647        } else {
9648            None
9649        }
9650    }
9651}
9652
9653impl PartialEq<str> for JsString {
9654    #[allow(clippy::cmp_owned)] // prevent infinite recursion
9655    fn eq(&self, other: &str) -> bool {
9656        String::from(self) == other
9657    }
9658}
9659
9660impl<'a> PartialEq<&'a str> for JsString {
9661    fn eq(&self, other: &&'a str) -> bool {
9662        <JsString as PartialEq<str>>::eq(self, other)
9663    }
9664}
9665
9666impl PartialEq<String> for JsString {
9667    fn eq(&self, other: &String) -> bool {
9668        <JsString as PartialEq<str>>::eq(self, other)
9669    }
9670}
9671
9672impl<'a> PartialEq<&'a String> for JsString {
9673    fn eq(&self, other: &&'a String) -> bool {
9674        <JsString as PartialEq<str>>::eq(self, other)
9675    }
9676}
9677
9678impl Default for JsString {
9679    fn default() -> Self {
9680        Self::from("")
9681    }
9682}
9683
9684impl<'a> From<&'a str> for JsString {
9685    fn from(s: &'a str) -> Self {
9686        JsString::unchecked_from_js(JsValue::from_str(s))
9687    }
9688}
9689
9690impl From<String> for JsString {
9691    fn from(s: String) -> Self {
9692        From::from(&*s)
9693    }
9694}
9695
9696impl From<char> for JsString {
9697    #[inline]
9698    fn from(c: char) -> Self {
9699        JsString::from_code_point1(c as u32).unwrap_throw()
9700    }
9701}
9702
9703impl<'a> From<&'a JsString> for String {
9704    fn from(s: &'a JsString) -> Self {
9705        s.obj.as_string().unwrap_throw()
9706    }
9707}
9708
9709impl From<JsString> for String {
9710    fn from(s: JsString) -> Self {
9711        From::from(&s)
9712    }
9713}
9714
9715impl fmt::Debug for JsString {
9716    #[inline]
9717    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
9718        fmt::Debug::fmt(&String::from(self), f)
9719    }
9720}
9721
9722impl fmt::Display for JsString {
9723    #[inline]
9724    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
9725        fmt::Display::fmt(&String::from(self), f)
9726    }
9727}
9728
9729impl str::FromStr for JsString {
9730    type Err = convert::Infallible;
9731    fn from_str(s: &str) -> Result<Self, Self::Err> {
9732        Ok(JsString::from(s))
9733    }
9734}
9735
9736// Symbol
9737#[wasm_bindgen]
9738extern "C" {
9739    #[wasm_bindgen(is_type_of = JsValue::is_symbol, typescript_type = "Symbol")]
9740    #[derive(Clone, Debug)]
9741    pub type Symbol;
9742
9743    /// The `Symbol.hasInstance` well-known symbol is used to determine
9744    /// if a constructor object recognizes an object as its instance.
9745    /// The `instanceof` operator's behavior can be customized by this symbol.
9746    ///
9747    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/hasInstance)
9748    #[wasm_bindgen(static_method_of = Symbol, getter, js_name = hasInstance)]
9749    pub fn has_instance() -> Symbol;
9750
9751    /// The `Symbol.isConcatSpreadable` well-known symbol is used to configure
9752    /// if an object should be flattened to its array elements when using the
9753    /// `Array.prototype.concat()` method.
9754    ///
9755    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/isConcatSpreadable)
9756    #[wasm_bindgen(static_method_of = Symbol, getter, js_name = isConcatSpreadable)]
9757    pub fn is_concat_spreadable() -> Symbol;
9758
9759    /// The `Symbol.asyncIterator` well-known symbol specifies the default AsyncIterator for an object.
9760    /// If this property is set on an object, it is an async iterable and can be used in a `for await...of` loop.
9761    ///
9762    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator)
9763    #[wasm_bindgen(static_method_of = Symbol, getter, js_name = asyncIterator)]
9764    pub fn async_iterator() -> Symbol;
9765
9766    /// The `Symbol.iterator` well-known symbol specifies the default iterator
9767    /// for an object.  Used by `for...of`.
9768    ///
9769    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/iterator)
9770    #[wasm_bindgen(static_method_of = Symbol, getter)]
9771    pub fn iterator() -> Symbol;
9772
9773    /// The `Symbol.match` well-known symbol specifies the matching of a regular
9774    /// expression against a string. This function is called by the
9775    /// `String.prototype.match()` method.
9776    ///
9777    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/match)
9778    #[wasm_bindgen(static_method_of = Symbol, getter, js_name = match)]
9779    pub fn match_() -> Symbol;
9780
9781    /// The `Symbol.replace` well-known symbol specifies the method that
9782    /// replaces matched substrings of a string.  This function is called by the
9783    /// `String.prototype.replace()` method.
9784    ///
9785    /// For more information, see `RegExp.prototype[@@replace]()` and
9786    /// `String.prototype.replace()`.
9787    ///
9788    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/replace)
9789    #[wasm_bindgen(static_method_of = Symbol, getter)]
9790    pub fn replace() -> Symbol;
9791
9792    /// The `Symbol.search` well-known symbol specifies the method that returns
9793    /// the index within a string that matches the regular expression.  This
9794    /// function is called by the `String.prototype.search()` method.
9795    ///
9796    /// For more information, see `RegExp.prototype[@@search]()` and
9797    /// `String.prototype.search()`.
9798    ///
9799    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/search)
9800    #[wasm_bindgen(static_method_of = Symbol, getter)]
9801    pub fn search() -> Symbol;
9802
9803    /// The well-known symbol `Symbol.species` specifies a function-valued
9804    /// property that the constructor function uses to create derived objects.
9805    ///
9806    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/species)
9807    #[wasm_bindgen(static_method_of = Symbol, getter)]
9808    pub fn species() -> Symbol;
9809
9810    /// The `Symbol.split` well-known symbol specifies the method that splits a
9811    /// string at the indices that match a regular expression.  This function is
9812    /// called by the `String.prototype.split()` method.
9813    ///
9814    /// For more information, see `RegExp.prototype[@@split]()` and
9815    /// `String.prototype.split()`.
9816    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/split)
9817    #[wasm_bindgen(static_method_of = Symbol, getter)]
9818    pub fn split() -> Symbol;
9819
9820    /// The `Symbol.toPrimitive` is a symbol that specifies a function valued
9821    /// property that is called to convert an object to a corresponding
9822    /// primitive value.
9823    ///
9824    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toPrimitive)
9825    #[wasm_bindgen(static_method_of = Symbol, getter, js_name = toPrimitive)]
9826    pub fn to_primitive() -> Symbol;
9827
9828    /// The `Symbol.toStringTag` well-known symbol is a string valued property
9829    /// that is used in the creation of the default string description of an
9830    /// object.  It is accessed internally by the `Object.prototype.toString()`
9831    /// method.
9832    ///
9833    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toString)
9834    #[wasm_bindgen(static_method_of = Symbol, getter, js_name = toStringTag)]
9835    pub fn to_string_tag() -> Symbol;
9836
9837    /// The `Symbol.for(key)` method searches for existing symbols in a runtime-wide symbol registry with
9838    /// the given key and returns it if found.
9839    /// Otherwise a new symbol gets created in the global symbol registry with this key.
9840    ///
9841    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/for)
9842    #[wasm_bindgen(static_method_of = Symbol, js_name = for)]
9843    pub fn for_(key: &str) -> Symbol;
9844
9845    /// The `Symbol.keyFor(sym)` method retrieves a shared symbol key from the global symbol registry for the given symbol.
9846    ///
9847    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/keyFor)
9848    #[wasm_bindgen(static_method_of = Symbol, js_name = keyFor)]
9849    pub fn key_for(sym: &Symbol) -> JsValue;
9850
9851    // Next major: deprecate
9852    /// The `toString()` method returns a string representing the specified Symbol object.
9853    ///
9854    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toString)
9855    #[wasm_bindgen(method, js_name = toString)]
9856    pub fn to_string(this: &Symbol) -> JsString;
9857
9858    /// The `toString()` method returns a string representing the specified Symbol object.
9859    ///
9860    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toString)
9861    #[wasm_bindgen(method, js_name = toString)]
9862    pub fn to_js_string(this: &Symbol) -> JsString;
9863
9864    /// The `Symbol.unscopables` well-known symbol is used to specify an object
9865    /// value of whose own and inherited property names are excluded from the
9866    /// with environment bindings of the associated object.
9867    ///
9868    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/unscopables)
9869    #[wasm_bindgen(static_method_of = Symbol, getter)]
9870    pub fn unscopables() -> Symbol;
9871
9872    /// The `valueOf()` method returns the primitive value of a Symbol object.
9873    ///
9874    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/valueOf)
9875    #[wasm_bindgen(method, js_name = valueOf)]
9876    pub fn value_of(this: &Symbol) -> Symbol;
9877}
9878
9879#[allow(non_snake_case)]
9880pub mod Intl {
9881    use super::*;
9882
9883    // Intl
9884    #[wasm_bindgen]
9885    extern "C" {
9886        /// The `Intl.getCanonicalLocales()` method returns an array containing
9887        /// the canonical locale names. Duplicates will be omitted and elements
9888        /// will be validated as structurally valid language tags.
9889        ///
9890        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales)
9891        #[cfg(not(js_sys_unstable_apis))]
9892        #[wasm_bindgen(js_name = getCanonicalLocales, js_namespace = Intl)]
9893        pub fn get_canonical_locales(s: &JsValue) -> Array;
9894
9895        /// The `Intl.getCanonicalLocales()` method returns an array containing
9896        /// the canonical locale names. Duplicates will be omitted and elements
9897        /// will be validated as structurally valid language tags.
9898        ///
9899        /// Throws a `RangeError` if any of the strings are not valid locale identifiers.
9900        ///
9901        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales)
9902        #[cfg(js_sys_unstable_apis)]
9903        #[wasm_bindgen(js_name = getCanonicalLocales, js_namespace = Intl, catch)]
9904        pub fn get_canonical_locales(s: &[JsString]) -> Result<Array<JsString>, JsValue>;
9905
9906        /// The `Intl.supportedValuesOf()` method returns an array containing the
9907        /// supported calendar, collation, currency, numbering system, or unit values
9908        /// supported by the implementation.
9909        ///
9910        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/supportedValuesOf)
9911        #[wasm_bindgen(js_name = supportedValuesOf, js_namespace = Intl)]
9912        pub fn supported_values_of(key: SupportedValuesKey) -> Array<JsString>;
9913    }
9914
9915    // Intl string enums
9916
9917    /// Key for `Intl.supportedValuesOf()`.
9918    #[wasm_bindgen]
9919    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
9920    pub enum SupportedValuesKey {
9921        Calendar = "calendar",
9922        Collation = "collation",
9923        Currency = "currency",
9924        NumberingSystem = "numberingSystem",
9925        TimeZone = "timeZone",
9926        Unit = "unit",
9927    }
9928
9929    /// Locale matching algorithm for Intl constructors.
9930    #[wasm_bindgen]
9931    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
9932    pub enum LocaleMatcher {
9933        Lookup = "lookup",
9934        BestFit = "best fit",
9935    }
9936
9937    /// Usage for `Intl.Collator`.
9938    #[wasm_bindgen]
9939    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
9940    pub enum CollatorUsage {
9941        Sort = "sort",
9942        Search = "search",
9943    }
9944
9945    /// Sensitivity for `Intl.Collator`.
9946    #[wasm_bindgen]
9947    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
9948    pub enum CollatorSensitivity {
9949        Base = "base",
9950        Accent = "accent",
9951        Case = "case",
9952        Variant = "variant",
9953    }
9954
9955    /// Case first option for `Intl.Collator`.
9956    #[wasm_bindgen]
9957    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
9958    pub enum CollatorCaseFirst {
9959        Upper = "upper",
9960        Lower = "lower",
9961        False = "false",
9962    }
9963
9964    /// Style for `Intl.NumberFormat`.
9965    #[wasm_bindgen]
9966    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
9967    pub enum NumberFormatStyle {
9968        Decimal = "decimal",
9969        Currency = "currency",
9970        Percent = "percent",
9971        Unit = "unit",
9972    }
9973
9974    /// Currency display for `Intl.NumberFormat`.
9975    #[wasm_bindgen]
9976    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
9977    pub enum CurrencyDisplay {
9978        Code = "code",
9979        Symbol = "symbol",
9980        NarrowSymbol = "narrowSymbol",
9981        Name = "name",
9982    }
9983
9984    /// Currency sign for `Intl.NumberFormat`.
9985    #[wasm_bindgen]
9986    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
9987    pub enum CurrencySign {
9988        Standard = "standard",
9989        Accounting = "accounting",
9990    }
9991
9992    /// Unit display for `Intl.NumberFormat`.
9993    #[wasm_bindgen]
9994    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
9995    pub enum UnitDisplay {
9996        Short = "short",
9997        Narrow = "narrow",
9998        Long = "long",
9999    }
10000
10001    /// Notation for `Intl.NumberFormat`.
10002    #[wasm_bindgen]
10003    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10004    pub enum NumberFormatNotation {
10005        Standard = "standard",
10006        Scientific = "scientific",
10007        Engineering = "engineering",
10008        Compact = "compact",
10009    }
10010
10011    /// Compact display for `Intl.NumberFormat`.
10012    #[wasm_bindgen]
10013    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10014    pub enum CompactDisplay {
10015        Short = "short",
10016        Long = "long",
10017    }
10018
10019    /// Sign display for `Intl.NumberFormat`.
10020    #[wasm_bindgen]
10021    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10022    pub enum SignDisplay {
10023        Auto = "auto",
10024        Never = "never",
10025        Always = "always",
10026        ExceptZero = "exceptZero",
10027    }
10028
10029    /// Rounding mode for `Intl.NumberFormat`.
10030    #[wasm_bindgen]
10031    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10032    pub enum RoundingMode {
10033        Ceil = "ceil",
10034        Floor = "floor",
10035        Expand = "expand",
10036        Trunc = "trunc",
10037        HalfCeil = "halfCeil",
10038        HalfFloor = "halfFloor",
10039        HalfExpand = "halfExpand",
10040        HalfTrunc = "halfTrunc",
10041        HalfEven = "halfEven",
10042    }
10043
10044    /// Rounding priority for `Intl.NumberFormat`.
10045    #[wasm_bindgen]
10046    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10047    pub enum RoundingPriority {
10048        Auto = "auto",
10049        MorePrecision = "morePrecision",
10050        LessPrecision = "lessPrecision",
10051    }
10052
10053    /// Trailing zero display for `Intl.NumberFormat`.
10054    #[wasm_bindgen]
10055    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10056    pub enum TrailingZeroDisplay {
10057        Auto = "auto",
10058        StripIfInteger = "stripIfInteger",
10059    }
10060
10061    /// Use grouping option for `Intl.NumberFormat`.
10062    ///
10063    /// Determines whether to use grouping separators, such as thousands
10064    /// separators or thousand/lakh/crore separators.
10065    ///
10066    /// The default is `Min2` if notation is "compact", and `Auto` otherwise.
10067    ///
10068    /// Note: The string values `"true"` and `"false"` are accepted by JavaScript
10069    /// but are always converted to the default value. Use `True` and `False`
10070    /// variants for the boolean behavior.
10071    ///
10072    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#usegrouping)
10073    #[wasm_bindgen]
10074    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10075    pub enum UseGrouping {
10076        /// Display grouping separators even if the locale prefers otherwise.
10077        Always = "always",
10078        /// Display grouping separators based on the locale preference,
10079        /// which may also be dependent on the currency.
10080        Auto = "auto",
10081        /// Display grouping separators when there are at least 2 digits in a group.
10082        Min2 = "min2",
10083        /// Same as `Always`. Display grouping separators even if the locale prefers otherwise.
10084        True = "true",
10085        /// Display no grouping separators.
10086        False = "false",
10087    }
10088
10089    /// Date/time style for `Intl.DateTimeFormat`.
10090    #[wasm_bindgen]
10091    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10092    pub enum DateTimeStyle {
10093        Full = "full",
10094        Long = "long",
10095        Medium = "medium",
10096        Short = "short",
10097    }
10098
10099    /// Hour cycle for `Intl.DateTimeFormat`.
10100    #[wasm_bindgen]
10101    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10102    pub enum HourCycle {
10103        H11 = "h11",
10104        H12 = "h12",
10105        H23 = "h23",
10106        H24 = "h24",
10107    }
10108
10109    /// Weekday format for `Intl.DateTimeFormat`.
10110    #[wasm_bindgen]
10111    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10112    pub enum WeekdayFormat {
10113        Narrow = "narrow",
10114        Short = "short",
10115        Long = "long",
10116    }
10117
10118    /// Era format for `Intl.DateTimeFormat`.
10119    #[wasm_bindgen]
10120    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10121    pub enum EraFormat {
10122        Narrow = "narrow",
10123        Short = "short",
10124        Long = "long",
10125    }
10126
10127    /// Year format for `Intl.DateTimeFormat`.
10128    #[wasm_bindgen]
10129    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10130    pub enum YearFormat {
10131        Numeric = "numeric",
10132        TwoDigit = "2-digit",
10133    }
10134
10135    /// Month format for `Intl.DateTimeFormat`.
10136    #[wasm_bindgen]
10137    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10138    pub enum MonthFormat {
10139        #[wasm_bindgen]
10140        Numeric = "numeric",
10141        #[wasm_bindgen]
10142        TwoDigit = "2-digit",
10143        #[wasm_bindgen]
10144        Narrow = "narrow",
10145        #[wasm_bindgen]
10146        Short = "short",
10147        #[wasm_bindgen]
10148        Long = "long",
10149    }
10150
10151    /// Day format for `Intl.DateTimeFormat`.
10152    #[wasm_bindgen]
10153    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10154    pub enum DayFormat {
10155        #[wasm_bindgen]
10156        Numeric = "numeric",
10157        #[wasm_bindgen]
10158        TwoDigit = "2-digit",
10159    }
10160
10161    /// Hour/minute/second format for `Intl.DateTimeFormat`.
10162    #[wasm_bindgen]
10163    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10164    pub enum NumericFormat {
10165        #[wasm_bindgen]
10166        Numeric = "numeric",
10167        #[wasm_bindgen]
10168        TwoDigit = "2-digit",
10169    }
10170
10171    /// Time zone name format for `Intl.DateTimeFormat`.
10172    #[wasm_bindgen]
10173    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10174    pub enum TimeZoneNameFormat {
10175        Short = "short",
10176        Long = "long",
10177        ShortOffset = "shortOffset",
10178        LongOffset = "longOffset",
10179        ShortGeneric = "shortGeneric",
10180        LongGeneric = "longGeneric",
10181    }
10182
10183    /// Day period format for `Intl.DateTimeFormat`.
10184    #[wasm_bindgen]
10185    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10186    pub enum DayPeriodFormat {
10187        Narrow = "narrow",
10188        Short = "short",
10189        Long = "long",
10190    }
10191
10192    /// Part type for `DateTimeFormat.formatToParts()`.
10193    #[wasm_bindgen]
10194    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10195    pub enum DateTimeFormatPartType {
10196        Day = "day",
10197        DayPeriod = "dayPeriod",
10198        Era = "era",
10199        FractionalSecond = "fractionalSecond",
10200        Hour = "hour",
10201        Literal = "literal",
10202        Minute = "minute",
10203        Month = "month",
10204        RelatedYear = "relatedYear",
10205        Second = "second",
10206        TimeZoneName = "timeZoneName",
10207        Weekday = "weekday",
10208        Year = "year",
10209        YearName = "yearName",
10210    }
10211
10212    /// Part type for `NumberFormat.formatToParts()`.
10213    #[wasm_bindgen]
10214    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10215    pub enum NumberFormatPartType {
10216        Compact = "compact",
10217        Currency = "currency",
10218        Decimal = "decimal",
10219        ExponentInteger = "exponentInteger",
10220        ExponentMinusSign = "exponentMinusSign",
10221        ExponentSeparator = "exponentSeparator",
10222        Fraction = "fraction",
10223        Group = "group",
10224        Infinity = "infinity",
10225        Integer = "integer",
10226        Literal = "literal",
10227        MinusSign = "minusSign",
10228        Nan = "nan",
10229        PercentSign = "percentSign",
10230        PlusSign = "plusSign",
10231        Unit = "unit",
10232        Unknown = "unknown",
10233    }
10234
10235    /// Type for `Intl.PluralRules` (cardinal or ordinal).
10236    #[wasm_bindgen]
10237    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10238    pub enum PluralRulesType {
10239        Cardinal = "cardinal",
10240        Ordinal = "ordinal",
10241    }
10242
10243    /// Plural category returned by `PluralRules.select()`.
10244    #[wasm_bindgen]
10245    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10246    pub enum PluralCategory {
10247        Zero = "zero",
10248        One = "one",
10249        Two = "two",
10250        Few = "few",
10251        Many = "many",
10252        Other = "other",
10253    }
10254
10255    /// Numeric option for `Intl.RelativeTimeFormat`.
10256    #[wasm_bindgen]
10257    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10258    pub enum RelativeTimeFormatNumeric {
10259        Always = "always",
10260        Auto = "auto",
10261    }
10262
10263    /// Style for `Intl.RelativeTimeFormat`.
10264    #[wasm_bindgen]
10265    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10266    pub enum RelativeTimeFormatStyle {
10267        Long = "long",
10268        Short = "short",
10269        Narrow = "narrow",
10270    }
10271
10272    /// Unit for `RelativeTimeFormat.format()`.
10273    #[wasm_bindgen]
10274    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10275    pub enum RelativeTimeFormatUnit {
10276        Year = "year",
10277        Years = "years",
10278        Quarter = "quarter",
10279        Quarters = "quarters",
10280        Month = "month",
10281        Months = "months",
10282        Week = "week",
10283        Weeks = "weeks",
10284        Day = "day",
10285        Days = "days",
10286        Hour = "hour",
10287        Hours = "hours",
10288        Minute = "minute",
10289        Minutes = "minutes",
10290        Second = "second",
10291        Seconds = "seconds",
10292    }
10293
10294    /// Part type for `RelativeTimeFormat.formatToParts()`.
10295    #[wasm_bindgen]
10296    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10297    pub enum RelativeTimeFormatPartType {
10298        Literal = "literal",
10299        Integer = "integer",
10300        Decimal = "decimal",
10301        Fraction = "fraction",
10302    }
10303
10304    /// Source indicator for range format parts.
10305    ///
10306    /// Indicates which part of the range (start, end, or shared) a formatted
10307    /// part belongs to when using `formatRangeToParts()`.
10308    ///
10309    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatRangeToParts#description)
10310    #[wasm_bindgen]
10311    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10312    pub enum RangeSource {
10313        /// The part is from the start of the range.
10314        StartRange = "startRange",
10315        /// The part is from the end of the range.
10316        EndRange = "endRange",
10317        /// The part is shared between start and end (e.g., a separator or common element).
10318        Shared = "shared",
10319    }
10320
10321    /// Type for `Intl.ListFormat`.
10322    #[wasm_bindgen]
10323    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10324    pub enum ListFormatType {
10325        /// For lists of standalone items (default).
10326        Conjunction = "conjunction",
10327        /// For lists representing alternatives.
10328        Disjunction = "disjunction",
10329        /// For lists of values with units.
10330        Unit = "unit",
10331    }
10332
10333    /// Style for `Intl.ListFormat`.
10334    #[wasm_bindgen]
10335    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10336    pub enum ListFormatStyle {
10337        /// "A, B, and C" (default).
10338        Long = "long",
10339        /// "A, B, C".
10340        Short = "short",
10341        /// "A B C".
10342        Narrow = "narrow",
10343    }
10344
10345    /// Part type for `Intl.ListFormat.formatToParts()`.
10346    #[wasm_bindgen]
10347    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10348    pub enum ListFormatPartType {
10349        /// A value from the list.
10350        Element = "element",
10351        /// A linguistic construct (e.g., ", ", " and ").
10352        Literal = "literal",
10353    }
10354
10355    /// Type for `Intl.Segmenter`.
10356    #[wasm_bindgen]
10357    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10358    pub enum SegmenterGranularity {
10359        /// Segment by grapheme clusters (user-perceived characters).
10360        Grapheme = "grapheme",
10361        /// Segment by words.
10362        Word = "word",
10363        /// Segment by sentences.
10364        Sentence = "sentence",
10365    }
10366
10367    /// Type for `Intl.DisplayNames`.
10368    #[wasm_bindgen]
10369    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10370    pub enum DisplayNamesType {
10371        /// Language display names.
10372        Language = "language",
10373        /// Region display names.
10374        Region = "region",
10375        /// Script display names.
10376        Script = "script",
10377        /// Currency display names.
10378        Currency = "currency",
10379        /// Calendar display names.
10380        Calendar = "calendar",
10381        /// Date/time field display names.
10382        DateTimeField = "dateTimeField",
10383    }
10384
10385    /// Style for `Intl.DisplayNames`.
10386    #[wasm_bindgen]
10387    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10388    pub enum DisplayNamesStyle {
10389        /// Full display name (default).
10390        Long = "long",
10391        /// Abbreviated display name.
10392        Short = "short",
10393        /// Minimal display name.
10394        Narrow = "narrow",
10395    }
10396
10397    /// Fallback for `Intl.DisplayNames`.
10398    #[wasm_bindgen]
10399    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10400    pub enum DisplayNamesFallback {
10401        /// Return the input code if no display name is available (default).
10402        Code = "code",
10403        /// Return undefined if no display name is available.
10404        None = "none",
10405    }
10406
10407    /// Language display for `Intl.DisplayNames`.
10408    #[wasm_bindgen]
10409    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10410    pub enum DisplayNamesLanguageDisplay {
10411        /// Use dialect names (e.g., "British English").
10412        Dialect = "dialect",
10413        /// Use standard names (e.g., "English (United Kingdom)").
10414        Standard = "standard",
10415    }
10416
10417    // Intl.RelativeTimeFormatOptions
10418    #[wasm_bindgen]
10419    extern "C" {
10420        /// Options for `Intl.RelativeTimeFormat` constructor.
10421        ///
10422        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat#options)
10423        #[wasm_bindgen(extends = Object)]
10424        #[derive(Clone, Debug)]
10425        pub type RelativeTimeFormatOptions;
10426
10427        #[wasm_bindgen(method, getter = localeMatcher)]
10428        pub fn get_locale_matcher(this: &RelativeTimeFormatOptions) -> Option<LocaleMatcher>;
10429        #[wasm_bindgen(method, setter = localeMatcher)]
10430        pub fn set_locale_matcher(this: &RelativeTimeFormatOptions, value: LocaleMatcher);
10431
10432        #[wasm_bindgen(method, getter = numeric)]
10433        pub fn get_numeric(this: &RelativeTimeFormatOptions) -> Option<RelativeTimeFormatNumeric>;
10434        #[wasm_bindgen(method, setter = numeric)]
10435        pub fn set_numeric(this: &RelativeTimeFormatOptions, value: RelativeTimeFormatNumeric);
10436
10437        #[wasm_bindgen(method, getter = style)]
10438        pub fn get_style(this: &RelativeTimeFormatOptions) -> Option<RelativeTimeFormatStyle>;
10439        #[wasm_bindgen(method, setter = style)]
10440        pub fn set_style(this: &RelativeTimeFormatOptions, value: RelativeTimeFormatStyle);
10441    }
10442
10443    impl RelativeTimeFormatOptions {
10444        pub fn new() -> RelativeTimeFormatOptions {
10445            JsCast::unchecked_into(Object::new())
10446        }
10447    }
10448
10449    impl Default for RelativeTimeFormatOptions {
10450        fn default() -> Self {
10451            RelativeTimeFormatOptions::new()
10452        }
10453    }
10454
10455    // Intl.ResolvedRelativeTimeFormatOptions
10456    #[wasm_bindgen]
10457    extern "C" {
10458        /// Resolved options returned by `Intl.RelativeTimeFormat.prototype.resolvedOptions()`.
10459        ///
10460        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/resolvedOptions)
10461        #[wasm_bindgen(extends = RelativeTimeFormatOptions)]
10462        #[derive(Clone, Debug)]
10463        pub type ResolvedRelativeTimeFormatOptions;
10464
10465        /// The resolved locale string.
10466        #[wasm_bindgen(method, getter = locale)]
10467        pub fn get_locale(this: &ResolvedRelativeTimeFormatOptions) -> JsString;
10468
10469        /// The numbering system used.
10470        #[wasm_bindgen(method, getter = numberingSystem)]
10471        pub fn get_numbering_system(this: &ResolvedRelativeTimeFormatOptions) -> JsString;
10472    }
10473
10474    // Intl.RelativeTimeFormatPart
10475    #[wasm_bindgen]
10476    extern "C" {
10477        /// A part of the formatted relative time returned by `formatToParts()`.
10478        ///
10479        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/formatToParts)
10480        #[wasm_bindgen(extends = Object)]
10481        #[derive(Clone, Debug)]
10482        pub type RelativeTimeFormatPart;
10483
10484        /// The type of this part.
10485        #[wasm_bindgen(method, getter = type)]
10486        pub fn type_(this: &RelativeTimeFormatPart) -> RelativeTimeFormatPartType;
10487
10488        /// The string value of this part.
10489        #[wasm_bindgen(method, getter = value)]
10490        pub fn value(this: &RelativeTimeFormatPart) -> JsString;
10491
10492        /// The unit used in this part (only for integer parts).
10493        #[wasm_bindgen(method, getter = unit)]
10494        pub fn unit(this: &RelativeTimeFormatPart) -> Option<JsString>;
10495    }
10496
10497    // Intl.LocaleMatcherOptions
10498    #[wasm_bindgen]
10499    extern "C" {
10500        /// Options for `supportedLocalesOf` methods.
10501        #[wasm_bindgen(extends = Object)]
10502        #[derive(Clone, Debug)]
10503        pub type LocaleMatcherOptions;
10504
10505        #[wasm_bindgen(method, getter = localeMatcher)]
10506        pub fn get_locale_matcher(this: &LocaleMatcherOptions) -> Option<LocaleMatcher>;
10507
10508        #[wasm_bindgen(method, setter = localeMatcher)]
10509        pub fn set_locale_matcher(this: &LocaleMatcherOptions, value: LocaleMatcher);
10510    }
10511
10512    impl LocaleMatcherOptions {
10513        pub fn new() -> LocaleMatcherOptions {
10514            JsCast::unchecked_into(Object::new())
10515        }
10516    }
10517
10518    impl Default for LocaleMatcherOptions {
10519        fn default() -> Self {
10520            LocaleMatcherOptions::new()
10521        }
10522    }
10523
10524    // Intl.Collator Options
10525    #[wasm_bindgen]
10526    extern "C" {
10527        /// Options for `Intl.Collator` and `String.prototype.localeCompare`.
10528        ///
10529        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator/Collator#options)
10530        #[wasm_bindgen(extends = Object)]
10531        #[derive(Clone, Debug)]
10532        pub type CollatorOptions;
10533
10534        #[wasm_bindgen(method, getter = localeMatcher)]
10535        pub fn get_locale_matcher(this: &CollatorOptions) -> Option<LocaleMatcher>;
10536        #[wasm_bindgen(method, setter = localeMatcher)]
10537        pub fn set_locale_matcher(this: &CollatorOptions, value: LocaleMatcher);
10538
10539        #[wasm_bindgen(method, getter = usage)]
10540        pub fn get_usage(this: &CollatorOptions) -> Option<CollatorUsage>;
10541        #[wasm_bindgen(method, setter = usage)]
10542        pub fn set_usage(this: &CollatorOptions, value: CollatorUsage);
10543
10544        #[wasm_bindgen(method, getter = sensitivity)]
10545        pub fn get_sensitivity(this: &CollatorOptions) -> Option<CollatorSensitivity>;
10546        #[wasm_bindgen(method, setter = sensitivity)]
10547        pub fn set_sensitivity(this: &CollatorOptions, value: CollatorSensitivity);
10548
10549        #[wasm_bindgen(method, getter = ignorePunctuation)]
10550        pub fn get_ignore_punctuation(this: &CollatorOptions) -> Option<bool>;
10551        #[wasm_bindgen(method, setter = ignorePunctuation)]
10552        pub fn set_ignore_punctuation(this: &CollatorOptions, value: bool);
10553
10554        #[wasm_bindgen(method, getter = numeric)]
10555        pub fn get_numeric(this: &CollatorOptions) -> Option<bool>;
10556        #[wasm_bindgen(method, setter = numeric)]
10557        pub fn set_numeric(this: &CollatorOptions, value: bool);
10558
10559        #[wasm_bindgen(method, getter = caseFirst)]
10560        pub fn get_case_first(this: &CollatorOptions) -> Option<CollatorCaseFirst>;
10561        #[wasm_bindgen(method, setter = caseFirst)]
10562        pub fn set_case_first(this: &CollatorOptions, value: CollatorCaseFirst);
10563    }
10564    impl CollatorOptions {
10565        pub fn new() -> CollatorOptions {
10566            JsCast::unchecked_into(Object::new())
10567        }
10568    }
10569    impl Default for CollatorOptions {
10570        fn default() -> Self {
10571            CollatorOptions::new()
10572        }
10573    }
10574
10575    // Intl.Collator ResolvedCollatorOptions
10576    #[wasm_bindgen]
10577    extern "C" {
10578        #[wasm_bindgen(extends = CollatorOptions)]
10579        #[derive(Clone, Debug)]
10580        pub type ResolvedCollatorOptions;
10581
10582        #[wasm_bindgen(method, getter = locale)]
10583        pub fn get_locale(this: &ResolvedCollatorOptions) -> JsString; // not Option, always present
10584        #[wasm_bindgen(method, getter = collation)]
10585        pub fn get_collation(this: &ResolvedCollatorOptions) -> JsString;
10586    }
10587
10588    // Intl.Collator
10589    #[wasm_bindgen]
10590    extern "C" {
10591        /// The `Intl.Collator` object is a constructor for collators, objects
10592        /// that enable language sensitive string comparison.
10593        ///
10594        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator)
10595        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.Collator")]
10596        #[derive(Clone, Debug)]
10597        pub type Collator;
10598
10599        /// The `Intl.Collator` object is a constructor for collators, objects
10600        /// that enable language sensitive string comparison.
10601        ///
10602        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator)
10603        #[cfg(not(js_sys_unstable_apis))]
10604        #[wasm_bindgen(constructor, js_namespace = Intl)]
10605        pub fn new(locales: &Array, options: &Object) -> Collator;
10606
10607        /// The `Intl.Collator` object is a constructor for collators, objects
10608        /// that enable language sensitive string comparison.
10609        ///
10610        /// Throws a `RangeError` if locales contain invalid values.
10611        ///
10612        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator)
10613        #[cfg(js_sys_unstable_apis)]
10614        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
10615        pub fn new(locales: &[JsString], options: &CollatorOptions) -> Result<Collator, JsValue>;
10616
10617        /// The Intl.Collator.prototype.compare property returns a function that
10618        /// compares two strings according to the sort order of this Collator
10619        /// object.
10620        ///
10621        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/compare)
10622        #[cfg(not(js_sys_unstable_apis))]
10623        #[wasm_bindgen(method, getter, js_class = "Intl.Collator")]
10624        pub fn compare(this: &Collator) -> Function;
10625
10626        /// Compares two strings according to the sort order of this Collator.
10627        ///
10628        /// Returns a negative value if `a` comes before `b`, positive if `a` comes
10629        /// after `b`, and zero if they are equal.
10630        ///
10631        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator/compare)
10632        #[cfg(js_sys_unstable_apis)]
10633        #[wasm_bindgen(method, js_class = "Intl.Collator")]
10634        pub fn compare(this: &Collator, a: &str, b: &str) -> i32;
10635
10636        /// The `Intl.Collator.prototype.resolvedOptions()` method returns a new
10637        /// object with properties reflecting the locale and collation options
10638        /// computed during initialization of this Collator object.
10639        ///
10640        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/resolvedOptions)
10641        #[cfg(not(js_sys_unstable_apis))]
10642        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
10643        pub fn resolved_options(this: &Collator) -> Object;
10644
10645        /// The `Intl.Collator.prototype.resolvedOptions()` method returns a new
10646        /// object with properties reflecting the locale and collation options
10647        /// computed during initialization of this Collator object.
10648        ///
10649        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/resolvedOptions)
10650        #[cfg(js_sys_unstable_apis)]
10651        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
10652        pub fn resolved_options(this: &Collator) -> ResolvedCollatorOptions;
10653
10654        /// The `Intl.Collator.supportedLocalesOf()` method returns an array
10655        /// containing those of the provided locales that are supported in
10656        /// collation without having to fall back to the runtime's default
10657        /// locale.
10658        ///
10659        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/supportedLocalesOf)
10660        #[cfg(not(js_sys_unstable_apis))]
10661        #[wasm_bindgen(static_method_of = Collator, js_namespace = Intl, js_name = supportedLocalesOf)]
10662        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
10663
10664        /// The `Intl.Collator.supportedLocalesOf()` method returns an array
10665        /// containing those of the provided locales that are supported in
10666        /// collation without having to fall back to the runtime's default
10667        /// locale.
10668        ///
10669        /// Throws a `RangeError` if locales contain invalid values.
10670        ///
10671        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/supportedLocalesOf)
10672        #[cfg(js_sys_unstable_apis)]
10673        #[wasm_bindgen(static_method_of = Collator, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
10674        pub fn supported_locales_of(
10675            locales: &[JsString],
10676            options: &LocaleMatcherOptions,
10677        ) -> Result<Array<JsString>, JsValue>;
10678    }
10679
10680    #[cfg(not(js_sys_unstable_apis))]
10681    impl Default for Collator {
10682        fn default() -> Self {
10683            Self::new(
10684                &JsValue::UNDEFINED.unchecked_into(),
10685                &JsValue::UNDEFINED.unchecked_into(),
10686            )
10687        }
10688    }
10689
10690    #[cfg(js_sys_unstable_apis)]
10691    impl Default for Collator {
10692        fn default() -> Self {
10693            Self::new(&[], &Default::default()).unwrap()
10694        }
10695    }
10696
10697    // Intl.DateTimeFormatOptions
10698    #[wasm_bindgen]
10699    extern "C" {
10700        /// Options for `Intl.DateTimeFormat` constructor.
10701        ///
10702        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#options)
10703        #[wasm_bindgen(extends = Object)]
10704        #[derive(Clone, Debug)]
10705        pub type DateTimeFormatOptions;
10706
10707        // Locale matching
10708        #[wasm_bindgen(method, getter = localeMatcher)]
10709        pub fn get_locale_matcher(this: &DateTimeFormatOptions) -> Option<LocaleMatcher>;
10710        #[wasm_bindgen(method, setter = localeMatcher)]
10711        pub fn set_locale_matcher(this: &DateTimeFormatOptions, value: LocaleMatcher);
10712
10713        // Calendar/numbering (free-form strings, no enum)
10714        #[wasm_bindgen(method, getter = calendar)]
10715        pub fn get_calendar(this: &DateTimeFormatOptions) -> Option<JsString>;
10716        #[wasm_bindgen(method, setter = calendar)]
10717        pub fn set_calendar(this: &DateTimeFormatOptions, value: &str);
10718
10719        #[wasm_bindgen(method, getter = numberingSystem)]
10720        pub fn get_numbering_system(this: &DateTimeFormatOptions) -> Option<JsString>;
10721        #[wasm_bindgen(method, setter = numberingSystem)]
10722        pub fn set_numbering_system(this: &DateTimeFormatOptions, value: &str);
10723
10724        // Timezone (free-form string)
10725        #[wasm_bindgen(method, getter = timeZone)]
10726        pub fn get_time_zone(this: &DateTimeFormatOptions) -> Option<JsString>;
10727        #[wasm_bindgen(method, setter = timeZone)]
10728        pub fn set_time_zone(this: &DateTimeFormatOptions, value: &str);
10729
10730        // Hour cycle
10731        #[wasm_bindgen(method, getter = hour12)]
10732        pub fn get_hour12(this: &DateTimeFormatOptions) -> Option<bool>;
10733        #[wasm_bindgen(method, setter = hour12)]
10734        pub fn set_hour12(this: &DateTimeFormatOptions, value: bool);
10735
10736        #[wasm_bindgen(method, getter = hourCycle)]
10737        pub fn get_hour_cycle(this: &DateTimeFormatOptions) -> Option<HourCycle>;
10738        #[wasm_bindgen(method, setter = hourCycle)]
10739        pub fn set_hour_cycle(this: &DateTimeFormatOptions, value: HourCycle);
10740
10741        // Style shortcuts
10742        #[wasm_bindgen(method, getter = dateStyle)]
10743        pub fn get_date_style(this: &DateTimeFormatOptions) -> Option<DateTimeStyle>;
10744        #[wasm_bindgen(method, setter = dateStyle)]
10745        pub fn set_date_style(this: &DateTimeFormatOptions, value: DateTimeStyle);
10746
10747        #[wasm_bindgen(method, getter = timeStyle)]
10748        pub fn get_time_style(this: &DateTimeFormatOptions) -> Option<DateTimeStyle>;
10749        #[wasm_bindgen(method, setter = timeStyle)]
10750        pub fn set_time_style(this: &DateTimeFormatOptions, value: DateTimeStyle);
10751
10752        // Component options
10753        #[wasm_bindgen(method, getter = weekday)]
10754        pub fn get_weekday(this: &DateTimeFormatOptions) -> Option<WeekdayFormat>;
10755        #[wasm_bindgen(method, setter = weekday)]
10756        pub fn set_weekday(this: &DateTimeFormatOptions, value: WeekdayFormat);
10757
10758        #[wasm_bindgen(method, getter = era)]
10759        pub fn get_era(this: &DateTimeFormatOptions) -> Option<EraFormat>;
10760        #[wasm_bindgen(method, setter = era)]
10761        pub fn set_era(this: &DateTimeFormatOptions, value: EraFormat);
10762
10763        #[wasm_bindgen(method, getter = year)]
10764        pub fn get_year(this: &DateTimeFormatOptions) -> Option<YearFormat>;
10765        #[wasm_bindgen(method, setter = year)]
10766        pub fn set_year(this: &DateTimeFormatOptions, value: YearFormat);
10767
10768        #[wasm_bindgen(method, getter = month)]
10769        pub fn get_month(this: &DateTimeFormatOptions) -> Option<MonthFormat>;
10770        #[wasm_bindgen(method, setter = month)]
10771        pub fn set_month(this: &DateTimeFormatOptions, value: MonthFormat);
10772
10773        #[wasm_bindgen(method, getter = day)]
10774        pub fn get_day(this: &DateTimeFormatOptions) -> Option<DayFormat>;
10775        #[wasm_bindgen(method, setter = day)]
10776        pub fn set_day(this: &DateTimeFormatOptions, value: DayFormat);
10777
10778        #[wasm_bindgen(method, getter = hour)]
10779        pub fn get_hour(this: &DateTimeFormatOptions) -> Option<NumericFormat>;
10780        #[wasm_bindgen(method, setter = hour)]
10781        pub fn set_hour(this: &DateTimeFormatOptions, value: NumericFormat);
10782
10783        #[wasm_bindgen(method, getter = minute)]
10784        pub fn get_minute(this: &DateTimeFormatOptions) -> Option<NumericFormat>;
10785        #[wasm_bindgen(method, setter = minute)]
10786        pub fn set_minute(this: &DateTimeFormatOptions, value: NumericFormat);
10787
10788        #[wasm_bindgen(method, getter = second)]
10789        pub fn get_second(this: &DateTimeFormatOptions) -> Option<NumericFormat>;
10790        #[wasm_bindgen(method, setter = second)]
10791        pub fn set_second(this: &DateTimeFormatOptions, value: NumericFormat);
10792
10793        #[wasm_bindgen(method, getter = fractionalSecondDigits)]
10794        pub fn get_fractional_second_digits(this: &DateTimeFormatOptions) -> Option<u8>;
10795        #[wasm_bindgen(method, setter = fractionalSecondDigits)]
10796        pub fn set_fractional_second_digits(this: &DateTimeFormatOptions, value: u8);
10797
10798        #[wasm_bindgen(method, getter = timeZoneName)]
10799        pub fn get_time_zone_name(this: &DateTimeFormatOptions) -> Option<TimeZoneNameFormat>;
10800        #[wasm_bindgen(method, setter = timeZoneName)]
10801        pub fn set_time_zone_name(this: &DateTimeFormatOptions, value: TimeZoneNameFormat);
10802
10803        #[wasm_bindgen(method, getter = dayPeriod)]
10804        pub fn get_day_period(this: &DateTimeFormatOptions) -> Option<DayPeriodFormat>;
10805        #[wasm_bindgen(method, setter = dayPeriod)]
10806        pub fn set_day_period(this: &DateTimeFormatOptions, value: DayPeriodFormat);
10807    }
10808
10809    impl DateTimeFormatOptions {
10810        pub fn new() -> DateTimeFormatOptions {
10811            JsCast::unchecked_into(Object::new())
10812        }
10813    }
10814
10815    impl Default for DateTimeFormatOptions {
10816        fn default() -> Self {
10817            DateTimeFormatOptions::new()
10818        }
10819    }
10820
10821    // Intl.ResolvedDateTimeFormatOptions
10822    #[wasm_bindgen]
10823    extern "C" {
10824        /// Resolved options returned by `Intl.DateTimeFormat.prototype.resolvedOptions()`.
10825        ///
10826        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/resolvedOptions)
10827        #[wasm_bindgen(extends = DateTimeFormatOptions)]
10828        #[derive(Clone, Debug)]
10829        pub type ResolvedDateTimeFormatOptions;
10830
10831        /// The resolved locale string.
10832        #[wasm_bindgen(method, getter = locale)]
10833        pub fn get_locale(this: &ResolvedDateTimeFormatOptions) -> JsString;
10834    }
10835
10836    // Intl.DateTimeFormatPart
10837    #[wasm_bindgen]
10838    extern "C" {
10839        /// A part of the formatted date returned by `formatToParts()`.
10840        ///
10841        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts)
10842        #[wasm_bindgen(extends = Object)]
10843        #[derive(Clone, Debug)]
10844        pub type DateTimeFormatPart;
10845
10846        /// The type of the part (e.g., "day", "month", "year", "literal", etc.)
10847        #[wasm_bindgen(method, getter = type)]
10848        pub fn type_(this: &DateTimeFormatPart) -> DateTimeFormatPartType;
10849
10850        /// The value of the part.
10851        #[wasm_bindgen(method, getter)]
10852        pub fn value(this: &DateTimeFormatPart) -> JsString;
10853    }
10854
10855    // Intl.DateTimeRangeFormatPart
10856    #[wasm_bindgen]
10857    extern "C" {
10858        /// A part of the formatted date range returned by `formatRangeToParts()`.
10859        ///
10860        /// Extends `DateTimeFormatPart` with a `source` property indicating whether
10861        /// the part is from the start date, end date, or shared between them.
10862        ///
10863        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatRangeToParts)
10864        #[wasm_bindgen(extends = DateTimeFormatPart)]
10865        #[derive(Clone, Debug)]
10866        pub type DateTimeRangeFormatPart;
10867
10868        /// The source of the part: "startRange", "endRange", or "shared".
10869        #[wasm_bindgen(method, getter)]
10870        pub fn source(this: &DateTimeRangeFormatPart) -> RangeSource;
10871    }
10872
10873    // Intl.DateTimeFormat
10874    #[wasm_bindgen]
10875    extern "C" {
10876        /// The `Intl.DateTimeFormat` object is a constructor for objects
10877        /// that enable language-sensitive date and time formatting.
10878        ///
10879        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat)
10880        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.DateTimeFormat")]
10881        #[derive(Clone, Debug)]
10882        pub type DateTimeFormat;
10883
10884        /// The `Intl.DateTimeFormat` object is a constructor for objects
10885        /// that enable language-sensitive date and time formatting.
10886        ///
10887        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat)
10888        #[cfg(not(js_sys_unstable_apis))]
10889        #[wasm_bindgen(constructor, js_namespace = Intl)]
10890        pub fn new(locales: &Array, options: &Object) -> DateTimeFormat;
10891
10892        /// The `Intl.DateTimeFormat` object is a constructor for objects
10893        /// that enable language-sensitive date and time formatting.
10894        ///
10895        /// Throws a `RangeError` if locales contain invalid values.
10896        ///
10897        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat)
10898        #[cfg(js_sys_unstable_apis)]
10899        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
10900        pub fn new(
10901            locales: &[JsString],
10902            options: &DateTimeFormatOptions,
10903        ) -> Result<DateTimeFormat, JsValue>;
10904
10905        /// The Intl.DateTimeFormat.prototype.format property returns a getter function that
10906        /// formats a date according to the locale and formatting options of this
10907        /// Intl.DateTimeFormat object.
10908        ///
10909        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/format)
10910        #[cfg(not(js_sys_unstable_apis))]
10911        #[wasm_bindgen(method, getter, js_class = "Intl.DateTimeFormat")]
10912        pub fn format(this: &DateTimeFormat) -> Function;
10913
10914        /// Formats a date according to the locale and formatting options of this
10915        /// `Intl.DateTimeFormat` object.
10916        ///
10917        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/format)
10918        #[cfg(js_sys_unstable_apis)]
10919        #[wasm_bindgen(method, js_class = "Intl.DateTimeFormat")]
10920        pub fn format(this: &DateTimeFormat, date: &Date) -> JsString;
10921
10922        /// The `Intl.DateTimeFormat.prototype.formatToParts()` method allows locale-aware
10923        /// formatting of strings produced by DateTimeFormat formatters.
10924        ///
10925        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts)
10926        #[cfg(not(js_sys_unstable_apis))]
10927        #[wasm_bindgen(method, js_class = "Intl.DateTimeFormat", js_name = formatToParts)]
10928        pub fn format_to_parts(this: &DateTimeFormat, date: &Date) -> Array;
10929
10930        /// The `Intl.DateTimeFormat.prototype.formatToParts()` method allows locale-aware
10931        /// formatting of strings produced by DateTimeFormat formatters.
10932        ///
10933        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts)
10934        #[cfg(js_sys_unstable_apis)]
10935        #[wasm_bindgen(method, js_class = "Intl.DateTimeFormat", js_name = formatToParts)]
10936        pub fn format_to_parts(this: &DateTimeFormat, date: &Date) -> Array<DateTimeFormatPart>;
10937
10938        /// The `Intl.DateTimeFormat.prototype.formatRange()` method formats a date range
10939        /// in the most concise way based on the locales and options provided when
10940        /// instantiating this `Intl.DateTimeFormat` object.
10941        ///
10942        /// Throws a `TypeError` if the dates are invalid.
10943        ///
10944        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatRange)
10945        #[wasm_bindgen(method, js_class = "Intl.DateTimeFormat", js_name = formatRange, catch)]
10946        pub fn format_range(
10947            this: &DateTimeFormat,
10948            start_date: &Date,
10949            end_date: &Date,
10950        ) -> Result<JsString, JsValue>;
10951
10952        /// The `Intl.DateTimeFormat.prototype.formatRangeToParts()` method returns an array
10953        /// of locale-specific tokens representing each part of the formatted date range
10954        /// produced by `Intl.DateTimeFormat` formatters.
10955        ///
10956        /// Throws a `TypeError` if the dates are invalid.
10957        ///
10958        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatRangeToParts)
10959        #[wasm_bindgen(method, js_class = "Intl.DateTimeFormat", js_name = formatRangeToParts, catch)]
10960        pub fn format_range_to_parts(
10961            this: &DateTimeFormat,
10962            start_date: &Date,
10963            end_date: &Date,
10964        ) -> Result<Array<DateTimeRangeFormatPart>, JsValue>;
10965
10966        /// The `Intl.DateTimeFormat.prototype.resolvedOptions()` method returns a new
10967        /// object with properties reflecting the locale and date and time formatting
10968        /// options computed during initialization of this DateTimeFormat object.
10969        ///
10970        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/resolvedOptions)
10971        #[cfg(not(js_sys_unstable_apis))]
10972        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
10973        pub fn resolved_options(this: &DateTimeFormat) -> Object;
10974
10975        /// The `Intl.DateTimeFormat.prototype.resolvedOptions()` method returns a new
10976        /// object with properties reflecting the locale and date and time formatting
10977        /// options computed during initialization of this DateTimeFormat object.
10978        ///
10979        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/resolvedOptions)
10980        #[cfg(js_sys_unstable_apis)]
10981        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
10982        pub fn resolved_options(this: &DateTimeFormat) -> ResolvedDateTimeFormatOptions;
10983
10984        /// The `Intl.DateTimeFormat.supportedLocalesOf()` method returns an array
10985        /// containing those of the provided locales that are supported in date
10986        /// and time formatting without having to fall back to the runtime's default
10987        /// locale.
10988        ///
10989        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/supportedLocalesOf)
10990        #[cfg(not(js_sys_unstable_apis))]
10991        #[wasm_bindgen(static_method_of = DateTimeFormat, js_namespace = Intl, js_name = supportedLocalesOf)]
10992        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
10993
10994        /// The `Intl.DateTimeFormat.supportedLocalesOf()` method returns an array
10995        /// containing those of the provided locales that are supported in date
10996        /// and time formatting without having to fall back to the runtime's default
10997        /// locale.
10998        ///
10999        /// Throws a `RangeError` if locales contain invalid values.
11000        ///
11001        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/supportedLocalesOf)
11002        #[cfg(js_sys_unstable_apis)]
11003        #[wasm_bindgen(static_method_of = DateTimeFormat, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
11004        pub fn supported_locales_of(
11005            locales: &[JsString],
11006            options: &LocaleMatcherOptions,
11007        ) -> Result<Array<JsString>, JsValue>;
11008    }
11009
11010    #[cfg(not(js_sys_unstable_apis))]
11011    impl Default for DateTimeFormat {
11012        fn default() -> Self {
11013            Self::new(
11014                &JsValue::UNDEFINED.unchecked_into(),
11015                &JsValue::UNDEFINED.unchecked_into(),
11016            )
11017        }
11018    }
11019
11020    #[cfg(js_sys_unstable_apis)]
11021    impl Default for DateTimeFormat {
11022        fn default() -> Self {
11023            Self::new(&[], &Default::default()).unwrap()
11024        }
11025    }
11026
11027    // Intl.NumberFormatOptions
11028    #[wasm_bindgen]
11029    extern "C" {
11030        /// Options for `Intl.NumberFormat` constructor.
11031        ///
11032        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#options)
11033        #[wasm_bindgen(extends = Object)]
11034        #[derive(Clone, Debug)]
11035        pub type NumberFormatOptions;
11036
11037        // Locale matching
11038        #[wasm_bindgen(method, getter = localeMatcher)]
11039        pub fn get_locale_matcher(this: &NumberFormatOptions) -> Option<LocaleMatcher>;
11040        #[wasm_bindgen(method, setter = localeMatcher)]
11041        pub fn set_locale_matcher(this: &NumberFormatOptions, value: LocaleMatcher);
11042
11043        // Numbering system (free-form string)
11044        #[wasm_bindgen(method, getter = numberingSystem)]
11045        pub fn get_numbering_system(this: &NumberFormatOptions) -> Option<JsString>;
11046        #[wasm_bindgen(method, setter = numberingSystem)]
11047        pub fn set_numbering_system(this: &NumberFormatOptions, value: &str);
11048
11049        // Style
11050        #[wasm_bindgen(method, getter = style)]
11051        pub fn get_style(this: &NumberFormatOptions) -> Option<NumberFormatStyle>;
11052        #[wasm_bindgen(method, setter = style)]
11053        pub fn set_style(this: &NumberFormatOptions, value: NumberFormatStyle);
11054
11055        // Currency options (currency code is free-form ISO 4217 string)
11056        #[wasm_bindgen(method, getter = currency)]
11057        pub fn get_currency(this: &NumberFormatOptions) -> Option<JsString>;
11058        #[wasm_bindgen(method, setter = currency)]
11059        pub fn set_currency(this: &NumberFormatOptions, value: &str);
11060
11061        #[wasm_bindgen(method, getter = currencyDisplay)]
11062        pub fn get_currency_display(this: &NumberFormatOptions) -> Option<CurrencyDisplay>;
11063        #[wasm_bindgen(method, setter = currencyDisplay)]
11064        pub fn set_currency_display(this: &NumberFormatOptions, value: CurrencyDisplay);
11065
11066        #[wasm_bindgen(method, getter = currencySign)]
11067        pub fn get_currency_sign(this: &NumberFormatOptions) -> Option<CurrencySign>;
11068        #[wasm_bindgen(method, setter = currencySign)]
11069        pub fn set_currency_sign(this: &NumberFormatOptions, value: CurrencySign);
11070
11071        // Unit options (unit name is free-form string)
11072        #[wasm_bindgen(method, getter = unit)]
11073        pub fn get_unit(this: &NumberFormatOptions) -> Option<JsString>;
11074        #[wasm_bindgen(method, setter = unit)]
11075        pub fn set_unit(this: &NumberFormatOptions, value: &str);
11076
11077        #[wasm_bindgen(method, getter = unitDisplay)]
11078        pub fn get_unit_display(this: &NumberFormatOptions) -> Option<UnitDisplay>;
11079        #[wasm_bindgen(method, setter = unitDisplay)]
11080        pub fn set_unit_display(this: &NumberFormatOptions, value: UnitDisplay);
11081
11082        // Notation
11083        #[wasm_bindgen(method, getter = notation)]
11084        pub fn get_notation(this: &NumberFormatOptions) -> Option<NumberFormatNotation>;
11085        #[wasm_bindgen(method, setter = notation)]
11086        pub fn set_notation(this: &NumberFormatOptions, value: NumberFormatNotation);
11087
11088        #[wasm_bindgen(method, getter = compactDisplay)]
11089        pub fn get_compact_display(this: &NumberFormatOptions) -> Option<CompactDisplay>;
11090        #[wasm_bindgen(method, setter = compactDisplay)]
11091        pub fn set_compact_display(this: &NumberFormatOptions, value: CompactDisplay);
11092
11093        // Sign display
11094        #[wasm_bindgen(method, getter = signDisplay)]
11095        pub fn get_sign_display(this: &NumberFormatOptions) -> Option<SignDisplay>;
11096        #[wasm_bindgen(method, setter = signDisplay)]
11097        pub fn set_sign_display(this: &NumberFormatOptions, value: SignDisplay);
11098
11099        // Digit options
11100        #[wasm_bindgen(method, getter = minimumIntegerDigits)]
11101        pub fn get_minimum_integer_digits(this: &NumberFormatOptions) -> Option<u8>;
11102        #[wasm_bindgen(method, setter = minimumIntegerDigits)]
11103        pub fn set_minimum_integer_digits(this: &NumberFormatOptions, value: u8);
11104
11105        #[wasm_bindgen(method, getter = minimumFractionDigits)]
11106        pub fn get_minimum_fraction_digits(this: &NumberFormatOptions) -> Option<u8>;
11107        #[wasm_bindgen(method, setter = minimumFractionDigits)]
11108        pub fn set_minimum_fraction_digits(this: &NumberFormatOptions, value: u8);
11109
11110        #[wasm_bindgen(method, getter = maximumFractionDigits)]
11111        pub fn get_maximum_fraction_digits(this: &NumberFormatOptions) -> Option<u8>;
11112        #[wasm_bindgen(method, setter = maximumFractionDigits)]
11113        pub fn set_maximum_fraction_digits(this: &NumberFormatOptions, value: u8);
11114
11115        #[wasm_bindgen(method, getter = minimumSignificantDigits)]
11116        pub fn get_minimum_significant_digits(this: &NumberFormatOptions) -> Option<u8>;
11117        #[wasm_bindgen(method, setter = minimumSignificantDigits)]
11118        pub fn set_minimum_significant_digits(this: &NumberFormatOptions, value: u8);
11119
11120        #[wasm_bindgen(method, getter = maximumSignificantDigits)]
11121        pub fn get_maximum_significant_digits(this: &NumberFormatOptions) -> Option<u8>;
11122        #[wasm_bindgen(method, setter = maximumSignificantDigits)]
11123        pub fn set_maximum_significant_digits(this: &NumberFormatOptions, value: u8);
11124
11125        // Grouping
11126        #[wasm_bindgen(method, getter = useGrouping)]
11127        pub fn get_use_grouping(this: &NumberFormatOptions) -> Option<UseGrouping>;
11128        #[wasm_bindgen(method, setter = useGrouping)]
11129        pub fn set_use_grouping(this: &NumberFormatOptions, value: UseGrouping);
11130
11131        // Rounding
11132        #[wasm_bindgen(method, getter = roundingMode)]
11133        pub fn get_rounding_mode(this: &NumberFormatOptions) -> Option<RoundingMode>;
11134        #[wasm_bindgen(method, setter = roundingMode)]
11135        pub fn set_rounding_mode(this: &NumberFormatOptions, value: RoundingMode);
11136
11137        #[wasm_bindgen(method, getter = roundingPriority)]
11138        pub fn get_rounding_priority(this: &NumberFormatOptions) -> Option<RoundingPriority>;
11139        #[wasm_bindgen(method, setter = roundingPriority)]
11140        pub fn set_rounding_priority(this: &NumberFormatOptions, value: RoundingPriority);
11141
11142        #[wasm_bindgen(method, getter = roundingIncrement)]
11143        pub fn get_rounding_increment(this: &NumberFormatOptions) -> Option<u32>;
11144        #[wasm_bindgen(method, setter = roundingIncrement)]
11145        pub fn set_rounding_increment(this: &NumberFormatOptions, value: u32);
11146
11147        #[wasm_bindgen(method, getter = trailingZeroDisplay)]
11148        pub fn get_trailing_zero_display(this: &NumberFormatOptions)
11149            -> Option<TrailingZeroDisplay>;
11150        #[wasm_bindgen(method, setter = trailingZeroDisplay)]
11151        pub fn set_trailing_zero_display(this: &NumberFormatOptions, value: TrailingZeroDisplay);
11152    }
11153
11154    impl NumberFormatOptions {
11155        pub fn new() -> NumberFormatOptions {
11156            JsCast::unchecked_into(Object::new())
11157        }
11158    }
11159
11160    impl Default for NumberFormatOptions {
11161        fn default() -> Self {
11162            NumberFormatOptions::new()
11163        }
11164    }
11165
11166    // Intl.ResolvedNumberFormatOptions
11167    #[wasm_bindgen]
11168    extern "C" {
11169        /// Resolved options returned by `Intl.NumberFormat.prototype.resolvedOptions()`.
11170        ///
11171        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/resolvedOptions)
11172        #[wasm_bindgen(extends = NumberFormatOptions)]
11173        #[derive(Clone, Debug)]
11174        pub type ResolvedNumberFormatOptions;
11175
11176        /// The resolved locale string.
11177        #[wasm_bindgen(method, getter = locale)]
11178        pub fn get_locale(this: &ResolvedNumberFormatOptions) -> JsString;
11179    }
11180
11181    // Intl.NumberFormatPart
11182    #[wasm_bindgen]
11183    extern "C" {
11184        /// A part of the formatted number returned by `formatToParts()`.
11185        ///
11186        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatToParts)
11187        #[wasm_bindgen(extends = Object)]
11188        #[derive(Clone, Debug)]
11189        pub type NumberFormatPart;
11190
11191        /// The type of the part (e.g., "integer", "decimal", "fraction", "currency", etc.)
11192        #[wasm_bindgen(method, getter = type)]
11193        pub fn type_(this: &NumberFormatPart) -> NumberFormatPartType;
11194
11195        /// The value of the part.
11196        #[wasm_bindgen(method, getter)]
11197        pub fn value(this: &NumberFormatPart) -> JsString;
11198    }
11199
11200    // Intl.NumberRangeFormatPart
11201    #[wasm_bindgen]
11202    extern "C" {
11203        /// A part of the formatted number range returned by `formatRangeToParts()`.
11204        ///
11205        /// Extends `NumberFormatPart` with a `source` property indicating whether
11206        /// the part is from the start number, end number, or shared between them.
11207        ///
11208        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatRangeToParts)
11209        #[wasm_bindgen(extends = NumberFormatPart)]
11210        #[derive(Clone, Debug)]
11211        pub type NumberRangeFormatPart;
11212
11213        /// The source of the part: "startRange", "endRange", or "shared".
11214        #[wasm_bindgen(method, getter)]
11215        pub fn source(this: &NumberRangeFormatPart) -> RangeSource;
11216    }
11217
11218    // Intl.NumberFormat
11219    #[wasm_bindgen]
11220    extern "C" {
11221        /// The `Intl.NumberFormat` object is a constructor for objects
11222        /// that enable language sensitive number formatting.
11223        ///
11224        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat)
11225        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.NumberFormat")]
11226        #[derive(Clone, Debug)]
11227        pub type NumberFormat;
11228
11229        /// The `Intl.NumberFormat` object is a constructor for objects
11230        /// that enable language sensitive number formatting.
11231        ///
11232        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat)
11233        #[cfg(not(js_sys_unstable_apis))]
11234        #[wasm_bindgen(constructor, js_namespace = Intl)]
11235        pub fn new(locales: &Array, options: &Object) -> NumberFormat;
11236
11237        /// The `Intl.NumberFormat` object is a constructor for objects
11238        /// that enable language sensitive number formatting.
11239        ///
11240        /// Throws a `RangeError` if locales contain invalid values.
11241        ///
11242        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat)
11243        #[cfg(js_sys_unstable_apis)]
11244        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
11245        pub fn new(
11246            locales: &[JsString],
11247            options: &NumberFormatOptions,
11248        ) -> Result<NumberFormat, JsValue>;
11249
11250        /// The Intl.NumberFormat.prototype.format property returns a getter function that
11251        /// formats a number according to the locale and formatting options of this
11252        /// NumberFormat object.
11253        ///
11254        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/format)
11255        #[cfg(not(js_sys_unstable_apis))]
11256        #[wasm_bindgen(method, getter, js_class = "Intl.NumberFormat")]
11257        pub fn format(this: &NumberFormat) -> Function;
11258
11259        /// Formats a number according to the locale and formatting options of this
11260        /// `Intl.NumberFormat` object.
11261        ///
11262        /// Accepts numeric strings for BigInt/arbitrary precision (e.g., `"123n"` → `"123"`,
11263        /// or use E notation: `"1000000E-6"` → `"1"`).
11264        ///
11265        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/format)
11266        #[cfg(js_sys_unstable_apis)]
11267        #[wasm_bindgen(method, js_class = "Intl.NumberFormat")]
11268        pub fn format(this: &NumberFormat, value: &JsString) -> JsString;
11269
11270        /// The `Intl.Numberformat.prototype.formatToParts()` method allows locale-aware
11271        /// formatting of strings produced by NumberTimeFormat formatters.
11272        ///
11273        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/formatToParts)
11274        #[cfg(not(js_sys_unstable_apis))]
11275        #[wasm_bindgen(method, js_class = "Intl.NumberFormat", js_name = formatToParts)]
11276        pub fn format_to_parts(this: &NumberFormat, number: f64) -> Array;
11277
11278        /// The `Intl.NumberFormat.prototype.formatToParts()` method allows locale-aware
11279        /// formatting of strings produced by `Intl.NumberFormat` formatters.
11280        ///
11281        /// Accepts numeric strings for BigInt/arbitrary precision (e.g., `"123n"` → `"123"`,
11282        /// or use E notation: `"1000000E-6"` → `"1"`).
11283        ///
11284        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatToParts)
11285        #[cfg(js_sys_unstable_apis)]
11286        #[wasm_bindgen(method, js_class = "Intl.NumberFormat", js_name = formatToParts)]
11287        pub fn format_to_parts(this: &NumberFormat, value: &JsString) -> Array<NumberFormatPart>;
11288
11289        /// Formats a range of numbers according to the locale and formatting options
11290        /// of this `Intl.NumberFormat` object.
11291        ///
11292        /// Accepts numeric strings for BigInt/arbitrary precision (e.g., `"123n"` → `"123"`,
11293        /// or use E notation: `"1000000E-6"` → `"1"`).
11294        ///
11295        /// Throws a `TypeError` if the values are invalid.
11296        ///
11297        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatRange)
11298        #[wasm_bindgen(method, js_class = "Intl.NumberFormat", js_name = formatRange, catch)]
11299        pub fn format_range(
11300            this: &NumberFormat,
11301            start: &JsString,
11302            end: &JsString,
11303        ) -> Result<JsString, JsValue>;
11304
11305        /// Returns an array of locale-specific tokens representing each part of
11306        /// the formatted number range.
11307        ///
11308        /// Accepts numeric strings for BigInt/arbitrary precision (e.g., `"123n"` → `"123"`,
11309        /// or use E notation: `"1000000E-6"` → `"1"`).
11310        ///
11311        /// Throws a `TypeError` if the values are invalid.
11312        ///
11313        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatRangeToParts)
11314        #[wasm_bindgen(method, js_class = "Intl.NumberFormat", js_name = formatRangeToParts, catch)]
11315        pub fn format_range_to_parts(
11316            this: &NumberFormat,
11317            start: &JsString,
11318            end: &JsString,
11319        ) -> Result<Array<NumberRangeFormatPart>, JsValue>;
11320
11321        /// The `Intl.NumberFormat.prototype.resolvedOptions()` method returns a new
11322        /// object with properties reflecting the locale and number formatting
11323        /// options computed during initialization of this NumberFormat object.
11324        ///
11325        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/resolvedOptions)
11326        #[cfg(not(js_sys_unstable_apis))]
11327        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11328        pub fn resolved_options(this: &NumberFormat) -> Object;
11329
11330        /// The `Intl.NumberFormat.prototype.resolvedOptions()` method returns a new
11331        /// object with properties reflecting the locale and number formatting
11332        /// options computed during initialization of this NumberFormat object.
11333        ///
11334        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/resolvedOptions)
11335        #[cfg(js_sys_unstable_apis)]
11336        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11337        pub fn resolved_options(this: &NumberFormat) -> ResolvedNumberFormatOptions;
11338
11339        /// The `Intl.NumberFormat.supportedLocalesOf()` method returns an array
11340        /// containing those of the provided locales that are supported in number
11341        /// formatting without having to fall back to the runtime's default locale.
11342        ///
11343        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/supportedLocalesOf)
11344        #[cfg(not(js_sys_unstable_apis))]
11345        #[wasm_bindgen(static_method_of = NumberFormat, js_namespace = Intl, js_name = supportedLocalesOf)]
11346        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
11347
11348        /// The `Intl.NumberFormat.supportedLocalesOf()` method returns an array
11349        /// containing those of the provided locales that are supported in number
11350        /// formatting without having to fall back to the runtime's default locale.
11351        ///
11352        /// Throws a `RangeError` if locales contain invalid values.
11353        ///
11354        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/supportedLocalesOf)
11355        #[cfg(js_sys_unstable_apis)]
11356        #[wasm_bindgen(static_method_of = NumberFormat, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
11357        pub fn supported_locales_of(
11358            locales: &[JsString],
11359            options: &LocaleMatcherOptions,
11360        ) -> Result<Array<JsString>, JsValue>;
11361    }
11362
11363    #[cfg(not(js_sys_unstable_apis))]
11364    impl Default for NumberFormat {
11365        fn default() -> Self {
11366            Self::new(
11367                &JsValue::UNDEFINED.unchecked_into(),
11368                &JsValue::UNDEFINED.unchecked_into(),
11369            )
11370        }
11371    }
11372
11373    #[cfg(js_sys_unstable_apis)]
11374    impl Default for NumberFormat {
11375        fn default() -> Self {
11376            Self::new(&[], &Default::default()).unwrap()
11377        }
11378    }
11379
11380    // Intl.PluralRulesOptions
11381    #[wasm_bindgen]
11382    extern "C" {
11383        /// Options for `Intl.PluralRules` constructor.
11384        ///
11385        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/PluralRules#options)
11386        #[wasm_bindgen(extends = Object)]
11387        #[derive(Clone, Debug)]
11388        pub type PluralRulesOptions;
11389
11390        #[wasm_bindgen(method, getter = localeMatcher)]
11391        pub fn get_locale_matcher(this: &PluralRulesOptions) -> Option<LocaleMatcher>;
11392        #[wasm_bindgen(method, setter = localeMatcher)]
11393        pub fn set_locale_matcher(this: &PluralRulesOptions, value: LocaleMatcher);
11394
11395        #[wasm_bindgen(method, getter = type)]
11396        pub fn get_type(this: &PluralRulesOptions) -> Option<PluralRulesType>;
11397        #[wasm_bindgen(method, setter = type)]
11398        pub fn set_type(this: &PluralRulesOptions, value: PluralRulesType);
11399
11400        #[wasm_bindgen(method, getter = minimumIntegerDigits)]
11401        pub fn get_minimum_integer_digits(this: &PluralRulesOptions) -> Option<u8>;
11402        #[wasm_bindgen(method, setter = minimumIntegerDigits)]
11403        pub fn set_minimum_integer_digits(this: &PluralRulesOptions, value: u8);
11404
11405        #[wasm_bindgen(method, getter = minimumFractionDigits)]
11406        pub fn get_minimum_fraction_digits(this: &PluralRulesOptions) -> Option<u8>;
11407        #[wasm_bindgen(method, setter = minimumFractionDigits)]
11408        pub fn set_minimum_fraction_digits(this: &PluralRulesOptions, value: u8);
11409
11410        #[wasm_bindgen(method, getter = maximumFractionDigits)]
11411        pub fn get_maximum_fraction_digits(this: &PluralRulesOptions) -> Option<u8>;
11412        #[wasm_bindgen(method, setter = maximumFractionDigits)]
11413        pub fn set_maximum_fraction_digits(this: &PluralRulesOptions, value: u8);
11414
11415        #[wasm_bindgen(method, getter = minimumSignificantDigits)]
11416        pub fn get_minimum_significant_digits(this: &PluralRulesOptions) -> Option<u8>;
11417        #[wasm_bindgen(method, setter = minimumSignificantDigits)]
11418        pub fn set_minimum_significant_digits(this: &PluralRulesOptions, value: u8);
11419
11420        #[wasm_bindgen(method, getter = maximumSignificantDigits)]
11421        pub fn get_maximum_significant_digits(this: &PluralRulesOptions) -> Option<u8>;
11422        #[wasm_bindgen(method, setter = maximumSignificantDigits)]
11423        pub fn set_maximum_significant_digits(this: &PluralRulesOptions, value: u8);
11424
11425        #[wasm_bindgen(method, getter = roundingPriority)]
11426        pub fn get_rounding_priority(this: &PluralRulesOptions) -> Option<RoundingPriority>;
11427        #[wasm_bindgen(method, setter = roundingPriority)]
11428        pub fn set_rounding_priority(this: &PluralRulesOptions, value: RoundingPriority);
11429
11430        #[wasm_bindgen(method, getter = roundingIncrement)]
11431        pub fn get_rounding_increment(this: &PluralRulesOptions) -> Option<u32>;
11432        #[wasm_bindgen(method, setter = roundingIncrement)]
11433        pub fn set_rounding_increment(this: &PluralRulesOptions, value: u32);
11434
11435        #[wasm_bindgen(method, getter = roundingMode)]
11436        pub fn get_rounding_mode(this: &PluralRulesOptions) -> Option<RoundingMode>;
11437        #[wasm_bindgen(method, setter = roundingMode)]
11438        pub fn set_rounding_mode(this: &PluralRulesOptions, value: RoundingMode);
11439
11440        #[wasm_bindgen(method, getter = trailingZeroDisplay)]
11441        pub fn get_trailing_zero_display(this: &PluralRulesOptions) -> Option<TrailingZeroDisplay>;
11442        #[wasm_bindgen(method, setter = trailingZeroDisplay)]
11443        pub fn set_trailing_zero_display(this: &PluralRulesOptions, value: TrailingZeroDisplay);
11444    }
11445
11446    impl PluralRulesOptions {
11447        pub fn new() -> PluralRulesOptions {
11448            JsCast::unchecked_into(Object::new())
11449        }
11450    }
11451
11452    impl Default for PluralRulesOptions {
11453        fn default() -> Self {
11454            PluralRulesOptions::new()
11455        }
11456    }
11457
11458    // Intl.ResolvedPluralRulesOptions
11459    #[wasm_bindgen]
11460    extern "C" {
11461        /// Resolved options returned by `Intl.PluralRules.prototype.resolvedOptions()`.
11462        ///
11463        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/resolvedOptions)
11464        #[wasm_bindgen(extends = PluralRulesOptions)]
11465        #[derive(Clone, Debug)]
11466        pub type ResolvedPluralRulesOptions;
11467
11468        /// The resolved locale string.
11469        #[wasm_bindgen(method, getter = locale)]
11470        pub fn get_locale(this: &ResolvedPluralRulesOptions) -> JsString;
11471
11472        /// The plural categories used by the locale.
11473        #[wasm_bindgen(method, getter = pluralCategories)]
11474        pub fn get_plural_categories(this: &ResolvedPluralRulesOptions) -> Array<JsString>;
11475    }
11476
11477    // Intl.PluralRules
11478    #[wasm_bindgen]
11479    extern "C" {
11480        /// The `Intl.PluralRules` object is a constructor for objects
11481        /// that enable plural sensitive formatting and plural language rules.
11482        ///
11483        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules)
11484        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.PluralRules")]
11485        #[derive(Clone, Debug)]
11486        pub type PluralRules;
11487
11488        /// The `Intl.PluralRules` object is a constructor for objects
11489        /// that enable plural sensitive formatting and plural language rules.
11490        ///
11491        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules)
11492        #[cfg(not(js_sys_unstable_apis))]
11493        #[wasm_bindgen(constructor, js_namespace = Intl)]
11494        pub fn new(locales: &Array, options: &Object) -> PluralRules;
11495
11496        /// The `Intl.PluralRules` object is a constructor for objects
11497        /// that enable plural sensitive formatting and plural language rules.
11498        ///
11499        /// Throws a `RangeError` if locales contain invalid values.
11500        ///
11501        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules)
11502        #[cfg(js_sys_unstable_apis)]
11503        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
11504        pub fn new(
11505            locales: &[JsString],
11506            options: &PluralRulesOptions,
11507        ) -> Result<PluralRules, JsValue>;
11508
11509        /// The `Intl.PluralRules.prototype.resolvedOptions()` method returns a new
11510        /// object with properties reflecting the locale and plural formatting
11511        /// options computed during initialization of this PluralRules object.
11512        ///
11513        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/resolvedOptions)
11514        #[cfg(not(js_sys_unstable_apis))]
11515        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11516        pub fn resolved_options(this: &PluralRules) -> Object;
11517
11518        /// The `Intl.PluralRules.prototype.resolvedOptions()` method returns a new
11519        /// object with properties reflecting the locale and plural formatting
11520        /// options computed during initialization of this PluralRules object.
11521        ///
11522        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/resolvedOptions)
11523        #[cfg(js_sys_unstable_apis)]
11524        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11525        pub fn resolved_options(this: &PluralRules) -> ResolvedPluralRulesOptions;
11526
11527        /// The `Intl.PluralRules.prototype.select()` method returns a String indicating
11528        /// which plural rule to use for locale-aware formatting.
11529        ///
11530        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/select)
11531        #[cfg(not(js_sys_unstable_apis))]
11532        #[wasm_bindgen(method, js_namespace = Intl)]
11533        pub fn select(this: &PluralRules, number: f64) -> JsString;
11534
11535        /// The `Intl.PluralRules.prototype.select()` method returns a String indicating
11536        /// which plural rule to use for locale-aware formatting.
11537        ///
11538        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/select)
11539        #[cfg(js_sys_unstable_apis)]
11540        #[wasm_bindgen(method, js_namespace = Intl)]
11541        pub fn select(this: &PluralRules, number: f64) -> PluralCategory;
11542
11543        /// The `Intl.PluralRules.prototype.selectRange()` method returns a string indicating
11544        /// which plural rule to use for locale-aware formatting of a range of numbers.
11545        ///
11546        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/selectRange)
11547        #[cfg(not(js_sys_unstable_apis))]
11548        #[wasm_bindgen(method, js_namespace = Intl, js_name = selectRange)]
11549        pub fn select_range(this: &PluralRules, start: f64, end: f64) -> JsString;
11550
11551        /// The `Intl.PluralRules.prototype.selectRange()` method returns a string indicating
11552        /// which plural rule to use for locale-aware formatting of a range of numbers.
11553        ///
11554        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/selectRange)
11555        #[cfg(js_sys_unstable_apis)]
11556        #[wasm_bindgen(method, js_namespace = Intl, js_name = selectRange)]
11557        pub fn select_range(this: &PluralRules, start: f64, end: f64) -> PluralCategory;
11558
11559        /// The `Intl.PluralRules.supportedLocalesOf()` method returns an array
11560        /// containing those of the provided locales that are supported in plural
11561        /// formatting without having to fall back to the runtime's default locale.
11562        ///
11563        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/supportedLocalesOf)
11564        #[cfg(not(js_sys_unstable_apis))]
11565        #[wasm_bindgen(static_method_of = PluralRules, js_namespace = Intl, js_name = supportedLocalesOf)]
11566        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
11567
11568        /// The `Intl.PluralRules.supportedLocalesOf()` method returns an array
11569        /// containing those of the provided locales that are supported in plural
11570        /// formatting without having to fall back to the runtime's default locale.
11571        ///
11572        /// Throws a `RangeError` if locales contain invalid values.
11573        ///
11574        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/supportedLocalesOf)
11575        #[cfg(js_sys_unstable_apis)]
11576        #[wasm_bindgen(static_method_of = PluralRules, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
11577        pub fn supported_locales_of(
11578            locales: &[JsString],
11579            options: &LocaleMatcherOptions,
11580        ) -> Result<Array<JsString>, JsValue>;
11581    }
11582
11583    #[cfg(not(js_sys_unstable_apis))]
11584    impl Default for PluralRules {
11585        fn default() -> Self {
11586            Self::new(
11587                &JsValue::UNDEFINED.unchecked_into(),
11588                &JsValue::UNDEFINED.unchecked_into(),
11589            )
11590        }
11591    }
11592
11593    #[cfg(js_sys_unstable_apis)]
11594    impl Default for PluralRules {
11595        fn default() -> Self {
11596            Self::new(&[], &Default::default()).unwrap()
11597        }
11598    }
11599
11600    // Intl.RelativeTimeFormat
11601    #[wasm_bindgen]
11602    extern "C" {
11603        /// The `Intl.RelativeTimeFormat` object is a constructor for objects
11604        /// that enable language-sensitive relative time formatting.
11605        ///
11606        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat)
11607        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.RelativeTimeFormat")]
11608        #[derive(Clone, Debug)]
11609        pub type RelativeTimeFormat;
11610
11611        /// The `Intl.RelativeTimeFormat` object is a constructor for objects
11612        /// that enable language-sensitive relative time formatting.
11613        ///
11614        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat)
11615        #[cfg(not(js_sys_unstable_apis))]
11616        #[wasm_bindgen(constructor, js_namespace = Intl)]
11617        pub fn new(locales: &Array, options: &Object) -> RelativeTimeFormat;
11618
11619        /// The `Intl.RelativeTimeFormat` object is a constructor for objects
11620        /// that enable language-sensitive relative time formatting.
11621        ///
11622        /// Throws a `RangeError` if locales contain invalid values.
11623        ///
11624        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat)
11625        #[cfg(js_sys_unstable_apis)]
11626        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
11627        pub fn new(locales: &[JsString]) -> Result<RelativeTimeFormat, JsValue>;
11628
11629        /// The `Intl.RelativeTimeFormat` object is a constructor for objects
11630        /// that enable language-sensitive relative time formatting.
11631        ///
11632        /// Throws a `RangeError` if locales or options contain invalid values.
11633        ///
11634        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat)
11635        #[cfg(js_sys_unstable_apis)]
11636        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
11637        pub fn new_with_options(
11638            locales: &[JsString],
11639            options: &RelativeTimeFormatOptions,
11640        ) -> Result<RelativeTimeFormat, JsValue>;
11641
11642        /// The `Intl.RelativeTimeFormat.prototype.format` method formats a `value` and `unit`
11643        /// according to the locale and formatting options of this Intl.RelativeTimeFormat object.
11644        ///
11645        /// Throws a `RangeError` if unit is invalid.
11646        ///
11647        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/format)
11648        #[cfg(not(js_sys_unstable_apis))]
11649        #[wasm_bindgen(method, js_class = "Intl.RelativeTimeFormat")]
11650        pub fn format(this: &RelativeTimeFormat, value: f64, unit: &str) -> JsString;
11651
11652        /// The `Intl.RelativeTimeFormat.prototype.format` method formats a `value` and `unit`
11653        /// according to the locale and formatting options of this Intl.RelativeTimeFormat object.
11654        ///
11655        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/format)
11656        #[cfg(js_sys_unstable_apis)]
11657        #[wasm_bindgen(method, js_class = "Intl.RelativeTimeFormat")]
11658        pub fn format(
11659            this: &RelativeTimeFormat,
11660            value: f64,
11661            unit: RelativeTimeFormatUnit,
11662        ) -> JsString;
11663
11664        /// The `Intl.RelativeTimeFormat.prototype.formatToParts()` method returns an array of
11665        /// objects representing the relative time format in parts that can be used for custom locale-aware formatting.
11666        ///
11667        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/formatToParts)
11668        #[cfg(not(js_sys_unstable_apis))]
11669        #[wasm_bindgen(method, js_class = "Intl.RelativeTimeFormat", js_name = formatToParts)]
11670        pub fn format_to_parts(this: &RelativeTimeFormat, value: f64, unit: &str) -> Array;
11671
11672        /// The `Intl.RelativeTimeFormat.prototype.formatToParts()` method returns an array of
11673        /// objects representing the relative time format in parts that can be used for custom locale-aware formatting.
11674        ///
11675        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/formatToParts)
11676        #[cfg(js_sys_unstable_apis)]
11677        #[wasm_bindgen(method, js_class = "Intl.RelativeTimeFormat", js_name = formatToParts)]
11678        pub fn format_to_parts(
11679            this: &RelativeTimeFormat,
11680            value: f64,
11681            unit: RelativeTimeFormatUnit,
11682        ) -> Array<RelativeTimeFormatPart>;
11683
11684        /// The `Intl.RelativeTimeFormat.prototype.resolvedOptions()` method returns a new
11685        /// object with properties reflecting the locale and relative time formatting
11686        /// options computed during initialization of this RelativeTimeFormat object.
11687        ///
11688        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/resolvedOptions)
11689        #[cfg(not(js_sys_unstable_apis))]
11690        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11691        pub fn resolved_options(this: &RelativeTimeFormat) -> Object;
11692
11693        /// The `Intl.RelativeTimeFormat.prototype.resolvedOptions()` method returns a new
11694        /// object with properties reflecting the locale and relative time formatting
11695        /// options computed during initialization of this RelativeTimeFormat object.
11696        ///
11697        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/resolvedOptions)
11698        #[cfg(js_sys_unstable_apis)]
11699        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11700        pub fn resolved_options(this: &RelativeTimeFormat) -> ResolvedRelativeTimeFormatOptions;
11701
11702        /// The `Intl.RelativeTimeFormat.supportedLocalesOf()` method returns an array
11703        /// containing those of the provided locales that are supported in date and time
11704        /// formatting without having to fall back to the runtime's default locale.
11705        ///
11706        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat/supportedLocalesOf)
11707        #[cfg(not(js_sys_unstable_apis))]
11708        #[wasm_bindgen(static_method_of = RelativeTimeFormat, js_namespace = Intl, js_name = supportedLocalesOf)]
11709        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
11710
11711        /// The `Intl.RelativeTimeFormat.supportedLocalesOf()` method returns an array
11712        /// containing those of the provided locales that are supported in date and time
11713        /// formatting without having to fall back to the runtime's default locale.
11714        ///
11715        /// Throws a `RangeError` if locales contain invalid values.
11716        ///
11717        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat/supportedLocalesOf)
11718        #[cfg(js_sys_unstable_apis)]
11719        #[wasm_bindgen(static_method_of = RelativeTimeFormat, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
11720        pub fn supported_locales_of(
11721            locales: &[JsString],
11722            options: &LocaleMatcherOptions,
11723        ) -> Result<Array<JsString>, JsValue>;
11724    }
11725
11726    #[cfg(not(js_sys_unstable_apis))]
11727    impl Default for RelativeTimeFormat {
11728        fn default() -> Self {
11729            Self::new(
11730                &JsValue::UNDEFINED.unchecked_into(),
11731                &JsValue::UNDEFINED.unchecked_into(),
11732            )
11733        }
11734    }
11735
11736    #[cfg(js_sys_unstable_apis)]
11737    impl Default for RelativeTimeFormat {
11738        fn default() -> Self {
11739            Self::new(&[]).unwrap()
11740        }
11741    }
11742
11743    // Intl.ListFormatOptions
11744    #[wasm_bindgen]
11745    extern "C" {
11746        /// Options for `Intl.ListFormat` constructor.
11747        ///
11748        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat#options)
11749        #[wasm_bindgen(extends = Object)]
11750        #[derive(Clone, Debug)]
11751        pub type ListFormatOptions;
11752
11753        #[wasm_bindgen(method, getter = localeMatcher)]
11754        pub fn get_locale_matcher(this: &ListFormatOptions) -> Option<LocaleMatcher>;
11755        #[wasm_bindgen(method, setter = localeMatcher)]
11756        pub fn set_locale_matcher(this: &ListFormatOptions, value: LocaleMatcher);
11757
11758        #[wasm_bindgen(method, getter = type)]
11759        pub fn get_type(this: &ListFormatOptions) -> Option<ListFormatType>;
11760        #[wasm_bindgen(method, setter = type)]
11761        pub fn set_type(this: &ListFormatOptions, value: ListFormatType);
11762
11763        #[wasm_bindgen(method, getter = style)]
11764        pub fn get_style(this: &ListFormatOptions) -> Option<ListFormatStyle>;
11765        #[wasm_bindgen(method, setter = style)]
11766        pub fn set_style(this: &ListFormatOptions, value: ListFormatStyle);
11767    }
11768
11769    impl ListFormatOptions {
11770        pub fn new() -> ListFormatOptions {
11771            JsCast::unchecked_into(Object::new())
11772        }
11773    }
11774
11775    impl Default for ListFormatOptions {
11776        fn default() -> Self {
11777            ListFormatOptions::new()
11778        }
11779    }
11780
11781    // Intl.ResolvedListFormatOptions
11782    #[wasm_bindgen]
11783    extern "C" {
11784        /// Resolved options returned by `Intl.ListFormat.prototype.resolvedOptions()`.
11785        ///
11786        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/resolvedOptions)
11787        #[wasm_bindgen(extends = ListFormatOptions)]
11788        #[derive(Clone, Debug)]
11789        pub type ResolvedListFormatOptions;
11790
11791        /// The resolved locale string.
11792        #[wasm_bindgen(method, getter = locale)]
11793        pub fn get_locale(this: &ResolvedListFormatOptions) -> JsString;
11794    }
11795
11796    // Intl.ListFormatPart
11797    #[wasm_bindgen]
11798    extern "C" {
11799        /// A part of the formatted list returned by `formatToParts()`.
11800        ///
11801        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/formatToParts)
11802        #[wasm_bindgen(extends = Object)]
11803        #[derive(Clone, Debug)]
11804        pub type ListFormatPart;
11805
11806        /// The type of the part ("element" or "literal").
11807        #[wasm_bindgen(method, getter = type)]
11808        pub fn type_(this: &ListFormatPart) -> ListFormatPartType;
11809
11810        /// The value of the part.
11811        #[wasm_bindgen(method, getter)]
11812        pub fn value(this: &ListFormatPart) -> JsString;
11813    }
11814
11815    // Intl.ListFormat
11816    #[wasm_bindgen]
11817    extern "C" {
11818        /// The `Intl.ListFormat` object enables language-sensitive list formatting.
11819        ///
11820        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat)
11821        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.ListFormat")]
11822        #[derive(Clone, Debug)]
11823        pub type ListFormat;
11824
11825        /// Creates a new `Intl.ListFormat` object.
11826        ///
11827        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat)
11828        #[cfg(not(js_sys_unstable_apis))]
11829        #[wasm_bindgen(constructor, js_namespace = Intl)]
11830        pub fn new(locales: &Array, options: &Object) -> ListFormat;
11831
11832        /// Creates a new `Intl.ListFormat` object.
11833        ///
11834        /// Throws a `RangeError` if locales or options contain invalid values.
11835        ///
11836        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat)
11837        #[cfg(js_sys_unstable_apis)]
11838        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
11839        pub fn new(
11840            locales: &[JsString],
11841            options: &ListFormatOptions,
11842        ) -> Result<ListFormat, JsValue>;
11843
11844        /// Formats a list of strings according to the locale and options.
11845        ///
11846        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/format)
11847        #[cfg(not(js_sys_unstable_apis))]
11848        #[wasm_bindgen(method, js_class = "Intl.ListFormat")]
11849        pub fn format(this: &ListFormat, list: &Array) -> JsString;
11850
11851        /// Formats a list of strings according to the locale and options.
11852        ///
11853        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/format)
11854        #[cfg(js_sys_unstable_apis)]
11855        #[wasm_bindgen(method, js_class = "Intl.ListFormat")]
11856        pub fn format(this: &ListFormat, list: &[JsString]) -> JsString;
11857
11858        /// Returns an array of objects representing the list in parts.
11859        ///
11860        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/formatToParts)
11861        #[cfg(not(js_sys_unstable_apis))]
11862        #[wasm_bindgen(method, js_class = "Intl.ListFormat", js_name = formatToParts)]
11863        pub fn format_to_parts(this: &ListFormat, list: &Array) -> Array;
11864
11865        /// Returns an array of objects representing the list in parts.
11866        ///
11867        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/formatToParts)
11868        #[cfg(js_sys_unstable_apis)]
11869        #[wasm_bindgen(method, js_class = "Intl.ListFormat", js_name = formatToParts)]
11870        pub fn format_to_parts(this: &ListFormat, list: &[JsString]) -> Array<ListFormatPart>;
11871
11872        /// Returns an object with properties reflecting the options used.
11873        ///
11874        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/resolvedOptions)
11875        #[cfg(not(js_sys_unstable_apis))]
11876        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11877        pub fn resolved_options(this: &ListFormat) -> Object;
11878
11879        /// Returns an object with properties reflecting the options used.
11880        ///
11881        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/resolvedOptions)
11882        #[cfg(js_sys_unstable_apis)]
11883        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11884        pub fn resolved_options(this: &ListFormat) -> ResolvedListFormatOptions;
11885
11886        /// Returns an array of supported locales.
11887        ///
11888        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/supportedLocalesOf)
11889        #[cfg(not(js_sys_unstable_apis))]
11890        #[wasm_bindgen(static_method_of = ListFormat, js_namespace = Intl, js_name = supportedLocalesOf)]
11891        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
11892
11893        /// Returns an array of supported locales.
11894        ///
11895        /// Throws a `RangeError` if locales contain invalid values.
11896        ///
11897        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/supportedLocalesOf)
11898        #[cfg(js_sys_unstable_apis)]
11899        #[wasm_bindgen(static_method_of = ListFormat, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
11900        pub fn supported_locales_of(
11901            locales: &[JsString],
11902            options: &LocaleMatcherOptions,
11903        ) -> Result<Array<JsString>, JsValue>;
11904    }
11905
11906    #[cfg(not(js_sys_unstable_apis))]
11907    impl Default for ListFormat {
11908        fn default() -> Self {
11909            Self::new(
11910                &JsValue::UNDEFINED.unchecked_into(),
11911                &JsValue::UNDEFINED.unchecked_into(),
11912            )
11913        }
11914    }
11915
11916    #[cfg(js_sys_unstable_apis)]
11917    impl Default for ListFormat {
11918        fn default() -> Self {
11919            Self::new(&[], &Default::default()).unwrap()
11920        }
11921    }
11922
11923    // Intl.SegmenterOptions
11924    #[wasm_bindgen]
11925    extern "C" {
11926        /// Options for `Intl.Segmenter` constructor.
11927        ///
11928        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/Segmenter#options)
11929        #[wasm_bindgen(extends = Object)]
11930        #[derive(Clone, Debug)]
11931        pub type SegmenterOptions;
11932
11933        #[wasm_bindgen(method, getter = localeMatcher)]
11934        pub fn get_locale_matcher(this: &SegmenterOptions) -> Option<LocaleMatcher>;
11935        #[wasm_bindgen(method, setter = localeMatcher)]
11936        pub fn set_locale_matcher(this: &SegmenterOptions, value: LocaleMatcher);
11937
11938        #[wasm_bindgen(method, getter = granularity)]
11939        pub fn get_granularity(this: &SegmenterOptions) -> Option<SegmenterGranularity>;
11940        #[wasm_bindgen(method, setter = granularity)]
11941        pub fn set_granularity(this: &SegmenterOptions, value: SegmenterGranularity);
11942    }
11943
11944    impl SegmenterOptions {
11945        pub fn new() -> SegmenterOptions {
11946            JsCast::unchecked_into(Object::new())
11947        }
11948    }
11949
11950    impl Default for SegmenterOptions {
11951        fn default() -> Self {
11952            SegmenterOptions::new()
11953        }
11954    }
11955
11956    // Intl.ResolvedSegmenterOptions
11957    #[wasm_bindgen]
11958    extern "C" {
11959        /// Resolved options returned by `Intl.Segmenter.prototype.resolvedOptions()`.
11960        ///
11961        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/resolvedOptions)
11962        #[wasm_bindgen(extends = SegmenterOptions)]
11963        #[derive(Clone, Debug)]
11964        pub type ResolvedSegmenterOptions;
11965
11966        /// The resolved locale string.
11967        #[wasm_bindgen(method, getter = locale)]
11968        pub fn get_locale(this: &ResolvedSegmenterOptions) -> JsString;
11969    }
11970
11971    // Intl.SegmentData
11972    #[wasm_bindgen]
11973    extern "C" {
11974        /// Data about a segment returned by the Segments iterator.
11975        ///
11976        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment/Segments#segment_data)
11977        #[wasm_bindgen(extends = Object)]
11978        #[derive(Clone, Debug)]
11979        pub type SegmentData;
11980
11981        /// The segment string.
11982        #[wasm_bindgen(method, getter)]
11983        pub fn segment(this: &SegmentData) -> JsString;
11984
11985        /// The index of the segment in the original string.
11986        #[wasm_bindgen(method, getter)]
11987        pub fn index(this: &SegmentData) -> u32;
11988
11989        /// The original input string.
11990        #[wasm_bindgen(method, getter)]
11991        pub fn input(this: &SegmentData) -> JsString;
11992
11993        /// Whether the segment is word-like (only for word granularity).
11994        #[wasm_bindgen(method, getter = isWordLike)]
11995        pub fn is_word_like(this: &SegmentData) -> Option<bool>;
11996    }
11997
11998    // Intl.Segments
11999    #[wasm_bindgen]
12000    extern "C" {
12001        /// The Segments object is an iterable collection of segments of a string.
12002        ///
12003        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment/Segments)
12004        #[wasm_bindgen(extends = Object)]
12005        #[derive(Clone, Debug)]
12006        pub type Segments;
12007
12008        /// Returns segment data for the segment containing the character at the given index.
12009        ///
12010        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment/Segments/containing)
12011        #[wasm_bindgen(method)]
12012        pub fn containing(this: &Segments, index: u32) -> Option<SegmentData>;
12013    }
12014
12015    // Intl.Segmenter
12016    #[wasm_bindgen]
12017    extern "C" {
12018        /// The `Intl.Segmenter` object enables locale-sensitive text segmentation.
12019        ///
12020        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter)
12021        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.Segmenter")]
12022        #[derive(Clone, Debug)]
12023        pub type Segmenter;
12024
12025        /// Creates a new `Intl.Segmenter` object.
12026        ///
12027        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/Segmenter)
12028        #[cfg(not(js_sys_unstable_apis))]
12029        #[wasm_bindgen(constructor, js_namespace = Intl)]
12030        pub fn new(locales: &Array, options: &Object) -> Segmenter;
12031
12032        /// Creates a new `Intl.Segmenter` object.
12033        ///
12034        /// Throws a `RangeError` if locales or options contain invalid values.
12035        ///
12036        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/Segmenter)
12037        #[cfg(js_sys_unstable_apis)]
12038        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
12039        pub fn new(locales: &[JsString], options: &SegmenterOptions) -> Result<Segmenter, JsValue>;
12040
12041        /// Returns a Segments object containing the segments of the input string.
12042        ///
12043        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment)
12044        #[wasm_bindgen(method, js_class = "Intl.Segmenter")]
12045        pub fn segment(this: &Segmenter, input: &str) -> Segments;
12046
12047        /// Returns an object with properties reflecting the options used.
12048        ///
12049        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/resolvedOptions)
12050        #[cfg(not(js_sys_unstable_apis))]
12051        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
12052        pub fn resolved_options(this: &Segmenter) -> Object;
12053
12054        /// Returns an object with properties reflecting the options used.
12055        ///
12056        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/resolvedOptions)
12057        #[cfg(js_sys_unstable_apis)]
12058        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
12059        pub fn resolved_options(this: &Segmenter) -> ResolvedSegmenterOptions;
12060
12061        /// Returns an array of supported locales.
12062        ///
12063        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/supportedLocalesOf)
12064        #[cfg(not(js_sys_unstable_apis))]
12065        #[wasm_bindgen(static_method_of = Segmenter, js_namespace = Intl, js_name = supportedLocalesOf)]
12066        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
12067
12068        /// Returns an array of supported locales.
12069        ///
12070        /// Throws a `RangeError` if locales contain invalid values.
12071        ///
12072        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/supportedLocalesOf)
12073        #[cfg(js_sys_unstable_apis)]
12074        #[wasm_bindgen(static_method_of = Segmenter, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
12075        pub fn supported_locales_of(
12076            locales: &[JsString],
12077            options: &LocaleMatcherOptions,
12078        ) -> Result<Array<JsString>, JsValue>;
12079    }
12080
12081    #[cfg(not(js_sys_unstable_apis))]
12082    impl Default for Segmenter {
12083        fn default() -> Self {
12084            Self::new(
12085                &JsValue::UNDEFINED.unchecked_into(),
12086                &JsValue::UNDEFINED.unchecked_into(),
12087            )
12088        }
12089    }
12090
12091    #[cfg(js_sys_unstable_apis)]
12092    impl Default for Segmenter {
12093        fn default() -> Self {
12094            Self::new(&[], &Default::default()).unwrap()
12095        }
12096    }
12097
12098    // Intl.DisplayNamesOptions
12099    #[wasm_bindgen]
12100    extern "C" {
12101        /// Options for `Intl.DisplayNames` constructor.
12102        ///
12103        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames#options)
12104        #[wasm_bindgen(extends = Object)]
12105        #[derive(Clone, Debug)]
12106        pub type DisplayNamesOptions;
12107
12108        #[wasm_bindgen(method, getter = localeMatcher)]
12109        pub fn get_locale_matcher(this: &DisplayNamesOptions) -> Option<LocaleMatcher>;
12110        #[wasm_bindgen(method, setter = localeMatcher)]
12111        pub fn set_locale_matcher(this: &DisplayNamesOptions, value: LocaleMatcher);
12112
12113        #[wasm_bindgen(method, getter = type)]
12114        pub fn get_type(this: &DisplayNamesOptions) -> Option<DisplayNamesType>;
12115        #[wasm_bindgen(method, setter = type)]
12116        pub fn set_type(this: &DisplayNamesOptions, value: DisplayNamesType);
12117
12118        #[wasm_bindgen(method, getter = style)]
12119        pub fn get_style(this: &DisplayNamesOptions) -> Option<DisplayNamesStyle>;
12120        #[wasm_bindgen(method, setter = style)]
12121        pub fn set_style(this: &DisplayNamesOptions, value: DisplayNamesStyle);
12122
12123        #[wasm_bindgen(method, getter = fallback)]
12124        pub fn get_fallback(this: &DisplayNamesOptions) -> Option<DisplayNamesFallback>;
12125        #[wasm_bindgen(method, setter = fallback)]
12126        pub fn set_fallback(this: &DisplayNamesOptions, value: DisplayNamesFallback);
12127
12128        #[wasm_bindgen(method, getter = languageDisplay)]
12129        pub fn get_language_display(
12130            this: &DisplayNamesOptions,
12131        ) -> Option<DisplayNamesLanguageDisplay>;
12132        #[wasm_bindgen(method, setter = languageDisplay)]
12133        pub fn set_language_display(this: &DisplayNamesOptions, value: DisplayNamesLanguageDisplay);
12134    }
12135
12136    impl DisplayNamesOptions {
12137        pub fn new() -> DisplayNamesOptions {
12138            JsCast::unchecked_into(Object::new())
12139        }
12140    }
12141
12142    impl Default for DisplayNamesOptions {
12143        fn default() -> Self {
12144            DisplayNamesOptions::new()
12145        }
12146    }
12147
12148    // Intl.ResolvedDisplayNamesOptions
12149    #[wasm_bindgen]
12150    extern "C" {
12151        /// Resolved options returned by `Intl.DisplayNames.prototype.resolvedOptions()`.
12152        ///
12153        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/resolvedOptions)
12154        #[wasm_bindgen(extends = DisplayNamesOptions)]
12155        #[derive(Clone, Debug)]
12156        pub type ResolvedDisplayNamesOptions;
12157
12158        /// The resolved locale string.
12159        #[wasm_bindgen(method, getter = locale)]
12160        pub fn get_locale(this: &ResolvedDisplayNamesOptions) -> JsString;
12161    }
12162
12163    // Intl.DisplayNames
12164    #[wasm_bindgen]
12165    extern "C" {
12166        /// The `Intl.DisplayNames` object enables the consistent translation of
12167        /// language, region, and script display names.
12168        ///
12169        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames)
12170        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.DisplayNames")]
12171        #[derive(Clone, Debug)]
12172        pub type DisplayNames;
12173
12174        /// Creates a new `Intl.DisplayNames` object.
12175        ///
12176        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames)
12177        #[cfg(not(js_sys_unstable_apis))]
12178        #[wasm_bindgen(constructor, js_namespace = Intl)]
12179        pub fn new(locales: &Array, options: &Object) -> DisplayNames;
12180
12181        /// Creates a new `Intl.DisplayNames` object.
12182        ///
12183        /// Throws a `RangeError` if locales or options contain invalid values.
12184        ///
12185        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames)
12186        #[cfg(js_sys_unstable_apis)]
12187        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
12188        pub fn new(
12189            locales: &[JsString],
12190            options: &DisplayNamesOptions,
12191        ) -> Result<DisplayNames, JsValue>;
12192
12193        /// Returns the display name for the given code.
12194        ///
12195        /// Returns `undefined` if fallback is "none" and no name is available.
12196        ///
12197        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/of)
12198        #[wasm_bindgen(method, js_class = "Intl.DisplayNames")]
12199        pub fn of(this: &DisplayNames, code: &str) -> Option<JsString>;
12200
12201        /// Returns an object with properties reflecting the options used.
12202        ///
12203        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/resolvedOptions)
12204        #[cfg(not(js_sys_unstable_apis))]
12205        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
12206        pub fn resolved_options(this: &DisplayNames) -> Object;
12207
12208        /// Returns an object with properties reflecting the options used.
12209        ///
12210        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/resolvedOptions)
12211        #[cfg(js_sys_unstable_apis)]
12212        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
12213        pub fn resolved_options(this: &DisplayNames) -> ResolvedDisplayNamesOptions;
12214
12215        /// Returns an array of supported locales.
12216        ///
12217        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/supportedLocalesOf)
12218        #[cfg(not(js_sys_unstable_apis))]
12219        #[wasm_bindgen(static_method_of = DisplayNames, js_namespace = Intl, js_name = supportedLocalesOf)]
12220        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
12221
12222        /// Returns an array of supported locales.
12223        ///
12224        /// Throws a `RangeError` if locales contain invalid values.
12225        ///
12226        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/supportedLocalesOf)
12227        #[cfg(js_sys_unstable_apis)]
12228        #[wasm_bindgen(static_method_of = DisplayNames, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
12229        pub fn supported_locales_of(
12230            locales: &[JsString],
12231            options: &LocaleMatcherOptions,
12232        ) -> Result<Array<JsString>, JsValue>;
12233    }
12234
12235    // Intl.Locale
12236    #[wasm_bindgen]
12237    extern "C" {
12238        /// The `Intl.Locale` object is a standard built-in property of the Intl object
12239        /// that represents a Unicode locale identifier.
12240        ///
12241        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale)
12242        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.Locale")]
12243        #[derive(Clone, Debug)]
12244        pub type Locale;
12245
12246        /// Creates a new `Intl.Locale` object.
12247        ///
12248        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/Locale)
12249        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
12250        pub fn new(tag: &str) -> Result<Locale, JsValue>;
12251
12252        /// Creates a new `Intl.Locale` object with options.
12253        ///
12254        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/Locale)
12255        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
12256        pub fn new_with_options(tag: &str, options: &Object) -> Result<Locale, JsValue>;
12257
12258        /// The base name of the locale (language + region + script).
12259        ///
12260        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/baseName)
12261        #[wasm_bindgen(method, getter = baseName)]
12262        pub fn base_name(this: &Locale) -> JsString;
12263
12264        /// The calendar type for the locale.
12265        ///
12266        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/calendar)
12267        #[wasm_bindgen(method, getter)]
12268        pub fn calendar(this: &Locale) -> Option<JsString>;
12269
12270        /// The case first sorting option.
12271        ///
12272        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/caseFirst)
12273        #[wasm_bindgen(method, getter = caseFirst)]
12274        pub fn case_first(this: &Locale) -> Option<JsString>;
12275
12276        /// The collation type for the locale.
12277        ///
12278        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/collation)
12279        #[wasm_bindgen(method, getter)]
12280        pub fn collation(this: &Locale) -> Option<JsString>;
12281
12282        /// The hour cycle for the locale.
12283        ///
12284        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/hourCycle)
12285        #[wasm_bindgen(method, getter = hourCycle)]
12286        pub fn hour_cycle(this: &Locale) -> Option<JsString>;
12287
12288        /// The language code for the locale.
12289        ///
12290        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/language)
12291        #[wasm_bindgen(method, getter)]
12292        pub fn language(this: &Locale) -> JsString;
12293
12294        /// The numbering system for the locale.
12295        ///
12296        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/numberingSystem)
12297        #[wasm_bindgen(method, getter = numberingSystem)]
12298        pub fn numbering_system(this: &Locale) -> Option<JsString>;
12299
12300        /// Whether the locale uses numeric collation.
12301        ///
12302        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/numeric)
12303        #[wasm_bindgen(method, getter)]
12304        pub fn numeric(this: &Locale) -> bool;
12305
12306        /// The region code for the locale.
12307        ///
12308        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/region)
12309        #[wasm_bindgen(method, getter)]
12310        pub fn region(this: &Locale) -> Option<JsString>;
12311
12312        /// The script code for the locale.
12313        ///
12314        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/script)
12315        #[wasm_bindgen(method, getter)]
12316        pub fn script(this: &Locale) -> Option<JsString>;
12317
12318        /// Returns an array of available calendars for the locale.
12319        ///
12320        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getCalendars)
12321        #[wasm_bindgen(method, js_class = "Intl.Locale", js_name = getCalendars)]
12322        pub fn get_calendars(this: &Locale) -> Array<JsString>;
12323
12324        /// Returns an array of available collations for the locale.
12325        ///
12326        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getCollations)
12327        #[wasm_bindgen(method, js_class = "Intl.Locale", js_name = getCollations)]
12328        pub fn get_collations(this: &Locale) -> Array<JsString>;
12329
12330        /// Returns an array of available hour cycles for the locale.
12331        ///
12332        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getHourCycles)
12333        #[wasm_bindgen(method, js_class = "Intl.Locale", js_name = getHourCycles)]
12334        pub fn get_hour_cycles(this: &Locale) -> Array<JsString>;
12335
12336        /// Returns an array of available numbering systems for the locale.
12337        ///
12338        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getNumberingSystems)
12339        #[wasm_bindgen(method, js_class = "Intl.Locale", js_name = getNumberingSystems)]
12340        pub fn get_numbering_systems(this: &Locale) -> Array<JsString>;
12341
12342        /// Returns an array of available time zones for the locale's region.
12343        ///
12344        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTimeZones)
12345        #[wasm_bindgen(method, js_class = "Intl.Locale", js_name = getTimeZones)]
12346        pub fn get_time_zones(this: &Locale) -> Option<Array<JsString>>;
12347
12348        /// Returns week information for the locale.
12349        ///
12350        /// May not be available in all environments.
12351        ///
12352        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getWeekInfo)
12353        #[wasm_bindgen(method, js_class = "Intl.Locale", js_name = getWeekInfo, catch)]
12354        pub fn get_week_info(this: &Locale) -> Result<WeekInfo, JsValue>;
12355
12356        /// Returns text layout information for the locale.
12357        ///
12358        /// May not be available in all environments.
12359        ///
12360        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo)
12361        #[wasm_bindgen(method, js_class = "Intl.Locale", js_name = getTextInfo, catch)]
12362        pub fn get_text_info(this: &Locale) -> Result<TextInfo, JsValue>;
12363
12364        /// Returns a new Locale with the specified calendar.
12365        ///
12366        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/maximize)
12367        #[wasm_bindgen(method, js_class = "Intl.Locale")]
12368        pub fn maximize(this: &Locale) -> Locale;
12369
12370        /// Returns a new Locale with the minimal subtags.
12371        ///
12372        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/minimize)
12373        #[wasm_bindgen(method, js_class = "Intl.Locale")]
12374        pub fn minimize(this: &Locale) -> Locale;
12375    }
12376
12377    // Intl.Locale WeekInfo
12378    #[wasm_bindgen]
12379    extern "C" {
12380        /// Week information for a locale.
12381        ///
12382        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getWeekInfo)
12383        #[wasm_bindgen(extends = Object)]
12384        #[derive(Clone, Debug)]
12385        pub type WeekInfo;
12386
12387        /// The first day of the week (1 = Monday, 7 = Sunday).
12388        #[wasm_bindgen(method, getter = firstDay)]
12389        pub fn first_day(this: &WeekInfo) -> u8;
12390
12391        /// Array of weekend days.
12392        #[wasm_bindgen(method, getter)]
12393        pub fn weekend(this: &WeekInfo) -> Array<Number>;
12394
12395        /// Minimal days in the first week of the year.
12396        #[wasm_bindgen(method, getter = minimalDays)]
12397        pub fn minimal_days(this: &WeekInfo) -> u8;
12398    }
12399
12400    // Intl.Locale TextInfo
12401    #[wasm_bindgen]
12402    extern "C" {
12403        /// Text layout information for a locale.
12404        ///
12405        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo)
12406        #[wasm_bindgen(extends = Object)]
12407        #[derive(Clone, Debug)]
12408        pub type TextInfo;
12409
12410        /// The text direction ("ltr" or "rtl").
12411        #[wasm_bindgen(method, getter)]
12412        pub fn direction(this: &TextInfo) -> JsString;
12413    }
12414
12415    // Intl.DurationFormat enums
12416
12417    /// The style for duration formatting.
12418    ///
12419    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat#style)
12420    #[wasm_bindgen]
12421    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
12422    pub enum DurationFormatStyle {
12423        Long = "long",
12424        Short = "short",
12425        Narrow = "narrow",
12426        Digital = "digital",
12427    }
12428
12429    /// The display style for individual duration units.
12430    ///
12431    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat#years)
12432    #[wasm_bindgen]
12433    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
12434    pub enum DurationUnitStyle {
12435        Long = "long",
12436        Short = "short",
12437        Narrow = "narrow",
12438    }
12439
12440    /// The display style for time duration units (hours, minutes, seconds).
12441    ///
12442    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat#hours)
12443    #[wasm_bindgen]
12444    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
12445    pub enum DurationTimeUnitStyle {
12446        Long = "long",
12447        Short = "short",
12448        Narrow = "narrow",
12449        Numeric = "numeric",
12450        #[wasm_bindgen(js_name = "2-digit")]
12451        TwoDigit = "2-digit",
12452    }
12453
12454    /// The display option for duration units.
12455    ///
12456    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat#yearsdisplay)
12457    #[wasm_bindgen]
12458    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
12459    pub enum DurationUnitDisplay {
12460        Auto = "auto",
12461        Always = "always",
12462    }
12463
12464    /// The type of a duration format part.
12465    ///
12466    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/formatToParts#type)
12467    #[wasm_bindgen]
12468    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
12469    pub enum DurationFormatPartType {
12470        Years = "years",
12471        Months = "months",
12472        Weeks = "weeks",
12473        Days = "days",
12474        Hours = "hours",
12475        Minutes = "minutes",
12476        Seconds = "seconds",
12477        Milliseconds = "milliseconds",
12478        Microseconds = "microseconds",
12479        Nanoseconds = "nanoseconds",
12480        Literal = "literal",
12481        Integer = "integer",
12482        Decimal = "decimal",
12483        Fraction = "fraction",
12484    }
12485
12486    // Intl.DurationFormatOptions
12487    #[wasm_bindgen]
12488    extern "C" {
12489        /// Options for `Intl.DurationFormat` constructor.
12490        ///
12491        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat#options)
12492        #[wasm_bindgen(extends = Object)]
12493        #[derive(Clone, Debug)]
12494        pub type DurationFormatOptions;
12495
12496        #[wasm_bindgen(method, getter = localeMatcher)]
12497        pub fn get_locale_matcher(this: &DurationFormatOptions) -> Option<LocaleMatcher>;
12498        #[wasm_bindgen(method, setter = localeMatcher)]
12499        pub fn set_locale_matcher(this: &DurationFormatOptions, value: LocaleMatcher);
12500
12501        #[wasm_bindgen(method, getter = style)]
12502        pub fn get_style(this: &DurationFormatOptions) -> Option<DurationFormatStyle>;
12503        #[wasm_bindgen(method, setter = style)]
12504        pub fn set_style(this: &DurationFormatOptions, value: DurationFormatStyle);
12505
12506        #[wasm_bindgen(method, getter = years)]
12507        pub fn get_years(this: &DurationFormatOptions) -> Option<DurationUnitStyle>;
12508        #[wasm_bindgen(method, setter = years)]
12509        pub fn set_years(this: &DurationFormatOptions, value: DurationUnitStyle);
12510
12511        #[wasm_bindgen(method, getter = yearsDisplay)]
12512        pub fn get_years_display(this: &DurationFormatOptions) -> Option<DurationUnitDisplay>;
12513        #[wasm_bindgen(method, setter = yearsDisplay)]
12514        pub fn set_years_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12515
12516        #[wasm_bindgen(method, getter = months)]
12517        pub fn get_months(this: &DurationFormatOptions) -> Option<DurationUnitStyle>;
12518        #[wasm_bindgen(method, setter = months)]
12519        pub fn set_months(this: &DurationFormatOptions, value: DurationUnitStyle);
12520
12521        #[wasm_bindgen(method, getter = monthsDisplay)]
12522        pub fn get_months_display(this: &DurationFormatOptions) -> Option<DurationUnitDisplay>;
12523        #[wasm_bindgen(method, setter = monthsDisplay)]
12524        pub fn set_months_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12525
12526        #[wasm_bindgen(method, getter = weeks)]
12527        pub fn get_weeks(this: &DurationFormatOptions) -> Option<DurationUnitStyle>;
12528        #[wasm_bindgen(method, setter = weeks)]
12529        pub fn set_weeks(this: &DurationFormatOptions, value: DurationUnitStyle);
12530
12531        #[wasm_bindgen(method, getter = weeksDisplay)]
12532        pub fn get_weeks_display(this: &DurationFormatOptions) -> Option<DurationUnitDisplay>;
12533        #[wasm_bindgen(method, setter = weeksDisplay)]
12534        pub fn set_weeks_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12535
12536        #[wasm_bindgen(method, getter = days)]
12537        pub fn get_days(this: &DurationFormatOptions) -> Option<DurationUnitStyle>;
12538        #[wasm_bindgen(method, setter = days)]
12539        pub fn set_days(this: &DurationFormatOptions, value: DurationUnitStyle);
12540
12541        #[wasm_bindgen(method, getter = daysDisplay)]
12542        pub fn get_days_display(this: &DurationFormatOptions) -> Option<DurationUnitDisplay>;
12543        #[wasm_bindgen(method, setter = daysDisplay)]
12544        pub fn set_days_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12545
12546        #[wasm_bindgen(method, getter = hours)]
12547        pub fn get_hours(this: &DurationFormatOptions) -> Option<DurationTimeUnitStyle>;
12548        #[wasm_bindgen(method, setter = hours)]
12549        pub fn set_hours(this: &DurationFormatOptions, value: DurationTimeUnitStyle);
12550
12551        #[wasm_bindgen(method, getter = hoursDisplay)]
12552        pub fn get_hours_display(this: &DurationFormatOptions) -> Option<DurationUnitDisplay>;
12553        #[wasm_bindgen(method, setter = hoursDisplay)]
12554        pub fn set_hours_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12555
12556        #[wasm_bindgen(method, getter = minutes)]
12557        pub fn get_minutes(this: &DurationFormatOptions) -> Option<DurationTimeUnitStyle>;
12558        #[wasm_bindgen(method, setter = minutes)]
12559        pub fn set_minutes(this: &DurationFormatOptions, value: DurationTimeUnitStyle);
12560
12561        #[wasm_bindgen(method, getter = minutesDisplay)]
12562        pub fn get_minutes_display(this: &DurationFormatOptions) -> Option<DurationUnitDisplay>;
12563        #[wasm_bindgen(method, setter = minutesDisplay)]
12564        pub fn set_minutes_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12565
12566        #[wasm_bindgen(method, getter = seconds)]
12567        pub fn get_seconds(this: &DurationFormatOptions) -> Option<DurationTimeUnitStyle>;
12568        #[wasm_bindgen(method, setter = seconds)]
12569        pub fn set_seconds(this: &DurationFormatOptions, value: DurationTimeUnitStyle);
12570
12571        #[wasm_bindgen(method, getter = secondsDisplay)]
12572        pub fn get_seconds_display(this: &DurationFormatOptions) -> Option<DurationUnitDisplay>;
12573        #[wasm_bindgen(method, setter = secondsDisplay)]
12574        pub fn set_seconds_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12575
12576        #[wasm_bindgen(method, getter = milliseconds)]
12577        pub fn get_milliseconds(this: &DurationFormatOptions) -> Option<DurationUnitStyle>;
12578        #[wasm_bindgen(method, setter = milliseconds)]
12579        pub fn set_milliseconds(this: &DurationFormatOptions, value: DurationUnitStyle);
12580
12581        #[wasm_bindgen(method, getter = millisecondsDisplay)]
12582        pub fn get_milliseconds_display(
12583            this: &DurationFormatOptions,
12584        ) -> Option<DurationUnitDisplay>;
12585        #[wasm_bindgen(method, setter = millisecondsDisplay)]
12586        pub fn set_milliseconds_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12587
12588        #[wasm_bindgen(method, getter = microseconds)]
12589        pub fn get_microseconds(this: &DurationFormatOptions) -> Option<DurationUnitStyle>;
12590        #[wasm_bindgen(method, setter = microseconds)]
12591        pub fn set_microseconds(this: &DurationFormatOptions, value: DurationUnitStyle);
12592
12593        #[wasm_bindgen(method, getter = microsecondsDisplay)]
12594        pub fn get_microseconds_display(
12595            this: &DurationFormatOptions,
12596        ) -> Option<DurationUnitDisplay>;
12597        #[wasm_bindgen(method, setter = microsecondsDisplay)]
12598        pub fn set_microseconds_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12599
12600        #[wasm_bindgen(method, getter = nanoseconds)]
12601        pub fn get_nanoseconds(this: &DurationFormatOptions) -> Option<DurationUnitStyle>;
12602        #[wasm_bindgen(method, setter = nanoseconds)]
12603        pub fn set_nanoseconds(this: &DurationFormatOptions, value: DurationUnitStyle);
12604
12605        #[wasm_bindgen(method, getter = nanosecondsDisplay)]
12606        pub fn get_nanoseconds_display(this: &DurationFormatOptions)
12607            -> Option<DurationUnitDisplay>;
12608        #[wasm_bindgen(method, setter = nanosecondsDisplay)]
12609        pub fn set_nanoseconds_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12610
12611        #[wasm_bindgen(method, getter = fractionalDigits)]
12612        pub fn get_fractional_digits(this: &DurationFormatOptions) -> Option<u8>;
12613        #[wasm_bindgen(method, setter = fractionalDigits)]
12614        pub fn set_fractional_digits(this: &DurationFormatOptions, value: u8);
12615    }
12616
12617    impl DurationFormatOptions {
12618        pub fn new() -> DurationFormatOptions {
12619            JsCast::unchecked_into(Object::new())
12620        }
12621    }
12622
12623    impl Default for DurationFormatOptions {
12624        fn default() -> Self {
12625            DurationFormatOptions::new()
12626        }
12627    }
12628
12629    // Intl.ResolvedDurationFormatOptions
12630    #[wasm_bindgen]
12631    extern "C" {
12632        /// Resolved options returned by `Intl.DurationFormat.prototype.resolvedOptions()`.
12633        ///
12634        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/resolvedOptions)
12635        #[wasm_bindgen(extends = DurationFormatOptions)]
12636        #[derive(Clone, Debug)]
12637        pub type ResolvedDurationFormatOptions;
12638
12639        /// The resolved locale string.
12640        #[wasm_bindgen(method, getter = locale)]
12641        pub fn get_locale(this: &ResolvedDurationFormatOptions) -> JsString;
12642
12643        /// The resolved numbering system.
12644        #[wasm_bindgen(method, getter = numberingSystem)]
12645        pub fn get_numbering_system(this: &ResolvedDurationFormatOptions) -> JsString;
12646    }
12647
12648    // Intl.Duration (input object for DurationFormat)
12649    #[wasm_bindgen]
12650    extern "C" {
12651        /// A duration object used as input to `Intl.DurationFormat.format()`.
12652        ///
12653        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/format#duration)
12654        #[wasm_bindgen(extends = Object)]
12655        #[derive(Clone, Debug)]
12656        pub type Duration;
12657
12658        #[wasm_bindgen(method, getter)]
12659        pub fn years(this: &Duration) -> Option<f64>;
12660        #[wasm_bindgen(method, setter)]
12661        pub fn set_years(this: &Duration, value: f64);
12662
12663        #[wasm_bindgen(method, getter)]
12664        pub fn months(this: &Duration) -> Option<f64>;
12665        #[wasm_bindgen(method, setter)]
12666        pub fn set_months(this: &Duration, value: f64);
12667
12668        #[wasm_bindgen(method, getter)]
12669        pub fn weeks(this: &Duration) -> Option<f64>;
12670        #[wasm_bindgen(method, setter)]
12671        pub fn set_weeks(this: &Duration, value: f64);
12672
12673        #[wasm_bindgen(method, getter)]
12674        pub fn days(this: &Duration) -> Option<f64>;
12675        #[wasm_bindgen(method, setter)]
12676        pub fn set_days(this: &Duration, value: f64);
12677
12678        #[wasm_bindgen(method, getter)]
12679        pub fn hours(this: &Duration) -> Option<f64>;
12680        #[wasm_bindgen(method, setter)]
12681        pub fn set_hours(this: &Duration, value: f64);
12682
12683        #[wasm_bindgen(method, getter)]
12684        pub fn minutes(this: &Duration) -> Option<f64>;
12685        #[wasm_bindgen(method, setter)]
12686        pub fn set_minutes(this: &Duration, value: f64);
12687
12688        #[wasm_bindgen(method, getter)]
12689        pub fn seconds(this: &Duration) -> Option<f64>;
12690        #[wasm_bindgen(method, setter)]
12691        pub fn set_seconds(this: &Duration, value: f64);
12692
12693        #[wasm_bindgen(method, getter)]
12694        pub fn milliseconds(this: &Duration) -> Option<f64>;
12695        #[wasm_bindgen(method, setter)]
12696        pub fn set_milliseconds(this: &Duration, value: f64);
12697
12698        #[wasm_bindgen(method, getter)]
12699        pub fn microseconds(this: &Duration) -> Option<f64>;
12700        #[wasm_bindgen(method, setter)]
12701        pub fn set_microseconds(this: &Duration, value: f64);
12702
12703        #[wasm_bindgen(method, getter)]
12704        pub fn nanoseconds(this: &Duration) -> Option<f64>;
12705        #[wasm_bindgen(method, setter)]
12706        pub fn set_nanoseconds(this: &Duration, value: f64);
12707    }
12708
12709    impl Duration {
12710        pub fn new() -> Duration {
12711            JsCast::unchecked_into(Object::new())
12712        }
12713    }
12714
12715    impl Default for Duration {
12716        fn default() -> Self {
12717            Duration::new()
12718        }
12719    }
12720
12721    // Intl.DurationFormatPart
12722    #[wasm_bindgen]
12723    extern "C" {
12724        /// A part of the formatted duration returned by `formatToParts()`.
12725        ///
12726        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/formatToParts)
12727        #[wasm_bindgen(extends = Object)]
12728        #[derive(Clone, Debug)]
12729        pub type DurationFormatPart;
12730
12731        /// The type of the part.
12732        #[wasm_bindgen(method, getter = type)]
12733        pub fn type_(this: &DurationFormatPart) -> DurationFormatPartType;
12734
12735        /// The value of the part.
12736        #[wasm_bindgen(method, getter)]
12737        pub fn value(this: &DurationFormatPart) -> JsString;
12738
12739        /// The unit this part represents (if applicable).
12740        #[wasm_bindgen(method, getter)]
12741        pub fn unit(this: &DurationFormatPart) -> Option<JsString>;
12742    }
12743
12744    // Intl.DurationFormat
12745    #[wasm_bindgen]
12746    extern "C" {
12747        /// The `Intl.DurationFormat` object enables language-sensitive duration formatting.
12748        ///
12749        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat)
12750        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.DurationFormat")]
12751        #[derive(Clone, Debug)]
12752        pub type DurationFormat;
12753
12754        /// Creates a new `Intl.DurationFormat` object.
12755        ///
12756        /// Throws a `RangeError` if locales or options contain invalid values.
12757        ///
12758        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat)
12759        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
12760        pub fn new(
12761            locales: &[JsString],
12762            options: &DurationFormatOptions,
12763        ) -> Result<DurationFormat, JsValue>;
12764
12765        /// Formats a duration according to the locale and formatting options.
12766        ///
12767        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/format)
12768        #[wasm_bindgen(method, js_class = "Intl.DurationFormat")]
12769        pub fn format(this: &DurationFormat, duration: &Duration) -> JsString;
12770
12771        /// Returns an array of objects representing the formatted duration in parts.
12772        ///
12773        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/formatToParts)
12774        #[wasm_bindgen(method, js_class = "Intl.DurationFormat", js_name = formatToParts)]
12775        pub fn format_to_parts(
12776            this: &DurationFormat,
12777            duration: &Duration,
12778        ) -> Array<DurationFormatPart>;
12779
12780        /// Returns an object with properties reflecting the options used.
12781        ///
12782        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/resolvedOptions)
12783        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
12784        pub fn resolved_options(this: &DurationFormat) -> ResolvedDurationFormatOptions;
12785
12786        /// Returns an array of supported locales.
12787        ///
12788        /// Throws a `RangeError` if locales contain invalid values.
12789        ///
12790        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/supportedLocalesOf)
12791        #[wasm_bindgen(static_method_of = DurationFormat, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
12792        pub fn supported_locales_of(
12793            locales: &[JsString],
12794            options: &LocaleMatcherOptions,
12795        ) -> Result<Array<JsString>, JsValue>;
12796    }
12797
12798    impl Default for DurationFormat {
12799        fn default() -> Self {
12800            Self::new(&[], &Default::default()).unwrap()
12801        }
12802    }
12803}
12804
12805#[wasm_bindgen]
12806extern "C" {
12807    /// The `PromiseState` object represents the the status of the promise,
12808    /// as used in `allSettled`.
12809    ///
12810    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled)
12811    #[must_use]
12812    #[wasm_bindgen(extends = Object, typescript_type = "any")]
12813    #[derive(Clone, Debug)]
12814    pub type PromiseState<T = JsValue>;
12815
12816    /// A string, either "fulfilled" or "rejected", indicating the eventual state of the promise.
12817    #[wasm_bindgen(method, getter = status)]
12818    pub fn get_status<T>(this: &PromiseState<T>) -> String;
12819
12820    /// Only present if status is "fulfilled". The value that the promise was fulfilled with.
12821    #[wasm_bindgen(method, getter = value)]
12822    pub fn get_value<T>(this: &PromiseState<T>) -> Option<T>;
12823
12824    /// Only present if status is "rejected". The reason that the promise was rejected with.
12825    #[wasm_bindgen(method, getter = reason)]
12826    pub fn get_reason<T>(this: &PromiseState<T>) -> Option<JsValue>;
12827}
12828
12829impl<T> PromiseState<T> {
12830    pub fn is_fulfilled(&self) -> bool {
12831        self.get_status() == "fulfilled"
12832    }
12833
12834    pub fn is_rejected(&self) -> bool {
12835        self.get_status() == "rejected"
12836    }
12837}
12838
12839/// Converts a `PromiseState<T>` into a `Result<T, JsValue>`, matching the
12840/// spec invariant that exactly one of the fulfilled value or the rejection
12841/// reason is populated per slot.
12842impl<T: JsGeneric + FromWasmAbi> From<PromiseState<T>> for Result<T, JsValue> {
12843    fn from(state: PromiseState<T>) -> Result<T, JsValue> {
12844        if state.is_fulfilled() {
12845            Ok(state.get_value().unwrap())
12846        } else {
12847            Err(state.get_reason().unwrap())
12848        }
12849    }
12850}
12851
12852// Promise
12853#[wasm_bindgen]
12854extern "C" {
12855    /// The `Promise` object represents the eventual completion (or failure) of
12856    /// an asynchronous operation, and its resulting value.
12857    ///
12858    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
12859    #[must_use]
12860    #[wasm_bindgen(extends = Object, typescript_type = "Promise<any>", no_promising)]
12861    #[derive(Clone, Debug)]
12862    pub type Promise<T = JsValue>;
12863
12864    /// Creates a new `Promise` with the provided executor `cb`
12865    ///
12866    /// The `cb` is a function that is passed with the arguments `resolve` and
12867    /// `reject`. The `cb` function is executed immediately by the `Promise`
12868    /// implementation, passing `resolve` and `reject` functions (the executor
12869    /// is called before the `Promise` constructor even returns the created
12870    /// object). The `resolve` and `reject` functions, when called, resolve or
12871    /// reject the promise, respectively. The executor normally initiates
12872    /// some asynchronous work, and then, once that completes, either calls
12873    /// the `resolve` function to resolve the promise or else rejects it if an
12874    /// error occurred.
12875    ///
12876    /// If an error is thrown in the executor function, the promise is rejected.
12877    /// The return value of the executor is ignored.
12878    ///
12879    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
12880    #[cfg(not(js_sys_unstable_apis))]
12881    #[wasm_bindgen(constructor)]
12882    pub fn new(cb: &mut dyn FnMut(Function, Function)) -> Promise;
12883
12884    /// Creates a new `Promise` with the provided executor `cb`
12885    ///
12886    /// The `cb` is a function that is passed with the arguments `resolve` and
12887    /// `reject`. The `cb` function is executed immediately by the `Promise`
12888    /// implementation, passing `resolve` and `reject` functions (the executor
12889    /// is called before the `Promise` constructor even returns the created
12890    /// object). The `resolve` and `reject` functions, when called, resolve or
12891    /// reject the promise, respectively. The executor normally initiates
12892    /// some asynchronous work, and then, once that completes, either calls
12893    /// the `resolve` function to resolve the promise or else rejects it if an
12894    /// error occurred.
12895    ///
12896    /// If an error is thrown in the executor function, the promise is rejected.
12897    /// The return value of the executor is ignored.
12898    ///
12899    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
12900    #[cfg(js_sys_unstable_apis)]
12901    #[wasm_bindgen(constructor)]
12902    pub fn new<T: JsGeneric>(
12903        cb: &mut dyn FnMut(Function<fn(T) -> Undefined>, Function<fn(JsValue) -> Undefined>),
12904    ) -> Promise<T>;
12905
12906    // Next major: deprecate
12907    /// Creates a new `Promise` with the provided executor `cb`
12908    ///
12909    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
12910    #[wasm_bindgen(constructor)]
12911    pub fn new_typed<T: Promising + JsGeneric>(
12912        cb: &mut dyn FnMut(Function<fn(T) -> Undefined>, Function<fn(JsValue) -> Undefined>),
12913    ) -> Promise<<T as Promising>::Resolution>;
12914
12915    /// The `Promise.all(iterable)` method returns a single `Promise` that
12916    /// resolves when all of the promises in the iterable argument have resolved
12917    /// or when the iterable argument contains no promises. It rejects with the
12918    /// reason of the first promise that rejects.
12919    ///
12920    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all)
12921    #[cfg(not(js_sys_unstable_apis))]
12922    #[wasm_bindgen(static_method_of = Promise)]
12923    pub fn all(obj: &JsValue) -> Promise;
12924
12925    /// The `Promise.all(iterable)` method returns a single `Promise` that
12926    /// resolves when all of the promises in the iterable argument have resolved
12927    /// or when the iterable argument contains no promises. It rejects with the
12928    /// reason of the first promise that rejects.
12929    ///
12930    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all)
12931    #[cfg(js_sys_unstable_apis)]
12932    #[wasm_bindgen(static_method_of = Promise, js_name = all)]
12933    pub fn all<I: Iterable>(obj: &I) -> Promise<Array<<I::Item as Promising>::Resolution>>
12934    where
12935        I::Item: Promising;
12936
12937    // Next major: deprecate
12938    /// The `Promise.all(iterable)` method returns a single `Promise` that
12939    /// resolves when all of the promises in the iterable argument have resolved
12940    /// or when the iterable argument contains no promises. It rejects with the
12941    /// reason of the first promise that rejects.
12942    ///
12943    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all)
12944    #[wasm_bindgen(static_method_of = Promise, js_name = all)]
12945    pub fn all_iterable<I: Iterable>(obj: &I) -> Promise<Array<<I::Item as Promising>::Resolution>>
12946    where
12947        I::Item: Promising;
12948
12949    /// The `Promise.allSettled(iterable)` method returns a single `Promise` that
12950    /// resolves when all of the promises in the iterable argument have either
12951    /// fulfilled or rejected or when the iterable argument contains no promises.
12952    ///
12953    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled)
12954    #[cfg(not(js_sys_unstable_apis))]
12955    #[wasm_bindgen(static_method_of = Promise, js_name = allSettled)]
12956    pub fn all_settled(obj: &JsValue) -> Promise;
12957
12958    /// The `Promise.allSettled(iterable)` method returns a single `Promise` that
12959    /// resolves when all of the promises in the iterable argument have either
12960    /// fulfilled or rejected or when the iterable argument contains no promises.
12961    ///
12962    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled)
12963    #[cfg(js_sys_unstable_apis)]
12964    #[wasm_bindgen(static_method_of = Promise, js_name = allSettled)]
12965    pub fn all_settled<I: Iterable>(
12966        obj: &I,
12967    ) -> Promise<Array<PromiseState<<I::Item as Promising>::Resolution>>>
12968    where
12969        I::Item: Promising;
12970
12971    // Next major: deprecate
12972    /// The `Promise.allSettled(iterable)` method returns a single `Promise` that
12973    /// resolves when all of the promises in the iterable argument have either
12974    /// fulfilled or rejected or when the iterable argument contains no promises.
12975    ///
12976    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled)
12977    #[wasm_bindgen(static_method_of = Promise, js_name = allSettled)]
12978    pub fn all_settled_iterable<I: Iterable>(
12979        obj: &I,
12980    ) -> Promise<Array<PromiseState<<I::Item as Promising>::Resolution>>>
12981    where
12982        I::Item: Promising;
12983
12984    /// The `Promise.any(iterable)` method returns a single `Promise` that
12985    /// resolves when any of the promises in the iterable argument have resolved
12986    /// or when the iterable argument contains no promises. It rejects with an
12987    /// `AggregateError` if all promises in the iterable rejected.
12988    ///
12989    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/any)
12990    #[cfg(not(js_sys_unstable_apis))]
12991    #[wasm_bindgen(static_method_of = Promise)]
12992    pub fn any(obj: &JsValue) -> Promise;
12993
12994    /// The `Promise.any(iterable)` method returns a single `Promise` that
12995    /// resolves when any of the promises in the iterable argument have resolved
12996    /// or when the iterable argument contains no promises. It rejects with an
12997    /// `AggregateError` if all promises in the iterable rejected.
12998    ///
12999    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/any)
13000    #[cfg(js_sys_unstable_apis)]
13001    #[wasm_bindgen(static_method_of = Promise, js_name = any)]
13002    pub fn any<I: Iterable>(obj: &I) -> Promise<<I::Item as Promising>::Resolution>
13003    where
13004        I::Item: Promising;
13005
13006    // Next major: deprecate
13007    /// The `Promise.any(iterable)` method returns a single `Promise` that
13008    /// resolves when any of the promises in the iterable argument have resolved
13009    /// or when the iterable argument contains no promises. It rejects with an
13010    /// `AggregateError` if all promises in the iterable rejected.
13011    ///
13012    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/any)
13013    #[wasm_bindgen(static_method_of = Promise, js_name = any)]
13014    pub fn any_iterable<I: Iterable>(obj: &I) -> Promise<<I::Item as Promising>::Resolution>
13015    where
13016        I::Item: Promising;
13017
13018    /// The `Promise.race(iterable)` method returns a promise that resolves or
13019    /// rejects as soon as one of the promises in the iterable resolves or
13020    /// rejects, with the value or reason from that promise.
13021    ///
13022    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race)
13023    #[cfg(not(js_sys_unstable_apis))]
13024    #[wasm_bindgen(static_method_of = Promise)]
13025    pub fn race(obj: &JsValue) -> Promise;
13026
13027    /// The `Promise.race(iterable)` method returns a promise that resolves or
13028    /// rejects as soon as one of the promises in the iterable resolves or
13029    /// rejects, with the value or reason from that promise.
13030    ///
13031    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race)
13032    #[cfg(js_sys_unstable_apis)]
13033    #[wasm_bindgen(static_method_of = Promise, js_name = race)]
13034    pub fn race<I: Iterable>(obj: &I) -> Promise<<I::Item as Promising>::Resolution>
13035    where
13036        I::Item: Promising;
13037
13038    // Next major: deprecate
13039    /// The `Promise.race(iterable)` method returns a promise that resolves or
13040    /// rejects as soon as one of the promises in the iterable resolves or
13041    /// rejects, with the value or reason from that promise.
13042    ///
13043    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race)
13044    #[wasm_bindgen(static_method_of = Promise, js_name = race)]
13045    pub fn race_iterable<I: Iterable>(obj: &I) -> Promise<<I::Item as Promising>::Resolution>
13046    where
13047        I::Item: Promising;
13048
13049    /// The `Promise.reject(reason)` method returns a `Promise` object that is
13050    /// rejected with the given reason.
13051    ///
13052    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject)
13053    #[cfg(not(js_sys_unstable_apis))]
13054    #[wasm_bindgen(static_method_of = Promise)]
13055    pub fn reject(obj: &JsValue) -> Promise;
13056
13057    /// The `Promise.reject(reason)` method returns a `Promise` object that is
13058    /// rejected with the given reason.
13059    ///
13060    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject)
13061    #[cfg(js_sys_unstable_apis)]
13062    #[wasm_bindgen(static_method_of = Promise, js_name = reject)]
13063    pub fn reject<T>(obj: &JsValue) -> Promise<T>;
13064
13065    // Next major: deprecate
13066    /// The `Promise.reject(reason)` method returns a `Promise` object that is
13067    /// rejected with the given reason.
13068    ///
13069    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject)
13070    #[wasm_bindgen(static_method_of = Promise, js_name = reject)]
13071    pub fn reject_typed<T>(obj: &JsValue) -> Promise<T>;
13072
13073    /// The `Promise.resolve(value)` method returns a `Promise` object that is
13074    /// resolved with the given value. If the value is a promise, that promise
13075    /// is returned; if the value is a thenable (i.e. has a "then" method), the
13076    /// returned promise will "follow" that thenable, adopting its eventual
13077    /// state; otherwise the returned promise will be fulfilled with the value.
13078    ///
13079    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve)
13080    #[wasm_bindgen(static_method_of = Promise, js_name = resolve)]
13081    pub fn resolve<U: Promising>(obj: &U) -> Promise<U::Resolution>;
13082
13083    /// The `catch()` method returns a `Promise` and deals with rejected cases
13084    /// only.  It behaves the same as calling `Promise.prototype.then(undefined,
13085    /// onRejected)` (in fact, calling `obj.catch(onRejected)` internally calls
13086    /// `obj.then(undefined, onRejected)`).
13087    ///
13088    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch)
13089    #[cfg(not(js_sys_unstable_apis))]
13090    #[wasm_bindgen(method)]
13091    pub fn catch<T>(this: &Promise<T>, cb: &ScopedClosure<dyn FnMut(JsValue)>) -> Promise<JsValue>;
13092
13093    /// The `catch()` method returns a `Promise` and deals with rejected cases
13094    /// only.  It behaves the same as calling `Promise.prototype.then(undefined,
13095    /// onRejected)` (in fact, calling `obj.catch(onRejected)` internally calls
13096    /// `obj.then(undefined, onRejected)`).
13097    ///
13098    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch)
13099    #[cfg(js_sys_unstable_apis)]
13100    #[wasm_bindgen(method, js_name = catch)]
13101    pub fn catch<'a, T, R: Promising>(
13102        this: &Promise<T>,
13103        cb: &ScopedClosure<'a, dyn FnMut(T) -> Result<R, JsError>>,
13104    ) -> Promise<R::Resolution>;
13105
13106    // Next major: deprecate
13107    /// Same as `catch`, but returning a result to become the new Promise value.
13108    #[wasm_bindgen(method, js_name = catch)]
13109    pub fn catch_map<'a, T, R: Promising>(
13110        this: &Promise<T>,
13111        cb: &ScopedClosure<'a, dyn FnMut(T) -> Result<R, JsError>>,
13112    ) -> Promise<R::Resolution>;
13113
13114    /// The `then()` method returns a `Promise`. It takes up to two arguments:
13115    /// callback functions for the success and failure cases of the `Promise`.
13116    ///
13117    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then)
13118    #[cfg(not(js_sys_unstable_apis))]
13119    #[wasm_bindgen(method)]
13120    pub fn then<'a, T>(this: &Promise<T>, cb: &ScopedClosure<'a, dyn FnMut(T)>)
13121        -> Promise<JsValue>;
13122
13123    /// The `then()` method returns a `Promise`. It takes up to two arguments:
13124    /// callback functions for the success and failure cases of the `Promise`.
13125    ///
13126    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then)
13127    #[cfg(js_sys_unstable_apis)]
13128    #[wasm_bindgen(method, js_name = then)]
13129    pub fn then<'a, T, R: Promising>(
13130        this: &Promise<T>,
13131        cb: &ScopedClosure<'a, dyn FnMut(T) -> Result<R, JsError>>,
13132    ) -> Promise<R::Resolution>;
13133
13134    /// The `then()` method returns a `Promise`. It takes up to two arguments:
13135    /// callback functions for the success and failure cases of the `Promise`.
13136    ///
13137    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then)
13138    #[wasm_bindgen(method, js_name = then)]
13139    pub fn then_with_reject<'a, T, R: Promising>(
13140        this: &Promise<T>,
13141        resolve: &ScopedClosure<'a, dyn FnMut(T) -> Result<R, JsError>>,
13142        reject: &ScopedClosure<'a, dyn FnMut(JsValue) -> Result<R, JsError>>,
13143    ) -> Promise<R::Resolution>;
13144
13145    // Next major: deprecate
13146    /// Alias for `then()` with a return value.
13147    /// The `then()` method returns a `Promise`. It takes up to two arguments:
13148    /// callback functions for the success and failure cases of the `Promise`.
13149    ///
13150    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then)
13151    #[wasm_bindgen(method, js_name = then)]
13152    pub fn then_map<'a, T, R: Promising>(
13153        this: &Promise<T>,
13154        cb: &ScopedClosure<'a, dyn FnMut(T) -> Result<R, JsError>>,
13155    ) -> Promise<R::Resolution>;
13156
13157    /// Same as `then`, only with both arguments provided.
13158    ///
13159    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then)
13160    #[wasm_bindgen(method, js_name = then)]
13161    pub fn then2(
13162        this: &Promise,
13163        resolve: &ScopedClosure<dyn FnMut(JsValue)>,
13164        reject: &ScopedClosure<dyn FnMut(JsValue)>,
13165    ) -> Promise;
13166
13167    /// The `finally()` method returns a `Promise`. When the promise is settled,
13168    /// whether fulfilled or rejected, the specified callback function is
13169    /// executed. This provides a way for code that must be executed once the
13170    /// `Promise` has been dealt with to be run whether the promise was
13171    /// fulfilled successfully or rejected.
13172    ///
13173    /// This lets you avoid duplicating code in both the promise's `then()` and
13174    /// `catch()` handlers.
13175    ///
13176    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/finally)
13177    #[wasm_bindgen(method)]
13178    pub fn finally<T>(this: &Promise<T>, cb: &ScopedClosure<dyn FnMut()>) -> Promise<JsValue>;
13179}
13180
13181impl<T: JsGeneric> Promising for Promise<T> {
13182    type Resolution = T;
13183}
13184
13185/// Internal: maps a tuple of `Promise<T_i>` to the result shapes of
13186/// [`Promise::all_tuple`] and [`Promise::all_settled_tuple`].
13187///
13188/// Implemented for every tuple arity 1..=8 of `Promise<T: JsGeneric>`. The
13189/// associated `Joined` / `Settled` types pin down the [`ArrayTuple`] shape
13190/// of the result so the one [`JsCast::unchecked_into`] needed to reinterpret
13191/// the [`Array<JsValue>`] returned by `Promise.all` / `Promise.allSettled`
13192/// is encapsulated inside each impl — the caller sees a fully-typed
13193/// `Promise<ArrayTuple<...>>`.
13194///
13195/// The soundness of the `unchecked_into`s here rests on `Promise.all` and
13196/// `Promise.allSettled` preserving input order and arity, which they do by
13197/// spec.
13198///
13199/// You normally call [`Promise::all_tuple`] / [`Promise::all_settled_tuple`]
13200/// rather than using this trait directly.
13201#[doc(hidden)]
13202pub trait PromiseTuple {
13203    /// The typed `ArrayTuple` shape the joined promise resolves to.
13204    ///
13205    /// For a tuple `(Promise<T1>, Promise<T2>, ...)` this is
13206    /// `ArrayTuple<(T1, T2, ...)>`.
13207    type Joined: JsGeneric;
13208
13209    /// The typed `ArrayTuple` shape the all-settled promise resolves to.
13210    ///
13211    /// For a tuple `(Promise<T1>, Promise<T2>, ...)` this is
13212    /// `ArrayTuple<(PromiseState<T1>, PromiseState<T2>, ...)>`.
13213    type Settled: JsGeneric;
13214
13215    /// Join via `Promise.all`, returning a typed `Promise`.
13216    fn all(self) -> Promise<Self::Joined>;
13217
13218    /// Settle via `Promise.allSettled`, returning a typed `Promise`.
13219    fn all_settled(self) -> Promise<Self::Settled>;
13220}
13221
13222macro_rules! impl_promise_tuple {
13223    ([$($T:ident)+] [$($idx:tt)+]) => {
13224        // Rust tuple of `Promise<T_i>`. Builds the heterogeneous
13225        // `ArrayTuple` of promises via the existing `From<(...)>` impl
13226        // (each element upcasts through `JsGeneric`), then delegates to
13227        // the `ArrayTuple` impl below.
13228        impl<$($T: JsGeneric),+> PromiseTuple for ($(Promise<$T>,)+) {
13229            type Joined = ArrayTuple<($($T,)+)>;
13230            type Settled = ArrayTuple<($(PromiseState<$T>,)+)>;
13231
13232            fn all(self) -> Promise<Self::Joined> {
13233                let tuple: ArrayTuple<($(Promise<$T>,)+)> = ($(self.$idx,)+).into();
13234                tuple.all()
13235            }
13236
13237            fn all_settled(self) -> Promise<Self::Settled> {
13238                let tuple: ArrayTuple<($(Promise<$T>,)+)> = ($(self.$idx,)+).into();
13239                tuple.all_settled()
13240            }
13241        }
13242
13243        // `ArrayTuple<(Promise<T_1>, ..., Promise<T_n>)>` — callers who
13244        // already have an `ArrayTuple` (e.g. from a binding that returns
13245        // one, or built via `.into()` earlier in a pipeline) can pass it
13246        // directly without unpacking into a Rust tuple.
13247        //
13248        // Hands the `ArrayTuple` straight to `Promise.all_iterable` /
13249        // `Promise.allSettled_iterable` and reinterprets the result
13250        // `Array<JsValue>` as the intended typed `ArrayTuple`. Safe because
13251        // `Promise.all` / `Promise.allSettled` preserve input order and
13252        // arity by spec.
13253        impl<$($T: JsGeneric),+> PromiseTuple for ArrayTuple<($(Promise<$T>,)+)> {
13254            type Joined = ArrayTuple<($($T,)+)>;
13255            type Settled = ArrayTuple<($(PromiseState<$T>,)+)>;
13256
13257            fn all(self) -> Promise<Self::Joined> {
13258                use wasm_bindgen::JsCast;
13259                Promise::all_iterable(&self).unchecked_into()
13260            }
13261
13262            fn all_settled(self) -> Promise<Self::Settled> {
13263                use wasm_bindgen::JsCast;
13264                Promise::all_settled_iterable(&self).unchecked_into()
13265            }
13266        }
13267    };
13268}
13269
13270impl_promise_tuple!([T1][0]);
13271impl_promise_tuple!([T1 T2] [0 1]);
13272impl_promise_tuple!([T1 T2 T3] [0 1 2]);
13273impl_promise_tuple!([T1 T2 T3 T4] [0 1 2 3]);
13274impl_promise_tuple!([T1 T2 T3 T4 T5] [0 1 2 3 4]);
13275impl_promise_tuple!([T1 T2 T3 T4 T5 T6] [0 1 2 3 4 5]);
13276impl_promise_tuple!([T1 T2 T3 T4 T5 T6 T7] [0 1 2 3 4 5 6]);
13277impl_promise_tuple!([T1 T2 T3 T4 T5 T6 T7 T8] [0 1 2 3 4 5 6 7]);
13278
13279impl Promise {
13280    /// Heterogeneous counterpart to [`Promise::all_iterable`]: accepts a Rust
13281    /// tuple of `Promise<T_i>` and returns a single [`Promise`] resolving to a
13282    /// typed [`ArrayTuple<(T_1, T_2, ..., T_n)>`].
13283    ///
13284    /// Destructure the awaited result via [`ArrayTuple::into_tuple`] to get
13285    /// the individual values back as a native Rust tuple. Implemented for
13286    /// arity 1..=8.
13287    ///
13288    /// Rejects with the first rejection, matching `Promise.all` semantics.
13289    ///
13290    /// # Example
13291    ///
13292    /// ```ignore
13293    /// use js_sys::Promise;
13294    ///
13295    /// let (response, buffer) = Promise::all_tuple((fetch_promise, buffer_promise))
13296    ///     .await?
13297    ///     .into_tuple();
13298    /// ```
13299    #[inline]
13300    pub fn all_tuple<T: PromiseTuple>(promises: T) -> Promise<T::Joined> {
13301        promises.all()
13302    }
13303
13304    /// Heterogeneous counterpart to [`Promise::all_settled_iterable`]: accepts
13305    /// a Rust tuple of `Promise<T_i>` and returns a single [`Promise`]
13306    /// resolving to a typed
13307    /// `ArrayTuple<(PromiseState<T_1>, ..., PromiseState<T_n>)>`.
13308    ///
13309    /// Unlike [`Promise::all_tuple`], this never rejects early: every input
13310    /// settles (fulfills or rejects) and is reflected by its [`PromiseState`]
13311    /// slot in the result tuple. Implemented for arity 1..=8.
13312    ///
13313    /// # Example
13314    ///
13315    /// ```ignore
13316    /// use js_sys::Promise;
13317    ///
13318    /// let results = Promise::all_settled_tuple((fetch_promise, buffer_promise)).await?;
13319    /// let (response_state, buffer_state) = results.into_tuple();
13320    /// ```
13321    #[inline]
13322    pub fn all_settled_tuple<T: PromiseTuple>(promises: T) -> Promise<T::Settled> {
13323        promises.all_settled()
13324    }
13325}
13326
13327/// Returns a handle to the global scope object.
13328///
13329/// This allows access to the global properties and global names by accessing
13330/// the `Object` returned.
13331pub fn global() -> Object {
13332    use once_cell::unsync::Lazy;
13333
13334    struct Wrapper<T>(Lazy<T>);
13335
13336    #[cfg(not(target_feature = "atomics"))]
13337    unsafe impl<T> Sync for Wrapper<T> {}
13338
13339    #[cfg(not(target_feature = "atomics"))]
13340    unsafe impl<T> Send for Wrapper<T> {}
13341
13342    #[cfg_attr(target_feature = "atomics", thread_local)]
13343    static GLOBAL: Wrapper<Object> = Wrapper(Lazy::new(get_global_object));
13344
13345    return GLOBAL.0.clone();
13346
13347    fn get_global_object() -> Object {
13348        // Accessing the global object is not an easy thing to do, and what we
13349        // basically want is `globalThis` but we can't rely on that existing
13350        // everywhere. In the meantime we've got the fallbacks mentioned in:
13351        //
13352        // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis
13353        //
13354        // Note that this is pretty heavy code-size wise but it at least gets
13355        // the job largely done for now and avoids the `Function` constructor at
13356        // the end which triggers CSP errors.
13357        #[wasm_bindgen]
13358        extern "C" {
13359            #[derive(Clone, Debug)]
13360            type Global;
13361
13362            #[wasm_bindgen(thread_local_v2, js_name = globalThis)]
13363            static GLOBAL_THIS: Option<Object>;
13364
13365            #[wasm_bindgen(thread_local_v2, js_name = self)]
13366            static SELF: Option<Object>;
13367
13368            #[wasm_bindgen(thread_local_v2, js_name = window)]
13369            static WINDOW: Option<Object>;
13370
13371            #[wasm_bindgen(thread_local_v2, js_name = global)]
13372            static GLOBAL: Option<Object>;
13373        }
13374
13375        // The order is important: in Firefox Extension Content Scripts `globalThis`
13376        // is a Sandbox (not Window), so `globalThis` must be checked after `window`.
13377        let static_object = SELF
13378            .with(Option::clone)
13379            .or_else(|| WINDOW.with(Option::clone))
13380            .or_else(|| GLOBAL_THIS.with(Option::clone))
13381            .or_else(|| GLOBAL.with(Option::clone));
13382        if let Some(obj) = static_object {
13383            if !obj.is_undefined() {
13384                return obj;
13385            }
13386        }
13387
13388        // Global object not found
13389        JsValue::undefined().unchecked_into()
13390    }
13391}
13392
13393// Float16Array
13394//
13395// Rust does not yet have a stable builtin `f16`, so the raw JS bindings live
13396// here and any Rust-side helper APIs use explicit `u16` / `f32` naming. The
13397// unsuffixed float APIs are reserved for a future native `f16` binding.
13398#[wasm_bindgen]
13399extern "C" {
13400    #[wasm_bindgen(extends = Object, typescript_type = "Float16Array")]
13401    #[derive(Clone, Debug)]
13402    pub type Float16Array;
13403
13404    /// The `Float16Array()` constructor creates a new array.
13405    ///
13406    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float16Array)
13407    #[wasm_bindgen(constructor)]
13408    pub fn new(constructor_arg: &JsValue) -> Float16Array;
13409
13410    /// The `Float16Array()` constructor creates an array with an internal
13411    /// buffer large enough for `length` elements.
13412    ///
13413    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float16Array)
13414    #[wasm_bindgen(constructor)]
13415    pub fn new_with_length(length: u32) -> Float16Array;
13416
13417    /// The `Float16Array()` constructor creates an array with the given
13418    /// buffer but is a view starting at `byte_offset`.
13419    ///
13420    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float16Array)
13421    #[wasm_bindgen(constructor)]
13422    pub fn new_with_byte_offset(buffer: &JsValue, byte_offset: u32) -> Float16Array;
13423
13424    /// The `Float16Array()` constructor creates an array with the given
13425    /// buffer but is a view starting at `byte_offset` for `length` elements.
13426    ///
13427    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float16Array)
13428    #[wasm_bindgen(constructor)]
13429    pub fn new_with_byte_offset_and_length(
13430        buffer: &JsValue,
13431        byte_offset: u32,
13432        length: u32,
13433    ) -> Float16Array;
13434
13435    /// The `fill()` method fills all elements from a start index to an end
13436    /// index with a static `f32` value.
13437    ///
13438    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill)
13439    #[wasm_bindgen(method, js_name = fill)]
13440    pub fn fill_with_f32(this: &Float16Array, value: f32, start: u32, end: u32) -> Float16Array;
13441
13442    /// The buffer accessor property represents the `ArrayBuffer` referenced
13443    /// by a `TypedArray` at construction time.
13444    #[wasm_bindgen(getter, method)]
13445    pub fn buffer(this: &Float16Array) -> ArrayBuffer;
13446
13447    /// The `subarray()` method returns a new `TypedArray` on the same
13448    /// `ArrayBuffer` store and with the same element types as this array.
13449    #[wasm_bindgen(method)]
13450    pub fn subarray(this: &Float16Array, begin: u32, end: u32) -> Float16Array;
13451
13452    /// The `slice()` method returns a shallow copy of a portion of a typed
13453    /// array into a new typed array object.
13454    #[wasm_bindgen(method)]
13455    pub fn slice(this: &Float16Array, begin: u32, end: u32) -> Float16Array;
13456
13457    /// The `forEach()` method executes a provided function once per array
13458    /// element, passing values as `f32`.
13459    #[wasm_bindgen(method, js_name = forEach)]
13460    pub fn for_each_as_f32(this: &Float16Array, callback: &mut dyn FnMut(f32, u32, Float16Array));
13461
13462    /// The `forEach()` method executes a provided function once per array
13463    /// element, passing values as `f32`.
13464    #[wasm_bindgen(method, js_name = forEach, catch)]
13465    pub fn try_for_each_as_f32(
13466        this: &Float16Array,
13467        callback: &mut dyn FnMut(f32, u32, Float16Array) -> Result<(), JsError>,
13468    ) -> Result<(), JsValue>;
13469
13470    /// The length accessor property represents the length (in elements) of a
13471    /// typed array.
13472    #[wasm_bindgen(method, getter)]
13473    pub fn length(this: &Float16Array) -> u32;
13474
13475    /// The byteLength accessor property represents the length (in bytes) of a
13476    /// typed array.
13477    #[wasm_bindgen(method, getter, js_name = byteLength)]
13478    pub fn byte_length(this: &Float16Array) -> u32;
13479
13480    /// The byteOffset accessor property represents the offset (in bytes) of a
13481    /// typed array from the start of its `ArrayBuffer`.
13482    #[wasm_bindgen(method, getter, js_name = byteOffset)]
13483    pub fn byte_offset(this: &Float16Array) -> u32;
13484
13485    /// The `set()` method stores multiple values in the typed array, reading
13486    /// input values from a specified array.
13487    #[wasm_bindgen(method)]
13488    pub fn set(this: &Float16Array, src: &JsValue, offset: u32);
13489
13490    /// Gets the value at `idx` as an `f32`, counting from the end if negative.
13491    #[wasm_bindgen(method, js_name = at)]
13492    pub fn at_as_f32(this: &Float16Array, idx: i32) -> Option<f32>;
13493
13494    /// The `copyWithin()` method shallow copies part of a typed array to another
13495    /// location in the same typed array and returns it, without modifying its size.
13496    ///
13497    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/copyWithin)
13498    #[wasm_bindgen(method, js_name = copyWithin)]
13499    pub fn copy_within(this: &Float16Array, target: i32, start: i32, end: i32) -> Float16Array;
13500
13501    /// Gets the value at `idx` as an `f32`, equivalent to JavaScript
13502    /// `arr[idx]`.
13503    #[wasm_bindgen(method, indexing_getter)]
13504    pub fn get_index_as_f32(this: &Float16Array, idx: u32) -> f32;
13505
13506    /// Sets the value at `idx` from an `f32`, equivalent to JavaScript
13507    /// `arr[idx] = value`.
13508    #[wasm_bindgen(method, indexing_setter)]
13509    pub fn set_index_from_f32(this: &Float16Array, idx: u32, value: f32);
13510}
13511
13512impl Default for Float16Array {
13513    fn default() -> Self {
13514        Self::new(&JsValue::UNDEFINED.unchecked_into())
13515    }
13516}
13517
13518impl TypedArray for Float16Array {}
13519
13520impl Float16Array {
13521    fn as_uint16_view(&self) -> Uint16Array {
13522        let buffer = self.buffer();
13523        Uint16Array::new_with_byte_offset_and_length(
13524            buffer.as_ref(),
13525            self.byte_offset(),
13526            self.length(),
13527        )
13528    }
13529
13530    /// Creates an array from raw IEEE 754 binary16 bit patterns.
13531    ///
13532    /// This pairs naturally with the optional `half` crate:
13533    ///
13534    /// ```rust
13535    /// use half::f16;
13536    /// use js_sys::Float16Array;
13537    ///
13538    /// let values = [f16::from_f32(1.0), f16::from_f32(-2.0)];
13539    /// let bits = values.map(f16::to_bits);
13540    /// let array = Float16Array::new_from_u16_slice(&bits);
13541    /// ```
13542    pub fn new_from_u16_slice(slice: &[u16]) -> Float16Array {
13543        let array = Float16Array::new_with_length(slice.len() as u32);
13544        array.copy_from_u16_slice(slice);
13545        array
13546    }
13547
13548    /// Copy the raw IEEE 754 binary16 bit patterns from this JS typed array
13549    /// into the destination Rust slice.
13550    ///
13551    /// # Panics
13552    ///
13553    /// This function will panic if this typed array's length is different than
13554    /// the length of the provided `dst` array.
13555    ///
13556    /// Values copied into `dst` can be converted back into `half::f16` with
13557    /// `half::f16::from_bits`.
13558    pub fn copy_to_u16_slice(&self, dst: &mut [u16]) {
13559        self.as_uint16_view().copy_to(dst);
13560    }
13561
13562    /// Copy raw IEEE 754 binary16 bit patterns from the source Rust slice into
13563    /// this JS typed array.
13564    ///
13565    /// # Panics
13566    ///
13567    /// This function will panic if this typed array's length is different than
13568    /// the length of the provided `src` array.
13569    ///
13570    /// When using the optional `half` crate, populate `src` with
13571    /// `half::f16::to_bits()`.
13572    pub fn copy_from_u16_slice(&self, src: &[u16]) {
13573        self.as_uint16_view().copy_from(src);
13574    }
13575
13576    /// Efficiently copies the contents of this JS typed array into a new Vec of
13577    /// raw IEEE 754 binary16 bit patterns.
13578    ///
13579    /// This makes it easy to round-trip through the optional `half` crate:
13580    ///
13581    /// ```rust
13582    /// use half::f16;
13583    ///
13584    /// let bits = array.to_u16_vec();
13585    /// let values: Vec<f16> = bits.into_iter().map(f16::from_bits).collect();
13586    /// ```
13587    pub fn to_u16_vec(&self) -> Vec<u16> {
13588        self.as_uint16_view().to_vec()
13589    }
13590}
13591
13592macro_rules! arrays {
13593    ($(#[doc = $ctor:literal] #[doc = $mdn:literal] $name:ident: $ty:ident,)*) => ($(
13594        #[wasm_bindgen]
13595        extern "C" {
13596            #[wasm_bindgen(extends = Object, typescript_type = $name)]
13597            #[derive(Clone, Debug)]
13598            pub type $name;
13599
13600            /// The
13601            #[doc = $ctor]
13602            /// constructor creates a new array.
13603            ///
13604            /// [MDN documentation](
13605            #[doc = $mdn]
13606            /// )
13607            #[wasm_bindgen(constructor)]
13608            pub fn new(constructor_arg: &JsValue) -> $name;
13609
13610            /// An
13611            #[doc = $ctor]
13612            /// which creates an array with an internal buffer large
13613            /// enough for `length` elements.
13614            ///
13615            /// [MDN documentation](
13616            #[doc = $mdn]
13617            /// )
13618            #[wasm_bindgen(constructor)]
13619            pub fn new_with_length(length: u32) -> $name;
13620
13621            /// An
13622            #[doc = $ctor]
13623            /// which creates an array from a Rust slice.
13624            ///
13625            /// [MDN documentation](
13626            #[doc = $mdn]
13627            /// )
13628            #[wasm_bindgen(constructor)]
13629            pub fn new_from_slice(slice: &[$ty]) -> $name;
13630
13631            /// An
13632            #[doc = $ctor]
13633            /// which creates an array with the given buffer but is a
13634            /// view starting at `byte_offset`.
13635            ///
13636            /// [MDN documentation](
13637            #[doc = $mdn]
13638            /// )
13639            #[wasm_bindgen(constructor)]
13640            pub fn new_with_byte_offset(buffer: &JsValue, byte_offset: u32) -> $name;
13641
13642            /// An
13643            #[doc = $ctor]
13644            /// which creates an array with the given buffer but is a
13645            /// view starting at `byte_offset` for `length` elements.
13646            ///
13647            /// [MDN documentation](
13648            #[doc = $mdn]
13649            /// )
13650            #[wasm_bindgen(constructor)]
13651            pub fn new_with_byte_offset_and_length(
13652                buffer: &JsValue,
13653                byte_offset: u32,
13654                length: u32,
13655            ) -> $name;
13656
13657            /// The `fill()` method fills all the elements of an array from a start index
13658            /// to an end index with a static value. The end index is not included.
13659            ///
13660            /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill)
13661            #[wasm_bindgen(method)]
13662            pub fn fill(this: &$name, value: $ty, start: u32, end: u32) -> $name;
13663
13664            /// The buffer accessor property represents the `ArrayBuffer` referenced
13665            /// by a `TypedArray` at construction time.
13666            #[wasm_bindgen(getter, method)]
13667            pub fn buffer(this: &$name) -> ArrayBuffer;
13668
13669            /// The `subarray()` method returns a new `TypedArray` on the same
13670            /// `ArrayBuffer` store and with the same element types as for this
13671            /// `TypedArray` object.
13672            #[wasm_bindgen(method)]
13673            pub fn subarray(this: &$name, begin: u32, end: u32) -> $name;
13674
13675            /// The `slice()` method returns a shallow copy of a portion of a typed
13676            /// array into a new typed array object. This method has the same algorithm
13677            /// as `Array.prototype.slice()`.
13678            #[wasm_bindgen(method)]
13679            pub fn slice(this: &$name, begin: u32, end: u32) -> $name;
13680
13681            /// The `forEach()` method executes a provided function once per array
13682            /// element. This method has the same algorithm as
13683            /// `Array.prototype.forEach()`. `TypedArray` is one of the typed array
13684            /// types here.
13685            #[wasm_bindgen(method, js_name = forEach)]
13686            pub fn for_each(this: &$name, callback: &mut dyn FnMut($ty, u32, $name));
13687
13688            /// The `forEach()` method executes a provided function once per array
13689            /// element. This method has the same algorithm as
13690            /// `Array.prototype.forEach()`. `TypedArray` is one of the typed array
13691            /// types here.
13692            #[wasm_bindgen(method, js_name = forEach, catch)]
13693            pub fn try_for_each(this: &$name, callback: &mut dyn FnMut($ty, u32, $name) -> Result<(), JsError>) -> Result<(), JsValue>;
13694
13695            /// The length accessor property represents the length (in elements) of a
13696            /// typed array.
13697            #[wasm_bindgen(method, getter)]
13698            pub fn length(this: &$name) -> u32;
13699
13700            /// The byteLength accessor property represents the length (in bytes) of a
13701            /// typed array.
13702            #[wasm_bindgen(method, getter, js_name = byteLength)]
13703            pub fn byte_length(this: &$name) -> u32;
13704
13705            /// The byteOffset accessor property represents the offset (in bytes) of a
13706            /// typed array from the start of its `ArrayBuffer`.
13707            #[wasm_bindgen(method, getter, js_name = byteOffset)]
13708            pub fn byte_offset(this: &$name) -> u32;
13709
13710            /// The `set()` method stores multiple values in the typed array, reading
13711            /// input values from a specified array.
13712            #[wasm_bindgen(method)]
13713            pub fn set(this: &$name, src: &JsValue, offset: u32);
13714
13715            /// Gets the value at `idx`, counting from the end if negative.
13716            #[wasm_bindgen(method)]
13717            pub fn at(this: &$name, idx: i32) -> Option<$ty>;
13718
13719            /// The `copyWithin()` method shallow copies part of a typed array to another
13720            /// location in the same typed array and returns it, without modifying its size.
13721            ///
13722            /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/copyWithin)
13723            #[wasm_bindgen(method, js_name = copyWithin)]
13724            pub fn copy_within(this: &$name, target: i32, start: i32, end: i32) -> $name;
13725
13726            /// Gets the value at `idx`, equivalent to the javascript `my_var = arr[idx]`.
13727            #[wasm_bindgen(method, indexing_getter)]
13728            pub fn get_index(this: &$name, idx: u32) -> $ty;
13729
13730            /// Sets the value at `idx`, equivalent to the javascript `arr[idx] = value`.
13731            #[wasm_bindgen(method, indexing_setter)]
13732            pub fn set_index(this: &$name, idx: u32, value: $ty);
13733
13734            /// Copies the Rust slice's data to self.
13735            ///
13736            /// This method is not expected to be public. It requires the length of the
13737            /// TypedArray to be the same as the slice, use `self.copy_from(slice)` instead.
13738            #[wasm_bindgen(method, js_name = set)]
13739            fn copy_from_slice(this: &$name, slice: &[$ty]);
13740
13741            /// Copies this TypedArray's data to Rust slice;
13742            ///
13743            /// This method is not expected to be public. It requires the length of the
13744            /// TypedArray to be the same as the slice, use `self.copy_to(slice)` instead.
13745            ///
13746            /// # Workaround
13747            ///
13748            /// We actually need `slice.set(typed_array)` here, but since slice cannot be treated as
13749            /// `Uint8Array` on the Rust side, we use `Uint8Array.prototype.set.call`, which allows
13750            /// us to specify the `this` value inside the function.
13751            ///
13752            /// Therefore, `Uint8Array.prototype.set.call(slice, typed_array)` is equivalent to
13753            /// `slice.set(typed_array)`.
13754            #[wasm_bindgen(js_namespace = $name, js_name = "prototype.set.call")]
13755            fn copy_to_slice(slice: &mut [$ty], this: &$name);
13756        }
13757
13758        impl $name {
13759            /// Creates a JS typed array which is a view into wasm's linear
13760            /// memory at the slice specified.
13761            ///
13762            /// This function returns a new typed array which is a view into
13763            /// wasm's memory. This view does not copy the underlying data.
13764            ///
13765            /// # Safety
13766            ///
13767            /// Views into WebAssembly memory are only valid so long as the
13768            /// backing buffer isn't resized in JS. Once this function is called
13769            /// any future calls to `Box::new` (or malloc of any form) may cause
13770            /// the returned value here to be invalidated. Use with caution!
13771            ///
13772            /// Additionally the returned object can be safely mutated but the
13773            /// input slice isn't guaranteed to be mutable.
13774            ///
13775            /// Finally, the returned object is disconnected from the input
13776            /// slice's lifetime, so there's no guarantee that the data is read
13777            /// at the right time.
13778            pub unsafe fn view(rust: &[$ty]) -> $name {
13779                wasm_bindgen::__rt::wbg_cast(rust)
13780            }
13781
13782            /// Creates a JS typed array which is a view into wasm's linear
13783            /// memory at the specified pointer with specified length.
13784            ///
13785            /// This function returns a new typed array which is a view into
13786            /// wasm's memory. This view does not copy the underlying data.
13787            ///
13788            /// # Safety
13789            ///
13790            /// Views into WebAssembly memory are only valid so long as the
13791            /// backing buffer isn't resized in JS. Once this function is called
13792            /// any future calls to `Box::new` (or malloc of any form) may cause
13793            /// the returned value here to be invalidated. Use with caution!
13794            ///
13795            /// Additionally the returned object can be safely mutated,
13796            /// the changes are guaranteed to be reflected in the input array.
13797            pub unsafe fn view_mut_raw(ptr: *mut $ty, length: usize) -> $name {
13798                let slice = core::slice::from_raw_parts_mut(ptr, length);
13799                Self::view(slice)
13800            }
13801
13802            /// Copy the contents of this JS typed array into the destination
13803            /// Rust pointer.
13804            ///
13805            /// This function will efficiently copy the memory from a typed
13806            /// array into this Wasm module's own linear memory, initializing
13807            /// the memory destination provided.
13808            ///
13809            /// # Safety
13810            ///
13811            /// This function requires `dst` to point to a buffer
13812            /// large enough to fit this array's contents.
13813            pub unsafe fn raw_copy_to_ptr(&self, dst: *mut $ty) {
13814                let slice = core::slice::from_raw_parts_mut(dst, self.length() as usize);
13815                self.copy_to(slice);
13816            }
13817
13818            /// Copy the contents of this JS typed array into the destination
13819            /// Rust slice.
13820            ///
13821            /// This function will efficiently copy the memory from a typed
13822            /// array into this Wasm module's own linear memory, initializing
13823            /// the memory destination provided.
13824            ///
13825            /// # Panics
13826            ///
13827            /// This function will panic if this typed array's length is
13828            /// different than the length of the provided `dst` array.
13829            pub fn copy_to(&self, dst: &mut [$ty]) {
13830                core::assert_eq!(self.length() as usize, dst.len());
13831                $name::copy_to_slice(dst, self);
13832            }
13833
13834            /// Copy the contents of this JS typed array into the destination
13835            /// Rust slice.
13836            ///
13837            /// This function will efficiently copy the memory from a typed
13838            /// array into this Wasm module's own linear memory, initializing
13839            /// the memory destination provided.
13840            ///
13841            /// # Panics
13842            ///
13843            /// This function will panic if this typed array's length is
13844            /// different than the length of the provided `dst` array.
13845            pub fn copy_to_uninit<'dst>(&self, dst: &'dst mut [MaybeUninit<$ty>]) -> &'dst mut [$ty] {
13846                core::assert_eq!(self.length() as usize, dst.len());
13847                let dst = unsafe { &mut *(dst as *mut [MaybeUninit<$ty>] as *mut [$ty]) };
13848                self.copy_to(dst);
13849                dst
13850            }
13851
13852            /// Copy the contents of the source Rust slice into this
13853            /// JS typed array.
13854            ///
13855            /// This function will efficiently copy the memory from within
13856            /// the Wasm module's own linear memory to this typed array.
13857            ///
13858            /// # Panics
13859            ///
13860            /// This function will panic if this typed array's length is
13861            /// different than the length of the provided `src` array.
13862            pub fn copy_from(&self, src: &[$ty]) {
13863                core::assert_eq!(self.length() as usize, src.len());
13864                self.copy_from_slice(src);
13865            }
13866
13867            /// Efficiently copies the contents of this JS typed array into a new Vec.
13868            pub fn to_vec(&self) -> Vec<$ty> {
13869                let len = self.length() as usize;
13870                let mut output = Vec::with_capacity(len);
13871                // Safety: the capacity has been set
13872                unsafe {
13873                    self.raw_copy_to_ptr(output.as_mut_ptr());
13874                    output.set_len(len);
13875                }
13876                output
13877            }
13878        }
13879
13880        impl<'a> From<&'a [$ty]> for $name {
13881            #[inline]
13882            fn from(slice: &'a [$ty]) -> $name {
13883                // This is safe because the `new` function makes a copy if its argument is a TypedArray
13884                $name::new_from_slice(slice)
13885            }
13886        }
13887
13888        impl Default for $name {
13889            fn default() -> Self {
13890                Self::new(&JsValue::UNDEFINED.unchecked_into())
13891            }
13892        }
13893
13894        impl TypedArray for $name {}
13895
13896
13897    )*);
13898}
13899
13900arrays! {
13901    /// `Int8Array()`
13902    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array
13903    Int8Array: i8,
13904
13905    /// `Int16Array()`
13906    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array
13907    Int16Array: i16,
13908
13909    /// `Int32Array()`
13910    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array
13911    Int32Array: i32,
13912
13913    /// `Uint8Array()`
13914    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array
13915    Uint8Array: u8,
13916
13917    /// `Uint8ClampedArray()`
13918    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray
13919    Uint8ClampedArray: u8,
13920
13921    /// `Uint16Array()`
13922    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array
13923    Uint16Array: u16,
13924
13925    /// `Uint32Array()`
13926    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array
13927    Uint32Array: u32,
13928
13929    /// `Float32Array()`
13930    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array
13931    Float32Array: f32,
13932
13933    /// `Float64Array()`
13934    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array
13935    Float64Array: f64,
13936
13937    /// `BigInt64Array()`
13938    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array
13939    BigInt64Array: i64,
13940
13941    /// `BigUint64Array()`
13942    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigUint64Array
13943    BigUint64Array: u64,
13944}
13945
13946/// Bridging between JavaScript `Promise`s and Rust `Future`s.
13947///
13948/// Enables `promise.await` directly on any [`Promise`].
13949/// This module is also re-exported by `wasm-bindgen-futures` for backwards compatibility.
13950pub mod futures;